﻿//安排div
function arrangeDiv(){
	var x=6;	//根据显示器的分辨率，设置横坐标
	var ww=window.screen.width;
	if(ww>1024 && ww<=1152){
		x=70;
	}else if(ww>1152){
		x=140;
	}
	
	var dt=document.getElementById("divTop");
	dt.style.left=x+"px";
	var dp=document.getElementById("divPosition");
	if(document.getElementById("divMiddle")){
	var dm=document.getElementById("divMiddle");
	}
	if(dp){
		dp.style.top=dt.offsetTop+dt.offsetHeight+"px";
		dp.style.left=x+"px";
		dm.style.top=dp.offsetTop+dp.offsetHeight+"px";
	}else{
		dm.style.top=dt.offsetTop+dt.offsetHeight+"px";
	}
	dm.style.left=x+"px";
	var db=document.getElementById("divBottom");
	var dMain=document.getElementById("divMain")||document.getElementById("divMain2");
	db.style.top=dm.offsetTop+Math.max(dm.offsetHeight,dMain.offsetHeight)+"px";
	db.style.left=x+"px";
	//中间栏的横坐标
	if(document.getElementById("divLeft")){
	var dLeft=document.getElementById("divLeft");
	dMain.style.left=dLeft.offsetLeft+dLeft.offsetWidth+"px";
	}
}
//查询
function search(keywordId,searchPage){
	var val=keywordId.value.replace(/(^\s*)|(\s*$)/g,"");
	if(val==""){
		window.alert("Please input keyword.");
		return false;
	}
	if(val.indexOf("{")>=0||val.indexOf("}")>=0){
		window.alert("Cannot search '{' or '}'.");
		return false;
	}
	window.open(searchPage+"?keyword="+val);
}
//分页
function goPage(url,ddlId){
	var ddl=document.getElementById(ddlId);
	if(url.indexOf(".aspx")>=0){
		var prefix="?";
		if(url.indexOf(prefix)>=0){
			prefix="&";
		}
		url+=prefix+"page="+((ddl.value=="")?"1":ddl.value);
	}else{
		//静态页面
		if(ddl.value>1){
			url=url.replace(".htm","_"+(ddl.value-1).toString()+".htm");
		}
	}
	window.open(url);
}
//目录查询
function searchInfo(){
	var txtHsCode=document.getElementById("txtHsCode");
	var txtName=document.getElementById("txtName");
	var txtScope=document.getElementById("txtScope");
	var valHsCode=txtHsCode.value.replace(/(^\s*)|(\s*$)/g,"");
	var valName=txtName.value.replace(/(^\s*)|(\s*$)/g,"");
	var valScope=txtScope.value.replace(/(^\s*)|(\s*$)/g,"");
	if(valHsCode==""&&valName==""&&valScope==""){
		alert("You must input at least one keyword in above 3 textboxes.");
		return;
	}
	var url="detail.aspx";
	if(valHsCode!=""){
		url+=((url.indexOf("?")>=0)?"&":"?")+"hscode="+valHsCode;
	}
	if(valName!=""){
		url+=((url.indexOf("?")>=0)?"&":"?")+"name="+valName;
	}
	if(valScope!=""){
		url+=((url.indexOf("?")>=0)?"&":"?")+"scope="+valScope;
	}
	window.open(url);
}
function clearTextBox(){
	var txtHsCode=document.getElementById("txtHsCode");
	var txtName=document.getElementById("txtName");
	var txtScope=document.getElementById("txtScope");
	txtHsCode.value="";
	txtName.value="";
	txtScope.value="";
	txtHsCode.focus();
}
//显/不显Email
function showEmail(al,show){
	var href=al.href;
	var html=al.innerHTML;
	if(show){
		al.href=href.replace('#','@');
		al.innerHTML=html.replace('#','@');
	}else{
		al.href=href.replace('@','#');
		al.innerHTML=html.replace('@','#');
	}
}


