//Global vars to hold connection to web pages
var xmlHttp5
var xmlHttp6

var id =  document.getElementById("huserid").value

function showPage1(str,cons) { 
	//Function that gets called
	//Currently we only call one other sub, but this could change
	//showStates(str,searchname,searchvalue,cons)
	showStates1(str,cons)

}
function showStates1(str,cons) {  
	//This sub will populate a table with all the states and get the 
	//pagination built
	
	//Make the AJAX connection for both the navigation and content
	xmlHttp5=GetXmlHttpObject()
	xmlHttp6=GetXmlHttpObject()
	
	//If we cant do the request error out
	if (xmlHttp5==null || xmlHttp6==null ) {
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	
	//First build the navigation panel
	var url=strsiteurl+"ajax-myprogame.php"
	url=url+"?p="+str
	url=url+"&t=nav"
	url=url+"&sid="+Math.random()
//Once the page finished loading put it into the div
	xmlHttp6.onreadystatechange=navDone 

	//Get the php page
	xmlHttp6.open("GET",url,true)
	xmlHttp6.send(null)
	
	//Build the url to call
	//Pass variables through the url
	var url=strsiteurl+"ajax-myprogame.php"
	url=url+"?p="+str+"&uid="+id
	url=url+"&t=con"
	url=url+"&sid="+Math.random()
	
	if(cons == 'unload')
	{
		var sortfield = document.getElementById('hid_sortfield_game').value;
		var sortvalue = document.getElementById('hid_sortvalue_game').value;
		var field
		
		url = url+"&"+field;
	} //alert(url)
	
//Once the page finished loading put it into the div
	xmlHttp5.onreadystatechange=stateChanged1 
	
	//Get the php page
	xmlHttp5.open("GET",url,true)
	xmlHttp5.send(null)
}

function navDone() { 
	//IF this is getting called when the page is done loading then fill the pagination div
	if (xmlHttp6.readyState==4 || xmlHttp6.readyState=="complete") { 
	 	//Update the Div tag with the outputted text
	 	document.getElementById("pgNavigation").innerHTML=xmlHttp6.responseText 
	} 
}

function stateChanged1() { 
	//IF this is getting called when the page is done loading the states then output the div
	if (xmlHttp5.readyState==4 || xmlHttp5.readyState=="complete") { 
	 	//Update the Div tag with the outputted text
	 	document.getElementById("myprogame_div").innerHTML=xmlHttp5.responseText 
	} 
}


function GetXmlHttpObject() {
	//Determine what browser we are on and make a httprequest connection for ajax
	var xmlHttp5=null;

	try {
	 	// Firefox, Opera 8.0+, Safari
	 	xmlHttp5=new XMLHttpRequest();
	}
	catch (e) {
	 	//Internet Explorer
	 	try {
	  		xmlHttp5=new ActiveXObject("Msxml2.XMLHTTP");
	  	}
	 	catch (e) {
	  		xmlHttp5=new ActiveXObject("Microsoft.XMLHTTP");
	  	}
	}
	
	return xmlHttp5;
}





//Onload start the user off on page one
window.onload = showPage1("1","onload");