var xmlHttp

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 addtoCart(str) {
	

	if (str.length==0){ 
  		return
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
  		alert ("Browser does not support HTTP Request")
  		return
	}
	
	var url="ajaxaddtocart.php";
	url=url+"?ac=add";
	url=url+"&pid="+str
	url=url+"&sid="+Math.random();
	
	xmlHttp.open("GET",url,true)
	xmlHttp.setRequestHeader("Content-Type","text/html; charset=windows-1255");
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.send(null)

	
	xmlHttp.open("GET",url,true)
	xmlHttp.setRequestHeader("Content-Type","text/html; charset=windows-1255");
	xmlHttp.onreadystatechange=updatecart
	xmlHttp.send(null)
	
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function updatecart() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("cart_preview").innerHTML=xmlHttp.responseText 
	}
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
function  changeSubCat(str){
	//alert(str)
	if (str.length==0){ 
  		return
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
  		alert ("Browser does not support HTTP Request")
  		return
	}
	if (str != "all"){
	var url="cat.php";
	url=url+"?cat="+str
	url=url+"&sid="+Math.random()
	
	xmlHttp.open("GET",url,true)
	xmlHttp.setRequestHeader("Content-Type","text/html; charset=windows-1255");
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.send(null)
	}
	else
	{
	var url="cat.php";
	url=url+"?cat="
	url=url+"&sid="+Math.random()
	
	xmlHttp.open("GET",url,true)
	xmlHttp.setRequestHeader("Content-Type","text/html; charset=windows-1255");
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.send(null)
		
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		//alert(xmlHttp.responseText);
		document.getElementById("sub_cat").innerHTML=xmlHttp.responseText 
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
function  sortItems(str){

	if (str.length==0){ 
  		return
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
  		alert ("Browser does not support HTTP Request")
  		return
	}
    var x = window.location.search;
   	if(window.location.search[0] != "?"){
   	var url="prod_show.php";
	url=url+"?sort="+str
	url=url+"&sid="+Math.random()
   	}
	else{
	var url="prod_show.php";
	url=url+x
	url=url+"&sort="+str
	url=url+"&sid="+Math.random()
	alert(url);
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.setRequestHeader("Content-Type","text/html; charset=windows-1255");
	xmlHttp.onreadystatechange=sortEMnow
	xmlHttp.send(null)
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function sortEMnow(str) { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		//alert(xmlHttp.responseText);
		document.getElementById("products").innerHTML=xmlHttp.responseText 
	}

}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function  makeFooter(str){
if (str.length==0){ 
  		return
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
  		alert ("Browser does not support HTTP Request")
  		return
	}
    var x = window.location.search;
   	if(window.location.search[0] != "?"){
   	var url="prod_foot.php";
	url=url+"?sort="+str
	url=url+"&sid="+Math.random()
   	}
	else{
	var url="prod_foot.php";
	url=url+x
	url=url+"&sort="+str
	url=url+"&sid="+Math.random()
	alert(url);
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.setRequestHeader("Content-Type","text/html; charset=windows-1255");
	xmlHttp.onreadystatechange=FooterMake
	xmlHttp.send(null)
}

function ChangeText(str) {
	
	if (str.length==0){ 
  		return
	}
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
  		alert ("Browser does not support HTTP Request")
  		return
	}

	var url="about_txt.php";
	url=url+"?id="+str
	url=url+"&sid="+Math.random()
	
	xmlHttp.open("GET",url,true)
	xmlHttp.setRequestHeader("Content-Type","text/html; charset=windows-1255");
	xmlHttp.onreadystatechange=aboutText
	xmlHttp.send(null)
	
	
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function aboutText(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		//alert(xmlHttp.responseText);
		document.getElementById("page_content_container").innerHTML=xmlHttp.responseText 
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function FooterMake() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		//alert(xmlHttp.responseText);
		document.getElementById("prod_footer").innerHTML=xmlHttp.responseText 
	}
}

function openWin(page, w, h){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=0,resizable=0,location=0,status=0,menubar=0,toolbar=0'
	win = window.open(page, "", winprops);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}