var headWidth = "152";
var headHeight = "152";
var basepath = "";
var firefox = navigator.userAgent.indexOf("Firefox") > 0;
var ie = (document.all && !window.opera);
var isSafari = navigator.userAgent.indexOf("Safari") != -1;
var isFireFox = navigator.userAgent.indexOf("Firefox") != -1;
var ie6 = ie && navigator.userAgent.indexOf("MSIE 6") != -1;
var isMac = navigator.userAgent.indexOf("Mac OS X") != -1;
var isMacFireFox = isFireFox && isMac;
function isNull(name) {
	return name == null || typeof (name) == "undefined";
}
function checkNum(obj)
{
	
	if(obj.value.match(/[^\d]+/)!==null)
	{
		try{
		if(obj.value.length<=1)
		{
			obj.value="";
			return;
		}
		obj.value = obj.value.substr(0,obj.value.length-1);
		}catch(e){return;}
		checkNum(obj);
	}
}
function checkFloat(obj,decimal){
	if(obj.value.length==0)return;
	if(!isNaN(parseFloat(obj.value))){
		obj.value=parseFloat(obj.value);
	}else{
		obj.value = obj.value.substr(0,obj.value.length-1);
		checkFloat(obj,decimal);
	}
	if(!isNull(decimal)){
		if(obj.value.indexOf(".")!=-1){
			obj.value=obj.value.substr(0,obj.value.indexOf(".")+1+decimal);
		}
	}
}
function checkLong(obj, length, name) {
	name = typeof (name) == "undefined" ? "" : name;
	if (obj.value.gbkLength() > length) {
		try {
			obj.value = obj.value.substr(0, length);
		}
		catch (e) {
			return;
		}
		alert(name + "\u5b57\u6570\u4e0d\u80fd\u5927\u4e8e" + length + "\u4e2a\u5b57\u7b26");
		return false;
	}
	return true;
}
function checkShort(obj, length, name) {
	name = typeof (name) == "undefined" ? "" : name;
	if (obj.value.gbkLength() < length) {
		alert(name + "\u5b57\u6570\u4e0d\u80fd\u5c11\u4e8e" + length + "\u4e2a\u5b57\u7b26");
		return false;
	}
	return true;
}
function checkUploadImage(obj) {
	if (obj.value.lastIndexOf(".") == -1) {
		alert("\u9519\u8bef\u7684\u6587\u4ef6");
		return false;
	}
	var fix = obj.value.substring(obj.value.lastIndexOf(".") + 1);
	if ("jpgJPGgifGIFpngPng".indexOf(fix) == -1) {
		alert("\u9519\u8bef\u7684\u56fe\u7247\u683c\u5f0f,\u53ea\u652f\u6301JPG\u3001PNG\u3001GIF\u56fe\u7247\u683c\u5f0f\u3002");
	obj.value="";
	obj.focus();
		return false;
	}
	return true;
}


function $(element) {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == "string") {
			element = document.getElementById(element);
		}
		if (arguments.length == 1) {
			return element;
		}
		elements.push(element);
	}
	return elements;
}
String.prototype.Trim = function () {
	return this.replace(/(^\s*)|(\s*$)/g, "");
};
function getImage(id, src, maxWidth, className, imgId,imgName) {
	var img = new Image();
	img.style.display="none";
	img.src = src;
	img.id = imgId;
	img.className = className;
	if(imgName!=null)
	{
		img.alt = imgName;
	}
	if (!isNaN(parseInt(img.width))) {
	if( img.width > maxWidth){
		var scale = maxWidth / img.width;
		img.width = scale*img.width;
		if(ie)
		img.height = scale*img.height;
		}
		img.style.display="block";
	}
	img["onload"] = function () {
		if (maxWidth != null && this.width > maxWidth) {
			var scale = maxWidth / this.width;
			this.width = scale*this.width;
			if(ie)
			this.height = scale*this.height;
		}
			img.style.display="block";
	};
	$(id).appendChild(img);
}
function windowOnload(fn) {
	if (document.addEventListener) {
		document.addEventListener("DOMContentLoaded", fn, null);
		return;
	}
	if (document.readyState != "complete") {
		window.setTimeout(function () {
			windowOnload(fn);
		}, 50);
		return;
	}
	window.setTimeout(fn, 1);
}
String.prototype.gbkLength = function () {
	var j = 0;
	for (var i = 0; i < this.length; i++) {
		if (this.charCodeAt(i) > 128) {
			j++;
			j++;
		} else {
			j++;
		}
	}
	return j;
};
function chkNull(id) {
	if ($(id) == null) {
		return true;
	}
	var str = $(id).value;
	if (str === null || str === "") {
		return false;
	}
	return true;
}
function chkDup(id1, id2) {
	if ($(id1) == null) {
		return false;
	}
	if ($(id2) == null) {
		return false;
	}
	var str = $(id1).value;
	var dupStr = $(id2).value;
	if (str.length !== 0 && str.length == dupStr.length && str.indexOf(dupStr) === 0) {
		return true;
	}
	return false;
}
function chkEmail(id) {
	var str = $(id).value;
	var matchArray = str.match(/^(.+)@(.+)\.(.+)$/);
	if (matchArray === null) {
		return false;
	}
	return true;
}
function chkNum(value) {
	var reNum = /^\d+$/;
	return !!reNum.exec(value);
}
function chkDate(id) {
	var str = $(id).value;
	var matchArray = str.match(/\d{4}-\d{2}-\d{2}/);
	if (matchArray === null) {
		return false;
	}
	return true;
}
function chkLength(id, len) {
	var str = $(id).value;
	if (str !== null && str.length > len) {
		return false;
	}
	return true;
}
 
function copy_clip(meintext) {
	if (window.clipboardData) {
   // the IE-manier
		window.clipboardData.setData("Text", meintext);
   // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
   // het is mij echter onbekend vanaf welke versie dit precies werkt:
	} else {
		if (window.netscape) { 
   // dit is belangrijk maar staat nergens duidelijk vermeld:
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch (e) {
				alert("\u6b64\u64cd\u4f5c\u88ab\u6d4f\u89c8\u5668\u62d2\u7edd\uff01\n\u8bf7\u5728\u6d4f\u89c8\u5668\u5730\u5740\u680f\u8f93\u5165\u201cabout:config\u201d\u5e76\u56de\u8f66\n\u7136\u540e\u5c06[signed.applets.codebase_principal_support]\u8bbe\u7f6e\u4e3a'true'");
			}   

   // maak een interface naar het clipboard
			var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard);
			if (!clip) {
				return;
			}
   // maak een transferable
			var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
			if (!trans) {
				return;
			}
   // specificeer wat voor soort data we op willen halen; text in dit geval
			trans.addDataFlavor("text/unicode");
   // om de data uit de transferable te halen hebben we 2 nieuwe objecten nodig   om het in op te slaan
			var str = new Object();
			var len = new Object();
			var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
			var copytext = meintext;
			str.data = copytext;
			trans.setTransferData("text/unicode", str, copytext.length * 2);
			var clipid = Components.interfaces.nsIClipboard;
			if (!clip) {
				return false;
			}
			clip.setData(trans, null, clipid.kGlobalClipboard);
		}
	}
	alert("\u4f60\u5df2\u7ecf\u628a\u4ee5\u4e0b\u5185\u5bb9\u590d\u5236\u5230\u4f60\u7684\u526a\u8d34\u677f:\n" + meintext);
	return false;
}
var bodyProperty = function () {
	var bodyST, bodyCH, bodyCW, bodySL;
	if (window.pageYOffset) {
		bodyST = window.pageYOffset;
	} else {
		if (document.documentElement && document.documentElement.scrollTop) {
			bodyST = document.documentElement.scrollTop;
		} else {
			if (document.body) {
				bodyST = document.body.scrollTop;
			}
		}
	}
	if (window.innerHeight) {
		bodyCH = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			bodyCH = document.documentElement.clientHeight;
		} else {
			if (document.body) {
				bodyCH = document.body.clientHeight;
			}
		}
	}
	var w = window, d = document, dd = d.documentElement;
	if (dd && dd.clientWidth) {
		bodyCW = dd.clientWidth;
	} else {
		if (w.innerWidth) {
			bodyCW = w.innerWidth;
		} else {
			if (d.body) {
				bodyCW = d.body.clientWidth;
			}
		}
	}
	if (w.pageXOffset) {
		bodySL = w.pageXOffset;
	} else {
		if (dd && dd.scrollLeft) {
			bodySL = dd.scrollLeft;
		} else {
			if (d.body) {
				bodySL = d.body.scrollLeft;
			}
		}
	}
	return {"scrollTop":bodyST, "scrollLeft":bodySL, "clientWidth":bodyCW, "clientHeight":bodyCH};
};
function showObjList(obj) {
	document.getElementById(obj).style.display = "block";
}
function closeObjList(obj) {
	document.getElementById(obj).style.display = "none";
}
var WadMark = {show:function () {
	var mark = this.get();
	body = bodyProperty();
	mark.style.display = "block";
	mark.style.width = (body.scrollLeft + document.body.offsetWidth) + "px";
	mark.style.height = (body.scrollTop + document.body.offsetHeight) + "px";
}, close:function () {
	var mark = this.get();
	mark.style.display = "none";
}, get:function () {
	var mark = document.getElementById("div_mark");
	if (mark == null) {
		mark = document.createElement("div");
		mark.id = "div_mark";
		mark.className = "wad_mark";
		document.body.appendChild(mark);
	}
	return mark;
}};
var POPmsg = {ids:{state:"msg_pop_state", btnDivId:"btnDiv", pop:"pop_msg", title:"pop_msg_title", content:"pop_msg_content", links:"pop_msg_links"}, show:function () {
	POPmsg.run();
	window["onresize"] = POPmsg.run;
	window["onscroll"] = POPmsg.run;
}, run:function () {
	var pop = POPmsg.get();
	position(pop);
	WadMark.show();
}, set:function (title, content, links, state) {
	this.setTitle(title);
	this.setContent(content);
	this.setLinks(links);
	if (state != null) {
		if (state == "error") {
			this.showState.error();
		} else {
			if (state == "alarm") {
				this.showState.alarm();
			} else {
				if (state == "success") {
					this.showState.success();
				}
			}
		}
	}
}, close:function () {
	var pop = this.get();
	pop.style.display = "none";
	window["onresize"] = null;
	window["onscroll"] = null;
	WadMark.close();
}, setTitle:function (title) {
	var pop = this.get();
}, setContent:function (content) {
	var pop = this.get();
	$(this.ids.content).innerHTML = content;
}, setLinks:function (links) {
	var pop = this.get();
	$(this.ids.links).innerHTML = links;
}, setBtns:function (btns) {
	var pop = this.get();
	$(this.ids.btnDivId).innerHTML = btns;
}, get:function () {
	var pop = $(this.ids.pop);
	if (pop == null) {
		pop = document.createElement("div");
		pop.id = this.ids.pop;
		pop.className = "pop_msg";
		var topImg = document.createElement("img");
		topImg.src=basepath+"/images/bg/pop_msg_top.gif";
		pop.appendChild(topImg);
		var content = document.createElement("div");
		content.className="content";
		content.id = this.ids.content;
		
		var state = document.createElement("div");
		state.id = this.ids.state;
		state.style.float="left";
		pop.appendChild(state);
		
		pop.appendChild(content);
		
		var links = document.createElement("div");
		links.className = "content";
		links.id = this.ids.links;
		pop.appendChild(links);
		document.body.appendChild(pop);
		this.initBtn();
		var bottomImg = document.createElement("img");
		bottomImg.src=basepath+"/images/bg/pop_msg_bottom.gif";
		pop.appendChild(bottomImg);
	}
	return pop;
}, initBtn:function () {
	var pop =this.get();
	var btnClose = $(this.ids.btnDivId);
	if (btnClose == null) {
		btnClose =document.createElement("div");
		btnClose.className = "pop_msg_btn";
		btnClose.id = this.ids.btnDivId;
		pop.appendChild(btnClose);
	}
	btnClose.innerHTML = "<input type='button' value='关闭' onclick='POPmsg.close();return false;' />";
}, showProcess:function () {
	return " onclick='POPmsg.close();Process.show();' ";
}, showState:{error:function () {
	//POPmsg.get();
	//$(POPmsg.ids.state).innerHTML = "<img src='" + basepath + "/images/icon/pop_error.gif' alt='\u51fa\u9519\u4e86' />";
}, alarm:function () {
	//POPmsg.get();
	//$(POPmsg.ids.state).innerHTML = "<img src='" + basepath + "/images/icon/pop_alarm.gif' alt='\u8b66\u544a' />";
}, success:function () {
	//POPmsg.get();
	//$(POPmsg.ids.state).innerHTML = "<img src='" + basepath + "/images/icon/pop_success.gif' alt='\u64cd\u4f5c\u6210\u529f' />";
}, clear:function () {
	POPmsg.get();
	$(POPmsg.ids.state).innerHTML = "";
}}, confirmDelete:function (obj) {
	content = "你确定要删除?";
	POPmsg.setContent(content);
	
	var btns = "<input id='popMsgCheckBtn' type='button' value='是' onclick='document.location=\"";
	try{
	btns +=  obj.href 
	}catch(e){
	}
	btns +=  "\";POPmsg.close();Process.show();'/>";
	btns += "<input type='button' value='否' onclick='POPmsg.close();'/>";
	this.setBtns(btns);
	POPmsg.show();
	return false;
}, unLogin:function () {
	POPmsg.setTitle("\u8fd8\u6ca1\u767b\u5f55");
	POPmsg.showState.error();
	POPmsg.setContent("\u4f60\u8fd8\u6ca1\u6709\u6ce8\u518c\u6216\u767b\u5f55\uff0c\u8bf7\u70b9\u51fb\u4e0b\u9762\u7684\u94fe\u63a5\u767b\u5f55\u6216\u6ce8\u518c!");
	POPmsg.setLinks("<a " + POPmsg.showProcess() + " href='" + basepath + "/unlogin.jhtml'>\u6211\u8981\u767b\u5f55</a><a  " + POPmsg.showProcess() + "  href='" + basepath + "/register.jhtml'>\u6211\u8981\u6ce8\u518c</a>");
}, error:function () {
	POPmsg.setTitle("出错了!");
	POPmsg.showState.error();
	POPmsg.setContent("对不起!系统出现了错误!");
	POPmsg.show();
}};
var Process = {show:function () {
	this.run();
	window["onresize"] = this.run;
	window["onscroll"] = this.run;
}, run:function () {
	var process = Process.get();
	position(process);
	WadMark.show();
}, close:function () {
	window["onresize"] = null;
	window["onscroll"] = null;
	this.get().style.display = "none";
	WadMark.close();
}, setContent:function (content) {
	this.get();
	document.getElementById("wad_process_content").innerHTML = content;
}, get:function () {
	var process = $("wad_process");
	if (process == null) {
		process = document.createElement("div");
		process.id = "wad_process";
		process.innerHTML = "\t<img src=\"" + basepath + "/images/icon/processing.gif\" /><span><label id=\"wad_process_content\">\u901a\u8baf\u4e2d\uff0c\u8bf7\u7a0d\u7b49</label>...</span>";
		document.body.appendChild(process);
	}
	return process;
}};
function position(object) {
	object = $(object);
	if (object == null) {
		return;
	}
	var body = bodyProperty();
	object.style.display = "block";
	object.style.left = (body.scrollLeft + body.clientWidth / 2 - object.offsetWidth / 2) + "px";
	object.style.top = (body.scrollTop + body.clientHeight / 2 - object.offsetHeight / 2) + "px";
}
String.prototype.clear = function () {
	var content = this;
	for (var i = 0; i < RegExps.length; i++) {
		content = content.replace(new RegExp(RegExps[i], "gm"), "$1");
	}
	return content;
};
var RegExps = new Array("class=[^\\s>]*([\\S>])", "on[a-zA-Z]+=[^\\s>]*([\\S>])", "<script[^>]*>.*</script>(\\s??)", "<style[^>]*>.*</style>(\\s??)", "<!--\\{\\d*\\}-->(\\s??)");
String.prototype.cut = function (length) {
	var strLength = this.length;
	var result = this.substr(0, length);
	if (strLength > length) {
		result += "...";
	}
	return result;
};
function fGetXY(aTag) {
	var oTmp = aTag;
	var pt = new Point(0, 0);
	try {
		do {
			pt.x += oTmp.offsetLeft;
			pt.y += oTmp.offsetTop;
			oTmp = oTmp.offsetParent;
		} while (oTmp.tagName.toUpperCase() != "BODY");
	}
	catch (e) {
	}
	return pt;
}
function Point(iX, iY) {
	this.x = iX;
	this.y = iY;
}
function getLinksBox(id) {
	var box = $(id);
	if (box == null) {
		box = document.createElement("div");
		with (box.style) {
			position = "absolute";
			zIndex = "99";
			lineHeight = "150%";
			visibility = "hidden";
			border = "1px solid #999999";
			backgroundColor = "#FFF";
		}
		box.id = id;
		document.body.appendChild(box);
	}
	return box;
}
function searchBoxFocus(obj, text) {
	if (obj.value == text) {
		obj.value = "";
	}
}
function searchBoxBlur(obj, text) {
	if (obj.value == "") {
		obj.value = text;
	}
}
function searchBoxSubmit(obj, text) {
	if (obj.value == "" || obj.value == text) {
		obj.value = "";
	}
}

function showBtn(objId,boxId){
var box =$(boxId);
var obj =$(objId);
var point = fGetXY(obj);
		with (box.style) {
			display = "block";
			left = (point.x ) + "px";
			top = (point.y -box.offsetHeight) + "px";
			zIndex = "99";
			position = "absolute";
		}
		if(obj["onmouseout"]==null)
		{
			box["onmouseover"] = function(){
			showBtn(obj,this);
			};
			obj["onmouseout"] = function(){
			closeBtn(box);
			};
			box["onmouseout"] = function(){
			closeBtn(this);
			};
		}
}
function closeBtn(boxId){
var box =$(boxId);
	with (box.style) {
			display = "none";
		}
}
function check_all(obj){
var cs =  document.getElementsByName(obj);
	for(var i=0;i<cs.length;i++)
	{
		cs[i].checked = true;
	}
}
function check_no(obj){
var cs =  document.getElementsByName(obj);
	for(var i=0;i<cs.length;i++)
	{
		cs[i].checked = false;
	}
}
function check_fan(obj){
var cs =  document.getElementsByName(obj);
	for(var i=0;i<cs.length;i++)
	{
		 cs[i].checked = cs[i].checked == true ? false : true;
	}
}
var City = {
	show:function(){
	 changeCity();
	},
	close:function(){
	 changeCity();
	}
};
function changeCity(){
if(jQuery("#wad_City").is(":hidden")){
	jQuery('.topNewsBox').css({"z-index":'-1'});
	jQuery('.sresult').css({"z-index":'-1'});
}else{
	jQuery('.topNewsBox').css({"z-index":'1'});
	jQuery('.sresult').css({"z-index":'1'});
}
jQuery('#wad_City').toggle("normal");
}
var showChatFrame=function () {
	var ele = document.getElementById("im_popupWindow_chat");
	if (ele) {
		var body = bodyProperty();
		if (typeof (body) != "undefind") {
			ele.style.top = (body.scrollTop + body.clientHeight - ele.offsetHeight - 1) + "px";
			ele.style.left = (body.scrollLeft + body.clientWidth - ele.offsetWidth - 1) + "px";
			return;
		}
	}else{
		ele = document.createElement("div");
		with(ele.style)
		{
		  position= "absolute";
		  width= "190px"; 
		  height= "36px";
		  zIndex="111112";
		  background="#fff";
		  borderTop="none";
		  borderBottom="none";
		  padding="0px";		  
		}
		ele.id = "im_popupWindow_chat";
		ele.innerHTML='<iframe scrolling="no" style="padding:0;margin:0;width:190px;height:36px;border:none;" frameborder="0" marginheight="0" marginwidth="0"  src="/include/chat.jsp"></iframe>';
		document.body.appendChild(ele);
		showChatFrame();
		return;
	}
}
Date.prototype.pattern = function (fmt) {
	var o = {"M+":this.getMonth() + 1, "d+":this.getDate(), "h+":this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, "H+":this.getHours(), "m+":this.getMinutes(), "s+":this.getSeconds(), "q+":Math.floor((this.getMonth() + 3) / 3), "S":this.getMilliseconds()};
	var week = {"0":"\u65e5", "1":"\u4e00", "2":"\u4e8c", "3":"\u4e09", "4":"\u56db", "5":"\u4e94", "6":"\u516d"};
	if (/(y+)/.test(fmt)) {
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	}
	if (/(E+)/.test(fmt)) {
		fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]);
	}
	for (var k in o) {
		if (new RegExp("(" + k + ")").test(fmt)) {
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		}
	}
	return fmt;
};

function goForward(url){
document.location.href=url;
return false;
}
function changeValidateCode(img){
img = jQuery(img);
var href = img.attr("src");
href = href.split("\?")[0]+"?time="+new Date().getTime();
img.attr("src",href);
}
function getAge(iYear,iMonth,iDay){
	var now =new Date();
	var big = parseInt((now.getMonth()+1+""+now.getDate()))>=parseInt((iMonth+""+iDay));
	return (now.getYear()-1-iYear+(big ? 1 : 0));

}
function getConstellation(iYear,iMonth,iDay){
	var cons=new Array("水瓶座","双鱼座", "牡羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "魔羯座");
	var con_days=new Array(20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22);
	var month = iMonth-1;
	var day = iDay;
	if (day < con_days[month]) {month = month - 1;}
	if (month < 0) { month=11; }
	return cons[month];
}