var helpKeyCode = 113;

var gdleft=0;
function writeBottom(path)
{
    var styletag = "content_bottom";
    document.write("<div id='"+styletag+"'>");
    //document.write("&nbsp;<img src='"+path+"/images/icon.gif'/>");
    document.write(" &nbsp;&nbsp;建议分辨率 1024*768 | IE 6.0 以上 | 福田保税区海关版权所有<br/>");
    document.write("<div class='links'><a href='#'>联系我们</a>&nbsp;</div>");
    document.write("</div>");
    if (document.getElementById("menutitle")!=null)
    data.style.width=content.offsetWidth-menutitle.offsetWidth-30;
    window.attachEvent("onresize",windowResize);
    var actionimgs=document.getElementsByName("actionimg");
    for (var n=0;n<actionimgs.length;n++)
    {
        actionimgs[n].disabled=true;
    }
}

function trClick(tr){
	var clickcolor = "#08387b";
	if (!isIE())
	{
		clickcolor = "rgb(8, 56, 123)";
	}
	with (tr.style) {
	if (backgroundColor.toLowerCase() == clickcolor.toLowerCase()) {
	backgroundColor = "transparent";
	color="black";
	}
	else {
	backgroundColor = clickcolor;
	color="white";}
	}
}

function activeMenu(menu,submenu) {
	hideMenu(menu);
	openMenu(submenu);
}

function openMenu(menu) {
	if (document.getElementById(menu)!=undefined)
	{
		with (document.getElementById(menu).style) {
			if (visibility=='' || visibility=="hidden")
			{
				visibility="visible";
				width="140px";
				height="auto";
				top=(document.getElementById(menu).offsetTop-20)+"px";
			}
		}
	}
}

function hideMenu(menu) {
	var menus = document.getElementsByTagName("DIV");
	if (!isIE())
		menus =  document.getElementsByName(menu);
	var j = 0;
	for (var i=0; i<menus.length; i++)
	{
		if (!isIE() || menus[i].name==menu)
		{
			hideMenuByObj(menus[i]);
			j++;
		}
	}
	if (j>0)
	{
		hideMenu('l'+(parseInt(menu.substring(1))+1));
	}
}

function hideMenuByObj(obj) {
	with (obj.style) {
		if (visibility=='visible')
		{
			visibility="hidden";
			width="0px";
			height="0px";
			top="auto";
		}
	}
}

function windowResize()
{
    var data = document.getElementById("data");
		var content = document.getElementById("content");
		if (document.getElementById('VicPopCal')!=null)
    VicPopCal.style.visibility = 'hidden';
    if (document.getElementById("accordionExample")!=null)
    {
        data.style.width=content.offsetWidth-145-30;
        var panels=document.getElementsByTagName("DIV");
	    for (var i=0;i<panels.length;i++)
	    {
	        if (panels[i].id.indexOf("panel")==0)
	        {
	            if (panels[i].style.visibility=='' || panels[i].style.visibility=='visible')
	            {
	                data.style.width=content.offsetWidth-145-30;
	                break;
	            }
	            else 
	            {
	                data.style.width=content.offsetWidth-30;break;
	            }
	        }
	    }
    }
}

function openWindowFull(url)
{
	//var newwin = open(url,'_self','top=0,left=0,menubar=no,toolbar=no,directories=no,location=no,status=no,resizable=yes,scrollbars=yes');
	//newwin.resizeTo(screen.width,screen.height);
}
function openNewWindowFull(url)
{
	var newwin = open(url,'_blank','top=0,left=0,menubar=no,toolbar=no,directories=no,location=no,status=no,resizable=yes,scrollbars=yes');
	newwin.resizeTo(screen.width,screen.height);
}
function openNewWindow(url)
{
	openNewWindow(url);
}
function openNewWindow(url,x,y)
{
	var newwin = open(url,'_blank','top=0,left=0,menubar=no,toolbar=no,directories=no,location=no,status=no,resizable=yes,scrollbars=yes');
	newwin.resizeTo(x,y);
	newwin.moveTo((screen.width-x)/3,(screen.height-y)/3);
}
function dateinput(textfield,nextfied)
{
	var evt=window.event;
	if (!isIE())
	{
		evt=SearchEvent();
	}
	Calendar.display(textfield, evt);
	//fPopCalendar(textfield,textfield,nextfied);
	//return false;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//yzh
function sel(url,title) {
	window.open(url,title,"width:200px;height:100px;left:200;top:120;status:0;location:0;toolbar:0;menubar:0;resizable:0;scrollbars:no");	
}
//打开对话框
function selx(url,window){
	var newwin = window.showModalDialog(url,window,"dialogWidth:750;dialogHeight:520px;center:yes;status:0;location:0;toolbar:0;menubar:0;resizable:0;scrollbars:no;edge:sunken");
}
//打开指定宽度和高度的对话框
function selx(url,window,width,height){
	var newwin = window.showModalDialog(url,window,"dialogWidth:" + width + "px;dialogHeight:"+ height + "px;center:yes;status:0;location:0;toolbar:0;menubar:0;resizable:0;scrollbars:no;edge:sunken");
}

function openModal(src, object, width, height){
    var leftLen = (screen.width - width)/2;
    var topLen = (screen.height - height)/2;
    return window.showModalDialog(src, object, 'dialogwidth=' + width + 'px; dialogheight=' + height + 'px; dialogleft=' + leftLen + 'px; dialogtop=' + topLen + 'px;status=no');
}   


function browserType() {
		var browser=navigator.appName;
		return browser;
}

function isIE() {
		if (browserType()=='Microsoft Internet Explorer')
		{
			return true;
		}
		return false;
}
//用回车跳到下一个输入框，用法：在<table>中加onkeydown="nextInput(event);"
//在遇到下一个输入是“确定”，“重置”，“取消”按钮时，不再下移焦点

function nextInput(event)
{ 
    var obj = event.srcElement;
    if(event.keyCode==13 && obj.type != "submit" && !(obj.type == "button" && (obj.outerHTML.indexOf('submit(') > 0 || obj.outerHTML.indexOf('Submit(') > 0))){

		
        if(obj.nextSibling != null && obj.nextSibling.type == "button" && obj.nextSibling.outerHTML.indexOf('dateinput(') > 0){
           obj.nextSibling.focus();
        }
        event.keyCode=9; 
		
        return false;
    }    
}
/*function nextInput(event)
{
    nextInput1(event);
}*/
function nextInput1(event)
{
		var evt=event;
		
		if (!isIE())
		{
			evt=SearchEvent();
		}
		var obj = (isIE()) ? evt.srcElement:evt.originalTarget;
		var objectType = obj.type;
		if(evt.keyCode==13 && objectType!='button' && objectType!='submit' && objectType!='reset' 
		&& objectType!='textarea' && objectType!='')
		{
			focusNext(obj);
		}
}
function focusNext(obj) {
	var nextobj = null;
	var ele = document.getElementsByTagName('INPUT');
	for(var i=0;i<ele.length;i++){
			var q=(i==ele.length-1)?0:i+1;// if last element : if any other
			if(obj==ele[i]){
					nextobj = ele[q];
			break;
		}
	}
	if (nextobj!=null && nextobj.type=='button' && nextobj.value=='确定' || nextobj.value=='重置' || nextobj.value=='取消')
	{
	} else if (nextobj!=null && (nextobj.type=='button' || nextobj.type=='hidden' || nextobj.disabled) )
		focusNext(nextobj);
	else
		nextobj.focus();
}
function SearchEvent()
{
    func=SearchEvent.caller;
    while(func!=null)
    {
        var arg0=func.arguments[0];
        if(arg0)
        {
            if(arg0.constructor==Event) // 如果就是event 对象
                return arg0;
        }
        func=func.caller;
    }
    return null;
}

function displaySelected(field,tdname)
{
	if (field.checked==true) {
		tdname.style.background='0A246A';
		tdname.style.color='white';
	} else {
		tdname.style.background='transparent';
		tdname.style.color='#2B4768';
	}
}

function launchPage(pageURL) {
  // document.location.assign(pageURL);
  window.document.location.href=pageURL;
}

function printSet() {
  factory.printing.SetMarginMeasure(1);
  factory.printing.leftMargin = 10 
  factory.printing.topMargin = 10 
  factory.printing.rightMargin = 10 
  factory.printing.bottomMargin =10 
}

function isAllDigits(argvalue) {
	argvalue = argvalue.toString();
	var validChars = "0123456789";
	var startFrom = 0;
	if (argvalue.substring(0, 2) == "0x") {
		validChars = "0123456789abcdefABCDEF";
		startFrom = 2;
	} else if (argvalue.charAt(0) == "o") {
		validChars = "01234567";
		startFrom = 1;
	} else if (argvalue.charAt(0) == "-") {
		startFrom = 1;
	}
	for (var n = startFrom; n < argvalue.length; n++) {
		if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
	}
	return true;
}

function getNewXmlHttpRequest() { 
 var A=null; 
 try { 
 A=new ActiveXObject("Msxml2.XMLHTTP");
 } 
 catch(e) { 
 try { 
 A=new ActiveXObject("Microsoft.XMLHTTP");
 } 
 catch(oc) { 
 A=null;
 } 
 } 
 if ( !A && typeof XMLHttpRequest != "undefined" ) { 
 A=new XMLHttpRequest();
 } 
 return A;
} 

function getItemNum(name) {
	return name.substring(name.indexOf('[')+1,name.indexOf(']'));
}

function checkHour(lable,obj) {
	var value = obj.value;
	if (trim(value).length==0)
	{
		return true;
	}
	if (!isAllDigits(value)) {
		alert(lable+'的小时数要是整数！');
		return false;
	}
	else if (value.length!=2)
	{
		alert(lable+'的小时数要是2位！');
		return false;
	}
	else if (parseInt(value)<0 || parseInt(value)>23) {
		alert(lable+'的小时数要是00-23！');
		return false;
	}
	return true;
}
function checkMins(lable,obj) {
	var value = obj.value;
	if (trim(value).length==0)
	{
		return true;
	}
	if (!isAllDigits(value)) {
		alert(lable+'的分钟数要是整数！');
		return false;
	} 
	else if (value.length!=2)
	{
		alert(lable+'的分钟数要是2位！');
		return false;
	}
	else if (parseInt(value)<0 || parseInt(value)>59) {
		alert(lable+'的分钟数要是00-59！');
		return false;
	}
	return true;
}