// JScript 文件


//选择产品类型,设置产品类型价格
function chooseBuyNum()
{
	

	var catrSum=0;
	var catrPrice=0;
        var id
	var catrBasePrice=0;
        id=$('id').value;
       
       catrBasePrice=$('basePrice').value;
       
       catrNum=$('BuyNum').options[$('BuyNum').selectedIndex].value;
	//alert(BuySum);
	 
         if(catrBasePrice==0){
        callServerprice(id);              //  selectprice.asp?t=6&id="+p;
         callServerpricetj(id,catrNum);   // selectprice.asp?t=7&id="+p+"&n="+num;

        }else{


        

        catrSum=catrBasePrice*catrNum;	

        strbuypeijianprice=  $("buypeijianprice").value;
          
       strtotalprice=parseFloat(catrSum)+parseFloat(strbuypeijianprice);

       
	$('SumMoney').style.display='';
	$('SumMoney').innerHTML=''+catrSum+'';
        $("buySumMoney").value=catrSum;
        $('gouwuprice').innerHTML=''+catrSum+'';
        $("buygouwuPrice").value=catrSum;
         
         $('peijianprice').innerHTML=''+strbuypeijianprice+'';
        $("buypeijianprice").value=strbuypeijianprice;

                 
         $('totalprice').innerHTML=''+strtotalprice+'';
        $("buytotalprice").value=strtotalprice;

        }
        

         $('pamount_'+id).value=catrNum;

	
}






function choosepcolor(pcolorid)
{	
        var  pcolorid,brandsid2,t2i
         t2i=$('pid_2_t2').value;
	
        var id
	var catrBasePrice=0;
        id=$('id').value;
        callServerbasicprice(id);
        catrBasePrice=$('basePrice').value;
	//设置当成点击为选中
	$("pcolors"+pcolorid).className='pcolorCurrent';
	//撤消除当前点击以外的选中状态
	for(var i=0;i<t2i;i++){
		if(i!=pcolorid){
			$("pcolors"+i).className='pcolor';
                       
		}
                else{
			$("pcolors"+i).className='pcolorCurrent';
                       $("pid_2_"+i).checked='true';
                       pid=$("pid_2_"+i).value;
                      brandsid2=$('pid_2_brandsID').value;
                       $("pid_"+brandsid2+"_"+id).value=pid;
                        callServercolorselect(pid);
                        callServercolor(pid);
                       
		}
	}
       }  
	
function choosesizecolor(sizecolorid)
{	
         var  sizecolorid,brandsid3,t3i
        var id
	var catrBasePrice=0;
        id=$('id').value;
        catrBasePrice=$('basePrice').value;
        callServerbasicprice(id,catrBasePrice);

         t3i=$('pid_3_t3').value;
	//设置当成点击为选中
	$("sizecolors"+sizecolorid).className='sizecolorCurrent';
	//撤消除当前点击以外的选中状态
	for(var i=0;i<t3i;i++){
		if(i!=sizecolorid){
			$("sizecolors"+i).className='sizecolor';
                       
		}
                else{
			$("sizecolors"+i).className='sizecolorCurrent';
                       $("pid_3_"+i).checked='true';
                      
                      pid=$("pid_3_"+i).value;
                      brandsid3=$('pid_3_brandsID').value;
                       $("pid_"+brandsid3+"_"+id).value=pid;
		
	      }

            }
          }



	
function choosejxcolor(jxcolorid)
{	
         var  jxcolorid,brandsid4,t4i
        var id
	var catrBasePrice=0;
        id=$('id').value;
        catrBasePrice=$('basePrice').value;
        callServerbasicprice(id,catrBasePrice);
         t4i=$('pid_4_t4').value;
	//设置当成点击为选中
	$("jxcolors"+jxcolorid).className='jxcolorCurrent';
	//撤消除当前点击以外的选中状态
	for(var i=0;i<t4i;i++){
		if(i!=jxcolorid){
			$("jxcolors"+i).className='jxcolor';
                       
		}
                else{
			$("jxcolors"+i).className='jxcolorCurrent';
                       $("pid_4_"+i).checked='true';
                        pid=$("pid_4_"+i).value;
                      brandsid4=$('pid_4_brandsID').value;
                       $("pid_"+brandsid4+"_"+id).value=pid;
                        
		}
	}
       }  


function choosetccolor(tccolorid)
{	
         var  tccolorid,brandsid5,t5i
        var id
	var catrBasePrice=0;
        id=$('id').value;
           catrNum=$('BuyNum').options[$('BuyNum').selectedIndex].value;
          strpeijianprice=$("buypeijianprice").value;
	//alert(BuySum);
         t5i=$('pid_5_t5').value;
	//设置当成点击为选中
	$("tccolors"+tccolorid).className='tccolorCurrent';
	//撤消除当前点击以外的选中状态
	for(var i=0;i<t5i;i++){
		if(i!=tccolorid){
			$("tccolors"+i).className='tccolor';
                       
		}
                else{
			$("tccolors"+i).className='tccolorCurrent';
                       $("pid_5_"+i).checked='true';

                        pid=$("pid_5_"+i).value;
                      brandsid5=$('pid_5_brandsID').value;
                       $("pid_"+brandsid5+"_"+id).value=pid;

                        pprice=$("proprice"+i).value;
                        

                        if(tccolorid==0){

                        callServerbasicprice(id,pprice);
                        callServerpricetj(id,catrNum);   // selectprice.asp?t=7&id="+p+"&n="+num;
                       callServerpricetjpjbp(id,pid,catrNum);   // 
                        

                       }else{

                        $('basePrice').value=pprice  
                        
   
     	                
                        catrSum=pprice*catrNum;	
                         strtotalprice=parseFloat(catrSum)+parseFloat(strpeijianprice);
                      
	               $('SumMoney').style.display='';
	                $('SumMoney').innerHTML=''+catrSum+'';       
                        $("buySumMoney").value=''+catrSum+'';

                        $('gouwuprice').innerHTML=''+catrSum+'';  
                         $("buygouwuprice").value=''+catrSum+'';

                         $('peijianprice').innerHTML=''+strpeijianprice+'';  
                         $("buypeijianprice").value=strpeijianprice;

                         $('totalprice').innerHTML=''+strtotalprice+'';  
                         $("buytotalprice").value=strtotalprice;


                       }
                         
                        
		}
	}
       
      
       $('pamount_'+id).value=catrNum;

       }  



function choosepjcolor(pjcolorid)
{	
         var  pjcolorid
         var  pprice
         var  price
         var  strprice
         var  t6i
        var id
	var catrBasePrice=0;
        id=$('id').value;
        catrBasePrice=$('basePrice').value;
        callServerbasicprice(id,catrBasePrice);
         t6i=$('pid_6_t6').value;
	strprice=$('basePrice').value;
	//设置当成点击为选中
	$("pjcolors"+pjcolorid).className='pjcolorCurrent';
	//撤消除当前点击以外的选中状态
	for(var i=0;i<t6i;i++){
		if($("pid_6_"+i).checked!='true'){
			$("pjcolors"+i).className='pjcolor';
                       pprice=$("proprice"+i).value;
                         
                       strprice=Number(strprice)-Number(pprice);
                       $("pid_6_"+i).checked='flase';
		}
                else{
			$("pjcolors"+i).className='pjcolorCurrent';
                       $("pid_6_"+i).checked='true';
                         pprice=$("proprice"+i).value;
                         
                        strprice=Number(strprice)+Number(pprice);
		}
	}
       
      
      $('basePrice').value=strprice
     

       }  


function choosekxpj(kxpjid)
{	
         var  kxpjid
         var  pprice
         var  price
         var  strprice
         var  pok
        var id
	var catrBasePrice=0;
        id=$('id').value;
        catrBasePrice=$('basePrice').value;

        callServerbasicprice(id,catrBasePrice);

       buygouwuprice =  $("buygouwuprice").value;
            buypeijianprice=   $("buypeijianprice").value;
            buytotalprice =   $("buytotalprice").value;
            buysummoney =   $("buysummoney").value;


	//设置当成点击为选中
	
	//撤消除当前点击以外的选中状态

                 pok=$("pjid_"+kxpjid).checked;
                 
                 

                if($(pok)!=true) {
                   
                       callServerkxpjdowntj(kxpjid,buytotalprice,id);
                   callServerkxpjdowntjpj(kxpjid,buypeijianprice);
                       callServerkxpjdown(kxpjid);
                       


                       alert('已经从购物车移除！');
                }
                else{
                  callServerkxpjontj(kxpjid,buytotalprice,id);
                   callServerkxpjontjpj(kxpjid,buypeijianprice);
                  callServerkxpjon(kxpjid);
                 alert('已经加入购物车！');
            }
                              
                        

	
 }  


function addmycart(addid)
{	
         var  addid
         var  pprice
         var  price
         var  strprice
         var  pok
        var id
	var catrBasePrice=0;
        id=$('id').value;
        catrBasePrice=$('basePrice').value;
        callServerbasicprice(id,catrBasePrice);
	callServeraddmycart(addid);
          alert('已经加入购物车！');
           
                              
                        

	
 }  





//触发初始商品基本价
var xmlHttp0 = false;
try {
  xmlHttp0 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp0 = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp0 = false;
  }
}
if (!xmlHttp0 && typeof XMLHttpRequest != 'undefined') {
  xmlHttp0 = new XMLHttpRequest();
}

//触发初始商品基本价更新
function callServerbasicprice(id,basicprice) {
  
  var url = "/selectprice.asp?t=0&id="+id+"&b="+basicprice;

  xmlHttp0.open("GET", url, true);

  xmlHttp0.onreadystatechange = updatePagebasicprice;
  xmlHttp0.send(null);  
  
}

function updatePagebasicprice() {
  if (xmlHttp0.readyState < 4) {
	document.check.basePrice.value="0";
       
  }
  if (xmlHttp0.readyState == 4) {
    var response = xmlHttp0.responseText;
	document.check.basePrice.value=response;
     
  }
}






var xmlHttp = false;
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

var xmlHttp1 = false;
try {
  xmlHttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp1 = false;
  }
}
if (!xmlHttp1 && typeof XMLHttpRequest != 'undefined') {
  xmlHttp1 = new XMLHttpRequest();
}


var xmlHttp2 = false;
try {
  xmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp2 = false;
  }
}
if (!xmlHttp2 && typeof XMLHttpRequest != 'undefined') {
  xmlHttp1 = new XMLHttpRequest();
}



function callServer(p) {
  
  var url = "/loadpropic.asp?id="+p;

  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updatePage;
  xmlHttp.send(null);  
  
}

function updatePage() {
  if (xmlHttp.readyState < 4) {
	test1.innerHTML="loading...";
  }
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
	test1.innerHTML=response;
  }
}

//价格初始化
function callServerprice(p) {
  
  var url = "/selectprice.asp?t=6&id="+p;

  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updatePageprice;
  xmlHttp.send(null);  
  
}

function updatePageprice() {
  if (xmlHttp.readyState < 4) {
   document.check.basePrice.value="";
        
  }
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
     totalprice.innerHTML=response;
     document.check.basePrice.value=response;
      document.check.buysummoney.value=response;
      document.check.buytotalprice.value=response;
      document.check.buygouwuprice.value=response;
  }
}


//价格初始化小计统计
function callServerpricetj(p,num) {
  
  var url = "/selectprice.asp?t=7&id="+p+"&n="+num;

  xmlHttp1.open("GET", url, true);
  xmlHttp1.onreadystatechange = updatePagepricetj;
  xmlHttp1.send(null);  
  
}

function updatePagepricetj() {
  if (xmlHttp1.readyState < 4) {
	
         SumMoney.innerHTML="loading...";
  }
  if (xmlHttp1.readyState == 4) {
    var response = xmlHttp1.responseText;
    
     SumMoney.innerHTML=response;
    totalprice.innerHTML=response;
    gouwuprice.innerHTML=response;
     document.check.buysummoney.value=response;
      document.check.buytotalprice.value=response;
      document.check.buygouwuprice.value=response;
  }
}


//选定官方标配价格综合统计
function  callServerpricetjpjbp(id,pid,num) {
  
  var url = "/addcarttjpjbp.asp?pid="+pid+"&id="+id+"&n="+num;

  xmlHttp2.open("GET", url, true);
  xmlHttp2.onreadystatechange = updatePagepricetjpjbp;
  xmlHttp2.send(null);  
  
}

function updatePagepricetjpjbp() {
  if (xmlHttp2.readyState < 4) {
	
         totalprice.innerHTML="loading...";
  }
  if (xmlHttp2.readyState == 4) {
    var response = xmlHttp2.responseText;
    
    
    totalprice.innerHTML=response;
    document.check.buytotalprice.value=response;
    
  }
}




function callServerkxpjon(kxpjid) {
  
  var url = "/addcart.asp?pid="+kxpjid;

  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updatePagekxpjon;
  xmlHttp.send(null);  
  
}

function updatePagekxpjon() {
  if (xmlHttp.readyState < 4) {
	mycarto.innerHTML="loading...";
  }
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
	mycarto.innerHTML=response;
  }
}

function callServerkxpjdown(kxpjid) {
  
  var url = "/delcart.asp?id="+kxpjid;

  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updatePagekxpjdown;
  xmlHttp.send(null);  
  
}

function updatePagekxpjdown() {
  if (xmlHttp.readyState < 4) {
	mycarto.innerHTML="loading...";
  }
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
	mycarto.innerHTML=response;
  }
}


//配件选定统计价格总数

function callServerkxpjontj(kxpjid,g,id) {
  
  var url = "/addcarttj.asp?pid="+kxpjid+"&g="+g+"&id="+id;

  xmlHttp1.open("GET", url, true);
  xmlHttp1.onreadystatechange = updatePagekxpjontj;
  xmlHttp1.send(null);  
  
}

function updatePagekxpjontj() {
  if (xmlHttp1.readyState < 4) {
	totalprice.innerHTML="loading...";
  }
  if (xmlHttp1.readyState == 4) {
    var response = xmlHttp1.responseText;
	totalprice.innerHTML=response;
         document.check.buytotalprice.value=response;
  }
}

//配件选定配件统计价格总数


function callServerkxpjontjpj(kxpjid,g) {
  
  var url = "/addcarttjpj.asp?pid="+kxpjid+"&g="+g;

  xmlHttp2.open("GET", url, true);
  xmlHttp2.onreadystatechange = updatePagekxpjontjpj;
  xmlHttp2.send(null);  
  
}

function updatePagekxpjontjpj() {
  if (xmlHttp2.readyState < 4) {
	peijianprice.innerHTML="loading...";
  }
  if (xmlHttp2.readyState == 4) {
    var response = xmlHttp2.responseText;
	peijianprice.innerHTML=response;
         document.check.buypeijianprice.value=response;
  }
}

//配件删除统计价格总数

function callServerkxpjdowntj(kxpjid,g,id) {
  
  var url = "/delcarttj.asp?pid="+kxpjid+"&g="+g+"&id="+id;

  xmlHttp1.open("GET", url, true);
  xmlHttp1.onreadystatechange = updatePagekxpjontj;
  xmlHttp1.send(null);  
  
}

function updatePagekxpjontj() {
  if (xmlHttp1.readyState < 4) {
	totalprice.innerHTML="loading...";
  }
  if (xmlHttp1.readyState == 4) {
    var response = xmlHttp1.responseText;
	totalprice.innerHTML=response;
         document.check.buytotalprice.value=response;
  }
}

//配件删除配件统计价格总数


function callServerkxpjdowntjpj(kxpjid,g) {
  
  var url = "/delcarttjpj.asp?pid="+kxpjid+"&g="+g;

  xmlHttp2.open("GET", url, true);
  xmlHttp2.onreadystatechange = updatePagekxpjontjpj;
  xmlHttp2.send(null);  
  
}

function updatePagekxpjontjpj() {
  if (xmlHttp2.readyState < 4) {
	peijianprice.innerHTML="loading...";
  }
  if (xmlHttp2.readyState == 4) {
    var response = xmlHttp2.responseText;
	peijianprice.innerHTML=response;
         document.check.buypeijianprice.value=response;
  }
}



function callServeraddmycart(addid) {
  
   var url = "/addcartok.asp?pid="+addid;

  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updatePageaddmycart;
  xmlHttp.send(null);  
  
}

function updatePageaddmycart() {
  if (xmlHttp.readyState < 4) {
	mycarto.innerHTML="loading...";
  }
  if (xmlHttp.readyState == 4) {
    var response = xmlHttp.responseText;
	mycarto.innerHTML=response;
  }
}


	
//-->