var Konami=function(){var konami={addEvent:function(obj,type,fn,ref_obj){
if(obj.addEventListener)
obj.addEventListener(type,fn,false);else if(obj.attachEvent)
{obj["e"+type+fn]=fn;obj[type+fn]=function(){obj["e"+type+fn](window.event,ref_obj);}
obj.attachEvent("on"+type,obj[type+fn]);}},input:"",pattern:"3838404037393739666513",load:function(link){this.addEvent(document,"keydown",function(e,ref_obj){if(ref_obj)konami=ref_obj;konami.input+=e?e.keyCode:event.keyCode;if(konami.input.indexOf(konami.pattern)!=-1){konami.code(link);konami.input="";return;}},this);this.iphone.load(link)},code:function(link){window.location=link},iphone:{start_x:0,start_y:0,stop_x:0,stop_y:0,tap:false,capture:false,keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],code:function(link){konami.code(link);},load:function(link){konami.addEvent(document,"touchmove",function(e){if(e.touches.length==1&&konami.iphone.capture==true){var touch=e.touches[0];konami.iphone.stop_x=touch.pageX;konami.iphone.stop_y=touch.pageY;konami.iphone.tap=false;konami.iphone.capture=false;konami.iphone.check_direction();}});konami.addEvent(document,"touchend",function(evt){if(konami.iphone.tap==true)konami.iphone.check_direction(link);},false);konami.addEvent(document,"touchstart",function(evt){konami.iphone.start_x=evt.changedTouches[0].pageX
konami.iphone.start_y=evt.changedTouches[0].pageY
konami.iphone.tap=true
konami.iphone.capture=true});},check_direction:function(link){x_magnitude=Math.abs(this.start_x-this.stop_x)
y_magnitude=Math.abs(this.start_y-this.stop_y)
x=((this.start_x-this.stop_x)<0)?"RIGHT":"LEFT";y=((this.start_y-this.stop_y)<0)?"DOWN":"UP";result=(x_magnitude>y_magnitude)?x:y;result=(this.tap==true)?"TAP":result;if(result==this.keys[0])this.keys=this.keys.slice(1,this.keys.length)
if(this.keys.length==0)this.code(link)}}}
return konami;}

$(document).ready(function(){

	konami = new Konami();
		konami.code = function() {
			$("#logo").html($("#logo").html() + '<img src="images/konami.png" style="position: absolute; top: 0; left: -25px; z-index: 99999999" alt="LOLS" />');
			}

		konami.load();

	$(document).pngFix();
	var remove = 0;

	if($("#searchBox").val() == "")
	{
		$("#searchBox").val($("#searchBox").attr("placeholder"));
	}

	if ($.browser.msie && $.browser.version.substr(0,1)<7) 
	{
		$("hr").replaceWith('<div class="hr"></div>');
	}

	$("#searchBox").click(function() {
		if($("#searchBox").val() == $("#searchBox").attr("placeholder"))
		{
			$("#searchBox").val("");
		}
	});

		$("#navigation ul").hide();
		
		$("#navigation ul").css('visibility', 'visible');
		
	  
	$("#navigation li").hover(function(){
		if($(this).find('img').length > 0)
		{
			$(this).find('img').attr("src", $(this).find('img').attr("src").split(".").join("-over."));
			$(this).addClass("hover");
		}
        $('ul:first',this).show();
    
    }, function(){
		if($(this).find('img').length > 0)
		{
			$(this).find('img').attr("src", $(this).find('img').attr("src").split("-over.").join("."));
			$(this).removeClass("hover");
		}
        $('ul:first',this).hide();
    
    });
	
	$("#topnav li").hover(function(){
        $('ul:first',this).show();
    
    }, function(){
        $('ul:first',this).hide();
    
    });
	
	$.each($(".epTitle"),function(){
		if($(this).html().length < 4)
		{
			$(this).html("");
		}
	});

	
	
		/*$(".subnav li").click(function(){
			$.each($(this).find("a"),function(){
				if($(this).attr("target") == "_blank")
				{
					window.open($(this).attr("href"));
				}
				else
				{
					top.location = $(this).attr("href");
				}
			});
		});

		$(".subnav li").css('cursor','pointer');*/
		
		 $.each($(".subnav li"),function( intIndex, objValue ){
			if(intIndex > $(".subnav li").length - 2){
				$(this).css('border-bottom','none');
			}
			
			if($(this).find("a").attr("href").replace("http://","") != $(this).find("a").attr("href"))
			{
				$(this).find("a").attr("target","_blank");
			}

		});
		
		 $.each($(".mainNav"),function( intIndex, objValue ){
			$(this).attr("id","nav"+(intIndex+1));

		});
		
		 $.each($(".mainNav"),function( intIndex, objValue ){
			 $.each($("#" + $(this).attr("id") + " li"),function( intIndex, objValue ){
			if(intIndex > $("#" + $(this).parent().parent().attr("id") + " li").length - 2){
				$(this).css('border-bottom','none');
			}

			});
	
		});
		


});

