﻿

/* --------------- tab 标签 ------------- */

    function TabSwitch(n,count,preTitle,preDescription)
    {    
    // alert(n+"|"+ count + preTitle+ preDescription);
       for(var i=1; i <= count;i++)
       { 
            var _objTitle = document.getElementById(preTitle+ i);
            var _objDescription = document.getElementById(preDescription + i);
            
          if(_objDescription != null )
          {  
               if(i==n)
               {
                    if(_objTitle.className == 'Mouse_Out')
                    {
                      _objTitle.className='Mouse_Over';
                    }
                    if(_objDescription.style.display == 'none')
                    {
                      _objDescription.style.display ='block';
                     
                    }    
               }
               else
               {
                    if(_objTitle.className == 'Mouse_Over')
                    {
                      _objTitle.className='Mouse_Out'; 
                    }
                    
                    if(_objDescription.style.display == 'block' || _objDescription.style.display == '')
                    {
                      _objDescription.style.display ='none';
                     
                    }
                  
               }
          }
       }    
    }
    
 var win1;
function favorites_add(productId)
{

    if(win1&&win1.open&&!win1.closed)
    {
      win1.opener=null;win1.close()
    }

    urlFavorites=_applicationPath + "favorites/favorites.aspx?itemId=" + productId ;

    win1=window.open(urlFavorites,'addfavour','left=320,top=320,height=200,width=280,resizable=0,scrollbars=0,status=no,toolbar=no,location=no,menu=no') ;
} 
    var win;
    function buy_add(productId)
    {
        var _buyProductAmountName =  "buyProductAmount"+productId;
        var _buyProductAmount = $get(_buyProductAmountName).value;

        if(win&&win.open&&!win.closed)
        {
          win.opener=null;win.close()
        }

        url=_applicationPath + "Shopping/AddToCart.aspx?itemId="+productId+"&productQuantity="+_buyProductAmount+"&selectBox=" + escape(SelectBox(productId)) ;
        win=window.open(url,'add','') ;
    }

    function isNotaNumber (inputString)
    {
      return (inputString=="" || isNaN(inputString));
    }
    function SelectBox(productId)
    {
       var _selectBox="";
       var _selectBoxName =  "selectBox"+productId;
       var _selectBoxCount = $get(_selectBoxName).value;

       for(i=0;i<_selectBoxCount;i++) 
       {
         var _name = "SELECT" + productId  +i;
         var _accounts =  document.getElementById(_name);
         if (_accounts !=null)
         {
             if(i==0)
             {
               _selectBox +=  _accounts.value;
             }
             else
             {
                _selectBox += "," + _accounts.value;
             }
         }        
       }
       return _selectBox;      
    } 
    
    
  /*----------------------- 高级搜索 -------------------*/
    var win33;
  function AdvanceSearchProduct(keyWords,typeId)
  {
    var _SearchUrl = _applicationPath + "product/product.aspx?keyWords=" + encodeURIComponent(keyWords); 
    
    if(typeId == 0)
    {
  
        window.location.href = _SearchUrl;     
    }
    else
    {
       if(win33&&win33.open&&!win33.closed)
        {
           win33.opener=null;win33.close()
        }
        
      win33=window.open(_SearchUrl,'add','');
    }
  }
  
    /*----------------------- 高级搜索 -------------------*/
    
    
      /*----------------------- 目录折叠 -------------------*/
  
  
   function CategoryOpenClose(currentNode,subId) 
   {    
   
     var ulId = "ul" + subId;
     var ulMenu = document.getElementById(ulId).style; 
      
     if (ulMenu.display == "block") 
       {
         ulMenu.display = "none";
         currentNode.parentNode.className = "categoryClose"; 
         return false;
       }  
       else
       {
         ulMenu.display = "block";	
         currentNode.parentNode.className = "categoryOpen"; 
         return false;
       }
   }    
  
  
  
      /*----------------------- 打开新窗口 -------------------*/
  
  function openNew(url)
   {					
        var udswin=window.open(url,"","toolbar=no,status=yes,resizable=yes");
		udswin.moveTo(0,0);
		udswin.resizeTo(window.screen.availWidth,window.screen.availHeight);
			
		
    } 
    function showShoppingCart()
    {

    url=_applicationPath + 'Shopping/ShoppingCart.aspx';
    win=window.open(url,'add','') ;

    if(win&&win.open&&!win.closed){win.location.reload();win.focus()}else alert('窗口还没有打开或已关闭')
    //if(win&&win.open&&!win.closed){win.opener=null;win.close()}else alert('还没有打开窗口或已关闭')
    }







/* ---------表单提交       --------------------------------------------------------- */

   function SaveHtmlCodeBlock(title,containId)
   { 
   
      if(document.getElementById(containId) ==null)
        {
          alert ('标志' + containId + '不存在');
        }
      else
        {
           MadeDisabled(containId);
           
           var _description =  document.getElementById(containId).innerHTML;     
           var  _reply =  "";
           
           WebFormTable.Save(0,title, _description,_reply, onFormTableSucceeded,onFormTableFailed,title);
         }
   }
   
   
   function MadeDisabled(containId)
   {
       var _htmlBlock = document.getElementById(containId)
       
       var items1 =  _htmlBlock.getElementsByTagName("input");
	    if(items1.length>0)
	    {
	        for(var i=0; i < items1.length; i++) 
	        {
	          items1[i].disabled="disabled";
	        }
	    }
	    
	    var items2 =  _htmlBlock.getElementsByTagName("select");
	    if(items2.length>0)
	    {
	        for(var i=0; i < items2.length; i++) 
	        {
	          items2[i].disabled="disabled";
	        }
	    }
	    
	    var items3 =  _htmlBlock.getElementsByTagName("textarea");
	    if(items3.length>0)
	    {
	        for(var i=0; i < items3.length; i++) 
	        {
	          items3[i].readonly="readonly";
	        }
	    }
	    
   }
    
    
  function onFormTableSucceeded(result,context) 
  { 
      if (result>0)
      {
        alert(context + "申请提交成功");
        
       window.location.href=window.location.href;
      }
      else
      {  
        alert(context + "申请提交不成功");
        return(false);
      }
  }
    
  function onFormTableFailed(error)
  {  
  }
  
  /*----------html文本获取----------- */
  
      
    /*  -------------不显标题的-------  */
     function ShowDescriptionByModuleIdAndTyepId(divNamePre,moduleId,typeId)
    { 
        //alert('aa');
        var divName_ShowDate = divNamePre;
        
         document.getElementById(divName_ShowDate).innerHTML = "<img src= '" + _applicationPath + +   "Images/loading.gif' alt='loading...'><span style='padding-left:6px; font-size: 14px; color:#FF9900';>载入中，请稍后...</span>";
             
       
           
         //alert(parentId);
         
        WebHtmlText.GetDescriptionByModuleIdAndTyepId(moduleId,typeId,onSucceededGetDescriptionByModuleIdAndTyepId,onFailedGetDescriptionByModuleIdAndTyepId,divName_ShowDate);
    }
 
   function onSucceededGetDescriptionByModuleIdAndTyepId(result,context) 
    {    
      
        document.getElementById(context).innerHTML = result; 
    }
    
    function onFailedGetDescriptionByModuleIdAndTyepId(error)
    {
       
    }
    
 /* ---- ProductsSearch_H --------------------------------------   */

 function SearchProductsH_Main()
  {
   
     var objH=document.getElementById('mySelectH');
     var index=objH.selectedIndex; 
     var val = objH.options[index].value;
     if(val==0)
     {
       window.location.href = _applicationPath + 'product/product.aspx?keyWords=' + encodeURIComponent($get('txtKeyWordsH').value) + "&moduleId=" + val; 
     }
     else
     {
       window.location.href = _applicationPath + 'product/product.aspx?keyWords=' + encodeURIComponent($get('txtKeyWordsH').value) + "&moduleId=" + val; 
     }
   }
   
    function SearchProductsH(){
    
		var objH;
		objH = document.getElementById("txtKeyWordsH");	
		if (objH.value.length == 0) {
			alert("请输入搜索关键字!");
			return false;
		}
		else
		{
		  SearchProductsH_Main();
		}
		
	   }  
	   
	   
 /* ---- OrderSearch_H --------------------------------------   */
 
    function SearchOrders_H()
    {
		var objOrderId_H = document.getElementById("txtOrderId_H");	
		if (objOrderId_H.value.length == 0) {
			alert("请输入10位数的订单号!");
			return false;
		}
		if (objOrderId_H.value.length != 10) {
			alert("请输入10位的订单号!");
			return false;
		}
		if (!isDigit(objOrderId_H.value) ) {
			alert("格式错误，订单号是应为数字,不包含其它字符!");
			return false;
		}
				
		if (objOrderId_H.value < 1000000000) {
			alert("格式错误，订单号第一位数字应大于等于1!");
			return false;
		}
		     var urlOrderSearchById_H = _applicationPath + 'shopping/OrderSearchById.aspx?orderId=' + encodeURIComponent(document.getElementById('txtOrderId_H').value); 
		     window.open( urlOrderSearchById_H,'add','scrollbars=yes,resizable=no,width=850,height=400');
      }
	
	
	function   isDigit(s)   
    {   
      var   patrn=/^[0-9]{1,20}$/;   
      if   (!patrn.exec(s))   return   false;   return   true;   
    }   
