//Global vars to hold connection to web pages

var xmlHttp

var xmlHttp2





function showgamespagecategory(str,cons,catid) { 

	

	//document.getElementById('hidcat').value = catid;

	//Function that gets called

	//Currently we only call one other sub, but this could change

	//showStates(str,searchname,searchvalue,cons)

	showStates(str,cons,catid)

}

function showStates(str,cons,catid) {  

	//alert(catid);

	//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

	xmlHttp=GetXmlHttpObject()

	xmlHttp2=GetXmlHttpObject()

	

	//If we cant do the request error out

	if (xmlHttp==null || xmlHttp2==null ) {

	 	alert ("Browser does not support HTTP Request")

	 	return

	}

	

	//Build the url to call

	//Pass variables through the url

	var url=strsiteurl+"ajax-gamepage-category.php"
	
	//var url="http://localhost/yashiv1.5/ajax-gamepage-category.php"
	
	url=url+"?p="+str

	url=url+"&t=con"

	

	//var gid =  document.getElementById('hidcat').value;

		

	url = url+"&categoryid="+catid;	
	//alert(url)

	//alert(catid);	

//Once the page finished loading put it into the div

	xmlHttp.onreadystatechange=stateChanged 
	//Get the php page

	xmlHttp.open("GET",url,true)

	xmlHttp.send(null)
	
	//replace haeder
	
	
	
	
	var url1 = strsiteurl + "ajax-replace-headercategory.php"
	url1 = url1+"?gamecatid="+catid;	
	
	xmlHttp2.onreadystatechange=stateChanged2 

	//Get the php page

	xmlHttp2.open("GET",url1,true)

	xmlHttp2.send(null)

}



function stateChanged() { 


	  if (xmlHttp.readyState == 1) {

    // Split the comma delimited response into an array

    //results = http.responseText;

 	  document.getElementById('gamecategory_div').innerHTML = "<div align=center><img src='http://www.vdevendran.com/Yashi/images/loading.gif'></div>"; 

	 }



	//IF this is getting called when the page is done loading the states then output the div

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		//alert('statechanged')
	 	//Update the Div tag with the outputted text
		//alert(xmlHttp.responseText)
	 	document.getElementById("gamecategory_div").innerHTML=xmlHttp.responseText
		

	} 

}

function stateChanged2() { 




	//IF this is getting called when the page is done loading the states then output the div

	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete") { 

	 	//Update the Div tag with the outputted text
			
	 	document.getElementById("curcat").innerHTML=xmlHttp2.responseText 

	} 

}





function GetXmlHttpObject() {

	//Determine what browser we are on and make a httprequest connection for ajax

	var xmlHttp=null;



	try {

	 	// Firefox, Opera 8.0+, Safari

	 	xmlHttp=new XMLHttpRequest();

	}

	catch (e) {

	 	//Internet Explorer

	 	try {

	  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

	  	}

	 	catch (e) {

	  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

	  	}

	}

	

	return xmlHttp;

}











//Onload start the user off on page one

//window.onload = showgamespagecategory("1","onload","1");



