﻿var addtoCart

function cartinject()
{
	var yqty = document.getElementById("qty").value;
	var yid = document.getElementById("id").value;
	var ycategoryid = document.getElementById("categoryid").value;
	var ycategoryname = document.getElementById("categoryname").value;
	var yunit = document.getElementById("unit").value;
	var ypackaccount = document.getElementById("packaccount").value;
	var ypriceoption = document.getElementById("priceoption").value;
	var ypricerange = document.getElementById("pricerange").value;
	var ypriceend = document.getElementById("priceend").value;
	var ypriceprice = document.getElementById("priceprice").value;
	var yphotourl = document.getElementById("photourl").value;
	var yproductname = document.getElementById("productname").value;
	//steven 2009.11.6 添加商品尺寸及颜色
	var yproductsize = document.getElementById("productsize").value;
	var yproductcolor = document.getElementById("productcolor").value;
	
	var yPackLong = document.getElementById("PackLong").value;
	var yPackWidth = document.getElementById("PackWidth").value;
	var yPackHeight = document.getElementById("PackHeight").value;
	var yPackWeight = document.getElementById("PackWeight").value;
	var yitemoptions = document.getElementById("itemoptions").value;
	
	addtoCart=GetXmlHttpObject3()
	
	if (addtoCart==null)
	{
	alert ("您的浏览器不支持AJAX！");
	return;
	}

  var url="add2cart.php";//steven 2009.11.6 添加商品尺寸及颜色
  url=url+"?qty="+yqty+"&id="+yid+"&categoryid="+ycategoryid+"&categoryname="+ycategoryname+"&unit="+yunit+"&packaccount="+ypackaccount+"&priceoption="+ypriceoption+"&pricerange="+ypricerange+"&priceend="+ypriceend+"&priceprice="+ypriceprice+"&photourl="+yphotourl+"&productname="+yproductname+"&productsize="+yproductsize+"&productcolor="+yproductcolor+"&PackLong="+yPackLong+"&PackWidth="+yPackWidth+"&PackHeight="+yPackHeight+"&PackWeight="+yPackWeight+"&itemoptions="+yitemoptions+"&"+Math.random();
  addtoCart.onreadystatechange=stateChanged3;
  addtoCart.open("GET",url,true);
  addtoCart.send(null);
} 

function stateChanged3() 
{
	if (addtoCart.readyState==4)
	{
		document.getElementById("echonewmonty").innerHTML=addtoCart.responseText;
		setTimeout("document.getElementById(\"littlewindowadd2cart\").style.display='none'",1000);
	}
}

function GetXmlHttpObject3()
{
  var addtoCart=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    addtoCart=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      addtoCart=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      addtoCart=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
return addtoCart;
}


function openlittlewindowaddtocart()
{
	var aloading = document.getElementById("littlewindowadd2cart");
	aloading.style.display = "block";
	aloading.style.top = document.documentElement.clientHeight/2+document.documentElement.scrollTop+"px";
}