// JavaScript Document
var xmlHttp;
var output="";

function xmlObject(url){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX! Please update to IE5.5+ or Firefox!");
		return;
	}
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
	}
	catch (e){
	  // Internet Explorer
	  try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}

function stateChanged() { 
	if (xmlHttp.readyState==4){
		if(xmlHttp.status == 200) { 
			document.getElementById(output).innerHTML=xmlHttp.responseText;
			show_total();
		}
	}
}

function show_total(){
	document.getElementById('total').innerHTML=document.getElementById('cart_total').innerHTML;
}

function update_cart(p_id,cmd){
	var url="ajax/update_cart.php";
	output="cart";
	url=url+"?p_id="+p_id;
	url=url+"&cmd="+cmd;
	url=url+"&sid="+Math.random();
	xmlObject(url);
}

function update_qty(p_id,range,cmd){
	var url="ajax/update_cart.php";
	output="cart";
	url=url+"?p_id="+p_id;
	url=url+"&cmd="+cmd;
	url=url+"&range="+range;
	url=url+"&sid="+Math.random();
	xmlObject(url);
}

function other_details(id){
	var url="ajax/other_details.php";
	output="other_details";
	var other_details=document.getElementById('other_details');
	other_details.style.visibility="visible";
	//other_details.style.display="block";
	other_details.style.left=document.body.clientWidth/2-320;
		
	var bg=document.getElementById('bg');
	bg.style.display="inline";
	bg.style.width="100%";
	bg.style.height=getPageSize()[1]+50;
	
	//alert(document.body.clientHeight);
	url=url+"?id="+id;
	//url=url+"&cmd="+cmd;
	url=url+"&sid="+Math.random();
	xmlObject(url);
}

function showHint(str){
	if (str.length==0){ 
		document.getElementById("cart").innerHTML="";
		return;
	}else{
		var url="ajax/register.php";
		output="cart";
		url=url+"?q="+str;
		url=url+"&sid="+Math.random();
		xmlObject(url);
	}
}
