function brows_check(){
	if (navigator.userAgent.indexOf("Firefox")!=-1){
		return "ff"; //ff for FireFox
	}else if (navigator.userAgent.indexOf("MSIE")!=-1){
		return "ie"; // ie for Internet Explorer
	}
	
}

function out(){
	//alert('profile updated successfully');
	//parent.parent.reload_pge();
	document.getElementById("msg").innerHTML="";
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}

	return objXMLHttp
} 

function stateChanged3() 
{ 
	if(xmlHttp.readyState==1){
		document.getElementById("ind").style.display="inline";
	}
	if(xmlHttp.readyState==2){
		document.getElementById("ind").style.display="inline";
	}
	if(xmlHttp.readyState==3){
		document.getElementById("ind").style.display="inline";
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete" || xmlHttp.readyState==0)
	{ 
		//DataLd();
		document.getElementById("ind").style.display="none";
		var dumy = xmlHttp.responseText;
		//document.getElementById("sbCats").innerHTML=dumy;
		//alert(dumy);
		var val = dumy.split("###");
		if( val[1] == 'yes' )
		{
			document.getElementById('shipping_price').innerHTML = "$"+val[2];
			var curTotal = document.getElementById('sub_total').value;
			var grand_total = Number(curTotal)+Number(val[2]);
			document.getElementById('grandTotal').innerHTML = "$"+grand_total.toFixed(2);
			var gst = (10/100)*Number(grand_total);
			document.getElementById('gstdiv').innerHTML = "$"+gst.toFixed(2);
			
			if( val[3] == 'Y' ) // if Shipping if Free
			{
				var yousave = val[4];
				document.getElementById('you_save').innerHTML = "<b>You Save: $"+yousave+"</b>";
			}
			
		}
		else
		{
			$.jGrowl('<div class=\'alert\'><b>'+val[1]+'</b></div>');
		}
	}
	
}  
 

function getShipping( id )
{
	//var form = document.add;
	//if(id !=""){
		
		var pid = id;
		
		<!-- ########## star form posting ######### -->
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 

		if(brows_check() == "ie"){
			var fChk = false;
		}else if(brows_check() == "ff"){
			var fChk = true;
		}
		xmlHttp.onreadystatechange=stateChanged3;
		xmlHttp.open("POST","scripts/getShipping.php",fChk)
		// Set our POST header correctly…
		var params = "id="+id;
		
		//alert(params);
		
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		  // Send the parms data…
		 xmlHttp.send(params);
	/*}
	else
	{
		//form.city.disabled =true;	
	}*/
 }
 
 
 
 
 
 /* ################################################  add to Cart  ######################################### */ 
 
function stateChanged() 
{ 
	if(xmlHttp.readyState==1){
		//document.getElementById("msg").innerHTML="Sending Request...";
	}
	if(xmlHttp.readyState==2){
		//document.getElementById("msg").innerHTML="Loading Data...";
	}
	if(xmlHttp.readyState==3){
		//document.getElementById("msg").innerHTML="Loading Data...";
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete" || xmlHttp.readyState==0)
	{ 
		//DataLd();
		var dumy = xmlHttp.responseText;
		//alert(dumy);
		var res = dumy.split("###");
		if(res[1] == "yes")
		{
			//parent.parent.show_msg("msg",res[0]);
			//load_page2('cartDiv', 'includes/cart_script.php', '&1=1')
			//$.jGrowl('<div class=\'alert\'><b>Item has been added to your Shopping Cart</b></div>');
			window.location.href="cart.html";
		}
		else if(res[1] == "no")
		{
			//parent.parent.show_msg("msg",res[0]);
			$.jGrowl('<div class=\'alert\'><b>'+res[2]+'</b></div>');
		}
	}
	
}  
 

function add_to_cart( pid, qty, cover_price )
{
	//alert(pid+" - "+qty+" - "+cover_price);
	if( cover_price == true ){
		var cover_only = 'Y';
	}
	else
	{
		var cover_only = 'N';
	}
	//alert(cover_only);
	//return false;

	//var pid = document.getElementById('pid').value;
	if(pid == "")
	{
		alert('select an item to proceed');
		return false;
	}
	
	//return false;
	
	<!-- ########## star form posting ######### -->
	
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
		if(brows_check() == "ie"){
			var fChk = false;
		}else if(brows_check() == "ff"){
			var fChk = true;
		}
			xmlHttp.onreadystatechange=stateChanged;
			xmlHttp.open("POST","scripts/add_to_cart_ajax.php",fChk)
		 // Set our POST header correctly…
		var params="pid="+pid+"&qty="+qty+"&cover_only="+cover_only;
		//alert(params); return false;
		  
		  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		  xmlHttp.setRequestHeader("Content-length", params.length);
		  xmlHttp.setRequestHeader("Connection", "close");
		
		  // Send the parms data…
		  xmlHttp.send(params);
 }
 
  /* ################################################   end  ######################################### */
