
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 Yjsearch(){
this.isCheck=false
}
Yjsearch.prototype = {

check : function(){return true},
handler:function(){},
operation:function()
   {
      if(this.check)
      {
         this.isCheck = this.check();
      }
      if(this.isCheck&&this.handler)
      {
         this.handler();
      }
   }
}


var YjshipperSearch = new Yjsearch();
YjshipperSearch.check = function (){ 

    var startportValue = JC_E("Yjstartport",true);
    var endportValue = JC_E("Yjendport",true);
    var feedbinValue = JC_E("Yjfeedbin",true);
   
    var startportDeValue = JC_E("Yjstartport",false).getAttribute("mod_notice_tip");
    var endportDeValue = JC_E("Yjendport",false).getAttribute("mod_notice_tip");
    var feedbinDeValue = JC_E("Yjfeedbin",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 YjshipperHandler()
{

    var index = location.search.indexOf("LayoutType");

    var type = '';
    if(index > -1)
    {
        type = '&'+ location.search.substring(index,location.search.length);
    }
    

    var startportID = JC_E("Yjstartport1",true);
    var endportID = JC_E("Yjendport1",true);
    var feedbinID = JC_E("Yjfeedbin1",true);

    var startportValue = JC_E("Yjstartport",true);
    var endportValue = JC_E("Yjendport",true);
    var feedbinValue = JC_E("Yjfeedbin",true);

    var formSearch = JC_E("frmyj",false);
    

    
    var startportDeValue = JC_E("Yjstartport",false).getAttribute("mod_notice_tip");
    var endportDeValue = JC_E("Yjendport",false).getAttribute("mod_notice_tip");
    var feedbinDeValue = JC_E("Yjfeedbin",false).getAttribute("mod_notice_tip");
     
    
    var search= startportID+","+startportValue+"_"+ endportID+","+endportValue+"_"+feedbinID+","+feedbinValue;
    if (startportValue==startportDeValue
       && endportValue==endportDeValue 
       && feedbinValue!=feedbinDeValue)
    { 

       formSearch.location = "http://shipping.jctrans.com/SeaRoutes/SearchByFCC.html?search=&sea="+feedbinID+","+feedbinValue+type;
      
    }
    if (startportValue!==startportDeValue
       && endportValue!==endportDeValue 
       && feedbinValue==feedbinDeValue)
    {
      
       formSearch.location = "http://shipping.jctrans.com/SeaRoutes/SearchByStartPortAndEndPort.html?search=&sea="+startportID+","+escape(startportValue)+"_"+endportID+","+escape(endportValue)
                        +"_,请输入承运人"+type;

    }

    if (startportValue!=startportDeValue 
       && endportValue==endportDeValue
       && feedbinValue!=feedbinDeValue)
    {
      formSearch.location = "http://shipping.jctrans.com/SeaRoutes/SearchByStartPortAndFCC.html?search=&sea="+startportID+","+escape(startportValue)+"_"+feedbinID+","+escape(feedbinValue)+type;

    }

    if (startportValue==startportDeValue
        &&endportValue!=endportDeValue 
        &&feedbinValue!=feedbinDeValue 
    )
    {
        formSearch.location = "http://shipping.jctrans.com/SeaRoutes/SearchByEndPortAndFCC.html?search=&sea="+endportID+","+escape(endportValue)+"_"+feedbinID+","+escape(feedbinValue)+type;


    }

    if (startportValue!=startportDeValue
        &&endportValue!=endportDeValue 
        &&feedbinValue!=feedbinDeValue)
    {

        formSearch.location = "http://shipping.jctrans.com/SeaRoutes/SearchByAll.html?search=&sea="+startportID+","+escape(startportValue)+"_"+ endportID+","+escape(endportValue)+"_"+feedbinID+","+escape(feedbinValue)+type;

    }

 

}

YjshipperSearch.handler = YjshipperHandler;

var YjfreightSearch = new Yjsearch();
YjfreightSearch.check =  function ()
{
    var startportValue = JC_E("Yjstartport",true);
    var endportValue = JC_E("Yjendport",true);
    var feedbinValue = JC_E("Yjfeedbin",true);   
      
    var startportDeValue = JC_E("Yjstartport",false).getAttribute("mod_notice_tip");
    var endportDeValue = JC_E("Yjendport",false).getAttribute("mod_notice_tip");
    var feedbinDeValue = JC_E("Yjfeedbin",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 YjfreightHandler()
{
      
    var startportID = JC_E("Yjstartport1",true);
    var endportID = JC_E("Yjendport1",true);
    var feedbinID = JC_E("Yjfeedbin1",true);

    var startportValue = JC_E("Yjstartport",true);
    var endportValue = JC_E("Yjendport",true);
    var feedbinValue = JC_E("Yjfeedbin",true);

    var formSearch = JC_E("frmyj",false);
    
    var startportDeValue = JC_E("Yjstartport",false).getAttribute("mod_notice_tip");

    var endportDeValue = JC_E("Yjendport",false).getAttribute("mod_notice_tip");
    var feedbinDeValue = JC_E("Yjfeedbin",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)
    }

    document.location = 'http://shipping.jctrans.com/FreightQuery/list-'+''+'-'+search+'-'+txtflag+'-'+weeks+'-'+strdatetime+'-'+txtBoxType+'.html';

    
}
YjfreightSearch.handler = YjfreightHandler;


function YjsearchOp()
{
   

    var checkedValue = JC_getRadioValue("YjsearchRdo");
 
    switch(checkedValue)
    {
        case "shipper":
            YjshipperSearch.operation();
        break;
                     
        case "freight":
            YjfreightSearch.operation();
        break;
    }
  
     
}


 
 






