
function getProducts(){
	selectCat = document.getElementById('ccid');
	selectProd = document.getElementById('pcid');
	
	alert(selectCat.innerHTML);
}
//var xmlHttp
//var itemID

function selectProducts(ccid)
{
	
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
 var list = document.getElementById(ccid);		
	var catid="";

	for (i=0; i<list.length; i++)
	{
		 if (list.options[i].selected) 
		 	catid += (catid != "" ? "_" : "") + list.options[i].value
	}
	
var url="ajax_select_products.php"
url=url+"?ccid="+catid
url=url+"&sid="+Math.random()

//xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.onreadystatechange=stateChanged
xmlHttp.send(null)
}

function getProds(url,cmd, cmd_field, cmd_value)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
 //var list = document.getElementById(ccid);		
	//var catid="";

	//for (i=0; i<list.length; i++)
	//{
		// if (list.options[i].selected) 
		 //	catid += (catid != "" ? "_" : "") + list.options[i].value
	//}
	
//var url="ajax_select_products.php"
//url=url+"?ccid="+catid
//url=url+"&sid="+Math.random()

//xmlHttp.onreadystatechange=stateChanged
//we need to manually escape the "+" sign because it is interpreted as " "
var params = "filter_cmd="+cmd+"&filter_cmd_field="+cmd_field+"&filter_cmd_value=" + escape(cmd_value).replace("+", "%2B");

xmlHttp.open("POST",url,true)
//Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");

xmlHttp.onreadystatechange=stateChanged
xmlHttp.send(params)

	
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 	document.getElementById("server").style.display = "none";
	str = xmlHttp.responseText;

	start_filters = str.indexOf('<!--%START_FILTERS%-->');
	end_filters = str.indexOf('<!--%END_FILTERS%-->');
	part_filters = str.slice(start_filters, end_filters);
	document.getElementById("filterWrapper").innerHTML=part_filters

	start = str.indexOf('<!--%START%-->');
	end = str.indexOf('<!--%END%-->');
	part = str.slice(start, end);
	document.getElementById("prod_boxes").innerHTML =part
	
	start_pg = str.indexOf('<!--%START_PG%-->');
	end_pg = str.indexOf('<!--%END_PG%-->');
	part_pg = str.slice(start_pg, end_pg);
	document.getElementById("pagNr").innerHTML =part_pg
	//alert(part);
	//var newDoc=document.open("text/html","replace");
	//newDoc.write(xmlDoc);
 	//newDoc.close();
	//prodContainer = newDoc.getElementById('prod_boxes');
	//alert(newDoc.getElementById("prod_boxes").innerHTML);
	
 
 }
 else{
 	document.getElementById("server").style.display = "block";
 }
}

function GetXmlHttpObject()
{
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;
}

function setParam(checked){
	if (!checked){
		param = "remove";
	}
	else {
		param = "add";
	}
	//alert(param);
	return param;
}

