﻿// JScript 文件

/*根据标签显示不同列表 BEGIN*/
function changNews(contrlObj, ViewObj, itemRow)
{
    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 = "this";}
    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()
{
    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;
    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();
}


// 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*/


/*显示与隐藏 在线软件应用 列表 BEGIN*/
function showlist(id,num){
	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)
{
    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 = "this";}
    if (newsObj.children[itemRow] != null){ newsObj.children[itemRow].style.display = "";}
}
/*END*/

/*页面跳转 BEGIN*/
function GotoUrl(theUrl)
{
    if (theUrl == "") { return false; }
    aGoToUrl.href = theUrl;    
    aGoToUrl.click();
}
/*END*/
