var pos=0;

function fnUp(){
	if (pos<2){
		pos++;
	}
	else{
		pos=0;
	}
}

function fnDown(){
	if(pos>1 && pos<4){
		pos++;
	}
	else{
		pos=0;
	}
}

function fnLeft(){
	if(pos==4 || pos==6){
		pos++;
	}
	else{
		pos=0;
	}
}

function fnRight(){
	if(pos==5 || pos==7){
		pos++;
	}
	else{
		pos=0;
	}
}

function fnA(){
	if(pos==9){
		pos++;
	}
	else{
		pos=0;
	}
}

function fnB(){
	if(pos==8){
		pos++;
	}
	else{
		pos=0;
	}
}

function fnEnter(){
	if(pos==10){
		//ALL PAGES
		jQuery('#bottomhint').addClass('hint2');
		jQuery('#bottomhint').html("<a href=\"contra.php\">\"I don't need a cheat code, I already have 30 lives.\"</a>");

		var pages=new Array("/ultimate.php","/roster/")
		var tf=0;
		for(var i=0; i<pages.length; i++){
			if(document.location.pathname==pages[i]){
				tf=1;
				break;
			}
		}
		if(tf==1){
			jQuery.get('incl/js/extra.php',{'p': document.location.pathname}, function(data){
				jQuery('#addHere').html(data);
			});
		}

		//SHOULD ONLY WORK FOR BIO, NOTHING ELSE
		var getNum=document.location.search.substring(document.location.search.indexOf("?")+1);
		jQuery.get('incl/js/extra.php',{'p': 'anybio', 's': getNum}, function(data){
			jQuery('#bioRight').html(data);
		});

		var today = new Date();
		var expiry = new Date(today.getTime() + 3600 * 1000);
		document.cookie = "code=1; expires=" + expiry.toGMTString()+"; path=/";

	}
	else{
		pos=0;
	}
}

function domo(){


jQuery(document).bind('keydown', 'up',fnUp);
jQuery(document).bind('keydown', 'down',fnDown);
jQuery(document).bind('keydown', 'left',fnLeft);
jQuery(document).bind('keydown', 'right',fnRight);
jQuery(document).bind('keydown', 'a',fnA);
jQuery(document).bind('keydown', 'b',fnB);
jQuery(document).bind('keydown', 'return',fnEnter);

}
 
jQuery(document).ready(domo);
