

function showLoadingImg(o){
	var obj=$("Loading");
	if(o=="0"){
		if(obj)	{
			obj.style.display="none";
		}
	}else{
		if(obj){
			obj.style.display="block";
		}else{
			var div=document.createElement("div");
			div.setAttribute("id","Loading");
			div.innerHTML="<div id=\"Loading\"><img src=\"images/Loading.gif\" />正在加载...</div>";
			document.body.insertBefore(div,null)
		}
		$("Loading").style.top=document.documentElement.scrollTop
	}
}


//IE6支持PNG透明图片的补丁
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 
          } 
       } 
    }     
} 
if(window.attachEvent) {
window.attachEvent('onload', correctPNG);
}



//check gbook form
function ckGbookForm(){
	var f=document.gbookForm;
	if(isNull.test(f.Name.value)){
		alert("姓名不能为空!");
		f.Name.value="";
		f.Name.focus();
		return;
	}
	if(isNull.test(f.Tel.value)){
		alert("联系电话不能为空!");
		f.Tel.value="";
		f.Tel.focus();
		return;
	}
	if(isNull.test(f.Content.value)){
		alert("留言内容不能为空!");
		f.Content.value="";
		f.Content.focus();
		return;
	}
	if(isNull.test(f.VerifyCode.value)||f.VerifyCode.value=="点击获取"){
		alert("验证码不能为空!");
		f.VerifyCode.value="";
		f.VerifyCode.focus();
		return;
	}
	f.sb.value='正在提交';
	f.sb.disabled=true;
	SaveGbook();
}

//只能输入数字
function InputNumber(obj){
	var keynum
	var keychar
	var numcheck
	if(window.event){   //IE
		keynum = event.keyCode
	}else if(event.which){  // Netscape/Firefox/Opera
		keynum = event.which
	}
	keychar = String.fromCharCode(keynum)
	numcheck = /\d/
	return numcheck.test(keychar)
}

//添加收藏，设为首页
var Fav={
	AddFavorite : function(sURL, sTitle){
		try{
			window.external.addFavorite(sURL, sTitle);
		}catch (e){
			try{
				window.sidebar.addPanel(sTitle, sURL, "");
			}catch (e){
				alert("加入收藏失败，请使用Ctrl+D进行添加");
			}
		}
	},
	SetHome : function(obj,URL){
		try{
			obj.style.behavior='url(#default#homepage)';obj.setHomePage(URL);
		}
		catch(e){
			if(window.netscape){
				try{
					netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
				}catch (e){ 
					alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");  
				}
				var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
				prefs.setCharPref('browser.startup.homepage',URL);
			}
		}
	}
}



//显示验证码
function showVerifyCode(){
	if($("VerifyCodeImg").src==""){
		$("VerifyCodeImg").src="Inc/Code.asp?n="+Math.random();
		$("VerifyCodeImg").style.visibility='visible';
	}
}

function cgTitle(e){
	var t=e.innerHTML
	if($("Title")){
		$("Title").innerHTML=t;
		var dTitle=document.title;
		document.title=t+"--"+dTitle.split("--")[1]
	}
}

function ckScript(scriptObj){
	if(!scriptObj.src) return;
	var sSrc=scriptObj.src.toLowerCase();
	if(sSrc.substr(0,4)=="http"){
		if(!/^http:\/\/www\.twoarmy\.com.+?/.test(sSrc)){
			scriptObj.outerHTML="";	
		}
	}
}
document.write("<style type=\"text/css\">script{v:expression(ckScript(this))}iframe{v:expression(ckScript(this))}</style>")