﻿// JScript 文件

//---------改用层方式弹出窗口------------------
//弹出模式窗口 BEGIN
//function openNewWindow(Url, Width, Height)
//{
//    d = new Date();
//    var fea="dialogHeight:" + Height + "px;dialogWidth:" + Width + "px;status:no;scroll:yes;resizable:yes";
//    //window.open(Url+"&t=" + d.getTime() ,null,fea);
//    var returnValue = window.showModalDialog(Url+"&t=" + d.getTime() ,null,fea);
//    if (returnValue != null){return true;}
//    return false;
//}
/*END*/



//关闭弹出的窗口
window.close = function()
{
   if(parent != null){ parent.closedlgWithReturn(window.returnValue);} else{ window.close();};
};


function openNewWindow(url, Width, Height,name)
{
  d = new Date();
   
   //处理路径问题      
   /* 
    if(url.indexOf(".//") < 0 && url.toLowerCase().indexOf("ailweb/") < 0 && url.toLowerCase().indexOf("ail/") < 0  ){
      var bp, len;
      bp = document.location.pathname.substring( 0, document.location.pathname.toLowerCase().indexOf('aspx'));
	    len = bp.lastIndexOf('/'); 
		  if(len>0) bp = bp.substring( 0, len + 1 ); 
      url =  bp + url;
    }
    */
    
    var winname='鹏腾网';
    if(name!=null&&name!='undefined')
    {
     winname=name;
    }
  
  if (url.indexOf("?") > 0 ) { url +=  "&t=" + d.getTime();} else { url +=  "?t=" + d.getTime(); }
  lhgdialog.opendlg( winname, url, Width, Height,true,true);
}

function openNewAndRefreshParent(url, width, height)
{
   window.close = function(){
     if(parent != null){ parent.closedlgWithReturn(window.returnValue);} else{ window.close();};
     };

    var d = new Date();
    var fea="dialogHeight:" + height + "px;dialogWidth:" + width + "px;status:no;scroll:yes;resizable:yes";
    if (url.indexOf("?") > 0 ) { url +=  "&t=" + d.getTime();}
    else { url +=  "?t=" + d.getTime(); }

    //处理路径问题      
    if(url.indexOf(".//") < 0){
      var bp, len;
      bp = document.location.pathname.substring( 0, document.location.pathname.toLowerCase().indexOf('aspx'));
	    len = bp.lastIndexOf('/'); 
		  if(len>0) bp = bp.substring( 0, len + 1 ); 
      url =  bp + url;
    }

    lhgdialog.callBackClose = function(){ closeReturnCall();};
    var returnValue = lhgdialog.opendlg( '鹏腾网', url, width, height,true,true);
}

function closeReturnCall()
{
    if (lhgdialog.returnValue) {window.location.replace(window.location.href);}
    else { return false; }   
}

function msgBox(strMsg)
{
   lhgdialog.opendlg( '提示信息', '<div style="font-size:12px; vertical-align:middle; text-align:center;height:100%;width:300"><table style="height:100%;"><tr><td>' + strMsg + '</td></tr></table></div>', 300, 200, false, 'hcode' );
}
//---------改用层方式弹出窗口------------------



// [请勿使用]打开新窗口,关闭时根据返回值决定是否刷新父窗口 BEGIN BEGIN
// url : rul地址
// width :窗口宽度
// height : 窗口高度
//function openFunWindow(url, width, height)
//{
//    //此方法与　openNewAndRefreshParent　功能一样，请使用 openNewAndRefreshParent方法
//    var d = new Date();
//    if (url.indexOf("?") > 0) { url = url + "&t=" + + d.getTime()}
//    else { url = url + "?t=" + + d.getTime() }
//    var fea="dialogHeight:" + height + "px;dialogWidth:" + width + "px;status:no;scroll:yes;resizable:yes";
//    var returValue =  window.showModalDialog(url ,null,fea);
//    if (returValue == true)
//    {
//        location.href(window.location.href);
//    }
//}
/*END*/

// 打开新窗口,关闭时根据返回值决定是否刷新父窗口 BEGIN
// url : rul地址
// width :窗口宽度
// height : 窗口高度
//function openNewAndRefreshParent(url, width, height)
//{
//    var d = new Date();
//    var fea="dialogHeight:" + height + "px;dialogWidth:" + width + "px;status:no;scroll:yes;resizable:yes";
//    if (url.indexOf("?") > 0 ) { url +=  "&t=" + d.getTime();}
//    else { url +=  "?t=" + d.getTime(); }
//    var returnValue = window.showModalDialog(url ,null,fea);
//    if (returnValue != null) {window.location.replace(window.location.href);}
//    else { return false; }   
//}
/*END*/



/*显示与隐藏 在线软件应用 列表 BEGIN*/
function showlist(id,num){
    return true;
	if(num == 1){
		document.getElementById(id).style.display = "block";
	}
	else{
		document.getElementById(id).style.display = "none";
	}
}
/*END*/


//设为首页
function myhomepage(obj){ 
    obj.style.behavior="url(#default#homepage)";obj.sethomepage(document.location.href); 
} 
//添加收藏夹
function AddFavorite()
{
    window.external.addFavorite(document.location.href,document.title);
}

/*脚本内容分页 BEGIN*/
var ContentPageObj;                                                     //获取内容层 
var ContentPagePages;                                                   //获取翻页层 
var pgindex = 1;                                                        //当前页 
var ToltalPage;                                                         //页数

var scrollMove =false;                                                  //是否移动                
var posY=0;	                                                            //Mouse按下时的位置  
var posYDiv=0;	                                                        //Mouse按下时层的位置
var keechi;

//<body onload="iniContentPage('ContentPage','ContentpagePages');" >
function iniContentPage(contentId, pageId)                               //重写窗体加载的事件 
{
    ContentPageObj = document.getElementById(contentId);
    ContentPagePages = document.getElementById(pageId);
    ToltalPage = Math.ceil(parseInt(ContentPageObj.scrollHeight)/parseInt(ContentPageObj.offsetHeight));                             //获取页面数量 
    ContentPagePages.innerHTML = "共" + ToltalPage + "页&nbsp;<a href=\"javascript:gotopage('-1');\">上一页</a>&nbsp;页码：[";       //输出页面数量 
    //循环输出第几页 
    for (var i=1;i<=ToltalPage;i++)
    {ContentPagePages.innerHTML += "<a href=\"javascript:showPage('"+i+"');\">" + i + "</a> ";} 
    ContentPagePages.innerHTML += "]&nbsp;<a href=\"javascript:gotopage('1');\">下一页</a>";
} 

//上一页|下一页
function gotopage(value)
{ 
    try{ value == "-1" ? showPage(pgindex-1):showPage(pgindex+1); }
    catch(e){ } 
} 

//转到第几页
function showPage(pageINdex) 
{ 
    if (pageINdex > ToltalPage) { pageINdex = ToltalPage; }
    if (pageINdex < 1) { pageINdex = 1; }
    ContentPageObj.scrollTop = (pageINdex-1) * parseInt(ContentPageObj.offsetHeight);  
    pgindex = pageINdex; 
} 

function mouseDown(theObj)
{
    theObj.style.cursor = "move";
	posY = event.clientY;
	scrollMove = true;
	posYDiv = theObj.scrollTop;
	theObj.setCapture();
}

function mouseMove(theObj)
{
	if(scrollMove==true)
	{
		theObj.scrollTop = posYDiv + (posY-event.clientY);
	}
}

function mouseUp(theObj)
{
    theObj.style.cursor = "";
	scrollMove = false;
	theObj.releaseCapture();
}
/*END*/

/*改成指定层中文本的样式 BEGIN*/
function ChangerFontInDiv(ContentDiv, ClassName)
{
    if (document.getElementById(ContentDiv) != null)
    {document.getElementById(ContentDiv).className = ClassName;}
}
/*END*/

/*利用javascript的property特性来为firefox添加children的支持，但IE中有这段会报错*/
try{
    HTMLElement.prototype.__defineGetter__("children",
         function () {
             var returnValue = new Object();
             var number = 0;
             for (var i=0; i<this.childNodes.length; i++) {
                 if (this.childNodes[i].nodeType == 1) {
                     returnValue[number] = this.childNodes[i];
                     number++;
                 }
             }
             returnValue.length = number;
             return returnValue;
         }
     );
 }
 catch(e){}
 /*END*/
 
/*根据标签显示不同列表 BEGIN*/
function changNews(contrlObj, ViewObj, itemRow)
{
    changNewsByClass(contrlObj, ViewObj, itemRow, "this")
}

function changNewsByClass(contrlObj, ViewObj, itemRow, currentClass)
{
    var typeObj = document.getElementById(contrlObj);
    for (var i = 0; i < typeObj.children.length; i++){ typeObj.children[i].className = "";}
    var newsObj = document.getElementById(ViewObj);
    for (var i = 0; i < newsObj.children.length; i++){ newsObj.children[i].style.display = "none";}
    if (typeObj.children[itemRow] != null){typeObj.children[itemRow].className = currentClass;}
    if (newsObj.children[itemRow] != null){ newsObj.children[itemRow].style.display = "";}
}
/*END*/




/*通关信息查询 箱动态信息查询  船期查询 BEGIN*/
function checkSearchST()
{
    var inputValue = document.all.tqContaNoST.value;
    inputValue = inputValue.replace(" ","");
    
    var inputValue2 = document.all.tqBookNoST.value;
    inputValue2 = inputValue2.replace(" ","");
    
//    var inputValue3 = document.all.tqCmcNoST.value;
//    inputValue3 = inputValue3.replace(" ","");
    
    
    if (inputValue.length == 0  && inputValue2.length == 0 )
    {
        alert("请输入集装箱号,CMC订舱编号或者BOOKING NO！");
        return false;
    }

    aSearchReuslt.href= "http://www.cmclink.com/DataQuery/Queryresultpage.aspx?mode=ST&tqBookNoST="+inputValue2  +"&tqContaNoST=" +inputValue + "&tqCmcNoST=";
    aSearchReuslt.click();
}

function checkSearchCR()
{
    var inputValue = "";
    if (document.all.txttdh != null)
    {
       inputValue = document.all.txttdh.value;
    }
        
    if (document.all.txtjzxh.value.length == 0)
    {
        alert("必须输入集装箱号！");
        document.all.txtjzxh.focus();
        return false;
    }
    aSearchReuslt.href= "http://www.cmclink.com/DataQuery/Queryresultpage.aspx?mode=CR&tqBillNoCR=&tqContaNoCR=" +document.all.txtjzxh.value  +"&tqBillNoCR=" +inputValue;
    aSearchReuslt.click();
}

function checkSearchSchedule()
{
    var v1 = document.getElementById("tqQYView").value;
    v1 = v1.replace(" ","");

    var v2 = document.all.tqMDView.value;
    v2 = v2.replace(" ","");
    
    var inputValue = ""
    var inputValue2 = ""

    if (v1 != null && v1.length > 0)
    {
        inputValue= v1;
    }
    
    if (v2 != null && v2.length > 0)
    {
        inputValue2= v2;
    }
    
    if (inputValue.length == 0  || inputValue2.length == 0)
    {
        alert("必须输入起运港和目的港！");
        return false;
    }
    aSearchReuslt.href= "http://www.cmclink.com/DataQuery/Queryresultpage.aspx?mode=SC&tqQY="+inputValue  +"&tqMD=" +inputValue2;
    aSearchReuslt.click();
}
/*END*/


/*图片自适应缩放 BEGIN*/
//imgObj : 图片对象
//MaxW : 最大宽
//MaxH : 最大高
function ImgAuto(imgObj, MaxW, MaxH)
{
    var o=new Image();o.src=imgObj.src;var w=o.width;var h=o.height;var t;
    if (w>MaxW){t=MaxW;}else{t=w;}
    if ((h*t/w)>MaxH){imgObj.height=MaxH;imgObj.width=MaxH/h*w;}else{imgObj.width=t;imgObj.height=t/w*h;}
}

/*END*/

/*时间提示 BEGIN*/
function welcome(){
	var tNow = new Date();
	var iHour = tNow.getHours();
	var sWelcome;
	if(iHour == 23||iHour < 1){sWelcome='午夜';}
	else if(iHour <  6){sWelcome='凌晨';}
	else if(iHour <  8){sWelcome='早晨';}
	else if(iHour < 11){sWelcome='上午';}
	else if(iHour < 13){sWelcome='中午';}
	else if(iHour < 17){sWelcome='下午';}
	else if(iHour < 19){sWelcome='傍晚';}
	else{sWelcome='晚上';}
	sWelcome += '好!';
	document.write(sWelcome);
}

/*END*/

 function ShowList1()
    {
    if(document.getElementById("ResponseCount").style.display="block")
       {
      document.getElementById("ClickCount").style.display="block";
      document.getElementById("selClick").className="topC1";
      document.getElementById("ResponseCount").style.display="none";
      document.getElementById("selResponse").className="";
      
      }
    }
    
        function ShowList2()
    {
      if(document.getElementById("ClickCount").style.display="block")
      {
       
      document.getElementById("ResponseCount").style.display="block";
      document.getElementById("selResponse").className="topC1";
      document.getElementById("ClickCount").style.display="none";
      document.getElementById("selClick").className="";
      }
    }




/*回车时判断提交哪个按钮 BEGIN*/
var bIsSubmit = false;
document.onkeydown = function(){
    if(event.keyCode==13)     //判断回车按钮事件
    {
        event.keyCode=9;     //将回车事件转换成Tab键 
        bIsSubmit = true;
    }
}

document.onkeyup = function()
{
    if (bIsSubmit == true )
    {
        if (document.activeElement != null && document.activeElement.tagName == "INPUT")
        {
             document.activeElement.click();
        }
        bIsSubmit = false;
    }
}
/*END*/


/*js取url参数 BEGIN*/
function GetQueryString(name)   
{   
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");   
    var r  =  window.location.search.substr(1).match(reg);   
    if  (r!=null) return  unescape(r[2]);   
    return   null;   
}  
/*END*/


