// JavaScript Document
function createObject() {


var ajaxRequest=null;  
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("BROWSER ERROR!");
				return false;
			}
		}
	}
	return ajaxRequest;
	
}




function products(pid,mod,grp)
{	var x=new Date().getTime();
		var http = createObject();
		var pos= pid.indexOf("main");
		var xyz ="";
	http.onreadystatechange = function(){
var temp=pid;

if (pos!=-1)
{
//pid=pid.substring(4);
grp="main";

}	
	if (grp=='subcat')
		var n="subcat"+pid;	
	else 
		var n="cat"+pid;
		
		if(http.readyState == 4){
			
			
			var ajaxDisplay = document.getElementById(n);				
			ajaxDisplay.innerHTML = http.responseText;
			document.close();
		} 
	}		
	
	if (pos!=-1)
{pid=pid.substring(4);
grp="main";

}

xyz= "main"+pid;

if (grp=='cat')
{
http.open("GET", "productscat_query.php?mod=" + mod+"&pid=" + pid+"&x=" + x, true); 
document.getElementById('prev_cat').value=pid;}
else if (grp=='subcat'){
http.open("GET", "products_query.php?mod=" + mod+"&pid=" + pid+"&x=" + x, true);
document.getElementById('prev').value=pid;}
else if (grp=='main')
{
http.open("GET", "productsmain_query.php?mod=" + mod+"&pid=" + pid+"&x=" + x, true);
document.getElementById('prev_cat').value=xyz;
}
	http.send(null); 
		
	}
	
