/**
 * @author Administrator
 */
    var iPageSize =4;       //per page to PageSize
    var iCurrentPage=1;     //current is number Page
    var iPageCountSize =0;  //PageCountSize
    var iPageCount=0;       //PageCount
    var iFromPageSize=0;    //from Page Size Start   
     
    var strAllProductID       = new Array(); //all productID;
    var strAllProductName     = new Array(); //all product Name;
    var strAllProductModel    = new Array(); //all product Model;
    var strAllProductImage    = new Array(); //all product Image;
    var strAllProductKeyWord  = new Array(); //all product KeyWord;
    var strAllProductPrice    = new Array(); //all product price;
    var strAllProductClassID  = new Array(); //all  product Class ID; 
         
    var searchProductID      = new Array();//search productID
    var searchProductName    = new Array();//search productName;
    var searchProductModel   = new Array(); //search productModel;
    var searchProductImage    = new Array(); // search productImage;
    var searchProductKeyWord   = new Array(); //search productKeyWord;
    var searchProductPrice    = new Array(); //search productPrice;
    var searchProductClassID   = new Array(); //search productClassID; 
    
    
    var arrProductClassID  = new Array(); //productClassID
    var arrProductClassName = new Array(); //productClassName   
    var classIds=new Array();//
    
    var strNullImage = "../images/pic_pro_small.jpg"; //product is not image is show 
    var strProductImageTafixPath = "../upload/small/";	
    
	var strTProductList = "TProductList";	
	
	var strOrderPassValue = "";
	
    function Search()
    {
        var strProductKey = document.getElementById("txtSearchKey").value;
        var strProductClassKey = document.getElementById("selSearchProductClassList");
       
        var iSelProductClassIndex   =  strProductClassKey.selectedIndex;
        var strSelProductClassValue =  strProductClassKey.options[iSelProductClassIndex].value;
        var strSelProductClassText  =  strProductClassKey.options[iSelProductClassIndex].text;   
        
        if(strProductKey == "")
        {
            SearchByProductClass(strSelProductClassValue);            
            FirstPage();
            PageDertption();
           // BindToSelSearchProductClassList();
        }
        else
        {
            SearchByPNameAndPCID(strProductKey,strSelProductClassValue);
            FirstPage();
            PageDertption();
          //  BindToSelSearchProductClassList();
        }                
    }
    
    //searchByPNameANDPCID
    function  SearchByPNameAndPCID(ProductName,ClassID)
    {     
        var TProductList = document.getElementById(strTProductList);  
        
        if(TProductList == null)
        {
        }
        else
        {            
          
            var iTotalLength = searchProductID.length;
            if(ClassID == "0")
            {
                  
                strAllProductID.length = 0;
                strAllProductName.length = 0;
                strAllProductModel.length  =0 ;
                strAllProductImage.length = 0;
                strAllProductKeyWord.length = 0;
                strAllProductPrice.length = 0;
                strAllProductClassID.length = 0;    
                            
                 //True or false
                 var middleParam =0;
                 
                 //Array ID
                 var iTempPassValue =0;
                 for(var i= 0; i<iTotalLength ;i++)
                 { 
                    var  newSearchKey = searchProductKeyWord[i].split(",");                    
                    
                    for(var k=0;k<newSearchKey.length;k++)
                    {
			newSearchKey[k]=newSearchKey[k].toLowerCase();
                        var myIndex =  newSearchKey[k].indexOf(ProductName.toLowerCase());
                        if(myIndex != -1)
                        {
                            middleParam =1;                                                   
                            break;
                        }
                        else
                        {                           
                        }                     
                    } 
                    
                    if(middleParam == 1)
                    {
                         strAllProductID[iTempPassValue] = searchProductID[i];
                         strAllProductName[iTempPassValue] = searchProductName[i];
                         strAllProductModel[iTempPassValue] =searchProductModel[i] ;
                         strAllProductImage[iTempPassValue] =searchProductImage[i];
                         strAllProductKeyWord[iTempPassValue]= searchProductKeyWord[i];
                         strAllProductPrice[iTempPassValue] = searchProductPrice[i];
                         strAllProductClassID[iTempPassValue] = searchProductClassID[i];    
                        
                        
                          iTempPassValue++;
                                              
                    }
                     middleParam=0;
                 }
            } 
            else
            {
                strAllProductID.length = 0;
                strAllProductName.length = 0;
                strAllProductModel.length  =0 ;
                strAllProductImage.length = 0;
                strAllProductKeyWord.length = 0;
                strAllProductPrice.length = 0;
                strAllProductClassID.length = 0;    
                 
                 var middleParam =0;                 
                 var iTempPassValue =0;

                 classIds=new Array();//清空array();
		 getClassid(ClassID);//获得id 

                 for(var i=0 ;i<iTotalLength ;i++)
                 {
                     var productClassID = searchProductClassID[i];  
		     for (var z=0;z<classIds.length;z++)
		     {
			if(productClassID==classIds[z])
			 {                  
                     //if(ClassID == productClassID)
                    // { 
                          var  newSearchKey = searchProductKeyWord[i].split(",");
                          for(var k=0;k<newSearchKey.length;k++)
                          {	
				newSearchKey[k]=newSearchKey[k].toLowerCase();
                              var myIndex =  newSearchKey[k].indexOf(ProductName.toLowerCase());
                              if(myIndex != -1)
                              {
                                 middleParam =1;                                                   
                                 break;
                              }
                              else
                              {                           
                              }                     
                          }                     
                           if(middleParam == 1)
                           {
                               strAllProductID[iTempPassValue] = searchProductID[i];
                               strAllProductName[iTempPassValue] = searchProductName[i];
                               strAllProductModel[iTempPassValue] =searchProductModel[i] ;
                                strAllProductImage[iTempPassValue] =searchProductImage[i];
                                strAllProductKeyWord[iTempPassValue]= searchProductKeyWord[i];
                                strAllProductPrice[iTempPassValue] = searchProductPrice[i];
                                strAllProductClassID[iTempPassValue] = searchProductClassID[i];   
                               
                               iTempPassValue++;
                                              
                          }
                          middleParam=0;    
			}                  
                     }
//}
                 }                                           
            }
            
        }
                   
    }
    
     ///searchByProductClass
    function SearchByProductClass(ClassID)
    {
        var TProductList = document.getElementById(strTProductList);  
        
        if(TProductList == null)
        {
        }
        else
        {  
            var iTotalLength = searchProductID.length;
            if(ClassID  == "0")
            {
                strAllProductID.length = 0;
                strAllProductName.length = 0;
                strAllProductModel.length  =0 ;
                strAllProductImage.length = 0;
                strAllProductKeyWord.length = 0;
                strAllProductPrice.length = 0;
                strAllProductClassID.length = 0;   
             
               for(var j=0;j< iTotalLength;j++)
               {
                   strAllProductID[j] = searchProductID[j];
                   strAllProductName[j] = searchProductName[j];
                   strAllProductModel[j] =searchProductModel[j] ;
                   strAllProductImage[j] =searchProductImage[j];
                   strAllProductKeyWord[j]= searchProductKeyWord[j];
                   strAllProductPrice[j] = searchProductPrice[j];
                   strAllProductClassID[j] = searchProductClassID[j];                      
               }  
                  
            }
            else
            {
                  
                  strAllProductID.length = 0;
                  strAllProductName.length = 0;
                  strAllProductModel.length  =0 ;
                  strAllProductImage.length = 0;
                  strAllProductKeyWord.length = 0;
                  strAllProductPrice.length = 0;
                  strAllProductClassID.length = 0;    
                 
                 var iTempVarPara=0;

                 classIds=new Array();//
		 getClassid(ClassID);//

		for(var i=0 ;i<iTotalLength;i++)
                 {
                     var productClassID = searchProductClassID[i];
                     for (var z=0;z<classIds.length;z++)
			{
						
			if(productClassID==classIds[z])
			 {
                     //if(ClassID == productClassID)
                     // {  
                            strAllProductID[iTempVarPara] = searchProductID[i];
                            strAllProductName[iTempVarPara] = searchProductName[i];
                            strAllProductModel[iTempVarPara] =searchProductModel[i] ;
                            strAllProductImage[iTempVarPara] =searchProductImage[i];
                            strAllProductKeyWord[iTempVarPara]= searchProductKeyWord[i];
                            strAllProductPrice[iTempVarPara] = searchProductPrice[i];
                            strAllProductClassID[iTempVarPara] = searchProductClassID[i];                    
                            iTempVarPara++; 
                    // }
			}
		    }
                 }                                           
            }
        }
    }

      // previous page
     function  PreviousPage()
     {        
        iCurrentPage --;
        iFromPageSize =  (iCurrentPage-1)*iPageSize;  
        var iloopData;
        
        if(iCurrentPage==1)
        {
           if(iPageCountSize>iPageSize)
           {
               iloopData = iPageSize;          
           }
           else
           {
              iloopData = iPageCountSize -iPageSize;
           }
        }        
        else if(iCurrentPage<1)
        {
           iCurrentPage =1;
           return;        
        }
        else
        {
          iloopData = iPageSize;
        }   
        
                
        var TProdctuList = document.getElementById(strTProductList);  
        TProductList.innerText="";
        if(TProductList == null)
        {
        }
        else
        {
            for(var i=0;i<iloopData;i++)
            {
                  TProductList.insertRow();
                   var  j= TProductList.rows.length -1 ;
                   TProductList.rows(j).insertCell(0);   
                   TProductList.rows(j).insertCell(0).setAttribute("className","productImage");   
                   
                   
                   var newDIVProductImage = document.createElement("div");
                   newDIVProductImage.innerHTML='<a href="productdetail.html?productID='+strAllProductID[i+iFromPageSize]+'"><img src="'+strAllProductImage[i+iFromPageSize]+'" width="160px" border="0"></a>';
                   
                   TProductList.rows(j).insertCell(0).appendChild(newDIVProductImage);
                   newDIVProductImage.style.paddingLeft="10px";
                  
                   
                   TProductList.rows(j).insertCell(1);
                   
                   var newDIVProductDesription = document.createElement("div");                  
                   
                   newDIVProductDesription.style.paddingTop = "70px";
                   //product Name
                   var newDIVProductName = document.createElement("div");
                   newDIVProductName.innerHTML="Name:"+strAllProductName[i+iFromPageSize];
                   
                   //product Model
                   var newDIVProductModel = document.createElement("div");
                   newDIVProductModel.innerHTML="Model:"+strAllProductModel[i+iFromPageSize];
                   
                   var newDIVFormContainer = document.createElement("div");
                   
                   var newSpanFormContainer = document.createElement("span");                  
                  newSpanFormContainer.style.color="black";
                  
                  newSpanFormContainer.innerHTML="<input name=\"button\" type=\"button\" class=\"unnamed2\" value=\"Product Detail\" onclick=\"location.href='productdetail.html?productID="+ strAllProductID[i+iFromPageSize] +"'\">";
                   
                   newDIVFormContainer.appendChild(newSpanFormContainer);
                   
                   newDIVProductDesription.appendChild(newDIVProductName);
                   newDIVProductDesription.appendChild(newDIVProductModel);
                   newDIVProductDesription.appendChild(newDIVFormContainer);
                   
                   TProductList.rows(j).insertCell(1).appendChild(newDIVProductDesription)    
            }    
            
            var    spanCurrentPage = document.getElementById("spanCurrentPage");
            if(spanCurrentPage == null)
            {}
            else
            {
               spanCurrentPage.innerText =iCurrentPage;
            }           
         }
               
     }
     
     //next page
     function NextPage()
     {
        iPageCountSize=strAllProductID.length;
        iCurrentPage++;
        iFromPageSize =  (iCurrentPage-1)*iPageSize;  
        var iloopData;        
        if(iCurrentPage == iPageCount)
        {
           iloopData= iPageCountSize-iFromPageSize;           
        }
        else if(iCurrentPage<iPageCount)
        {
           iloopData = iPageSize;       
        }
        else if(iCurrentPage>iPageCount)
        {
           iCurrentPage = iPageCount;  
           return;
        }
        
        var TProdctuList = document.getElementById(strTProductList);  
        
        TProdctuList.innerText="";
        
        if(TProductList == null)
        {
        }
        else
        {
            for(var i=0;i<iloopData;i++)
            {
                   TProductList.insertRow();
                   var  j= TProductList.rows.length -1 ;
                   TProductList.rows(j).insertCell(0);   
                   TProductList.rows(j).insertCell(0).setAttribute("className","productImage");   
                   
                   
                   var newDIVProductImage = document.createElement("div");
                   newDIVProductImage.innerHTML='<a href="productdetail.html?productID='+strAllProductID[i+iFromPageSize]+'"><img src="'+strAllProductImage[i+iFromPageSize]+'" width="160px" border="0"></a>';
                   
                   TProductList.rows(j).insertCell(0).appendChild(newDIVProductImage);
                   newDIVProductImage.style.paddingLeft="10px";
                  
                   
                   TProductList.rows(j).insertCell(1);
                   
                   var newDIVProductDesription = document.createElement("div");                  
                   
                   newDIVProductDesription.style.paddingTop = "70px";
                   //product Name
                   var newDIVProductName = document.createElement("div");
                   newDIVProductName.innerHTML="Name:"+strAllProductName[i+iFromPageSize];
                   
                   //product Model
                   var newDIVProductModel = document.createElement("div");
                   newDIVProductModel.innerHTML="Model:"+strAllProductModel[i+iFromPageSize];
                   
                   var newDIVFormContainer = document.createElement("div");
                   
                   var newSpanFormContainer = document.createElement("span");                  
                  newSpanFormContainer.style.color="black";
                  
                  newSpanFormContainer.innerHTML="<input name=\"button\" type=\"button\" class=\"unnamed2\" value=\"Product Detail\" onclick=\"location.href='productdetail.html?productID="+ strAllProductID[i+iFromPageSize] +"'\">";
                   
                   newDIVFormContainer.appendChild(newSpanFormContainer);
                   
                   newDIVProductDesription.appendChild(newDIVProductName);
                   newDIVProductDesription.appendChild(newDIVProductModel);
                   newDIVProductDesription.appendChild(newDIVFormContainer);
                   
                   TProductList.rows(j).insertCell(1).appendChild(newDIVProductDesription);                
            }  
            
            var    spanCurrentPage = document.getElementById("spanCurrentPage");
            if(spanCurrentPage == null)
            {}
            else
            {
                spanCurrentPage.innerText =iCurrentPage;
            }            
         } 
     }
     
     //last page
    function LastPage()
    {
        iCurrentPage = iPageCount;          
      
        if(iPageCount == 0)
        {
           return;
        }
        
        iFromPageSize =(iPageCount -1)*iPageSize;       
        var iLoopData = iPageCountSize -iFromPageSize;         
        
        var TProdctuList = document.getElementById(strTProductList);  
        TProductList.innerText="";
        
        if(TProductList == null)
        {
        }
        else
        {
            for(var i=0;i<iLoopData;i++)
            {
                   TProductList.insertRow();
                   var  j= TProductList.rows.length -1 ;
                   TProductList.rows(j).insertCell(0);   
                   TProductList.rows(j).insertCell(0).setAttribute("className","productImage");   
                   
                   
                   var newDIVProductImage = document.createElement("div");
                   newDIVProductImage.innerHTML='<a href="productdetail.html?productID='+strAllProductID[i+iFromPageSize]+'"><img src="'+strAllProductImage[i+iFromPageSize]+'" width="160px" border="0"></a>';
                   
                   TProductList.rows(j).insertCell(0).appendChild(newDIVProductImage);
                   newDIVProductImage.style.paddingLeft="10px";
                  
                   
                   TProductList.rows(j).insertCell(1);
                   
                   var newDIVProductDesription = document.createElement("div");                  
                   
                   newDIVProductDesription.style.paddingTop = "70px";
                   //product Name
                   var newDIVProductName = document.createElement("div");
                   newDIVProductName.innerHTML="Name:"+strAllProductName[i+iFromPageSize];
                   
                   //product Model
                   var newDIVProductModel = document.createElement("div");
                   newDIVProductModel.innerHTML="Model:"+strAllProductModel[i+iFromPageSize];
                   
                   var newDIVFormContainer = document.createElement("div");
                   
                   var newSpanFormContainer = document.createElement("span");                  
                  newSpanFormContainer.style.color="black";
                  
                  newSpanFormContainer.innerHTML="<input name=\"button\" type=\"button\" class=\"unnamed2\" value=\"Product Detail\" onclick=\"location.href='productdetail.html?productID="+ strAllProductID[i+iFromPageSize] +"'\">";
                   
                   newDIVFormContainer.appendChild(newSpanFormContainer);
                   
                   newDIVProductDesription.appendChild(newDIVProductName);
                   newDIVProductDesription.appendChild(newDIVProductModel);
                   newDIVProductDesription.appendChild(newDIVFormContainer);
                   
                   TProductList.rows(j).insertCell(1).appendChild(newDIVProductDesription)  
            }  
            
            var    spanCurrentPage = document.getElementById("spanCurrentPage");
            if(spanCurrentPage == null)
            {}
            else
            {
              spanCurrentPage.innerText =iCurrentPage;
            }              
         }
    }    
    
    //sel change Page
    function SelChangePage()
    {
        var SelCurrentPage=document.getElementById("SelCurrentPage");
        var iSelCurrentPage=SelCurrentPage.selectedIndex;                
        iCurrentPage =  SelCurrentPage.options[iSelCurrentPage].value;   
        iFromPageSize =  (iCurrentPage-1)*iPageSize;  
        var iloopData;  
        if(iCurrentPage == iPageCount)
        {
          iloopData= iPageCountSize - iFromPageSize;
        }        
        else if(iCurrentPage == 1)
        {          
           if(iPageCountSize>iPageSize)
           {
               iloopData = iPageSize;   
                 
           }
           else
           {
              iloopData = iPageCountSize -iPageSize;
           }        
        }
        else
        {          
          iloopData = iPageSize;
        } 
        
        var TProductList = document.getElementById(strTProductList);
        TProductList.innerText="";        
        
        for(var i=0; i<iloopData;i++)
        {   
                  TProductList.insertRow();
                   var  j= TProductList.rows.length -1 ;
                   TProductList.rows(j).insertCell(0);   
                   TProductList.rows(j).insertCell(0).setAttribute("className","productImage");   
                   
                   
                   var newDIVProductImage = document.createElement("div");
                   newDIVProductImage.innerHTML='<a href="productdetail.html?productID='+strAllProductID[i+iFromPageSize]+'"><img src="'+strAllProductImage[i+iFromPageSize]+'" width="160px" border="0"></a>';
                   
                   TProductList.rows(j).insertCell(0).appendChild(newDIVProductImage);
                   newDIVProductImage.style.paddingLeft="10px";
                  
                   
                   TProductList.rows(j).insertCell(1);
                   
                   var newDIVProductDesription = document.createElement("div");                  
                   
                   newDIVProductDesription.style.paddingTop = "70px";
                   //product Name
                   var newDIVProductName = document.createElement("div");
                   newDIVProductName.innerHTML="Name:"+strAllProductName[i+iFromPageSize];
                   
                   //product Model
                   var newDIVProductModel = document.createElement("div");
                   newDIVProductModel.innerHTML="Model:"+strAllProductModel[i+iFromPageSize];
                   
                   var newDIVFormContainer = document.createElement("div");
                   
                   var newSpanFormContainer = document.createElement("span");                  
                  newSpanFormContainer.style.color="black";
                  
                  newSpanFormContainer.innerHTML="<input name=\"button\" type=\"button\" class=\"unnamed2\" value=\"Product Detail\" onclick=\"location.href='productdetail.html?productID="+ strAllProductID[i+iFromPageSize] +"'\">";
                   
                   newDIVFormContainer.appendChild(newSpanFormContainer);
                   
                   newDIVProductDesription.appendChild(newDIVProductName);
                   newDIVProductDesription.appendChild(newDIVProductModel);
                   newDIVProductDesription.appendChild(newDIVFormContainer);
                   
                   TProductList.rows(j).insertCell(1).appendChild(newDIVProductDesription)              
          } 
       
       var    spanCurrentPage = document.getElementById("spanCurrentPage");
       if(spanCurrentPage == null)
       {}
       else
       {
            spanCurrentPage.innerText =iCurrentPage;
       }       
    }   
               
     //first page
     function FirstPage()
     {
         iCurrentPage = 1;
         var  firstSize  = strAllProductID.length;         
         var fromLoopPara = iPageSize;        
         
         if(iPageSize >= firstSize)
         {
            fromLoopPara = firstSize;
         }
         else
         {
            fromLoopPara = iPageSize;
            
         }          
                 
         var TProductList = document.getElementById(strTProductList);  
         TProductList.innerText="";
         if(TProductList == null)
         {
         }
         else
         {
             for(var i=0;i<fromLoopPara;i++)
             {
                
                   TProductList.insertRow();
                   var  j= TProductList.rows.length -1 ;
                   TProductList.rows(j).insertCell(0);   
                   TProductList.rows(j).insertCell(0).setAttribute("className","productImage");   
                   
                   
                   var newDIVProductImage = document.createElement("div");
                   newDIVProductImage.innerHTML='<a href="productdetail.html?productID='+strAllProductID[i]+'"><img src="'+strAllProductImage[i]+'" width="160px" border="0"></a>';
                   
                   TProductList.rows(j).insertCell(0).appendChild(newDIVProductImage);
                   newDIVProductImage.style.paddingLeft="10px";
                  
                   
                   TProductList.rows(j).insertCell(1);
                   
                   var newDIVProductDesription = document.createElement("div");                  
                   
                   newDIVProductDesription.style.paddingTop = "70px";
                   //product Name
                   var newDIVProductName = document.createElement("div");
                   newDIVProductName.innerHTML="Name:"+strAllProductName[i];
                   
                   //product Model
                   var newDIVProductModel = document.createElement("div");
                   newDIVProductModel.innerHTML="Model:"+strAllProductModel[i];
                   
                   var newDIVFormContainer = document.createElement("div");
                   
                   var newSpanFormContainer = document.createElement("span");                  
                  newSpanFormContainer.style.color="black";
                  
                  newSpanFormContainer.innerHTML="<input name=\"button\" type=\"button\" class=\"unnamed2\" value=\"Product Detail\" onclick=\"location.href='productdetail.html?productID="+ strAllProductID[i+iFromPageSize] +"'\">";
                   
                   newDIVFormContainer.appendChild(newSpanFormContainer);
                   
                   newDIVProductDesription.appendChild(newDIVProductName);
                   newDIVProductDesription.appendChild(newDIVProductModel);
                   newDIVProductDesription.appendChild(newDIVFormContainer);
                   
                   TProductList.rows(j).insertCell(1).appendChild(newDIVProductDesription)     
              
              
                  var spanCurrentPage = document.getElementById("spanCurrentPage");
                  if(spanCurrentPage == null)
                  {}
                  else
                  {
                    spanCurrentPage.innerText =iCurrentPage;
                  }    
              }   
       }
 }
	
	
//page descript	
function  PageDertption()
{
    iPageCountSize=strAllProductID.length;     
    iPageCount =Math.ceil(iPageCountSize/((1.0)*iPageSize)); 
    var spanPageCountSize = document.getElementById("spanPageCountSize");
    if(spanPageCountSize == null)
    {}
    else
    {
            spanPageCountSize.innerText = iPageCountSize;
    }    
             
     var    spanCurrentPage = document.getElementById("spanCurrentPage");
     if(spanCurrentPage == null)
     {}
     else
     {
          spanCurrentPage.innerText =iCurrentPage;
     }       
     var spanPageCount = document.getElementById("spanPageCount");
     if(spanPageCount == null)
     {}
     else
      {
             spanPageCount.innerText = iPageCount;
      }                
       var SelCurrentPage = document.getElementById("SelCurrentPage");    
       SelCurrentPage.options.length = 0;      
       for(var i=0;i<iPageCount ;i++)
      {
         var selOptionValue = i+1;
         SelCurrentPage.options[i]= new Option("Go To:"+selOptionValue,selOptionValue);             
     }         
}
	//product details load
function ProductDetailsLoad() 
{   
     var strUri =   window.location.search;         
     var aa = strUri.split('&');       
     var iLength = aa.length;  
        
     var myString = "";        
     var ClassName="";
     var ClassID = ""
     
     if( iLength == 2)
     {
            strOrderPassValue = strUri.substring(strUri.lastIndexOf("=")+1);
            // strOrderPassValue =   strUri.substring(lastIndexOf("="));
            //  window.alert("第二个参数的值是:" + strOrderPassValue);                                
      }     
              
     if(iLength>0)
     {
           myString =  aa[0].substring(1);
           var mystr1 = myString.split("=");  
           var myClassName =  mystr1[0];
           if(myClassName == "id")
           {
               ClassName = "id" ;
               ClassID =  mystr1[0];             
           }
        }
        else
        {
        }           
        var TProductList = document.getElementById(strTProductList);         
        if(ClassName != "id")
        {
           if(TProductList == null)
           {
           }
           else
           {
           
               var iTempPageObject = iPageSize;
               if(strAllProductID.length >= iPageSize)
               {                                                       
               }
               else
               {
                  iTempPageObject = strAllProductID.length;                                
               }
               
               for(var i=0; i< iTempPageObject;i++)
               {  
                   TProductList.insertRow();
                   var  j= TProductList.rows.length -1 ;
                   TProductList.rows(j).insertCell(0);   
                   TProductList.rows(j).insertCell(0).setAttribute("className","productImage");   
                   
                   
                   var newDIVProductImage = document.createElement("div");
                   newDIVProductImage.innerHTML='<a href="productdetail.html?productID='+strAllProductID[i]+'"><img src="'+strAllProductImage[i]+'" width="160px" border="0"></a>';
                   
                   TProductList.rows(j).insertCell(0).appendChild(newDIVProductImage);
                   newDIVProductImage.style.paddingLeft="10px";
                  
                   
                   TProductList.rows(j).insertCell(1);
                   
                   var newDIVProductDesription = document.createElement("div");                  
                   
                   newDIVProductDesription.style.paddingTop = "70px";
                   //product Name
                   var newDIVProductName = document.createElement("div");
                   newDIVProductName.innerHTML="Name:"+strAllProductName[i];
                   
                   //product Model
                   var newDIVProductModel = document.createElement("div");
                   newDIVProductModel.innerHTML="Model:"+strAllProductModel[i];
                   
                   var newDIVFormContainer = document.createElement("div");
                   
                   var newSpanFormContainer = document.createElement("span");                  
                   newSpanFormContainer.style.color="black";
                  
                  newSpanFormContainer.innerHTML="<input name=\"button\" type=\"button\" class=\"unnamed2\" value=\"Product Detail\" onclick=\"location.href='productdetail.html?productID="+ strAllProductID[i+iFromPageSize] +"'\">";
                   
                   newDIVFormContainer.appendChild(newSpanFormContainer);
                   
                   newDIVProductDesription.appendChild(newDIVProductName);
                   newDIVProductDesription.appendChild(newDIVProductModel);
                   newDIVProductDesription.appendChild(newDIVFormContainer);
                   
                   TProductList.rows(j).insertCell(1).appendChild(newDIVProductDesription)                   
               } 
               //start page()
               PageDertption();
               //end page();
                              
           }               
        }
        else if(ClassName == "id")
        {   
           var strPassValue= strUri.substring(strUri.indexOf("=")+1); 
           if(TProductList == null)
           {
           }
           else
           {              
                //
              
  		 var xmlDoc 
		//IE
        	if (window.ActiveXObject) 
        	{ 
            	xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        	} 
        	// code for Mozilla, Firefox, Opera, etc. 
        	else if (window.XMLHttpRequest) 
        	{ 
            	xmlDoc =document.implementation.createDocument("","",null); 
        	}
		else
		{
	    	alert("对不起！您所使用的浏览器不支持该网站的全部功能");
		}
        	xmlDoc.async ="false";
        	xmlDoc.load("../productEN1.xml"); 
                var products =xmlDoc.selectSingleNode("//NewDataSet").childNodes; 
                var itempArrayVar =0; 
                strAllProductID.length =0;
                strAllProductName.length=0;
                strAllProductModel.length = 0;
                strAllProductImage.length = 0;
                strAllProductKeyWord.length = 0;
                strAllProductPrice.length = 0;
                strAllProductClassID.length = 0;
               
               for(var i=0; i<products.length;i++)
               {
                  var childProductchildProduct = products.item(i).childNodes;
                  var P_ClassID = childProductchildProduct.item(4).text;

		  getClassid(strPassValue);
		 if (classIds.length==0)
		{
		 if(strPassValue == P_ClassID)
                  	{
	     	      	var productID       = childProductchildProduct.item(0).text;
             
                      var productName     = childProductchildProduct.item(1).text;
                      var productModel    = childProductchildProduct.item(2).text;
                      var productImage = childProductchildProduct.item(3).text;
                      strAllProductID[itempArrayVar]   = productID;
                      strAllProductName[itempArrayVar]  = productName;
                      strAllProductModel[itempArrayVar]    = productModel;
  
                      if(productImage == '0')
                     {
                         strAllProductImage[itempArrayVar] = strNullImage;                                       
                     }
                     else
                     {
                          strAllProductImage[itempArrayVar] =strProductImageTafixPath + productImage;                    
                     }          
                         
                      itempArrayVar++;
                   }
				}else{
			 	 for (var z=0;z<classIds.length;z++)
				{
			
                  if(P_ClassID==classIds[z])
                  {
                  
                 // if(strPassValue == P_ClassID)
                  //{
                  	//alert(classIds[z]);
	     	      	  var productID       = childProductchildProduct.item(0).text;
                      var productName     = childProductchildProduct.item(1).text;
                      var productModel    = childProductchildProduct.item(2).text;
                      var productImage = childProductchildProduct.item(3).text;
                      strAllProductID[itempArrayVar]   = productID;
                      strAllProductName[itempArrayVar]  = productName;
                      strAllProductModel[itempArrayVar]    = productModel;
  
                      if(productImage == '0')
                     {
                         strAllProductImage[itempArrayVar] = strNullImage;                                       
                     }
                     else
                     {
                          strAllProductImage[itempArrayVar] =strProductImageTafixPath + productImage;                    
                     }          
                         
                      itempArrayVar++;
                   }
                }
		}
	}
                
                var iTempPageObject = iPageSize;
                if(itempArrayVar >= iPageSize)
                {                                                       
                }
                else
                {
                   iTempPageObject = itempArrayVar;                       
                }
                
                for(var i=0;i<iTempPageObject;i++)
                {
                   TProductList.insertRow();
                   var  j= TProductList.rows.length -1 ;
                   TProductList.rows(j).insertCell(0);   
                   TProductList.rows(j).insertCell(0).setAttribute("className","productImage");   
                   
                   
                   var newDIVProductImage = document.createElement("div");
                   newDIVProductImage.innerHTML='<a href="productdetail.html?productID='+strAllProductID[i]+'"><img src="'+strAllProductImage[i]+'" width="160px" border="0"></a>';
                   
                   TProductList.rows(j).insertCell(0).appendChild(newDIVProductImage);
                   newDIVProductImage.style.paddingLeft="10px";
                  
                   
                   TProductList.rows(j).insertCell(1);
                   
                   var newDIVProductDesription = document.createElement("div");                  
                   
                   newDIVProductDesription.style.paddingTop = "70px";
                   //product Name
                   var newDIVProductName = document.createElement("div");
                   newDIVProductName.innerHTML="Name:"+strAllProductName[i];
                   
                   //product Model
                   var newDIVProductModel = document.createElement("div");
                   newDIVProductModel.innerHTML="Model:"+strAllProductModel[i];
                   
                   var newDIVFormContainer = document.createElement("div");
                   
                   var newSpanFormContainer = document.createElement("span");                  
                  newSpanFormContainer.style.color="black";
                  
                  newSpanFormContainer.innerHTML="<input name=\"button\" type=\"button\" class=\"unnamed2\" value=\"Product Detail\" onclick=\"location.href='productdetail.html?productID="+ strAllProductID[i+iFromPageSize] +"'\">";
                   
                   newDIVFormContainer.appendChild(newSpanFormContainer);
                   
                   newDIVProductDesription.appendChild(newDIVProductName);
                   newDIVProductDesription.appendChild(newDIVProductModel);
                   newDIVProductDesription.appendChild(newDIVFormContainer);
                   
                   TProductList.rows(j).insertCell(1).appendChild(newDIVProductDesription) 
                } 
                PageDertption();
             }
          } 
          
    }    
  
	//bint product class to datalist
	 function BindToSelSearchProductClassList()
     {
         var selSearchProductClassList = document.getElementById("selSearchProductClassList");
         if(selSearchProductClassList == null)
         {}
         else
         {
             selSearchProductClassList.options[0] = new Option("Please Choose","0");
             var iTempVar = arrProductClassID.length;
             for(var i=1;i <= iTempVar;i++)
             {
                 selSearchProductClassList.options[i] = new Option(arrProductClassName[i-1],arrProductClassID[i-1]);                 
             }              
         }
     }
	 
	//product class 
	 function GetAllProductClassInfoData()
     {        
         var xmlDoc 
	//IE
        if (window.ActiveXObject) 
        { 
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        } 
        // code for Mozilla, Firefox, Opera, etc. 
        else if (window.XMLHttpRequest) 
        { 
            xmlDoc =document.implementation.createDocument("","",null); 
        }
	else
	{
	    alert("对不起！您所使用的浏览器不支持该网站的全部功能");
	}
        xmlDoc.async ="false";
        xmlDoc.load("../productClassEN.xml"); 
        var productClass=xmlDoc.selectSingleNode("//NewDataSet").childNodes;  
        for(var i=0;i<productClass.length; i++)
        {
               var childProductClass = productClass.item(i).childNodes;
               var productClassID    =  childProductClass.item(0).text;
               var productClassName  = childProductClass.item(1).text;
                 
               arrProductClassID[i] = productClassID;
               arrProductClassName[i] = productClassName;            
        }     
     }
	 
		//
	  	function getClassid(strPassValue)
	{
		var xmlClassDoc;
  	 	if (window.ActiveXObject) 
   		{ 
   	    	xmlClassDoc = new ActiveXObject("Microsoft.XMLDOM");
  	 	} 
   	 	// code for Mozilla, Firefox, Opera, etc. 
   	 	else if (window.XMLHttpRequest) 
   	 	{ 
    	    	xmlClassDoc=document.implementation.createDocument("","",null); 
   	 	} 
   	 		xmlClassDoc.async=false; 
   	 		xmlClassDoc.load("../productClass.xml");
     			var productClass=xmlClassDoc.documentElement.childNodes;  //获取所有table节点
			classIds[0]=strPassValue;
		    	childClass(productClass,strPassValue);

		
	}

	
	function childClass(productClass,value)
	{
		
		
		for(var j=0;j<productClass.length;j++)
        	{		
            		var cls = productClass.item(j);
            		if(cls.nodeName.toLowerCase() == "table")
            		{  
                	var childProductClass = productClass.item(j).childNodes;
                	var productClassSupID = childProductClass.item(3).text;
					var productClassID    = childProductClass.item(0).text;
                	if (productClassSupID == value)
                	{	
						classIds[j+1]=productClassID;
                   		childClass(productClass,productClassID);
                	}	                
            		}	
		}
	}

   	//Get All productInfo
	function GetAllProductInfoData()
    {
        var xmlDoc 
	//IE
        if (window.ActiveXObject) 
        { 
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        } 
        // code for Mozilla, Firefox, Opera, etc. 
        else if (window.XMLHttpRequest) 
        { 
            xmlDoc =document.implementation.createDocument("","",null); 
        }
	else
	{
	    alert("对不起！您所使用的浏览器不支持该网站的全部功能");
	}
        xmlDoc.async ="false";
        xmlDoc.load("../productEN1.xml"); 
        var products =xmlDoc.selectSingleNode("//NewDataSet").childNodes;   
        
        for(var i=0; i<products.length;i++)
        {
             var childProductchildProduct = products.item(i).childNodes;
             var productID       = childProductchildProduct.item(0).text;
             
             var productName     = childProductchildProduct.item(1).text;
             var productModel    = childProductchildProduct.item(2).text;
             var productImage    = childProductchildProduct.item(3).text;
             var productKeyWord  = "";
             var productClassID  = childProductchildProduct.item(4).text;
	         var productPrice    = "";
                 
             strAllProductID[i]   = productID;
             strAllProductName[i]  = productName;
             strAllProductModel[i]    = productModel;
             strAllProductKeyWord[i]  = productKeyWord;
             strAllProductClassID[i]   =  productClassID   
             strAllProductPrice[i] = productPrice;
             if(productImage == '0')
             {
                   strAllProductImage[i] = strNullImage;                                       
             }
             else
             {
                  strAllProductImage[i] =strProductImageTafixPath + productImage;                    
             }   
             
             searchProductID[i] = productID;
             searchProductName[i] = productName;
             searchProductModel[i] = productModel;
             searchProductKeyWord[i] = strAllProductName[i];
             searchProductPrice[i] = productPrice;
             searchProductClassID[i] = productClassID;
             
             if(productImage == '0')
             {
                   searchProductImage[i] = strNullImage;                                       
             }
             else
             {
                  searchProductImage[i] =strProductImageTafixPath + productImage;                    
             }                      
       }
    } 

	//product details Main
    function  ProductListMain()
    {
       GetAllProductInfoData();  
       //GetAllProductClassInfoData(); 
       //BindToSelSearchProductClassList();   
       ProductDetailsLoad();     
    }
