﻿    /*----------------------------------*/
    /*         Common Check             */
    /*----------------------------------*/
    function isDate(parm)
    {
      var r = parm.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
      if(r==null) return false;
      var d = new Date(r[1], r[3]-1,r[4]);
      return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
    }

    /*----------------------------------*/
    /*         User Manager             */
    /*----------------------------------*/
    if (!objbeforeItem)
    {
        var objbeforeItem=null;
        var objbeforeItembackgroundColor=null;
    } 

    function ItemOver(obj,varuserid)
    {
        if(objbeforeItem)
        {
            objbeforeItem.style.backgroundColor = objbeforeItembackgroundColor;
        }
        objbeforeItembackgroundColor = obj.style.backgroundColor;
        objbeforeItem = obj;
        obj.style.backgroundColor = "#B9D1F3";           
        document.getElementById("_userid").value = varuserid;       
    }
    function UserAdmin_DeleteUser()
    {
        if(!confirm("您确认要删除用户吗?")) return;
        
        __doPostBack('deleteuser','');
    }
    
    function ApplicationAdd()
    {      
        var m_url = "BusinessApplication_New.aspx";         
        OpenWindow(m_url);         
    } 
     
    /*----------------------------------*/
    /*         Open Window              */
    /*----------------------------------*/
    function OpenWindow(url)
	{			
		var x = 0;
		var y = 0;
		var height = 0;
		var width = 0;
		
		if(screen.width < 1024)
		{
			height = 500;
			width = 780;				
		}
		else
		{
			height = 700;
			width = 950;			
		}			
		x = (screen.width - width)/2;
		y = (screen.height - height)/2;
			
		var status = "top="+y+",left="+x+",width="+width+",height="+height+",scrollbars=yes";	
		window.open(url,'_window',status);
	}
	
    function OpenWindow_PrintDO(url)
	{	
		if(!confirm('DO资料仅供参考,请与实际报关资料核对.\n\若有疑问,请致电0755-26693771.\n\r\n\r确认要打印码?')) return;
		var x = 0;
		var y = 0;
		var height = 0;
		var width = 0;
		
		if(screen.width < 1024)
		{
			height = 500;
			width = 780;				
		}
		else
		{
			height = 700;
			width = 950;			
		}			
		x = (screen.width - width)/2;
		y = (screen.height - height)/2;
			
		var status = "top="+y+",left="+x+",width="+width+",height="+height+",scrollbars=yes";
				
		window.open(url,'_window',status);
	}
	
	function OpenWindow_PrintDelete(url)
	{	
		if(!confirm('确认要打印码换单委托书吗?')) return;
		var x = 0;
		var y = 0;
		var height = 0;
		var width = 0;
		
		if(screen.width < 1024)
		{
			height = 500;
			width = 780;				
		}
		else
		{
			height = 700;
			width = 950;			
		}			
		x = (screen.width - width)/2;
		y = (screen.height - height)/2;
			
		var status = "top="+y+",left="+x+",width="+width+",height="+height+",scrollbars=yes";
				
		window.open(url,'_window',status);
	}
		
	function ShowInformation(id)
	{
		var url = "/Cenozoic/ShowInformation.aspx?id="+id;

		var iWidth = screen.width - 200;
		var iHeight = screen.height - 150;
		var x = 100;
		var y = 50;
		var status = "top=" + y + ",left=" + x + ",width=" + iWidth + ",height=" + iHeight + ",scrollbars=yes";
		
		window.open(url,"",status);		
	}						    
	/*----------------------------------*/
    /*         ToolBar Script           */
    /*----------------------------------*/
	function updatecell(item,status)
	{
	    if(item==null) return;
	    if(status == null) return;
	    
	    var m_cm=document.all[item];
	    if(m_cm==null) return;
	    
	    switch (status)
	    {
	        case "over":
	            if(m_cm.className != "ToolBarItemOver") m_cm.className="ToolBarItemOver";
	            break;
	        case "out":
	            m_cm.className="ToolBarItem";
	            break;
	        case "down":
	            m_cm.className="ToolBarItemDown";
	            break;
	    }
	    
	    return;
	 }
	 
	/*----------------------------------*/
    /*     Show PCF Detail Script       */
    /*----------------------------------*/
    function ShowPCFDetail(id)
	{
		var url = "PCFFeeDetail.aspx?id="+id;

		var iWidth = screen.width - 200;
		var iHeight = screen.height - 150;
		var x = 100;
		var y = 50;
		var status = "top=" + y + ",left=" + x + ",width=" + iWidth + ",height=" + iHeight + ",scrollbars=yes";
		
		window.open(url,"",status);		
	}
    
	 
	/*----------------------------------*/
    /*         PCF Booking Script       */
    /*----------------------------------*/
    function ChangeCheckBoxState(id, checkState)
    {
        var cb = document.getElementById(id);
        if (cb != null) cb.checked = checkState;
    }

    function ChangeAllCheckBoxStates(checkState)
    {
        if (CheckBoxIDs == null) return;
        
        for (var i = 0; i < CheckBoxIDs.length; i++)
         ChangeCheckBoxState(CheckBoxIDs[i], checkState);
    }
    
    function CheckSync(ClientID,DocumentNo)
    {
        var cb = document.getElementById(ClientID);
        if (cb == null) return;
        
        var obj;
        
        for (var i = 0; i < CheckBoxIDs.length; i++)
        {
          if(CheckBoxIDs[i] == ClientID) continue;
          
          if(DocumentNos[i] == DocumentNo)
          {
             obj = document.getElementById(CheckBoxIDs[i]);
             if (obj == null) continue;
             
             obj.checked = cb.checked;
          }
        }     
     }
     
     function DoBooking()
     {        
        if (CheckBoxIDs == null) return;
          
        var boolChecked = false;
          
        for (var i = 0; i < CheckBoxIDs.length; i++)
        {
          obj = document.getElementById(CheckBoxIDs[i]);
          if (obj == null) return;
             
          if(obj.checked)
          {
             boolChecked = true;
             break;
           }
        }
          
        if(!boolChecked)
        {
          alert("请选择需要预约的集装箱!");
          return;
        }
          
        __doPostBack('DoBooking','');     
     }
    
    function DoCheck()
    {
        var obj = document.getElementById("ctl00$ContentPlaceHolderContent$TextBoxPassword");
        if (obj == null) return;
        
        if(obj.value == "")
        {
          alert("请输入核销密码!");
          return;
        }
        
        if (CheckBoxIDs == null) return;
        
        var boolChecked = false;
        
        for (var i = 0; i < CheckBoxIDs.length; i++)
        {
          obj = document.getElementById(CheckBoxIDs[i]);
          if (obj == null) return;
          
          if(obj.checked)
          {
             boolChecked = true;
             break;
          }
        }
        
        if(!boolChecked)
        {
          alert("请选择需要核销的集装箱!");
          return;
        }
        
        __doPostBack('DoCheck','');     
    }
    
    /*----------------------------------*/
    /*         InboundFee Script        */
    /*----------------------------------*/
    function InboundFee_GenerateReport()
    {              
        var obj_startdate = document.all["ctl00_ContentPlaceHolderContent_TextBoxStartDate"];
        var obj_enddate = document.all["ctl00_ContentPlaceHolderContent_TextboxEndDate"];
        var obj_feereport = document.all["ctl00_ContentPlaceHolderContent_FeeReport"];
                
        if(obj_startdate == null) return;
        if(obj_enddate == null) return;
        if(obj_feereport == null) return;
                      
        if(!isDate(obj_startdate.value))
        {
            alert("起始日期格式错误!");
            return;
        }
        
        if(!isDate(obj_enddate.value))
        {
            alert("终止日期格式错误!");
            return;
        }
        
        var m_url = "InBoundFeeReport.aspx?startDate=" + obj_startdate.value + "&endDate=" + obj_enddate.value;        
        obj_feereport.src = m_url;
    }
    
    /*----------------------------------*/
    /*         Print FeeReport          */
    /*----------------------------------*/
    function PrintFeeSummary()
    {   
        var obj_year = document.all["ctl00$ContentPlaceHolderContent$DropDownListYear"];
        var obj_month = document.all["ctl00_ContentPlaceHolderContent_DropdownlistMonth"];
        var obj_location = document.all["ctl00_ContentPlaceHolderContent_DropDownListLocation"];
                
        if(obj_year == null) return;
        if(obj_month == null) return;
        if(obj_location == null) return;
        
        var m_url = "OutBoundFeeSummaryPrint.aspx?date=" + obj_year.value + "-" + obj_month.value + "&location=" + obj_location.value ; 
        OpenWindow(m_url);       
    }
    
    function PrintFeeList()
    { 
         var obj_year = document.all["ctl00$ContentPlaceHolderContent$DropDownListYear"];
        var obj_month = document.all["ctl00_ContentPlaceHolderContent_DropdownlistMonth"];
         var obj_location = document.all["ctl00_ContentPlaceHolderContent_DropDownListLocation"];
                
        if(obj_year == null) return;
        if(obj_month == null) return;
        if(obj_location == null) return;
        
        var m_url = "OutBoundFeeListPrint.aspx?date=" + obj_year.value + "-" + obj_month.value + "&location=" + obj_location.value ;  
        OpenWindow(m_url);                   
    }
   
   
   /*----------------------------------*/
   /*         Print FeeReport          */
   /*----------------------------------*/
    function Notice_Delete(id)
    {
        if(!confirm("您确认要删除通知吗?")) return;
        
        __doPostBack('DELETE',id);
    }
    
    