﻿var gColor = "#f00";
//鼠标经过事件
     function addEventOn(labelID,switchID,maxNum){
         for(i=1;i<=maxNum;i++)
          document.getElementById(labelID+i).onmouseover= JSsetSwitch(labelID,switchID,i,maxNum);
        JSshowSwitch(labelID,switchID,1,maxNum);
     }
//单击事件
     function addEventOnclick(labelID,switchID,maxNum){
         for(i=1;i<=maxNum;i++)
          document.getElementById(labelID+i).onclick= JSsetSwitch(labelID,switchID,i,maxNum);
        JSshowSwitch(labelID,switchID,1,maxNum);
     }
     
     
     var JSsetSwitch=function(labelID,switchID,num,maxNum){
        return function(){JSshowSwitch(labelID,switchID,num,maxNum);}
     }
     
     function JSshowSwitch(labelID,switchID,num,maxNum){
         for(i=1;i<=maxNum;i++){
           document.getElementById(labelID+i).className=null;
           document.getElementById(switchID+i).style.display="none";
         }
        document.getElementById(labelID+num).className="selected";
        document.getElementById(switchID+num).style.display="";
        if(num == 1) {
            document.getElementById("searchType").value = "material";
        }
        else if(num==2) {
             document.getElementById("searchType").value = "product";
        }else {
            document.getElementById("searchType").value = "productname";
        }
     }
     
     
     function doSearch() {
        if(document.getElementById("searchType").value == "material") {
             window.location = "searchrss_m.aspx?keyword=" + encodeURIComponent(document.getElementById("textfield").value);
        }else if(document.getElementById("searchType").value == "productname") {
             window.location = "searchrss_n.aspx?keyword=" + encodeURIComponent(document.getElementById("textfield").value);
        }
        else {
            window.location = "searchrss.aspx?keyword=" + encodeURIComponent(document.getElementById("textfield").value);
        }
        return false;
     }
     
     
     function ocAction(objID) {
        var o = document.getElementById(objID);
        if(o.style.display == "none") {
            o.style.display = "block";
        }else 
        {
            o.style.display = "none";
        }
     }
     
     function imgWH(imgID,W,H)
    {
       var image = new Image();
       image.src = imgID.src;
       var intWidth=image.width;
       var intHeight=image.height;
       if(intWidth>W)
       {
         intHeight=intHeight*W/intWidth;
         intWidth=W;
       }
       if(intHeight>H)
       {
         intWidth=intWidth*127/intHeight;
         intHeight=H;
       }
       imgID.width=intWidth;
       imgID.height=intHeight;
    }
     