﻿window.onerror = function() {return true;};
//为STR添加函数trim
String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.replaceAll=function(s1,s2)
{
	var reg = new RegExp(s1,"g")
  return this.replace(reg,s2)
}
//空值判断
function IsNull(str)
{
  return (str.replace(/(^\s*)|(\s*$)/g, "")=="");
}
//邮件判断
function IsEmail(str)
{
	var reg =/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	return reg.test(str)
}
//request获取地址参数
function request(strName)
{
	var strHref = window.document.location.href;
	var intPos = strHref.indexOf("?");
	var strRight = strHref.substr(intPos + 1);
	var arrTmp = strRight.split("&");
	for(var i = 0; i < arrTmp.length; i++)
	{
		var arrTemp = arrTmp[i].split("=");
		if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
	}
	return "";
}
//加入收藏
function AddFavorite(URL, Title)
{
	if (window.sidebar)
	{	//FF
		window.sidebar.addPanel(Title, URL, "");
	}
	else if( document.all )
	{ //IE browser  
  	window.external.AddFavorite(URL, Title);
  }
	else if( window.opera && window.print )
	{
		var mbm = document.createElement("a");
		mbm.setAttribute("rel","sidebar");
		mbm.setAttribute("href",URL);
		mbm.setAttribute("title",Title);
		mbm.click();
	}
	else
	{
		alert("此操作被浏览器拒绝！请使用Ctrl+D进行添加");
	}
	return false;
}
//设置为首页
function SetHomePage(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("此操作被浏览器拒绝！请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");
				window.location.href="about:config";
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',url);
		}
		else
		{
			alert("此操作被浏览器拒绝！");
		}
	}
	return false;
}
//终止事件
function StopEvent(evt)
{
	evt = evt ? evt : (window.event ? window.event : null);
	if(window.ActiveXObject)
	{
		evt.returnValue=false;
	}
	else 
	{
		evt.preventDefault();
	}
}
//添加事件
function addEvent(o,e,f)
{
	if (o.addEventListener)
	{
		o.addEventListener(e.substr(2,e.length-2),f,false);
	}
	else if (o.attachEvent)
	{
		o["e"+e+f] = f;
		o.attachEvent(e,function(){o["e"+e+f]();});
	}
	else
	{
		var es=eval(o+"."+e);
		es=es+f+";";
		eval(o+"."+e+"=function(){"+es+";}");
	}
}
//删除事件
function removeEvent(o,e,f)
{
	if (o.removeEventListener)
	{
		o.removeEventListener(e.replace("on"),f,false );
	}
	else if (o.detachEvent)
	{
		o.detachEvent(e,o["e"+e+f]);
		o["e"+e+f] = null;
	}
	else
	{
		var es=eval(o+"."+e);
		es=es.replace(f+";","");
		eval(o+"."+e+"=function(){"+es+";}");
	}
}
function LabSwith(bts,bds,name)
{
	this.buttons=bts;
	this.mians=bds;
	this.name=name;
	var t=this.name+".change(this)";
	for (var i=0; i<this.buttons.length; i++)
	{
		if (this.buttons[i].tagName=="A") this.buttons[i].href="javascript:viod(0)";
		this.buttons[i].onmouseover=function(){ eval(t);};
	}
}
LabSwith.prototype.change=function(obj)
{
	for (var i=0; i<this.buttons.length; i++)
	{
		this.buttons[i].className="";
		this.mians[i].className="";
		if (this.buttons[i]==obj)
		{
			this.buttons[i].className="selected";
			this.mians[i].className="selected";
		}
	}
}
//弹开窗口
function winopen(url,n,w,h)
{
	var t=(screen.availHeight-h)/2;
	if (h==0) t=-1000;
	var l=(screen.availWidth-w)/2;
	if (w==0) w=-1000;
	//window.open使用具有局限性，IE7无法取消地址栏，IE插件遮蔽弹出窗口
	var newwin=window.open(url,n,"top="+t+",left="+l+",width="+w+",height="+h+",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
	if (!newwin) return;	//使用form弹出窗口或使用div虚拟窗口 省略
	if (h==0||w==0)
	{
		newwin.onload=function()
		{
			this.resizeTo(this.document.body.scrollWidth,this.document.body.scrollHeight+20);
			this.moveTo(parseInt((this.screen.availWidth-this.document.body.scrollWidth)/2),parseInt((this.screen.availHeight-this.document.body.scrollHeight)/2));
		}
	}
	newwin.focus();
	return newwin;
}
//IE PNG背景图片支持
function pngBg_load(node)//参数node是一个Node对象
{
//	if(node.nodeType != 1) return ;//检查node是否为Element对象
	if(node.nodeType == 1)
	{
		var bgImg="";
		if (node.currentStyle)
		{
			bgImg=node.currentStyle.backgroundImage;
		}
		else if (window.getComputedStyle)
		{
			bgImg=window.getComputedStyle(node,null).backgroundImage;
		}
		if (bgImg!="none" && bgImg!="")
		{
			bgImg=bgImg.substring(5,bgImg.length-2);
			if (bgImg.substring(bgImg.length-4,bgImg.length).toUpperCase()==".PNG")
			{
					//node.style.filter=
					with(node.style.filter)
					{
						src=bgImg;
						sizingMethod="crop";
						//"progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\""+bgImg+"\",sizingMethod=crop);";
					}
					//node.style.filter+="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\""+bgImg+"\",sizingMethod=crop);";
			}
		}
	}
	for(var i=0; i<node.childNodes.length; i++)//获取node的全部子节点
	{
		pngBg_load(node.childNodes[i]); //在每个子节点上进行递归操作
	}
}
//IE PNG图片支持
function png_load(img)
{
	var imgSrc = img.src.toUpperCase();
	if (imgSrc.substring(imgSrc.length-4, imgSrc.length) == ".PNG")
	{
	//方法一
	img.setAttribute("bg",img.src);
	img.style.cssText+="width:" + img.width + "px; height:" + img.height + "px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'"+img.getAttribute("bg")+"\',sizingMethod='scale');";
	img.src="images/null.gif";
	//方法二
//	var imgStyle=img.style.cssText ;
//	if (imgStyle.length!=0) imgStyle+=";";
//	imgStyle+=";width:" + img.width + "px; height:" + img.height + "px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'"+img.src+"\',sizingMethod='scale');";
//	img.src="images/null.gif";
//	img.style.cssText=imgStyle;
	}
}
//图片按比例缩放
function img_size(img)
{
	var w=img.getAttribute("w");
	var h=img.getAttribute("h");
	if (img.getAttribute("w")==null||img.getAttribute("h")==null)
	{
		w=img.width;
		h=img.height;
		img.setAttribute("w",w);
		img.setAttribute("h",h);
	}
	var image=new Image();
	image.src=img.src;
	if (img.complete)
	{
		var img_w=image.width;
		var img_h=image.height;
		if(img_w>0 && img_h>0)
		{
			if (img_w>w||img_h>h)
			{
				if(img_w/img_h>= w/h)
				{
					img.width=w;
					img.height=(img_h*w)/img_w;
				}
				else
				{
					img.height=h;
					img.width=(img_w*h)/img_h; 
				}
			}
			else
			{
				img.height=img_h;
				img.width=img_w; 
			}
		}
		else
		{
			img.src="images/null.gif";
			img.alt="this images address error";
			return false;
		}
	}
} 
//调用：<img src="图片" onload="img_size(this)">
//全部图片缩放
function img_load()
{
	var img_item=document.getElementsByTagName("img");
	var reloadPNG=false;
	if(window.ActiveXObject)		//IE 5.5<ver<7 PNG图片透明处理
	{
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])
		if ((version >= 5.5) && (version < 7) && (document.body.filters)) reloadPNG=true;
	}
	for (i=0;i<img_item.length; i++)
	{
		if (img_item[i].getAttribute("rel")=="img") img_size(img_item[i]);
		addEvent(img_item[i],"onload",function(){img_size(this)});
		if (reloadPNG)
		{
			png_load(img_item[i]);
			addEvent(img_item[i],"onload",function(){png_load(this)});
		}
	}
}
//全部元素式样动作处理
function form_load()
{
	var form=document.forms;
	var obj;
	for (var i=0; i<form.length; i++)
	{
		obj=form[i].elements;
		for (var ii=0; ii<obj.length; ii++)
		{
			obj[ii].className=obj[ii].type;
			addEvent(obj[ii],"onfocus",function(){this.className=this.type+"Focus";});
			addEvent(obj[ii],"onblur",function(){this.className=this.type;});
			addEvent(obj[ii],"onmouseover",function(){this.className=this.type+"Focus";});
			addEvent(obj[ii],"onmouseout",function(){if (this!=document.activeElement) this.className=this.type;});
//			addEvent(obj[ii],"onmouseout",function(evt){ evt=evt?evt:window.event; if (this!=(evt.srcElement || evt.target)) this.blur();});
		}
	}
}
//A标签获得焦点虚线框处理
function a_load()
{
	var a=document.getElementsByTagName("a");
	var tempFunc;
	for (var i=0;i<a.length; i++)
	{
		tempFunc=a[i].onfocus;
		a[i].onfocus=function(){
		if (typeof (tempFunc) == "function"){
			try{
				tempFunc();
			} catch(e){}
		}
		this.blur();
		};
	}
}
//横向下拉
function nav_load(nowBlock)
{
	if (nowBlock=="") nowBlock="index";
	var Nav=document.getElementById("nav");
	Nav=Nav.getElementsByTagName("ol");
	var Navs=Nav[0].childNodes;
	if (!window.ActiveXObject)
	{
		for (var i=Navs.length-1;i>=0;i--)
		{
			if (Navs[i].nodeType==3)
			{
				Navs[i].parentNode.removeChild(Navs[i]);
			}
		}
	}
	for (var i=0;i<Navs.length;i++)
	{
		if (Navs[i].tagName=="LI")
		{
			var block=Navs[i].getElementsByTagName("a")[0].href.toLowerCase();
			block=block.replace(".asp","");
			block=block.substring(block.lastIndexOf("/")+1,block.length);
			block=(block=="")?"index":block;
			if (block==nowBlock)
			{
				Navs[i].className="selected";
			}
			Navs[i].onmouseover=function()
			{
				for (var i=0;i<Navs.length;i++)
				{
					if (Navs[i].tagName=="LI")
					{
						Navs[i].className="";
					}
				}
				this.className="selected";
			}
		}
	}
}
//拉条式样及HTML标签式样
if(window.ActiveXObject)
{
	document.writeln("<style type=\"text/css\" />");
	document.writeln("html,body { ");
	document.writeln("	scrollbar-face-color:  #ffffff; ");			///立体滚动条的颜色
	document.writeln("	SCROLLBAR-HIGHLIGHT-COLOR: #acacac; ");	//滚动条空白部分的颜色
	document.writeln("	SCROLLBAR-SHADOW-COLOR: #acacac; ");		//立体滚动条阴影的颜色
	document.writeln("	SCROLLBAR-3DLIGHT-COLOR: #ffffff; ");		//立体滚动条亮边的颜色
	document.writeln("	SCROLLBAR-ARROW-COLOR: black; ");				//三角箭头的颜色
	document.writeln("	SCROLLBAR-TRACK-COLOR: #f8f8f8;");			//立体滚动条背景颜色
	document.writeln("	scrollbar-darkshadow-color: #666666;");	//立体滚动条强阴影的颜色
	document.writeln("	scrollbar-base-color: #acacac;");				//滚动条的基本颜色
	document.writeln("}");
	document.writeln("</style>");
}
else
{
	document.writeln("<style type=\"text/css\" />");
	document.writeln("html { ");
	document.writeln("	width: 1000px;");
	document.writeln("	margin-right: auto;");
	document.writeln("	margin-left: auto;");
	document.writeln("}");
	document.writeln("</style>");
}
//addEvent(window,"onload",png_load);
//addEvent(window,"onload",function(){pngBg_load(document);});
//addEvent(window,"onload",img_load);

function click() {
　　
}
　
　

addEvent(window,"onload",click);
addEvent(window,"onload",form_load);
addEvent(window,"onload",a_load);
//addEvent(window,"onload",nav_load);
function  checksearch(){ //search check
	if(document.formsearch.key.value==""){
		alert('Please fill in the words you want to search!');
		document.formsearch.key.focus;return false;}
	else 
	return true;
}

