// JavaScript Document


function returnProducts(cat, p)
{
	var category = cat;
	var pageIndex = p;

	 //----------------------------------------------------AJAX ----------------------------------------------
		
	//Clear our fetching variable
	var xmlhttp=false; 
	//Try to create active x object
	try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); 
		} catch (e) {
		try {
			 xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); 
		} catch (E) {
			 xmlhttp = false;
		}
	 }
	 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		 xmlhttp = new XMLHttpRequest();
	 }
	
	var page = 'pages/returnProducts.cfm';
	var params = '?category=' + category +'&pageIndex=' + pageIndex;
	
	var file = page+params;

	//Open the file through GET, and add the page we want to retrieve as a GET variable
	xmlhttp.open('GET',file, true);
	
	xmlhttp.onreadystatechange=function() 
	{
		if(xmlhttp.readyState == 1)
		{
			//add loader
		}
		else if(xmlhttp.readyState==4) //Check if it is ready to recieve data 
		{ 
		   //Make sure there is something in the content variable
		   var content = xmlhttp.responseText; 
		
			  //The content data which has been retrieved
			  if( content )
			  { 
					document.getElementById("productsDiv").innerHTML = content;
					document.getElementById("productsDiv").style.display = "block";
			  }
		}
	}
	//Nullify the XMLHttpRequest
	xmlhttp.send(null);
	//--------------------------------------------------//END AJAX ------------------------------------------------
}