﻿ 
    
 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 + "Products/ProductsList.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(itemId,subId) 
   {
     var  _img =  document.getElementById('img' + itemId);
     var  _ul =  document.getElementById('ul' + itemId);
     
     if (_ul.style.display == "block") 
     {
         _ul.style.display = "none";  
         _img.src = _applicationPath +  "uploads/Fckeditor/SysPhoto/Icon/" + subId + "menu_close.gif";
         return false;
     }  
     else
     {
         _ul.style.display = "block";	
         _img.src = _applicationPath + "uploads/Fckeditor/SysPhoto/Icon/" + subId + "menu_open.gif";
         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 ShowContentsByModuleIdAndTyepId(divNamePre,moduleId,typeId)
    { 
        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>";
                      
        WebHtmlText.GetDescriptionByModuleIdAndTyepId(moduleId,typeId,onSucceededGetByModuleIdAndTyepId,onFailedGetByModuleIdAndTyepId,divName_ShowDate);
    }
 
   function onSucceededGetByModuleIdAndTyepId(result,context) 
    {    
      document.getElementById(context).innerHTML = result;
      
      translateInitilization();//中文简体与繁体的切换函数
    }
    
    function onFailedGetByModuleIdAndTyepId(error)
    {
       
    }   
    
    
    /*  -------------不显标题的-------  */
     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;
    
      
      translateInitilization();//中文简体与繁体的切换函数
    }
    
    function onFailedGetDescriptionByModuleIdAndTyepId(error)
    {
       
    }   