﻿// JScript 文件

function productattribute(classids,orderid)
{
    var bigbox=document.getElementById("pr_searchBox");
    var selects=bigbox.getElementsByTagName("select");
    var atts=document.getElementById("ctl00_ContentPlaceHolder1_attlist");
   
    ///初始化
    this.ini=function(values,min,max,key)
            {
               
                for(var i=0;i<selects.length;i++)
                {
                     selects[i].options.add(new Option("--不限--","0"),0);
                }
                
                var as=atts.getElementsByTagName("select");
                for(var i=0;i<as.length;i++)
                {
                    for(var ii=0;ii<as[i].options.length;ii++)
                    {
                        
                           as[i].options[ii].selected=values.indexOf(as[i].options[ii].value)>-1; 
                       
                    }
                }
                as=atts.getElementsByTagName("input");
                for(var a=0;a<as.length;a++)
                {
                    if(as[a].type=="checkbox")
                    {
                        as[a].checked=values.indexOf(as[a].value)>-1; 
                    }
                }
                document.getElementById("tmin").value=min;
                document.getElementById("tmax").value=max;
                document.getElementById("tkey").value=key;
                document.getElementById("psort").value=orderid;
                
            }
    ///取得选定的商品属性,不包品牌
   this.returnvalue= function()
    {
        var retus="";
         
          var as=atts.getElementsByTagName("select");
                for(var i=0;i<as.length;i++)
                {
                    for(var ii=0;ii<as[i].options.length;ii++)
                    {
                        
                          if(as[i].options[ii].selected)
                          {
                          retus=retus+as[i].options[ii].value+",";
                          }
                       
                    }
                }
                as=atts.getElementsByTagName("input");
                for(var a=0;a<as.length;a++)
                {
                    if(as[a].type=="checkbox")
                    {
                        if(as[a].checked)
                        {
                             retus=retus+ as[a].value+","; 
                        }
                    }
                }
                return  retus;
                
    }
    ///取得商品品牌
    this.returnbrandid=function()
    {
        return document.getElementById("ctl00_ContentPlaceHolder1_blist").value;
    }
    this.gourl=function()
    {
   
     
        document.location.href=("/"+classids+"-"+this.returnbrandid()+"-1-"+ this.returnvalue()+"-"+document.getElementById("tmin").value+"-"+document.getElementById("tmax").value+"/product.html"+
        document.getElementById("tkey").value+"_"+document.getElementById("psort").value);
    }
    
    
    
}

function productcompare()
{
    var chs=document.getElementById("c_right").getElementsByTagName("input");
    var ids="";
    var b=0;
    for(var i=0;i<chs.length;i++)
    {
        if(chs[i].type=="checkbox")
        {
            if(chs[i].checked)
            {
                ids=ids+chs[i].value+",";
                b++;
             }
        }
    }
    if(b<1||b>5)
        alert("请选择1-5件商品进行对比!")
   else
   {
 
         window.open("/compareproduct.html?"+ids,"_blank");
         }
   
    
}