function price_format(price, precision) {
var x, cnt, top, botom;
	precision = Math.pow(10, precision);
	price = Math.round(price*precision)/precision;
	top = Math.floor(price);
	bottom = Math.round((price-top)*precision)+precision;
	top = top+"";
	bottom = bottom+"";
	cnt = 0;
	for(x = top.length; x >= 0; x--) {
		if(cnt%3 == 0 && cnt > 0 && x > 0)
			top = top.substr(0,x)+","+top.substr(x,top.length);
		cnt++;
	}
	price = top+"."+bottom.substr(1,bottom.length);
	return price;
}

function ALSHOW(v){
	if(v=="s"){
		document.getElementById("altshow").style.visibility="visible";
	}
	if(v=="h"){
		document.getElementById("altshow").style.visibility="hidden";
	}
}

function ShowOptions(id){
	if(document.getElementById("systemoptions"+id).style.display=="none"){
		animatedcollapse.show("systemoptions"+id);
		//document.getElementById("systemoptions"+id).style.display="block";
		document.getElementById("btn"+id).src="images/minus.jpg";
	}else{
		animatedcollapse.hide("systemoptions"+id);
		//document.getElementById("systemoptions"+id).style.display="none";
		document.getElementById("btn"+id).src="images/plue.jpg";
	}
}
							
function UPDATE_CART(pid,loop,sessid){
	var qty=document.getElementById("product_qty_"+loop).value;
	if(qty==""){
		alert("Please specify Product Quantity!");
	}else{
		if(qty=="0"){
			var de=confirm("Order Quantity for this item is '0'. Are you sure you want to Proceed?");
			if(de==true){
				location.href="cart.php?_task=update_cart&pid="+pid+"&product_qty="+qty+"&sessionid="+sessid;
			}
		}else{
			location.href="cart.php?_task=update_cart&pid="+pid+"&product_qty="+qty+"&sessionid="+sessid;
		}
	}
}

function DELETE_CART(pid,loop,sid){
	location.href="cart.php?_task=delete_item&pid="+pid+"&sessionid="+sid;
}

var xmlHttp
function PRODUCT_OPTIONS(sessionid,productid,categoryid,product_options,full_amount)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="./include/product_options.php";
url=url+"?productid="+productid+"&sessionid="+sessionid+"&categoryid="+categoryid+"&product_options="+product_options+"&full_amount="+full_amount;
url=url+"&sid="+Math.random();
//alert(url);
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
	if(xmlHttp.readyState==4){ 
	//alert(xmlHttp.responseText);
		//document.getElementById("basket_box").innerHTML=xmlHttp.responseText;
	}
}

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;
}
