﻿/* 常用代码 */
var REQUIRED_CN = "请输入%Field%。\n"
var REQUIRED_EN = "%Field% is required.\n"

/* 去除字符串两端的空格 */
function Trim(asString){
	return asString.replace(/(^\s*)|(\s*$)/g, "");
}

/* 表单必填项检查 */
function FormCheck(aobjForm, asLanguage){
	var sMessage = "";
	var sTitle;
	var sRequired;
	
	switch(asLanguage.toLowerCase()){
		case "en":
			sRequired = REQUIRED_EN;
			break;
		default:
			sRequired = REQUIRED_CN;
			break;
	}
	
	for(var i = 0; i < aobjForm.elements.length; i ++){
		sTitle = aobjForm.elements[i].getAttribute("title");
		if(sTitle != null && sTitle.indexOf("*") != -1
		&& Trim(aobjForm.elements[i].value) == ""){
			sMessage += sRequired.replace("%Field%", sTitle.substring(0, sTitle.indexOf("*")));
		}
	}
	
	if(sMessage.length > 0){
		alert(sMessage);
		return false;
	}else{
		return true;
	}
}

/* 设置页面url参数 */
function SetUrl(asUrl, asQueryString, asParm, asValue){
	var iPos = -1;
	var sUrl = asUrl;
	var iNewPos = -1;
	
	if(sUrl == ""){
		sUrl = document.location.protocol + document.location.port + "//"
				 + document.location.hostname + document.location.pathname;
	}
	
	if(asQueryString == null || asQueryString == ''){
		sUrl += '?' + asParm + '=' + asValue;
		return sUrl;
	}
	
	if(asQueryString.charAt(0) == '?'){
		asQueryString = asQueryString.substr(1);
	}
	
	asQueryString = asQueryString.toLowerCase();
	iPos = asQueryString.indexOf(asParm + '=');
	
	if(iPos == -1){
		sUrl += '?' + asQueryString + '&' + asParm + '=' + asValue;
		return sUrl
	}
	
	iNewPos = asQueryString.indexOf('&', iPos + 1);
	if(iNewPos == -1){
		asQueryString = asQueryString.replace(asQueryString.substr(iPos), asParm + '=' + asValue);
	}else{
		asQueryString = asQueryString.replace(asQueryString.substring(iPos, iNewPos), asParm + '=' + asValue);
	}
	
	sUrl += '?' + asQueryString;
	
	return sUrl;
}

/* 弹出窗口 */
function OpenWindow(asUrl, aiWidth, aiHeight, aiType){
	var objWindow;
	var iLeft = (screen.availWidth - aiWidth) / 2;
	var iTop = (screen.availHeight - aiHeight) / 2;
	
	switch(aiType){
		case 2:
			objWindow = window.open(asUrl, "",
									"menubar=0,toolbar=0,location=0,status=0,"
								+ "resizable=0,scrollbars=0," 
								+ "width=" + aiWidth + ",height=" + aiHeight
								+ ",top=" + iTop + ",left=" + iLeft);
			break;
		case 1:
			objWindow = window.open(asUrl, "",
									"menubar=0,toolbar=0,location=0,status=0,"
								+ "resizable=0,scrollbars=1," 
								+ "width=" + aiWidth + ",height=" + aiHeight
								+ ",top=" + iTop + ",left=" + iLeft);
			break;
		default:
			objWindow = window.open(asUrl, "");
			break;
	}
}
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. 

{ 

    var arVersion = navigator.appVersion.split("MSIE") 

    var version = parseFloat(arVersion[1]) 

    if ((version >= 5.5) && (document.body.filters)) 

    { 

       for(var j=0; j<document.images.length; j++) 

       { 

          var img = document.images[j] 

          var imgName = img.src.toUpperCase() 

          if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 

          { 

             var imgID = (img.id) ? "id='" + img.id + "' " : "" 

             var imgClass = (img.className) ? "class='" + img.className + "' " : "" 

             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 

             var imgStyle = "display:inline-block;" + img.style.cssText 

             if (img.align == "left") imgStyle = "float:left;" + imgStyle 

             if (img.align == "right") imgStyle = "float:right;" + imgStyle 

             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 

             var strNewHTML = "<span " + imgID + imgClass + imgTitle 

             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 

             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 

             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 

             img.outerHTML = strNewHTML 

             j = j-1 

          } 

       } 

    }     

} 

window.attachEvent("onload", correctPNG); 
function showInfo(f) 
{ 
document.getElementById("popasp_table1").style.display="none"; 
document.getElementById("popasp_table2").style.display="none"; 
document.getElementById("popasp_table3").style.display="none"; 
document.getElementById("t1").style.background="url(/images/an01.jpg)"; 
document.getElementById("t2").style.background="url(/images/an01.jpg)"; 
document.getElementById("t3").style.background="url(/images/an01.jpg)"; 
document.getElementById("popasp_table"+f).style.display=""; 
document.getElementById("t"+f).style.background="url(/images/an02.jpg)"; 
} 
