//list动态组合,曹旭东 2010-02-02
String.prototype.getQueryString = function(name)   
{   
   var reg = new RegExp("(^|&|\\?)"+ name +"=([^&]*)(&|$)"), r;   
   if ( r=this.match(reg) ) return unescape(r[2]);   
   return "0";   
} 

//根据地址栏的值和id的比较来确定哪个是选中的
function checkSearchPara2010()
{
   var $=jQuery
   var url=window.location.href.replace(".htm","");
   var arrurl=url.split("_");
   var arra= $(".Select a");
   
     var _index=url.indexOf("?");
     var catid,siteid,url_aspx;
     if(_index>0)
     {
       catid=url.getQueryString("catid");  
       siteid=url.getQueryString("siteid");
       url_aspx=arrurl[0]+"_"+siteid+"_"+catid+"_0_0_0_0_0_0_0_0_0_0_0_0_0";//原先旧的未url重写的地址要单独处理一下
      // url_aspx=arrurl[0]+"_"+siteid+"_"+catid+"_"+brandid+"_0_0_0_0_0_0_0_0_0_0_0_0";//原先旧的未url重写的地址要单独处理一下
     } 
    
   
   for(var i=0;i<arra.length;i++)//全部id循环
   {
   	    if (arra[i].id.length==6)
   	    {document.getElementById(arra[i].id).className="Line";}//“全部”默认有样式
   	    
   	    for(var j=0;j<arrurl.length;j++)//url值循环
	    {
    	  if (arra[i].id.substring(5)==arrurl[j]&&arra[i].id.length!=6)//要排除“全部”的条件
    	     {
    	         document.getElementById(arra[i].id).className="Line";
    	         document.getElementById(arra[i].id.substring(0,5)+"0").className="";//"全部"的不选中
    	     }
        }
        
          if (_index>0)
          {
              arra[i].href =newurl(url_aspx,arra[i].href);//原先旧的url地址单独组合
          }
          else
          {
              arra[i].href =newurl(window.location.href,arra[i].href);//根据点击当前地址和页面本身的地址组合成新的链接
          }
            
            if (arra[i].id.length==6)//"全部"的遍历并单独处理一下
            {
             arra[i].href=newurlall(arra[i].href,arra[i].id.substring(0,2));//arra[i].id.substring(0,2)代表参数在url地址中的位置（第几个参数）
            }

//            switch(arra[i].id)//排序和显示方式url组合的处理
//            {
//              case "0_order_1":
//                urlorder=urlbegin+"_"+siteid+"_"+catid+"_0_0_1_2_1_0_0_0_0_0_0_0_0"
//                arra[i].href=newurl(window.location.href,urlorder);
//                break;
//             case "0_order_2":
//                urlorder=urlbegin+"_"+siteid+"_"+catid+"_0_0_2_2_1_0_0_0_0_0_0_0_0"
//                arra[i].href=newurl(window.location.href,urlorder);
//                break;
//             case "0_order_3":
//                urlorder=urlbegin+"_"+siteid+"_"+catid+"_0_0_3_2_1_0_0_0_0_0_0_0_0"
//                arra[i].href=newurl(window.location.href,urlorder);
//                break;
//             case "0_order_4":
//                urlorder=urlbegin+"_"+siteid+"_"+catid+"_0_0_4_2_1_0_0_0_0_0_0_0_0"
//                arra[i].href=newurl(window.location.href,urlorder);
//                break;
//             case "0_order_5":
//                urlorder=urlbegin+"_"+siteid+"_"+catid+"_0_0_5_2_1_0_0_0_0_0_0_0_0"
//                arra[i].href=newurl(window.location.href,urlorder);
//                break;
//            case "0_type_1":
//                urlorder=urlbegin+"_"+siteid+"_"+catid+"_0_0_1_1_1_0_0_0_0_0_0_0_0"
//                arra[i].href=newurl(window.location.href,urlorder);
//                break;
//            case "0_type_2":
//                urlorder=urlbegin+"_"+siteid+"_"+catid+"_0_0_1_2_1_0_0_0_0_0_0_0_0"
//                arra[i].href=newurl(window.location.href,urlorder);
//                break;
//            }
   }
   
   switch (arrurl[5])//排序的样式
   {
     case "1":
      document.getElementById("span_0_order_1").className="Box bg";
      break;
     case "2":
      document.getElementById("span_0_order_2").className="Box bg";
      document.getElementById("span_0_order_1").className="Box";
      break;
     case "3":
      document.getElementById("span_0_order_34").className="Box bg";
      document.getElementById("span_0_order_1").className="Box";
      break;
     case "4":
      document.getElementById("span_0_order_34").className="Box bg";
      document.getElementById("span_0_order_1").className="Box";
      break;
     case "5":
      document.getElementById("span_0_order_5").className="Box bg";
      document.getElementById("span_0_order_1").className="Box";
      break;
   }
   switch(arrurl[6])//显示方式的样式
   {
       case "1":
        document.getElementById("span_0_type_1").src="http://static.51mdq.com/images/span_0_type_1.gif";
        document.getElementById("span_0_type_2").src="http://static.51mdq.com/images/span_0_type_2_1.gif";
       break;
       case "2":
        document.getElementById("span_0_type_1").src="http://static.51mdq.com/images/span_0_type_1_1.gif";
        document.getElementById("span_0_type_2").src="http://static.51mdq.com/images/span_0_type_2.gif";
       break;
   }
}

function newurlall(url1,id)//对导航“全部”进行的特殊处理
{
  var url3="";
  var arrurl1=url1.replace(".htm","").split("_");
     for (var a=0;a<arrurl1.length;a++)
     {
      if (a==parseInt(id))
        {arrurl1[a]="0";}
       url3=url3+arrurl1[a]+"_"; 
     }
 return url3.substring(0,url3.length-1)+".htm";
}

function newurl(url1,url2)//导航链接处理,url1为当前URL地址，url2为每个导航自己的链接
{
  
    var url3="";
    var arrurl1=url1.replace(".htm","").split("_");
    var arrurl2=url2.replace(".htm","").split("_");

    for (var a=0;a<arrurl1.length;a++)
      {
          for(var b=0;b<arrurl2.length;b++)
          {
               if (a==b)
                   {
                   if (arrurl1[a]==arrurl2[b])
                    {url3=url3+arrurl1[a]+"_";}
                    else
                    {
                      if(arrurl1[a]=="0"&&arrurl2[a]!="0")
                       {
                           url3=url3+arrurl2[a]+"_";
                        }
                      if(arrurl1[a]!="0"&&arrurl2[a]=="0")
                       {
                           if (a!=7)
                           {url3=url3+arrurl1[a]+"_";}
                           else //分页的参数要单独处理一下（不要保留分页的页码参数，不然排序和筛选没有意义了）
                           {url3=url3+arrurl2[a]+"_";}
                        }
                     if(arrurl1[a]!="0"&&arrurl2[a]!="0") 
                       {
                         url3=url3+arrurl2[a]+"_";
                       }
                    }
                }
          }
      }
return url3.substring(0,url3.length-1)+".htm";
}


