function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function hidetable(theTable) {
	if (document.getElementById(theTable).style.display == 'none') {
		document.getElementById(theTable).style.display = 'none';
	} else {
		document.getElementById(theTable).style.display = 'none';
	}
}

function show_hide(theTable) {
	if (document.getElementById(theTable).style.display == 'none') {
		document.getElementById(theTable).style.display = 'block';
	} else {
		document.getElementById(theTable).style.display = 'none';
	}
}

function showtab(thetab) {
	hidalltab();
	document.getElementById(thetab).style.display = 'block';	
	document.getElementById('i'+thetab).src='/images/ongtab_' + thetab + '.gif'; 
}

function hidalltab(trun) {
	document.getElementById('controls').style.display = 'none';
	document.getElementById('icontrols').src='/images/gtab_controls.gif'; 	
	
	document.getElementById('shareemail').style.display = 'none';
	document.getElementById('ishareemail').src='/images/gtab_shareemail.gif'; 		
	
	document.getElementById('postwebsite').style.display = 'none';
	document.getElementById('ipostwebsite').src='/images/gtab_postwebsite.gif'; 	
	
	document.getElementById('moregames').style.display = 'none';	
	document.getElementById('imoregames').src='/images/gtab_moregames.gif'; 	
	
	if (trun != 0) {
		document.getElementById('igamewindow').src='/images/gtab_gamewindow.gif'; 			
	}
}

function gametabon() {
	document.getElementById('igamewindow').src='/images/ongtab_gamewindow.gif'; 	
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
openCenteredWindow(theURL, 540, 760, winName, ''); 
}

function openCenteredWindow(url, height, width, name, parms) {
	var width = screen.width * 0.95;
	var height = screen.height * 0.80;
	url = url + '/' + width + '/' + height;
   var left = Math.floor( (screen.width - width) / 2);
   var top = Math.floor( (screen.height - height) / 2);
   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
   if (parms) { winParms += "," + parms; }
   var win = window.open(url, name, winParms);
   win.window.focus(); 
   return win;
}

function MM_openSmWindow(theURL,winName,features) { //v2.0
openSmallCentered(theURL, 540, 760, winName, ''); 
}

function openSmallCentered(url, height, width, name, parms) {
	var width = 300;
	var height = 120;
	url = url + '/' + width + '/' + height;
   var left = Math.floor( (screen.width - width) / 2);
   var top = Math.floor( (screen.height - height) / 2);
   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
   if (parms) { winParms += "," + parms; }
   var win = window.open(url, name, winParms);
   win.window.focus(); 
   return win;
}

function enable_space() {
	window.onkeydown = function(e) { 
		if(e.keyCode==32) { 
			return true; 
		} 
	}
};  

function disable_space() {
	window.onkeydown=function(e) { 
		if(e.keyCode==32 || e.keyCode==38 || e.keyCode==40 || e.keyCode==36 || e.keyCode==35 || e.keyCode==38 || e.keyCode==33 || e.keyCode==34) { 
	  		return false; 
		} 
	}
};  

function xmlhttpPost(strURL,w,h,c,p) {
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			updatepage(self.xmlHttpReq.responseText);
		}
	}
	self.xmlHttpReq.send(getquerystring(w,h,c,p));
}

function getquerystring(w,h,c,p) {
	qstr = 'w=' + escape(w) +  '&h=' + escape(h) + '&c=' + escape(c) + '&p=' + escape(p);  // NOTE: no '?' before querystring
	return qstr;
}

function updatepage(str) {
	document.getElementById("more_games_show").innerHTML = str;
}

function updateload() {
	document.getElementById("more_games_show").innerHTML =  '<table width=100% border=0 cellspacing=0 cellpadding=4 bgcolor=><tr><td bgcolor=#FF6215><img src=/images/loading_games.gif width=94 height=14></td></tr></table>';
}

function aj_more_games(w,h,c,p) {
	xmlhttpPost("/moregames.php",w,h,c,p);
}