﻿// JScript 文件
  var sumprice=0.00;  
  var changeprice = new Array();
  var sumwieght=0.00;
  var changeweight = new Array(); 
  var allprice=0.0
  var ProductNum = new Array(); 
  var str ;
 function Uni_onclick1(str1,str2,str3,str4,str5)
 {
   var i=str1;
   var j=str2;
   var sumnum =str3;
   var ToalPrice;
   var productImagename=document.getElementById("productImage" + str3);
   var productImagenamez =productImagename.value;
   var ProductImage=document.getElementById("prodctImage"+i);
   if (productImagenamez!="")
   {
    ProductImage.src="ImageZoom.aspx?jpeg="+productImagenamez+"&tw=100&th=90"   //+"."+productImagenamehz;
   }
   else
   {
   ProductImage.src="ImageZoom.aspx?jpeg=space.gif&tw=100&th=90"   //+"."+productImagenamehz;
   }

//   ProductImage.src="images_product/"+productImagename   //+"."+productImagenamehz;
//   var productImagenamehz=eval("document.all.productImagehz" + str3);
//   var productImagenamehz =productImagenamehz.value;
 
//  var sumprice1=parsefloat(string productprice);
//   if (str2=="0")
//    {
//     allprice=eval(sumprice);
//    headif.innerHTML= "$"+allprice;
//    }
//    else
//    {
// allprice=eval(sumprice)+eval(productprice.value);
//    headif.innerHTML= "$"+allprice;
//    } 
  //重量数组
//   var productwieght=eval("document.all.productwi" + str3);
//   var index=eval(str4)-1;
//   changeweight[index]=productprice.value;
   //价格数组
   var productprice=document.getElementById("productpr" + str3);
   var headif = document.getElementById("SystemToalPrice1");
   var headif1 = document.getElementById("SystemToalPrice2");
   var index=eval(str4)-1;
   changeprice[index]=productprice.value;
   //上面是改变数组
     sumprice=0.0
   for (i=0;i<changeprice.length;i++)
   {
//    sumwieght=eval(sumwieght)+eval(changeweight[i]);
     sumprice=eval(sumprice)+eval(changeprice[i]);
   }
//     headif.innerHTML=sumprice.toFixed(2);
//     headif1.innerHTML=sumprice.toFixed(2);
    headif.innerHTML=priceform(sumprice)
    headif1.innerHTML=priceform(sumprice)
    //修改选择后的部件信息
    var partname=document.getElementById("partname"+str4);
   ProductNum[index]=partname.value+":"+str5
 }
 function  priceform(strprice)
 {
 strprice=eval(strprice)*100/100;
 var priceannry
    var strprice;
     strprice=sumprice+"";
     priceannry=strprice.split(".")
     if (priceannry[0].length>3 && priceannry[0].length<=6 )
      {
       var strsub1=priceannry[0];
       var strsub2=priceannry[0];
       var strsub3
       var strsub4
       strsub3=priceannry[1]+""
      // alert(strsub3)
       if(strsub3=='undefined')
       {
         strsub3=""
        }
       else 
       {
         strsub3="."+priceannry[1]
       }
       strsub4=strsub1.substr(0,strsub1.length-3)+","+strsub2.substr(strsub2.length-3,3)+strsub3;
         return strsub4
      }
     else
      {
          return sumprice
      }
 }
 //初始化
 function  form_load()
 {
  var productpart=document.getElementById("productpart");
  var j =eval(productpart.value);
  var s=0;
  for(i=0;i<j;i++)   
  {   
  ++s;
   //总部件数
  var partname=document.getElementById("partname"+s);
  var productid=document.getElementById("productid"+s);
   ProductNum[i]=partname.value+":"+productid.value;  
   //总价
  var HiddenSumPrice=document.getElementById("Sum_prict"+s);
  changeprice[i] =HiddenSumPrice.value;  
  sumprice=eval(sumprice)+eval(HiddenSumPrice.value);  
    //总重量
   //   var HiddenSumwieght=eval("document.all.Sum_wieght"+s);
  //  changeweight[i] =HiddenSumwieght.value;  
 //  sumwieght=eval(sumwieght)+eval(HiddenSumwieght.value);  
  }   
  var headif = document.getElementById("SystemToalPrice1");
  var headif1 = document.getElementById("SystemToalPrice2");
 //  sumprice=eval(sumprice)*100/100;
//  headif.innerHTML=sumprice.toFixed(2);   
//  headif1.innerHTML=sumprice.toFixed(2);
    headif.innerHTML=priceform(sumprice)
    headif1.innerHTML=priceform(sumprice)
 }

 function InitAjax()
{
　var ajax=false; 
　try { 
　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
　} catch (e) { 
　　try { 
　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
　　} catch (E) { 
　　　ajax = false; 
　　} 
　}
　if (!ajax && typeof XMLHttpRequest!='undefined') { 
　　ajax = new XMLHttpRequest(); 
　} 
　return ajax;
}

 function  form_submit()
 {
   str="$";
   for(i=0;i<ProductNum.length;i++)   
  {   
   str=str+ProductNum[i]+"$"; 
  } 
  var SysId=document.getElementById("SysId");
  var SysName=document.getElementById("SysName");
    //location.href("makeOrder.aspx?select_system_info="+str+"&SysId="+SysId.value+"&sumprice="+sumprice+"&SystemName="+SysName.value);
    var url
    var postStr
    postStr="select_system_info="+str+"&SysId="+SysId.value+"&sumprice="+sumprice+"&SystemName="+SysName.value  //+"&sumweight="+sumwieght
    url="makeOrder.aspx"
     var ajax = InitAjax();
//通过Post方式打开连接
　//***************************************************
   ajax.open("POST", url, true); 

　//定义传输的文件HTTP头信息
　ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 

　//发送POST数据
　ajax.send(postStr);

　//获取执行状态
　ajax.onreadystatechange = function() 
　{ 
　　//如果执行状态成功，那么就把返回信息写到指定的层里
　　if (ajax.readyState == 4 && ajax.status == 200) 
　　{ 
　　    var upinfo=document.getElementById("UPInfo");
　　    if (ajax.responseText=="Add to cart")
　　           {
　　          parent.window.location='cartview.aspx';
　　          // alert(ajax.responseText)
　　           }
　　    else
　　           {
　　            alert(ajax.responseText)
　　           }
　　   //alert(ajax.responsetext);
　　} 
　}
 }
 function openurl()
 {
  var links = document.getElementsByTagName('a');
  for (var i=0;i < links.length;i++) 
   {
    if (links[i].className == 'new-window') 
     {
      links[i].onclick = function() 
       {
        var properties = "toolbar=0,location=0,scrollbars=1,height=" + document.documentElement.clientHeight/1.5;
        properties = properties + ",width="+document.documentElement.clientWidth/1.5;
        properties = properties + ",left=0,top=0";
        window.open(this.href,'tipwindow',properties);
        return false;
        };
      }
    }
  }
  function formback()
 {
 history.go(-1) 
 }
 function OpenMoreInfoChooseWindow (_url) {	
	var winplay = window.open(_url, 'MoreInfo', "width=1000, height=400, location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
	if (parseInt(navigator.appVersion) >= 4) { winplay.window.focus(); }
  }
// function 　()
// {
// window.showModalDialog('cc-cvv.htm','','dialogHeight:500px;dialogwidth:540px;status=no;help=no;');
// }
 
  function GetUserPass(_url) {	
	var winplay = window.open(_url, 'MoreInfo', "width=320, height=160, channelmode=no,top=500,left=500,location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
	if (parseInt(navigator.appVersion) >= 4) { winplay.window.focus(); }
  }
  function sc1()
  {
     document.getElementById("advertisement").style.top=(document.documentElement.scrollTop+eval(200))+"px"; //(document.documentElement.clientHeight-document.getElementById("advertisement").offsetHeight)/2
     document.getElementById("advertisement").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("advertisement").offsetWidth-eval(30))+"px";
   }
    function sc2()
 {
      document.getElementById("advertisement").style.top=(document.documentElement.scrollTop+eval(200)) +"px"; //(document.documentElement.clientHeight-document.getElementById("advertisement").offsetHeight)/2
      document.getElementById("advertisement").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("advertisement").offsetWidth-eval(20))+"px";
  }
  function displayPopup(url,width,height)
 {
  var properties = "toolbar=0,location=0,scrollbars=1,height=" + height;
  properties = properties + ",width=" + width;
  properties = properties + ",left=0,top=0";
  popupHandle = open(url, "tipwindow", properties);
 }
