﻿
function JC_E(e,v)
{
   if(typeof(e) == "string")
   {
       var o  = document.getElementById(e);
       if(o && v == true)
       {
        
         return document.getElementById(e).value;
       }
       else
       {
          return o;
       }
       
   }
}

function JC_Es(e)
{
   if(typeof(e) == "string")
   {
       var o  = document.getElementsByName(e);

       return o;      
   }
}


function JC_getRadioValue(e)
{
    var o = JC_Es(e);
    var r = '';
    if(o)
    {
         for(i=0;i<o.length;i++)
         {
             if(o[i].checked == true)
             {
                 r = o[i].value;
                 break;
             }
         }

    }
    return r;
}

function search(){
this.isCheck=false
}
search.prototype = {

check : function(){return true},
handler:function(){},
operation:function()
   {
      if(this.check)
      {
         this.isCheck = this.check();
      }
      if(this.isCheck&&this.handler)
      {
         this.handler();
      }
   }
}


var shipperSearch = new search();
shipperSearch.check = function (){ 

    var startportValue = JC_E("startport",true);
    var endportValue = JC_E("endport",true);
    var feedbinValue = JC_E("feedbin",true);
   
    var startportDeValue = JC_E("startport",false).getAttribute("mod_notice_tip");
    var endportDeValue = JC_E("endport",false).getAttribute("mod_notice_tip");
    var feedbinDeValue = JC_E("feedbin",false).getAttribute("mod_notice_tip");
   
   
   if (startportValue==startportDeValue 
        &&endportValue==endportDeValue 
        &&feedbinValue==feedbinDeValue)
    {
         alert("请输入搜索条件搜索船期！");
          return false;
    }
    if (startportValue==startportDeValue 
        &&endportValue!=endportDeValue 
        &&feedbinValue==feedbinDeValue)
    {
        alert("请输入起始港或承运人搜索船期！");
        return false;
    }
    if (startportValue!=startportDeValue 
        &&endportValue==endportDeValue 
        &&feedbinValue==feedbinDeValue)
    {
        alert("请输入目的港或承运人搜索船期！");
        return false;
    }
   
    return true;
   
   };
function shipperHandler()
{

    var index = location.search.indexOf("LayoutType");

    var type = '';
    if(index > -1)
    {
        type = '&'+ location.search.substring(index,location.search.length);
    }
    

    var startportID = JC_E("startport1",true);
    var endportID = JC_E("endport1",true);
    var feedbinID = JC_E("feedbin1",true);

    var startportValue = JC_E("startport",true);
    var endportValue = JC_E("endport",true);
    var feedbinValue = JC_E("feedbin",true);

    var formSearch = JC_E("form1",false);
    

    
    var startportDeValue = JC_E("startport",false).getAttribute("mod_notice_tip");
    var endportDeValue = JC_E("endport",false).getAttribute("mod_notice_tip");
    var feedbinDeValue = JC_E("feedbin",false).getAttribute("mod_notice_tip");
     
    
    var search= startportID+","+startportValue+"_"+ endportID+","+endportValue+"_"+feedbinID+","+feedbinValue;
    if (startportValue==startportDeValue
       && endportValue==endportDeValue 
       && feedbinValue!=feedbinDeValue)
    { 

       formSearch.setAttribute("action","../SeaRoutes/SearchByFCC.html?search=&sea="+feedbinID+","+feedbinValue+type);
      
       formSearch.submit();
    }
    if (startportValue!==startportDeValue
       && endportValue!==endportDeValue 
       && feedbinValue==feedbinDeValue)
    {
      
       formSearch.setAttribute("action","../SeaRoutes/SearchByStartPortAndEndPort.html?search=&sea="+startportID+","+escape(startportValue)+"_"+endportID+","+escape(endportValue)
                        +"_,请输入承运人"+type);
  
    
                       
       formSearch.submit();
    }

    if (startportValue!=startportDeValue 
       && endportValue==endportDeValue
       && feedbinValue!=feedbinDeValue)
    {
      formSearch.setAttribute("action","../SeaRoutes/SearchByStartPortAndFCC.html?search=&sea="+startportID+","+escape(startportValue)+"_"+feedbinID+","+escape(feedbinValue)+type);

      formSearch.submit();
    }

    if (startportValue==startportDeValue
        &&endportValue!=endportDeValue 
        &&feedbinValue!=feedbinDeValue 
    )
    {
        formSearch.setAttribute("action","../SeaRoutes/SearchByEndPortAndFCC.html?search=&sea="+endportID+","+escape(endportValue)+"_"+feedbinID+","+escape(feedbinValue)+type);

        formSearch.submit();
    }

    if (startportValue!=startportDeValue
        &&endportValue!=endportDeValue 
        &&feedbinValue!=feedbinDeValue)
    {

        formSearch.setAttribute("action","../SeaRoutes/SearchByAll.html?search=&sea="+startportID+","+escape(startportValue)+"_"+ endportID+","+escape(endportValue)+"_"+feedbinID+","+escape(feedbinValue)+type);
        formSearch.submit();
    }

 

}

shipperSearch.handler = shipperHandler;

var freightSearch = new search();
freightSearch.check =  function ()
{
    var startportValue = JC_E("startport",true);
    var endportValue = JC_E("endport",true);
    var feedbinValue = JC_E("feedbin",true);   
      
    var startportDeValue = JC_E("startport",false).getAttribute("mod_notice_tip");
    var endportDeValue = JC_E("endport",false).getAttribute("mod_notice_tip");
    var feedbinDeValue = JC_E("feedbin",false).getAttribute("mod_notice_tip");     
         
    if (startportValue==startportDeValue && endportValue==endportDeValue)
    {
        alert("请输入搜索条件搜索运价！");return false;
    }
    if (startportValue==startportDeValue && endportValue!=endportDeValue)
    {
        alert("请输入起始港搜索运价！");return false;
    }
    if (startportValue!=startportDeValue && endportValue==endportDeValue)
    {
        alert("请输入目的港搜索运价！");return false;
    }   
    
    return true;
    
};

function freightHandler()
{
      
    var startportID = JC_E("startport1",true);
    var endportID = JC_E("endport1",true);
    var feedbinID = JC_E("feedbin1",true);

    var startportValue = JC_E("startport",true);
    var endportValue = JC_E("endport",true);
    var feedbinValue = JC_E("feedbin",true);

    var formSearch = JC_E("form1",false);
    
    var startportDeValue = JC_E("startport",false).getAttribute("mod_notice_tip");

    var endportDeValue = JC_E("endport",false).getAttribute("mod_notice_tip");
    var feedbinDeValue = JC_E("feedbin",false).getAttribute("mod_notice_tip");
 
      
    var sp1=startportID;
    var ep1=endportID;
    var sp=startportValue;
    var ep=endportValue;
    var fb1='';
    var fb=feedbinDeValue;

    if(feedbinValue!=feedbinDeValue)
    {
   
        fb1=feedbinID;
        fb=feedbinValue;
    }
  
    var search= sp1+","+sp+"_"+ ep1+","+ep+"_"+fb1+","+fb;
    
  
        
    var txtflag=1;
    var weeks="";
    var strdatetime="";
    var txtBoxType="";
   
    if ( JC_E('txtflag',false)!=null)
    {
        txtflag=JC_E('txtflag',true);
    } 
    if (JC_E("FullYear",false)!=null
        &&JC_E("lblweekCount",false)!=null)
    {
        weeks=JC_E("FullYear",true)+JC_E("lblweekCount",false).innerText;
    }
    if (JC_E('strdatetime',false)!=null)
    {
        strdatetime=replaceDate(JC_E('strdatetime',true));
    }
    if (JC_E("txtBoxType",false)!=null)
    {
      txtBoxType=JC_E("txtBoxType",true)
    }

    formSearch.setAttribute("action", '../FreightQuery/list-'+''+'-'+search+'-'+txtflag+'-'+weeks+'-'+strdatetime+'-'+txtBoxType+'.html');

    formSearch.submit();
    
}
freightSearch.handler = freightHandler;


function searchOp()
{

    freightSearch.operation();
     
}


 
 





