

function getXMLHttpObj()
{
  var xmlHttpObj

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttpObj = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttpObj;
}
function getLoadPage(url,loadpageId,overlaystyle,containertype)
{
	//document.getElementById("PlantSelectionBox").innerHTML ="<table valign=\"middle\" height=\"112\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"19\" width=\"40%\"><br /><br /><br /><br /><br /></td><td width=\"60%\"><img src=\"<?php echo $IMGPATH?>/images/calculating.gif\" width=\"121\" height=\"19\" /></td></tr></table>";
	//document.getElementById("loadPage").innerHTML ="<table valign=\"middle\" height=\"100\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"19\" width=\"41%\" ></td><td width=\"59%\"><img src=\"<?php echo $IMGPATH?>/images/loading.gif\" width=\"121\" height=\"19\" /></td></tr></table>";
	//document.getElementById("RightMenu").innerHTML ="<table width=\"100%\" valign=\"middle\" height=\"174\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"19\" width=\"15%\" ></td><td width=\"85%\"><img src=\"<?php echo $IMGPATH?>/images/loading_green.gif\" width=\"121\" height=\"19\" /></td></tr></table>";
	getLoadPageById(url,loadpageId,overlaystyle,containertype);
}
function getLoadPageById(url,loadpageId,overlaystyle,containertype)
{
	//alert(url);
	
	document.getElementById("overlaystyle").value=overlaystyle;
	var xmlHttpObj = getXMLHttpObj();
	xmlHttpObj.open("GET", url, true);
	xmlHttpObj.onreadystatechange = function()
	{
		handleResponse(xmlHttpObj,loadpageId,overlaystyle,containertype);
	}
	xmlHttpObj.send(null);
}
function handleResponse(xmlHttpObj,loadpageId,overlaystyle,containertype)
{
	if (xmlHttpObj.readyState == 4)
	{
		if (xmlHttpObj.status == 200)
		{
			//var resultStr = xmlHttpObj.responseText.split("~~~~~");
			var resultStr = "";
			if(overlaystyle	!=	"")
			{
				var browser=navigator.appName;
				if(browser	==	"Netscape")
					resultStr	=	"<div class=\"netscape\"></div>";
				else
					resultStr	=	"<div class=\"default\"></div>";

				resultStr	+=	"<div id=\"ajaxloaded\" style=\""+overlaystyle+"\">"+xmlHttpObj.responseText+"</div>";
			}
			else
			{
//				resultStr	=	"<div >"+xmlHttpObj.responseText+"</div>";
				resultStr	=	xmlHttpObj.responseText;
			}
			//alert(resultStr);
			if (containertype=="innerHTML")
			{
				document.getElementById(loadpageId).innerHTML	=	resultStr;
				var hid	=	document.getElementById('hiddensel').value;
				var arr = hid.split("@##@");
			
				setcolor(arr[0],arr[1],arr[2],arr[3],arr[4],arr[5]);
			}
			
			else if (containertype=="pricevalue")
			{
				document.getElementById(loadpageId).value	=	resultStr;
				//document.write(resultStr)
				//alert("@@@"+resultStr+"@@@@@");
				//calTotalPrice();

					calTotalPriceOnBasePriceChange();
				//calTotalPrice();
			}
			
			
			else if (containertype=="color")
			{

				//alert(resultStr);
				document.getElementById(loadpageId).innerHTML	=	resultStr;
				var hid	=	document.getElementById('hiddensel').value;
				var arr = hid.split("@##@");
		
				setcolor(arr[0],arr[1],arr[2],arr[3],arr[4]);
			}
			else if (containertype=="topcartsummery")
			{
				
				document.getElementById(loadpageId).innerHTML	=	resultStr;
			}


		}
		else
			alert("status is " + xmlHttpObj.status);
	}
}
function updateCart(url,loadpageId,overlaystyle,cost,quantity,indexid,cindexid)
{
	//document.getElementById("PlantSelectionBox").innerHTML ="<table valign=\"middle\" height=\"112\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"19\" width=\"40%\"><br /><br /><br /><br /><br /></td><td width=\"60%\"><img src=\"<?php echo $IMGPATH?>/images/calculating.gif\" width=\"121\" height=\"19\" /></td></tr></table>";
	//document.getElementById("loadPage").innerHTML ="<table valign=\"middle\" height=\"100\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"19\" width=\"41%\" ></td><td width=\"59%\"><img src=\"<?php echo $IMGPATH?>/images/loading.gif\" width=\"121\" height=\"19\" /></td></tr></table>";
	//document.getElementById("RightMenu").innerHTML ="<table width=\"100%\" valign=\"middle\" height=\"174\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"19\" width=\"15%\" ></td><td width=\"85%\"><img src=\"<?php echo $IMGPATH?>/images/loading_green.gif\" width=\"121\" height=\"19\" /></td></tr></table>";
	updateCartById(url,loadpageId,overlaystyle,cost,quantity,indexid,cindexid);
}
function updateCartById(url,loadpageId,overlaystyle,cost,quantity,indexid,cindexid)
{
	document.getElementById("overlaystyle").value=overlaystyle;
	var xmlHttpObj = getXMLHttpObj();
	xmlHttpObj.open("GET", url, true);
	xmlHttpObj.onreadystatechange = function()
	{
		updateCartHandleResponse(xmlHttpObj,loadpageId,overlaystyle,cost,quantity,indexid,cindexid);
	}
	xmlHttpObj.send(null);
}
function updateCartHandleResponse(xmlHttpObj,loadpageId,overlaystyle,cost,quantity,indexid,cindexid)
{
	if (xmlHttpObj.readyState == 4)
	{
		if (xmlHttpObj.status == 200)
		{
			//var resultStr = xmlHttpObj.responseText.split("~~~~~");
			var resultStr = "";
			if(overlaystyle	!=	"")
			{
				resultStr	=	"<div class=\"bkg\"></div><div id=\"ajaxloaded\" style=\""+overlaystyle+"\">"+xmlHttpObj.responseText+"</div>";
			}
			else
			{
				resultStr	=	"<div >"+xmlHttpObj.responseText+"</div>";
			}
			document.getElementById(loadpageId).innerHTML	=	resultStr;
			settotalcost(cost,quantity,indexid)
			setsubtotal(cindexid)
			setgrandtotal("sub_total")
		}
		else
			alert("status is " + xmlHttpObj.status);
	}
}
function deleteCartItem(url,loadpageId,overlaystyle,rowindex,cindexid,cartitem)
{
	//document.getElementById("PlantSelectionBox").innerHTML ="<table valign=\"middle\" height=\"112\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"19\" width=\"40%\"><br /><br /><br /><br /><br /></td><td width=\"60%\"><img src=\"<?php echo $IMGPATH?>/images/calculating.gif\" width=\"121\" height=\"19\" /></td></tr></table>";
	//document.getElementById("loadPage").innerHTML ="<table valign=\"middle\" height=\"100\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"19\" width=\"41%\" ></td><td width=\"59%\"><img src=\"<?php echo $IMGPATH?>/images/loading.gif\" width=\"121\" height=\"19\" /></td></tr></table>";
	//document.getElementById("RightMenu").innerHTML ="<table width=\"100%\" valign=\"middle\" height=\"174\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"19\" width=\"15%\" ></td><td width=\"85%\"><img src=\"<?php echo $IMGPATH?>/images/loading_green.gif\" width=\"121\" height=\"19\" /></td></tr></table>";
	deleteCartItemById(url,loadpageId,overlaystyle,rowindex,cindexid,cartitem);
}
function deleteCartItemById(url,loadpageId,overlaystyle,rowindex,cindexid,cartitem)
{
	document.getElementById("overlaystyle").value=overlaystyle;
	var xmlHttpObj = getXMLHttpObj();
	xmlHttpObj.open("GET", url, true);
	xmlHttpObj.onreadystatechange = function()
	{
		deleteCartItemHandleResponse(xmlHttpObj,loadpageId,overlaystyle,rowindex,cindexid,cartitem);
	}
	xmlHttpObj.send(null);
}
function deleteCartItemHandleResponse(xmlHttpObj,loadpageId,overlaystyle,rowindex,cindexid,cartitem)
{
	if (xmlHttpObj.readyState == 4)
	{
		if (xmlHttpObj.status == 200)
		{
			//var resultStr = xmlHttpObj.responseText.split("~~~~~");
			var resultStr = "";
			if(overlaystyle	!=	"")
			{
				resultStr	=	"<div class=\"bkg\"></div><div id=\"ajaxloaded\" style=\""+overlaystyle+"\">"+xmlHttpObj.responseText+"</div>";
			}
			else
			{
				resultStr	=	"<div >"+xmlHttpObj.responseText+"</div>";
			}
			//alert(resultStr);
			document.getElementById(loadpageId).innerHTML	=	resultStr;
			deleteclientsidecart(rowindex,cindexid,cartitem);
		}
		else
			alert("status is " + xmlHttpObj.status);
	}
}
function expressshipping1()
{
document.getElementById("final_shippind_charge").innerHTML = (document.getElementById("hship_country").value).toFixed(2);
document.getElementById("final_sum_price").innerHTML = (parseFloat(document.getElementById("hsumprice").value)+parseFloat(document.getElementById("hship_country").value)).toFixed(2); 
document.getElementById("total_amt").value = (parseFloat(document.getElementById("hsumprice").value)+parseFloat(document.getElementById("hship_country").value)).toFixed(2); 
}
function expressshipping()
{
	var expressshippingobj = document.getElementById("twodayshipping"); 
	
	var ship_country = document.getElementById("hship_country").value; 
	var shipTo_state = document.getElementById("shipTo_state").value;
	var itemCount = document.getElementById("itemCount").value;
	var itemCountWithQuantity = document.getElementById("itemCountWithQuantity").value;
	var url = "../includes/php/exshipping.php?twodayshipping=15&ship_country="+ship_country;
	var shippingonwidth = document.getElementById("hshippingonwidth").value; 

	if(expressshippingobj.checked == true)
	{
		var xmlHttpObj = getXMLHttpObj();
		var url = "../includes/php/exshipping.php?twodayshipping=15&ship_country="+ship_country+"&shipTo_state="+shipTo_state+"&itemCount="+itemCount+"&itemCountWithQuantity="+itemCountWithQuantity;
		xmlHttpObj.open("GET", url, true);
		xmlHttpObj.onreadystatechange = function()
		{
			if (xmlHttpObj.readyState == 4)
			{
				if (xmlHttpObj.status == 200)
				{	
				
					var final_shipping = (parseFloat(xmlHttpObj.responseText) + parseFloat(shippingonwidth));
					document.getElementById("final_shippind_charge").innerHTML = final_shipping.toFixed(2);
					document.getElementById("final_sum_price").innerHTML = (parseFloat(document.getElementById("hsumprice").value)+final_shipping).toFixed(2); 
					document.getElementById("total_amt").value = (parseFloat(document.getElementById("hsumprice").value)+final_shipping).toFixed(2); 
					document.getElementById("total_amt_PP").value = (parseFloat(document.getElementById("hsumprice").value)+final_shipping).toFixed(2); 
					//alert(final_shipping);
				}
				else
				alert("status is " + xmlHttpObj.status);
			}
		}
		xmlHttpObj.send(null);
		//alert("true true true true with true");
	}
	else
	{
		var xmlHttpObj = getXMLHttpObj();
		var url = "../includes/php/exshipping.php?twodayshipping=0&ship_country="+ship_country+"&shipTo_state="+shipTo_state+"&itemCount="+itemCount+"&itemCountWithQuantity="+itemCountWithQuantity;
//alert(url);
//document.write(url);
		xmlHttpObj.open("GET", url, true);
		xmlHttpObj.onreadystatechange = function()
		{
			if (xmlHttpObj.readyState == 4)
			{
				if (xmlHttpObj.status == 200)
				{	
					var final_shipping = (parseFloat(xmlHttpObj.responseText) + parseFloat(shippingonwidth));
					document.getElementById("final_shippind_charge").innerHTML = final_shipping.toFixed(2);
					document.getElementById("final_sum_price").innerHTML = (parseFloat(document.getElementById("hsumprice").value)+final_shipping).toFixed(2); 
					document.getElementById("total_amt").value = (parseFloat(document.getElementById("hsumprice").value)+final_shipping).toFixed(2); 
					document.getElementById("total_amt_PP").value = (parseFloat(document.getElementById("hsumprice").value)+final_shipping).toFixed(2); 
				}
				else
				alert("status is " + xmlHttpObj.status);
			}
		}
		xmlHttpObj.send(null);
		//alert("falseeeeeeeeeeeeeeeeeeeeeee");
	}
		
	
}