var ajaxTimeOut = 180;

function externallinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
	}
}

window.onload = externallinks;

function changeLine(tagname,AdLine,ModLine,OverLine) {
	var a = document.getElementsByTagName(tagname);
	var j = 0;
	for (i = 0;i < a.length ;i ++ ){
		if (a[i].getAttribute('name') == 'l') {
			if (j % 2 == 0) {
				a[i].className = ModLine;
				a[i].onmouseout = function(){this.className = ModLine}
			}
			else {
				a[i].className = AdLine;
				a[i].onmouseout = function(){this.className =AdLine}
			}
			j = j + 1;
			a[i].onmouseover = function(){this.className = OverLine}
		}
		else if (a[i].getAttribute('name') == 'v') {
			a[i].className = 'classAdParticular';
		}
	}
}

function GetStrTrueLength(str) {
	return str.match(/[^\r|\n| -~]/g) == null ? str.replace(/[\r|\n]/g,"").length : str.replace(/[\r|\n]/g,"").length + str.match(/[^\r|\n| -~]/g).length ;
}

function GetUserCity(virtualRoot,tag) {
	if (document.getElementById(tag)) xmlHttpPost(false,'',virtualRoot +'/Lib/','action=getusercity',0,1,tag);
}

function GetSearchResult(e,val,a,id,s) {
	var tag = document.getElementById(id);
	var c;
	val = val.replace(/ /g,'');
	var k = e.keyCode;
	if (k != 13 && k != 16 && k != 17 && k != 27 && k != 37 && k != 38 && k != 39 && k != 40 && k != 144){
		c = function() {
			if (val != '' && val.length > 1){
				xmlHttpPost(false,'Loading...','/Lib/','action=GetSearchResult&val='+ val +'&a='+ a +'&s='+ s +'&id='+ id,0,0,id);
				if (tag.innerHTML != '') {
					if (tag.style.display == 'none' && val.replace(/ /g,'') != '') {
						showTr(id);
						tag.style.opacity = 0.85;
						tag.style.filter = 'Alpha(opacity=85)';
						tag.style.zIndex = 7777;
					}
				}
			}
			else {
				tag.style.display = 'none';
			}
			clearTimeout(c);
		}
		setTimeout(c,500);
	}
	else if (k == 27|| k == 32){
		tag.style.display = 'none';
	}
	else if (k == 13){
		tag.style.display = 'none';
		searchsubmit(s);
	}
	else if (k == 38 || k == 40) {
		if (tag.style.display != 'none' && document.getElementById('searchResultDiv')){
			var t = -1;
			var j = document.getElementById('searchResultCount').value - 1;
			for (var i=0; i <= j; i++) {
				if (document.getElementById('r_'+ i) && document.getElementById('r_'+ i).className == 'resultFocusLi') {
					document.getElementById('r_'+ i).className = 'searchResultli';
					t = i;
				}
			}
			if (k == 40) t = t + 1;
			if (k == 38) t = t - 1;
			if (t > j) t = 0;
			if (t < 0) t = j;
			if (document.getElementById('r_'+ t)) {
				document.getElementById('r_'+ t).className = 'resultFocusLi';
				document.getElementById('k').value = document.getElementById('text_'+ t).innerHTML;
			}
		}
	}
}

function GetSearchCityResult(e,id,s) {
	var tag = document.getElementById(id);
	var k = e.keyCode;
	if (k != 13 && k != 16 && k != 17 && k != 27 && k != 37 && k != 38 && k != 39 && k != 40 && k != 144){
		if (tag.style.display == 'none') {
			showTr(id);
			tag.style.opacity = 0.85;
			tag.style.filter = 'Alpha(opacity=85)';
			tag.style.zIndex = 7777;
		}
		xmlHttpPost(true,'Loading...','/Lib/','action=GetSearchCityResult&s='+ s,0,0,id);
		if (tag.innerHTML == '') tag.style.display = 'none';
	}
	else if (k == 27|| k == 32){
		tag.style.display = 'none';
	}
	else if (k == 13){
		tag.style.display = 'none';
		searchsubmit(s);
	}
	else if (k == 38 || k == 40) {
		if (tag.style.display != 'none' && document.getElementById('searchResultCityDiv') && s != '搜人才'){
			var t = -1;
			var j = document.getElementById('searchResultCityCount').value - 1;
			for (var i=0; i <= j; i++) {
				if (document.getElementById('a_'+ i) && document.getElementById('a_'+ i).className == 'resultFocusLi') {
					document.getElementById('a_'+ i).className = 'searchResultli';
					t = i;
				}
			}
			if (k == 40) t = t + 1;
			if (k == 38) t = t - 1;
			if (t > j) t = 0;
			if (t < 0) t = j;
			if (document.getElementById('a_'+ t)) {
				document.getElementById('a_'+ t).className = 'resultFocusLi';
				document.getElementById('a').value = document.getElementById('area_'+ t).innerHTML;
			}
		}
	}
}

function GetRndInfoPath() {
	var a = xmlHttpPost(false,'','/Lib/','action=GetRandomInfoPath',0,2,'');
	return a;
}

function GetBackPassWord(mail,tag) {
	if (mail.replace(/ /g,'') == ''){
		alert('请输入您在注册时填写的E-Mail地址。');
	}
	else xmlHttpPost(true,'正在发出密码找回邮件，请稍后……','/Lib/','action=GetBackPassWord&mail='+ mail,0,0,tag);
}

function GetReActivation(mail,tag) {
	if (mail.replace(/ /g,'') == ''){
		alert('请输入您在注册时填写的E-Mail地址。');
	}
	else xmlHttpPost(true,'正在发出激活码，请稍后……','/Lib/','action=GetReActivation&mail='+ mail,0,0,tag);
}

function Activation(key,mail,tag) {
	xmlHttpPost(true,'正在完成激活步骤，请稍后……','/Lib/','action=Activation&mail='+ mail +'&k='+ key,0,0,tag);
}

function checkMailCode(key,mail,tag) {
	xmlHttpPost(true,'正在完成邮箱认证步骤，请稍后……','/Lib/user/common/?action=checkMailCode','mail='+ mail +'&k='+ key,0,0,tag);
}

function GetBackActivation(key,mail,l,tag) {
	xmlHttpPost(true,'正在完成找回密码的最后步骤，请稍后……','/Lib/','action=GetBackActivation&mail='+ mail +'&l='+ l +'&k='+ key,0,0,tag);
}

function MailSubscribe(mail,k,a,tag) {
	xmlHttpPost(true,'正在完成订阅步骤，请稍后……','/Lib/','action=MailSubscribe&k='+ k +'&a='+ a +'&mail='+ mail,0,0,tag);
}

function MailUnSubscribe(mail,tag) {
	xmlHttpPost(true,'正在完成退定步骤，请稍后……','/Lib/','action=MailUnSubscribe&mail='+ mail,0,0,tag);
}

function Request(strName){
	var paraUrl = location.search;
	if(paraUrl.indexOf("?")!=-1)
	{
		var strRight = paraUrl.substr(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 "";
	}
	else{
		return "";
	}
}

function filterDoman() {
	var a = location.href.toLowerCase();
	if (a.indexOf('www.rc913.com/index.shtml') > 0) location.href = 'http://www.rc913.com/';
	else if (a.indexOf('liuxue.rc913.com/index.shtml') > 0) location.href = 'http://liuxue.rc913.com/';
	else if (a.indexOf('blog.zgz93.com/index.shtml') > 0) location.href = 'http://blog.zgz93.com/';
	else if (a.indexOf('jz.zgz93.com/index.shtml') > 0) location.href = 'http://jz.zgz93.com/';
	else if (a.indexOf('job.zgz93.com/index.shtml') > 0) location.href = 'http://job.zgz93.com/';
	else if (a.indexOf('zhishu.zgz93.com/index.shtml') > 0) location.href = 'http://zhishu.zgz93.com/';
	else if (a.indexOf('it.zgz93.com/index.shtml') > 0) location.href = 'http://it.zgz93.com/';
	else if (a.indexOf('news.zgz93.com/index.shtml') > 0) location.href = 'http://news.zgz93.com/';
	else if (a.indexOf('tie.zgz93.com/index.shtml') > 0) location.href = 'http://tie.zgz93.com/';
	else if (a.indexOf('jipin.zgz93.com/index.shtml') > 0) location.href = 'http://jipin.zgz93.com/';
	else if (a.indexOf('chongdian.zgz93.com/index.shtml') > 0) location.href = 'http://chongdian.zgz93.com/';
	else if (a.indexOf('help.zgz93.com/index.shtml') > 0) location.href = 'http://help.zgz93.com/';
}

function GetSearchResultInnerHTML() {
	var s = Request("s");
	var k = Request("k");
	var a = Request("a");
	var p = Request("p");
	var l = Request("l");
	switch (s){
	case '搜课程':
		var tag = 'r_b,resultPage,resultCount,resultTime';
		break;
	default :
		var tag = 'searchResultDiv,resultPage,resultCount,resultTime,searchResultRightDiv';
		break;
	}
	xmlHttpPost(false,'','/Lib/','action=GetSearchResultList&s='+ s +'&k='+ k +'&l='+ l +'&a='+ a +'&p='+ p,0,0,tag);
}

function GetJobParticularInnerHTML(id) {
	if (id != '') xmlHttpPost(false,'','/Lib/','action=GetJobParticularInnerHTML&id='+ id,0,0,'searchResultDiv,searchResultRightDiv');
}

function GetCompanyParticularInnerHTML(id) {
	if (id != '') xmlHttpPost(false,'','/Lib/','action=GetCompanyParticularInnerHTML&id='+ id,0,0,'searchResultDiv,searchResultRightDiv');
}

function GetUserParticularInnerHTML(id) {
	if (id != '') xmlHttpPost(false,'','/Lib/','action=GetUserParticularInnerHTML&id='+ id,0,0,'searchResultDiv,searchResultRightDiv');
}

function GetCourseParticular(id) {
	if (id != '') xmlHttpPost(false,'','/Lib/','action=GetCourseParticular&id='+ id,0,0,'CourseParticular,resultTime,adDiv,Favorited,Posted');
}

function searchsubmit(s) {
	switch (s){
	case '搜资讯':
		var a = escape(document.getElementById('k').value);
		if (a == '') location.href = 'http://www.zgz93.com/html/zxpd/';
		else top.location.href='http://www.zgz93.com/Search.shtml?page=1&key='+ a;
		break;
	case '搜课程':
		var l = Request("l");
		var a = escape(document.getElementById('k').value);
		if (a == '') location.href = 'http://www.rc913.com/';
		else {
			if (l == '') l = 1;
			top.location.href='http://www.rc913.com/CourseSearch.shtml?s='+ escape(s) +'&k='+ escape(document.getElementById('k').value) +'&l='+ l +'&a='+ escape(document.getElementById('a').value);
		}
		break;
	default :
		var l = Request("l");
		if (l == '') l = 1;
		top.location.href='http://www.zgz93.com/List.shtml?s='+ escape(s) +'&k='+ escape(document.getElementById('k').value) +'&l='+ l +'&a='+ escape(document.getElementById('a').value);
		break;
	}
}

function changeResultClass(total,num) {
	for (var i = 0; i <= total ;i ++ )
	{
		if (i == num)
		{
			document.getElementById('r_'+ i).className = 'resultFocusLi';
			document.getElementById('k').value = document.getElementById('text_'+ i).innerHTML;
		}
		else
		{
			document.getElementById('r_'+ i).className = 'searchResultli';
		}
	}
}

function changeResultCityClass(total,num) {
	for (var i = 0; i <= total ;i ++ )
	{
		if (i == num)
		{
			document.getElementById('a_'+ i).className = 'resultFocusLi';
			document.getElementById('a').value = document.getElementById('area_'+ i).innerHTML;
		}
		else
		{
			document.getElementById('a_'+ i).className = 'searchResultli';
		}
	}
}

function clearChangeResultClass(num) {
	document.getElementById('r_'+ num).className = 'searchResultli';
}

function clearChangeResultCityClass(num) {
	document.getElementById('a_'+ num).className = 'searchResultli';
}

function help(e,virtualRoot,id) {
	var coll = document.getElementsByTagName('div')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).className == 'selfLink'){
				coll.item(i).style.display = 'none';
			}
		}
	}
	if (!document.getElementById(id)) {
		createDiv(e,id,'selfLink');
		document.getElementById(id).style.opacity = 0.90;
		document.getElementById(id).style.filter = 'Alpha(opacity=90)';
		document.getElementById(id).style.display = '';
		xmlHttpPost(true,'',virtualRoot +'/Lib/','action=help&id='+ id,0,0,id);
	}
	else {
		document.getElementById(id).style.display = '';
		document.getElementById(id).style.left = returnXY(e,'x') +'px';
		document.getElementById(id).style.top = (returnXY(e,'y') + 6) +'px';
	}
}

function closehelp(tag) {
	if (document.getElementById(tag)) document.getElementById(tag).style.display = 'none';
}

function login() {
	var c;clearTimeout(c);
	var FloatForm="";var ufo;
	if(arguments[0]!=undefined)	{FloatForm		= arguments[0];ufo=document.getElementById(FloatForm);}
	if (checkUserName() && checkPasswords()){
		var d = document.domain;
		var u = document.getElementById('UserName').value;
		var p = document.getElementById('UserPwd').value;
		var s = 0;
		if (document.getElementById('save').checked) s = 1;
		var t = getUserType();
		var url = location.href.toLowerCase().split('login.shtml?url=');
		var refererUrl = '';
		for (var i = 1;i < url.length ;i ++ ){
			refererUrl += url[i];
		}

		if(FloatForm=='')createFullDiv('FullScreenContDiv');
		if(!document.getElementById('passportWaitDiv')){
			var cDiv = document.createElement("div");
			if(FloatForm==''){
				document.body.appendChild(cDiv);
				cDiv.className = 'passportWaitDiv';
				cDiv.style.left = document.documentElement.scrollWidth / 2 - 180 +'px';}
			else{
				ufo.appendChild(cDiv);
				cDiv.className = 'passportWaitDivF';
				ufo.style.display='block';
				}
			cDiv.id = 'passportWaitDiv';
		}else{
			if(FloatForm!='')ufo.style.display='block';
			}
		document.getElementById('passportWaitDiv').style.display = 'block';
		document.getElementById('passportWaitDiv').innerHTML = '<img src="/Lib/Images/loading/loading1.gif" alt="" class="picMiddle" />正在登录海都人才通行证，请稍后……';
		var cElement
		try{
       		 cElement = document.createElement('<iframe name="passportFrame1" id="passportFrame1"></iframe>');
    	}
		catch(e){
			cElement = document.createElement('iframe');
			cElement.name = 'passportFrame1';
			cElement.id = 'passportFrame1';
   		 }
		if(FloatForm==''){document.body.appendChild(cElement);}else{ufo.appendChild(cElement);}

		cElement.id = 'passportFrame1';
		cElement.style.display = 'none';
		if (d.indexOf('zgz93.com') >= 0) {
		//	alert("登录成功");
			cElement.src = 'http://www.rc913.com/Lib/?action=login&u='+ u +'&psw='+ p +'&s='+ s +'&t='+ t;

		}
		else if (d.indexOf('rc913.com') >= 0) {
			cElement.src = 'http://www.zgz93.com/Lib/?action=login&u='+ u +'&psw='+ p +'&s='+ s +'&t='+ t;
		}
		//passportFrame1.window.location.reload();
		//window.open(document.all.passportFrame1.src,'passportFrame1','');
		c = function(){loginSubmit(u,p,s,t,refererUrl,FloatForm)}
		setTimeout(c,1000);
	}
	else document.getElementById('UserName').focus();
}

function logout() {
	var d = document.domain;
	createFullDiv('FullScreenContDiv');
	var cDiv = document.createElement("div");
	document.body.appendChild(cDiv);
	cDiv.id = 'passportLogoutDiv';
	cDiv.className = 'passportWaitDiv';
	cDiv.style.left = document.documentElement.scrollWidth / 2 - 180 +'px';
	cDiv.innerHTML = '<img src="/Lib/Images/loading/loading1.gif" alt="" class="picMiddle" />正在注销您的账号，请稍后……';
	var cElement = document.createElement("iframe");
	document.body.appendChild(cElement);
	cElement.id = 'passportLogoutFrame';
	cElement.style.display = 'none';
	if (d.indexOf('zgz93.com') >= 0) {
		cElement.src = 'http://www.rc913.com/Lib/?action=logout';
	}
	else if (d.indexOf('rc913.com') >= 0) {
		cElement.src = 'http://www.zgz93.com/Lib/?action=logout';
	}
	var c = function(){
		xmlHttpPost(false,'','/Lib/','action=logout',0,0,'');
		location.reload();
	}
	setTimeout(c,3000);
}

function GetLoginUrl() {
	var a = location.href;
	var b = a.split('?url=');
	location.href='/Login.shtml?url='+ b[b.length - 1];
}

function loginSubmit(usn,psw,save,utype,url,FloatForm) {
	var d;clearTimeout(d);
	var a = xmlHttpPost(false,'','/Lib/','action=login&u='+ usn +'&psw='+ psw +'&s='+ save +'&t='+ utype,0,2,'');
	var b = '';
	if(a!='1'&&a!='0'){//err for fail login
		if (document.getElementById('FullScreenDiv')) document.getElementById('FullScreenDiv').style.display = 'none';
		if (document.getElementById('FullScreenContDiv')) document.getElementById('FullScreenContDiv').style.display = 'none';
		if (document.getElementById('passportWaitDiv')) document.getElementById('passportWaitDiv').style.display = 'none';
		if (document.getElementById(FloatForm)) document.getElementById(FloatForm).style.display = 'none';
		}
	switch(a){
		case '0':
			if (url == '' || url.indexOf('/Help/Index.shtml?s=1,2') != -1 || url.indexOf('undefined') != -1 || url.indexOf('UserReg.shtml') != -1 || url.indexOf('404.shtml') != -1 || url.indexOf('Login.shtml') != -1) b = '/User/';
			else b = url;
			if (document.getElementById('passportWaitDiv')){
				if(FloatForm==''){
					document.getElementById('passportWaitDiv').innerHTML = '<strong>您已经成功登录海都人才通行证。现在您可以：</strong><ul class="loginedItem"><li onclick="location.href = \''+ b +'\';">返回登录之前的页面</li><li onclick="location.href = \'/User/\';">进入会员中心</li><li onclick="location.href=\'http://www.zgz93.com/\';">转到海都招聘网首页</li><li onclick="location.href=\'http://job.zgz93.com/\';">转到海都招聘网人才大市场</li><li onclick="location.href=\'http://www.rc913.com/\';">转到海都淘课BAR首页</li></ul><strong>3秒钟后将自动转到登录之前的页面。</strong>';
					var d = function () {
						location.href = b;
					}
					setTimeout(d,3000);
				}else{
					document.getElementById('passportWaitDiv').innerHTML = '<strong>您已经成功登录海都人才通行证。3秒钟后将自动刷新当前页面';
					setTimeout('location.reload()',3000);
					}
			}
			break;
		case '1':
			switch(getCookie('nUserType')) {
				case '64P0S5763E0DV45I1845' :
					var c = '/PartUser/';
				case '183L122K3MF9628E5KU0' :
					var c = '/School/';
				case 'E6YP3K7QZCHR8FG85SFF' :
					var c = '/Train/';
				default :
					var c = '/BUser/'
			}
			if (url == '' || url.indexOf('/Help/Index.shtml?s=1,2') != -1 || url.indexOf('undefined') != -1 || url.indexOf('UserReg.shtml') != -1 || url.indexOf('404.shtml') != -1 || url.indexOf('Login.shtml') != -1) b = c;
			else b = url;
			if (document.getElementById('passportWaitDiv')){
				if(FloatForm==''){
					document.getElementById('passportWaitDiv').innerHTML = '<strong>您已经成功登录海都人才通行证，现在您可以：</strong><ul class="loginedItem"><li onclick="location.href = \''+ b +'\';">返回登录之前的页面</li><li onclick="location.href = \''+ c +'\';">进入会员中心</li><li onclick="location.href=\'http://www.zgz93.com/\';">转到海都招聘网首页</li><li onclick="location.href=\'http://job.zgz93.com/\';">转到海都招聘网人才大市场</li><li onclick="location.href=\'http://www.rc913.com/\';">转到海都淘课BAR首页</li></ul><strong>3秒钟后将自动转到登录之前的页面。</strong>';
					var d = function () {location.href = b;}
					setTimeout(d,3000);
				}else{
					document.getElementById('passportWaitDiv').innerHTML = '<strong>您已经成功登录海都人才通行证。3秒钟后将自动刷新当前页面';
					setTimeout(location.reload(),3000);
					}
			}
			break;
		case '2':
			location.href = '/Help/Index.shtml?s=1,2';
			break;
		case '3':
			alert('系统中查找不到此帐户，请重新输入。');
			break;
		case '4':
			alert('您输入的密码错误，请重新输入。');
			if (document.getElementById('PassWordGetBack')) GetBackPsw();
			break;
		case '5':
			alert('您的账号尚未激活。激活邮件在您注册时已经发出，请到您的邮箱查收。');
			break;
		case '6':
			alert('无法写入Cookie，请清空您浏览器的Cookie后重试。');
			break;
		case '7':
			alert('您的会员卡号尚未激活！');
			location.href = '/CardNoActiv.Shtml?v='+ usn ;
			break;
		default :
			alert('无法写入Cookie，请清空您浏览器的Cookie后重试。');
			break;
	}
}


function checkLogin() {
	if (document.getElementById('login')) xmlHttpPost(true,'正在获取用户状态……','/Lib/','action=checkJobLogin',0,0,'login');
}
function UserPicDel(id,l) {
	xmlHttpPost(false,'','/Lib/','action=deluserpic&id='+ id +'&l='+ l,0,3,'cont_main');
	if (typeof(UserPicExport) == "function") UserPicExport(l);
}
function selectRsm(table,nJobID){
	createlayer('',700,85);
	document.getElementById('out_Title').innerHTML = '请选择您的简历：';
	document.getElementById('out_Foot').style.display = 'none';
	//juecomajax("..","/Lib/user/?subaction=GetRsmViewList","POST","ReadGO=ok&nJobID="+nJobID+"&table="+table,false,false,"#out_Main");
	new Model().AjaxComon("GetRsmViewList","/Lib/user/?subaction=GetRsmViewList","ReadGO=ok&nJobID="+nJobID+"&table="+table,"#out_Main")
}
function JobApply(exp,table,jobid,nRsmID){
	var l = xmlHttpPost(false,'','/Lib/','action=ResultLoginState',0,2,'');
		if (l == 'True') {
			if (getCookie('nUserType') == '2'){
				if (document.getElementById('out_Main')) {
					
					$('#out_Main').html('<div class="warningDiv" id="postResult"></div>');
					xmlHttpPost(true,'正在投递您的简历，投递成功后，我们将通过邮件发送给对方。','/Lib/','action=jobexport&t='+ table +'&s='+ exp +'&id='+ jobid+'&nrsmid='+nRsmID,0,0,'postResult');
				}
			}
			else {
				alert('只有个人会员才能投递简历应聘。');
			}
		}
		else {
			alert('注册登陆后方能执行此操作！\n只需填写一个E-Mail！\n就能成为海都招聘会员。');
			location.href = '/Login.shtml?url='+ location.href;
		}
	}
function JobExport(exp,table,jobid) {
	switch (exp){
	case 'Favorite':
		xmlHttpPost(false,'','/Lib/','action=jobexport&t='+ table +'&s='+ exp +'&id='+ jobid,0,8,'');
		break;
	case 'Commend' :
		createFullDiv('FullScreenContDiv');
		if (document.getElementById('FullScreenContDiv')) xmlHttpPost(false,'','/Lib/','action=jobexport&t='+ table +'&s='+ exp +'&id='+ jobid,0,0,'FullScreenContDiv');
		if (document.getElementById('massageDiv')) {
			document.getElementById('massageDiv').style.width = '600px';
			document.getElementById('massageDiv').style.top = document.documentElement.scrollTop +'px';
		}
		break;
	case 'Post' :
		var l = xmlHttpPost(false,'','/Lib/','action=ResultLoginState',0,2,'');
		if (l == 'True') {
			if (getCookie('nUserType') == '2'){
				if (getCookie('nState') == '1'){
					createFullDiv('FullScreenContDiv');
					if (document.getElementById('FullScreenContDiv')) {
						document.getElementById('FullScreenContDiv').innerHTML = '<div class="massageDiv" id="massageDiv"><div class="textAlignCenter"><img class="seflLinkClose" src="/Lib/Images/Close.gif" alt="关闭" title="关闭" onclick="javascript: closeFullDiv();" /></div><div class="warningDiv" id="postResult"></div></div>';
						xmlHttpPost(true,'正在投递您的简历，投递成功后，我们将通过邮件发送给对方。','/Lib/','action=jobexport&t='+ table +'&s='+ exp +'&id='+ jobid,0,0,'postResult');
						if (document.getElementById('massageDiv')) {
							document.getElementById('massageDiv').style.width = '600px';
							document.getElementById('massageDiv').style.top = document.documentElement.scrollTop +'px';
						}
					}
				}
				else {
					alert('您个人的基本资料还没有填写完整，暂不能投递简历。\n请到会员中心将您的简历填写完整。以方便企业查看。');
					location.href = '/User/';
				}
			}
			else {
				alert('只有个人会员才能投递简历应聘。');
			}
		}
		else {
			alert('注册登陆后方能执行此操作！\n只需填写一个E-Mail！\n就能成为海都招聘会员。');
			location.href = '/Login.shtml?url='+ location.href;
		}
		break;
	default :
		var l = xmlHttpPost(false,'','/Lib/','action=ResultLoginState',0,2,'');
		if (l == 'True') {
			xmlHttpPost(false,'','/Lib/','action=jobexport&t='+ table +'&s='+ exp +'&id='+ jobid,0,8,'');
		}
		else {
			alert('注册登陆后方能执行此操作！\n只需填写一个E-Mail！\n就能成为海都招聘会员。');
			location.href = '/Login.shtml?url='+ location.href;
		}
		break;
	}
}

function showAddress(address,str,tag,mapType,show,zoom) {
	var map = null;
	var geocoder = null;
	var directionsPanel;
    var directions;
	switch (show){
	case 1:
		createFullDiv('FullScreenContDiv');
		if (document.getElementById('FullScreenContDiv')) {
			document.getElementById('FullScreenContDiv').innerHTML = '<div id="massageDiv" class="massageDiv"><div id="mapTitleDiv" class="mapTitle"><img class="seflLinkClose" src="/Lib/Images/Close.gif" alt="关闭" title="关闭" onclick="javascript: closeFullDiv();" /><span id="mapTitle" style="font-weight:bold;"></span></div><div id="showMapDiv" class="mapDiv" style="width:69%;"></div><div id="mapRoute" class="mapRoute" style="width:30%; padding:0% 0% 0% 1%;"></div></div>';
			document.getElementById('mapTitleDiv').style.opacity = 0.80;
			document.getElementById('mapTitleDiv').style.filter = 'Alpha(opacity=80)';
		}
		if (document.getElementById('massageDiv')) {
			document.getElementById('massageDiv').style.top = document.documentElement.scrollTop +'px';
			var trueHeight = document.documentElement.scrollTop + document.getElementById('massageDiv').scrollHeight;
			if (trueHeight > document.body.scrollHeight) document.getElementById('FullScreenDiv').style.height = (trueHeight + 40) +'px';
		}
		break;
	default :
		createFullDiv('FullScreenContDiv');
		if (document.getElementById('FullScreenContDiv')) {
			document.getElementById('FullScreenContDiv').innerHTML = '<div id="massageDiv" class="massageDiv"><div id="mapTitleDiv" class="mapTitle"><img class="seflLinkClose" src="/Lib/Images/Close.gif" alt="关闭" title="关闭" onclick="javascript: closeFullDiv();" /><span id="mapTitle" style="font-weight:bold;"></span></div><div id="showMapDiv" class="mapDiv" style="width:100%;"></div></div>';
			document.getElementById('mapTitleDiv').style.opacity = 0.80;
			document.getElementById('mapTitleDiv').style.filter = 'Alpha(opacity=80)';
		}
		if (document.getElementById('massageDiv')) {
			document.getElementById('massageDiv').style.top = document.documentElement.scrollTop +'px';
			var trueHeight = document.documentElement.scrollTop + document.getElementById('massageDiv').scrollHeight;
			if (trueHeight > document.body.scrollHeight) document.getElementById('FullScreenDiv').style.height = (trueHeight + 40) +'px';
		}
		break;
	}
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById(tag));
		geocoder = new GClientGeocoder();
	}
	if (zoom < 0) zoom = 0;
	if (zoom > 19) zoom = 19;
	if (document.getElementById('mapTitle')) document.getElementById('mapTitle').innerHTML = '<a href="/Help/Index.shtml?s=10" target="_blank">如何让我的公司位置在地图上正确显示？</a> <input type="text" id="customAddress" style="width:200px;" value="请输入地址信息" onclick="if (document.getElementById(\'customAddress\').value == \'请输入地址信息\') document.getElementById(\'customAddress\').value = \'\'" onkeyup="if (event.keyCode == 13) document.getElementById(\'customAddressButton\').click();" /> <input type="button" id="customAddressButton" value="定位" onclick="if (document.getElementById(\'customAddress\').value != \'\' || document.getElementById(\'customAddress\').value != \'请输入地址信息\') showAddress(document.getElementById(\'customAddress\').value,document.getElementById(\'customAddress\').value +\'|\'+ document.getElementById(\'customAddress\').value,\'showMapDiv\',0,0,16)" />';
	switch (mapType){
	case 1:
		map.setMapType(G_SATELLITE_MAP);
		break;
	case 2:
		map.setMapType(G_HYBRID_MAP);
		break;
	default:
		map.setMapType(G_NORMAL_MAP);
		break;
	}
	if (geocoder) {
		geocoder.getLatLng(address,function(point) {
			if (!point) {
				document.getElementById(tag).innerHTML = '<div class="loadingDiv"><img src="/Images/System/warning.gif" alt="提示" class="picMiddle" /> <span class="warning">无法解析：'+ address +'。</span></div>';
			} else {
				map.setCenter(point, zoom);
				map.clearOverlays();
				map.setUIToDefault();
				switch (show){
				case 1:
					directionsPanel = document.getElementById('mapRoute');
					directions = new GDirections(map, directionsPanel);
					directions.load('from: 福州 to: '+ address);
					break;
				default :
					var strSplit = str.split('|');
					var html = '<div class="fontFocusBold">'+ strSplit[0] +'</div><div><span class="fontBold">地址：</span>'+ strSplit[1] +'</div><div><span class="fontBold">地图位置：</span>'+ address +'</div>';
					map.openInfoWindowTabsHtml(map.getCenter(),html);
					break;
				}
			}
		});
	}
}
function showLargePic(maxWidth,src,w,h) {
	if (src == null) return false;
	var showSrc = '';
	createFullDiv('FullScreenContDiv');
	setTimeout("document.getElementById('picLoadingDiv').style.display = 'none'; document.getElementById('picShowDiv').style.display = '';",800);
	if (document.getElementById('FullScreenContDiv')) {
		if (w > maxWidth) {
			w = maxWidth;
			h = 0;
			showSrc = '/Lib/?action=outputsmallpic&width='+ w +'&height='+ h +'&url='+ escape(src);
		}
		else {
			showSrc = src;
		}
		var a = '<div class="showPicDiv"><input type="button" value="放大" name="zoomOut" onclick="javascript: picZoom('+ maxWidth +',\'largePic\',\''+ src +'\','+ w +',\'out\')" /> <input type="button" value="缩小" name="zoonIn" onclick="javascript: picZoom('+ maxWidth +',\'largePic\',\''+ src +'\','+ w +',\'in\')" /> <input type="button" value="复原" name="zoonReset" onclick="javascript: picZoom('+ maxWidth +',\'largePic\',\''+ src +'\','+ w +',\'reset\')" /> <input type="button" value="关闭" onclick="javascript: closeFullDiv();" /></div>';
		document.getElementById('FullScreenContDiv').innerHTML = '<div id="massageDiv" class="massageDiv" style="text-align:center;">'+ a +'<div id="picLoadingDiv" class="loadingDiv"><img src="/Lib/Images/loading/loading1.gif" alt="" class="picMiddle" />正在载入图片，请稍后……</div><div id="picShowDiv" style="display:none;"><a href="'+ escape(src) +'" target="_blank"><img id="largePic" src="'+ showSrc +'" alt="" width="'+ w +'" /></a></div>'+ a +'</div>';
	}
	if (document.getElementById('massageDiv')) {
		document.getElementById('massageDiv').style.width = (maxWidth + 20) +'px';
		document.getElementById('massageDiv').style.top = document.documentElement.scrollTop +'px';
		var trueHeight = document.documentElement.scrollTop + document.getElementById('massageDiv').scrollHeight;
		if (trueHeight > document.body.scrollHeight) document.getElementById('FullScreenDiv').style.height = (trueHeight + 40) +'px';
	}
}

function  picZoom(maxWidth,id,src,ow,t) {
	var minWidth = 100;
	var showSrc = '';
	var width = document.getElementById('largePic').width;
	switch (t){
	case 'in':
		if (width <= minWidth) return false;
		var w = Math.round(width * 0.8);
		if (w < minWidth) w = minWidth;
		showSrc = '/Lib/?action=outputsmallpic&width='+ w +'&height=0&url='+ escape(src)
		break;
	case 'out':
		if (width >= maxWidth) return false;
		var w = Math.round(width * 1.2);
		if (w > maxWidth) w = maxWidth;
		showSrc = '/Lib/?action=outputsmallpic&width='+ w +'&height=0&url='+ escape(src)
		break;
	case 'reset':
		var w = ow;
		showSrc = src
		break;
	}
	document.getElementById('largePic').width = w;
	document.getElementById('largePic').src = showSrc;
}

function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg) {
	var tmp = '';
	var tmp2 = '';
	switch ( errorNumber ) {
		case 0 :
			alert('上传成功！');
			location.reload();
			break ;
		case 1 :
			alert(customMsg);
			break ;
		case 10 :
			alert(customMsg);
			break ;
		case 200 :
			alert('超出文件大小限制');
			break ;
		case 201 :
			alert('上传成功！但有重名文件，本次上传的文件被重命名为：' + fileName);
			location.reload();
			break ;
		case 202 :
			alert('不支持的文件格式！或者超出文件大小限制');
			break ;
		case 203 :
			alert('您没有足够的权限上传文件，请检查服务器权限设置');
			break ;
		default :
			alert('无法完成上传，错误代码: ' + errorNumber);
			break ;
	}
}


function copyToClipboard(txt) {
	if(window.clipboardData) {
		window.clipboardData.clearData();
		window.clipboardData.setData("Text", txt);
	} else if(navigator.userAgent.indexOf("Opera") != -1) {
		window.location = txt;
	} else if (window.netscape) {
		try {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		} catch (e) {
			alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'\n\n您可以尝试用右键或者按Ctrl+V进行复制。");
			return false;
		}
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip)
			return;
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans)
			return;
		trans.addDataFlavor('text/unicode');
		var str = new Object();
		var len = new Object();
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext = txt;
		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('复制成功');
}

function LoadJsCssFile(filename, filetype){
	switch (filetype){
	case 0 :
		var fileref = document.createElement('script');
		fileref.setAttribute("type","text/javascript");
		fileref.setAttribute("src",filename);
		break;
	case 1 :
		var fileref = document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href",filename);
		break;
	case 2 :
		var fileref = document.createElement("link");
		fileref.setAttribute("rel", "shortcut icon");
		fileref.setAttribute("type", "image/ico");
		fileref.setAttribute("href",filename);
		break;
	default :
		break;
	}
	if (typeof fileref != "undefined") document.getElementsByTagName("head")[0].appendChild(fileref)
}

function getOs() {
	var sAgent = navigator.userAgent.toLowerCase();
	if (sAgent.indexOf("msie") >= 0) return 'IE';
	if (sAgent.indexOf("firefox") >= 0) return 'Firefox';
	if (sAgent.indexOf("safari") >= 0) return 'Safari';
	if (sAgent.indexOf("opera") >= 0) return 'Opera';
	if (sAgent.indexOf("netscape") >= 0) return 'NetScape';
	if (sAgent.indexOf("camino") >= 0) return 'Camino';
	if (sAgent.indexOf("gecko/") >= 0) return 'Gecko';
	return 'unknown';
}

function loadGoogleMapAPI() {
	var domain = document.domain;
	if (domain.indexOf("www.zgz93.com") >= 0) {
		document.write('<script src="http://ditu.google.cn/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAx3gqDIos2dxryl3kBsJQghRdx0AgQ2RRCqEKhnQ4EzAe1E4cfhT-CeYmurr4z_jxElLlZrmcc_bGaw&hl=zh-CN" type="text/javascript"><\/script>');
	}
	else if (domain.indexOf("it.zgz93.com") >= 0) {
		document.write('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAx3gqDIos2dxryl3kBsJQghTwdydJiV30Ziy9rtTlSP9iekH-aBRJVtfNPPDN4PgpMtKVfa2Hc7vvgg" type="text/javascript"><\/script>');
	}
	else if (domain.indexOf("liuxue.rc913.com") >= 0) {
		document.write('<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAx3gqDIos2dxryl3kBsJQghQFQM6DraOE9VketnvxOcJPbh0XixTUDxjfnTSZd6J6b8X3J1yexwoJcg" type="text/javascript"><\/script>');
	}
	else if (domain.indexOf("www.rc913.com") >= 0) {
		document.write('<script src="http://ditu.google.cn/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAx3gqDIos2dxryl3kBsJQghRdGHtpPA6pq5aCBLHaHFuBMfPUyBQNlY7zKfHzeySDOibUXrFAQVB7vQ&hl=zh-CN" type="text/javascript"><\/script>');
	}
}

function poiseHeight(tag,tagNum,deduct) {
	var a = tag.split(',');
	switch (parseInt(tagNum)){
	case 2:
		var h0 = document.getElementById(a[0]).scrollHeight + deduct;
		var h1 = document.getElementById(a[1]).scrollHeight + deduct;
		if (parseInt(h0) > parseInt(h1)) document.getElementById(a[1]).style.height = h0 +'px';
		else document.getElementById(a[0]).style.height = h1 +'px';
		break;
	case 3:
		var h0 = document.getElementById(a[0]).scrollHeight + deduct;
		var h1 = document.getElementById(a[1]).scrollHeight + deduct;
		var h2 = document.getElementById(a[2]).scrollHeight + deduct;
		if (parseInt(h0) > parseInt(h1) && parseInt(h0) > parseInt(h2)) {
			document.getElementById(a[0]).style.height = h0 +'px';
			document.getElementById(a[1]).style.height = h0 +'px';
			document.getElementById(a[2]).style.height = h0 +'px';
		}
		else if (parseInt(h1) > parseInt(h0) && parseInt(h1) > parseInt(h2)) {
			document.getElementById(a[0]).style.height = h1 +'px';
			document.getElementById(a[1]).style.height = h1 +'px';
			document.getElementById(a[2]).style.height = h1 +'px';
		}
		else if (parseInt(h2) > parseInt(h0) && parseInt(h2) > parseInt(h1)) {
			document.getElementById(a[0]).style.height = h2 +'px';
			document.getElementById(a[1]).style.height = h2 +'px';
			document.getElementById(a[2]).style.height = h2 +'px';
		}
		break;
	}
}

function addFavorite(url,name){
	switch(getOs()){
		case 'IE' :
			window.external.addFavorite(url,name);
			break;
		default :
			window.sidebar.addPanel(name,url,"");
			break;
	}
}

function SendMail(title,mail,cont,file,id) {
	if (mail == '') alert('请输入收件人的E-Mail地址。');
	else xmlHttpPost(true,'邮件发送中，请稍后……','/Lib/','action=sendmail&title='+ title +'&mail='+ mail +'&cont='+ cont +'&file='+ file,0,0,id);
}

function setHomepage(url){
	switch(getOs()){
		case 'IE' :
			document.body.style.behavior = 'url(#default#homepage)';
			document.body.setHomePage(url);
			break;
		default :
			if (window.sidebar){
				if(window.netscape){
					try {
						netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
					}
					catch (e) {
						alert('设置首页的操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 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);
			}
			break;
	}
}

function SetCookie(name,value,days) {
	var exp = new Date();
	exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000);
	document.cookie = name +'='+ escape(value) + ';expires='+ exp.toGMTString();
}

function getCookie(name) {
	var val = '';
	var node = '';
	var key = '';
	var arr = document.cookie.match(new RegExp("(^| )E%2DDragon%5FCMS=([^;]*)(;|$)"));
	if(arr != null) {
		node = arr[2];
		var a = node.split('&')
		for (var i = 0;i < a.length ;i++ ){
			key = a[i].split('=');
			if (key[0] == escape(name)) {
				return unescape(key[1]);
				break;
			}
		}
	}
}

function ReturnMultipleValue(tag) {
	if (document.getElementById(tag)){
		var result = '';
		for (var i = 0; i < document.getElementById(tag).options.length; i ++) {
			if (document.getElementById(tag).options[i].selected) {
				if (result == '') result = document.getElementById(tag).options[i].value;
				else result = result +','+ document.getElementById(tag).options[i].value;
			}
		}
		return result;
	}
}

function selectAllCheckBox(objName,selfObjName){
	var coll = document.getElementsByTagName('input');
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).name == objName) coll.item(i).checked = document.getElementById(selfObjName).checked;
		}
	}
	else coll.checked = document.getElementById(selfObjName).checked;
}

function getInnerText(obj){
	var a = document.getElementById(obj);
	return document.all?a.innerText:a.textContent;
}

function getValueList(tagName,tagId){
	var result = "";
	var coll = document.getElementsByTagName(tagName)
	if(!coll) return result;
	if(coll.length){
		for(var i = 0;i<coll.length;i++){
			if(coll.item(i).checked) {
				if (coll.item(i).name == tagId) result += (result == "")?coll.item(i).value:("," + coll.item(i).value);
			}
		}
	}else{
		if(coll.checked) result = coll.value;
	}
	return result;
}

function getItemValue(tagName,val) {
	if (val == '***') document.getElementById(tagName).value = '';
	else {
		if (document.getElementById(tagName).value == '') document.getElementById(tagName).value = val;
		else document.getElementById(tagName).value = document.getElementById(tagName).value +','+ val;
	}
}

function checkDisabled(tagName,objNull) {
	var coll = document.getElementsByTagName('input')
	var temp = false;
	if (objNull == '') temp = true;
	if (!coll) return;
	if (coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).name == tagName)  coll.item(i).disabled = temp;
		}
	}
	else coll.disabled = temp;
}

function hiddenSelect(showType) {
	var coll = document.getElementsByTagName('select')
	if (!coll) return;
	if (coll.length){
		for(var i = 0;i < coll.length;i++){
			if (showType == 'hidden') {
				if (coll.item(i).style.display != 'none' ) coll.item(i).style.display = 'none';
			}
			else {
				if (coll.item(i).style.display == 'none' ) coll.item(i).style.display = '';
			}
		}
	}
}

function closeFullDiv() {
	hiddenSelect('show');
	document.getElementById('FullScreenDiv').style.display = 'none';
	document.getElementById('FullScreenContDiv').style.display = 'none';
}

function createDiv(e,id,style) {
	if (!document.getElementById(id)) {
		var cDiv = document.createElement("div");
		cDiv.id = id;
		cDiv.className = style;
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 8880;
		document.body.appendChild(cDiv);
		if ((returnXY(e,'x') + document.getElementById(id).scrollWidth) > document.documentElement.scrollWidth) {
			cDiv.style.left = (document.documentElement.scrollWidth - document.getElementById(id).scrollWidth) - 20 +'px';
		}
		else {
			cDiv.style.left = returnXY(e,'x') +'px';
		}
		if ((returnXY(e,'y') + document.getElementById(id).scrollHeight) > document.documentElement.scrollHeight) {
			cDiv.style.top = (document.documentElement.scrollHeight - document.getElementById(id).scrollHeight) - 20 +'px';
		}
		else {
			cDiv.style.top = (returnXY(e,'y') + 6) +'px';
		}
	}
}

function createFullDiv(id) {
	hiddenSelect('hidden');
	if (!document.getElementById('FullScreenDiv')) {//判断FullScreenDiv是否存在
		var cDiv = document.createElement("div");
		cDiv.id = 'FullScreenDiv';
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 8888;
		cDiv.style.left = '0px';
		cDiv.style.top = '0px';
		cDiv.style.width = '100%';
		cDiv.style.height = document.documentElement.scrollHeight + 100 +'px';
		cDiv.style.backgroundColor = '#666666';
		cDiv.style.opacity = 0.80;
		cDiv.style.filter = 'Alpha(opacity=80)';
		document.body.appendChild(cDiv);
	}
	else {
		document.getElementById('FullScreenDiv').style.display = '';
		document.getElementById('FullScreenDiv').style.height = document.documentElement.scrollHeight + 100 +'px';
	}
	if (!document.getElementById(id)) {
		var cDiv = document.createElement("div");
		cDiv.id = id;
		cDiv.style.position = 'absolute';
		cDiv.style.zIndex = 9998;
		cDiv.style.width = '100%';
		cDiv.style.left = '0px';
		cDiv.style.top = '20px';
		document.body.appendChild(cDiv);
	}
	else {
		document.getElementById(id).style.display = '';
		document.getElementById(id).style.height = document.body.scrollHeight - 40 +'px';
	}
}

function returnXY(e,sType) {
	e = e || window.event;
	if (sType == 'x') return e.pageX ||(e.clientX?e.clientX + document.documentElement.scrollLeft:0);
	if (sType == 'y') return e.pageY ||(e.clientY?e.clientY + document.documentElement.scrollTop:0);
}

function setWeather(e,virtualRoot,id) {
	var coll = document.getElementsByTagName('div')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).className == 'setWeather'){
				coll.item(i).style.display = 'none';
			}
		}
	}
	if (!document.getElementById(id)) {
		createDiv(e,id,'setWeather');
		xmlHttpPost(true,'',virtualRoot +'/Lib/','action=setweather&result=show&id='+ id,0,0,id);
	}
	else {
		document.getElementById(id).style.display = '';
		if ((returnXY(e,'x') + document.getElementById(id).scrollWidth) > document.documentElement.scrollWidth) {
			document.getElementById(id).style.left = (document.documentElement.scrollWidth - document.getElementById(id).scrollWidth) - 20 +'px';
		}
		else {
			document.getElementById(id).style.left = returnXY(e,'x') +'px';
		}
		if ((returnXY(e,'y') + document.getElementById(id).scrollHeight) > document.documentElement.scrollHeight) {
			document.getElementById(id).style.top = (document.documentElement.scrollHeight - document.getElementById(id).scrollHeight) - 20 +'px';
		}
		else {
			document.getElementById(id).style.top = (returnXY(e,'y') + 6) +'px';
		}
	}
	document.getElementById(id).style.opacity = 0.80;
	document.getElementById(id).style.filter = 'Alpha(opacity=80)';
}

function right(mainStr,lngLen) {
	if (mainStr.length - lngLen >= 0 && mainStr.length >= 0 && mainStr.length - lngLen <= mainStr.length) return mainStr.substring(mainStr.length - lngLen,mainStr.length)
	else return null
}


function DateAdd(interval,number,date,style){
	number = parseInt(number);
	if (typeof(date)=="string"){
		date = date.split(/\D/);
		--date[1];
		eval("var date = new Date("+date.join(",")+")");
	}
	if (typeof(date)=="object"){
		var date = date
	}
	switch(interval){
		case "y": date.setFullYear(date.getFullYear() + number); break;
		case "m": date.setMonth(date.getMonth() + number); break;
		case "d": date.setDate(date.getDate() + number); break;
		case "w": date.setDate(date.getDate() + 7 * number); break;
		case "h": date.setHours(date.getHours() + number); break;
		case "n": date.setMinutes(date.getMinutes() + number); break;
		case "s": date.setSeconds(date.getSeconds() + number); break;
		case "l": date.setMilliseconds(date.getMilliseconds() + number); break;
	}
	var a;
	a = style.replace(/Y/g,date.getFullYear());
	a = a.replace(/M/g,right('0'+ (date.getMonth() + 1).toString(),2));
	a = a.replace(/D/g,right('0'+ date.getDate().toString(),2));
	a = a.replace(/H/g,right('0'+ date.getHours().toString(),2));
	a = a.replace(/N/g,right('0'+ date.getMinutes().toString(),2));
	a = a.replace(/S/g,right('0'+ date.getSeconds().toString(),2));
	a = a.replace(/y/g,right(date.getFullYear().toString(),2));
	a = a.replace(/m/g,(date.getMonth() + 1));
	a = a.replace(/d/g,date.getDate());
	a = a.replace(/h/g,date.getHours());
	a = a.replace(/n/g,date.getMinutes());
	a = a.replace(/s/g,date.getSeconds());
	return a;
}

function selfLink(e,virtualRoot,id,text) {
	var coll = document.getElementsByTagName('div')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).className == 'selfLink'){
				coll.item(i).style.display = 'none';
			}
		}
	}
	if (!document.getElementById(id)) {
		createDiv(e,id,'selfLink');
		xmlHttpPost(true,'',virtualRoot +'/Lib/','action=showSelfLink&title='+ text +'&id='+ id,0,0,id);
	}
	else {
		document.getElementById(id).style.display = '';
		document.getElementById(id).style.left = returnXY(e,'x') +'px';
		document.getElementById(id).style.top = (returnXY(e,'y') + 6) +'px';
	}
}

function windowOpen(url,item,val,target) {
	var a = item.split("|")
	var b = val.split("|")
	if (target == 'open') {
		if (item == '') window.open(url);
		else {
			for (var i = 0;i < a.length ;i ++ ){
				if (i == 0) url = url +'?'+ a[i] +'='+ escape(b[i]);
				else  url = url +'&'+ a[i] +'='+ escape(b[i]);
			}
			window.open(url);
		}
	}
	else {
		if (item == '') location.href = url;
		else {
			for (var i = 0;i < a.length ;i ++ ){
				if (i == 0) url = url +'?'+ a[i] +'='+ escape(b[i]);
				else  url = url +'&'+ a[i] +'='+ escape(b[i]);
			}
			location.href = url;
		}
	}
}

function menuStyle(objName,tag){
	var coll = document.getElementsByTagName('span')
	if(!coll) return;
	if(coll.length){
		for(var i = 0;i < coll.length;i++){
			if (coll.item(i).id == objName){
				if (tag == 'top') coll.item(i).className = 'clickedtop';
				else coll.item(i).className = 'clickedmenu';
			}
			else {
				if (tag == 'top') coll.item(i).className = '';
				else coll.item(i).className = 'menu';
			}
		}
	}
}

function randomChar(l,t){
	var x = '';
	switch (t){
	case 1:
		x = '0123456789poiuytrewqasdfghjklmnbvcxzQWERTYUIOPLKJHGFDSAZXCVBNM';
		break;
	case 2:
		x = '0123456789ABCDEF';
		break;
	default:
		x = '0123456789';
		break;
	}
	var tmp = "";
	for(var i = 0;i < l;i ++) {
		tmp += x.charAt(Math.ceil(Math.random()*100000000)%x.length);
	}
	return tmp;
}

function changeClassName(stype,num,count,selfClass,tagClass) {
	if (document.getElementById(stype +'_'+ num)) document.getElementById(stype +'_'+ num).className = tagClass;
	for (var i = 0; i <= count; i ++) {
		if (i != num) {
			if (document.getElementById(stype +'_'+ i)) document.getElementById(stype +'_'+ i).className = selfClass;
		}
	}
}

function setIntervalchangeClassName(stype,count,step,showType) {
	var j = 0;
	for (var i = 0; i < count; i ++) {
		if (document.getElementById(stype +'_'+ i) && document.getElementById(stype +'_'+ i).style.display != 'none') {
			j = i;
			break;
		}
	}
	var k = j + 1;
	if (k >= count) k = 0;
	document.getElementById(stype +'_'+ j).style.display = 'none';
	if (showType) showBlock(stype +'_'+ k,step);
	else document.getElementById(stype +'_'+ k).style.display = 'block';
}

function showTr(id) {
	if (document.getElementById(id).style.display == 'none'){
		document.getElementById(id).style.display = ''
	}
	else document.getElementById(id).style.display = 'none'
}

function showBlocks(pre,num,count,step) {
	if (document.getElementById(pre +'_'+ num)) showBlock(pre +'_'+ num,step);
	for (var i = 0; i < count; i ++) {
		if (i != num) {
			if (document.getElementById(pre +'_'+ i)) hiddenBlock(pre +'_'+ i,step);
		}
	}
}

function showBlock(tag,step){
	if (document.getElementById(tag).style.display == 'none') {
		var h = 0;
		document.getElementById(tag).style.display = 'block';
		document.getElementById(tag).style.overflow = 'hidden';
		var max_h = document.getElementById(tag).scrollHeight;
		document.getElementById(tag).style.height = '1px';
		var anim = function(){
			h += step;
			if(h >= max_h){
				if (navigator.userAgent.toLowerCase().indexOf("msie 6.0") >= 0) {
					document.getElementById(tag).style.height = max_h - 20 +'px';
					document.getElementById(tag).style.overflow = 'auto';
				}
				else document.getElementById(tag).style.height = 'auto';
				if(tt) window.clearInterval(tt);
			}
			else{
				document.getElementById(tag).style.height = h +'px';
			}
		}
		var tt = window.setInterval(anim,2);
	}
}

function hiddenBlock(tag,step){
	if (document.getElementById(tag).style.display == 'block') {
		var h = document.getElementById(tag).scrollHeight;
		if (navigator.userAgent.toLowerCase().indexOf("msie 6.0") >= 0) document.getElementById(tag).style.overflow = 'hidden';
		var anim = function(){
			h -= step;
			if(h <= 5){
				document.getElementById(tag).style.display = 'none';
				if(tt) window.clearInterval(tt);
			}
			else{
				document.getElementById(tag).style.height = h +'px';
			}
		}
		var tt = window.setInterval(anim,10);
	}
}

function changePic(pic1,pic2,id) {
	if (document.getElementById(id).title == '点击展开') {
		document.getElementById(id).src = pic2;
		document.getElementById(id).title = '点击合起';
	}
	else {
		document.getElementById(id).src = pic1;
		document.getElementById(id).title = '点击展开';
	}
}

function openSelWin(url,winWidth,winHeight) {
	var regWin = window.open(url,'selWin_'+ randomChar(10,1),'modal=yes,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no,width='+ winWidth +',height='+ winHeight);
	if (regWin) {
		regWin.moveTo((screen.availWidth - winWidth) / 2,(screen.availHeight - winHeight - 12) / 2);
		regWin.focus();
	}
	return true;
}

function getFieldVal(virtualRoot,act,oprateTable,key,PublicID,tagObj,updateTF) {
	xmlHttpPost(true,'',virtualRoot +'/Lib/','action=getFieldVal&obj='+ act +'&table='+ oprateTable +'&key='+ key +'&id='+ PublicID +'&updateTF='+ updateTF,0,0,tagObj)
}

function getReNum(virtualRoot,PublicID,tagObj) {
	xmlHttpPost(true,'',virtualRoot +'/Lib/','action=getReviewNum&id='+ PublicID,0,0,tagObj)
}

function CustomSqlList(virtualRoot,tempType,tempName,condition,topNum,picOrText,tagId) {
	xmlHttpPost(true,'',virtualRoot +'/Lib/','action=CustomSqlList&tempType='+ tempType +'&tempName='+ unescape(tempName).replace(/ /g,'%20') +'&condition='+ unescape(condition).replace(/,/g,'%20').replace(/ /g,'%20') +'&pic='+ picOrText +'&topNum='+ topNum,0,0,'CustomList_'+ tagId)
}

function CheckReviewLength(virtualRoot,reviewType,PublicID,pageNo,maxLength) {
	var a = GetLength('reviewCont_'+ PublicID);
	var str = '';
	if (getOs() == 'Opera') str = document.getElementById('reviewCont_'+ PublicID).value;
	else str = escape(GetContents('reviewCont_'+ PublicID))
	if (a == 0) alert('1、帖子内容不能为空\n2、请不要使用纯表情或纯图片作为帖子内容');
	else if (a > maxLength) alert('帖子内容超出字数限制');
	else {
		if (document.getElementById('P_'+ PublicID) && document.getElementById('reviewTempId_'+ PublicID)) {
			xmlHttpPost(true,'<div style="text-align:center; clear:both; margin:10px;">正在提交您的帖子，请稍后...</div>',virtualRoot +'/Lib/','action=getReviewList&id='+ PublicID +'&reviewType='+ reviewType +'&pageNo='+ pageNo +'&tempid='+ document.getElementById('reviewTempId_'+ PublicID).value +'&reviewcont='+ str,0,0,'P_'+ PublicID);
			SetContents('reviewCont_'+ PublicID,'');
			location.href = '#P_'+ PublicID;
		}
		else alert('出现意外错误，帖子无法提交');
	}
}

function getReview(virtualRoot,reviewType,PublicID,pageNo,tempId,reviewCont) {
	if (document.getElementById('P_'+ PublicID)) xmlHttpPost(true,'',virtualRoot +'/Lib/','action=getReviewList&id='+ PublicID +'&reviewType='+ reviewType +'&pageNo='+ pageNo +'&tempid='+ tempId,0,0,'P_'+ PublicID);
}

function GetServerData(resultType,virtualRoot,act,val1,val2,val3,val4,tagObj) {
	xmlHttpPost(resultType,'',virtualRoot +'/Lib/','action=getserverdata&obj='+ act +'&val1='+ val1 +'&val2='+ val2 +'&val3='+ val3 +'&val4='+ val4,0,0,tagObj);
}

function SearchSubmit(virtualRoot) {
	var key = document.getElementById('keyword').value;
	if (key == '') alert('请输入关键字');
	else location.href = virtualRoot +'/Search.shtml?page=1&key='+ escape(key);
}

function CheckReadGroup(virtualRoot,readscore,infoId,pageNo) {
	var userRead = xmlHttpPost(false,'',virtualRoot +'/Lib/','action=getUserReadGroup&id='+ infoId +'&readscore='+ readscore,0,2,'');
	if (userRead == 'True') xmlHttpPost(true,'',virtualRoot +'/Lib/','action=checkReadGroup&id='+ infoId +'&pageNo='+ pageNo,0,0,'Info_'+ infoId);
}

function userLogout(virtualRoot) {
	if (confirm('是否真的要退出？')){
		xmlHttpPost(false,'',virtualRoot +'/Lib/','action=userLogout',0,9,'');
	}
}

function GetUserLoginForm(virtualRoot,tempId,formId) {
	xmlHttpPost(false,'',virtualRoot +'/Lib/','action=checkUser&tempid='+ tempId +'&id='+ formId,0,0,'LoginForm_'+ formId);
	xmlHttpPost(false,'',virtualRoot +'/Lib/','action=onlineTime',0,0,'');
}

function ChkUserLogin(virtualRoot,action,formId) {
	var tempid = document.getElementById('tempId').value;
	var usn = document.getElementById('usn').value;
	var psw = document.getElementById('psw').value;
	var code = document.getElementById('code').value;
	var saveCookie = document.getElementById('savecookie').checked;
	if (saveCookie) saveCookie = 1;
	xmlHttpPost(true,'身份验证中，请稍后...',virtualRoot +'/Lib/','action='+ action +'&tempid='+ tempid +'&usn='+ usn +'&psw='+ psw +'&code='+ code +'&savecookie='+ saveCookie +'&id='+ formId,0,0,'LoginForm_'+ formId);
}

function GetNextOrForwardInfoLink(virtualRoot,infoTable,classid,infoid,forwardOrBack,cutNum,endStr,linkStyle,isLink) {
	var a = 0;
	var b = 0;
	var c = true
	if (isLink == 1) {
		a = 1;
		b = 6;
		c = false;
	}
	xmlHttpPost(c,'请稍后...',virtualRoot +'/Lib/','action=GetBackOrForwardInfoLink&showType='+ forwardOrBack +'&classid='+ classid +'&infoid='+ infoid +'&infotable='+ infoTable +'&cutnum='+ cutNum +'&endstr='+ escape(endStr) +'&linkstyle='+ linkStyle +'&islink='+ a,0,b,forwardOrBack +'Info_'+ infoid)
}

function GetActionFlagCont(virtualRoot,resultType,flagID,pageNo) {
	var ajaxType = true;
	if (resultType == 3) ajaxType = false;
	xmlHttpPost(ajaxType,'Loading...',virtualRoot +'/Lib/','action=changePage&id='+ flagID +'&page='+ pageNo,0,0,'P_'+ flagID)
}

function changePage(virtualRoot,resultType,action,pCount,pButton,pPlace,pType,tagObj,condition) {
	var pNo = '';
	var ajaxType = true;
	if (resultType == 3) ajaxType = false;
	if (pButton == 'First') pNo = 1;
	else if (pButton == 'Previous'){
		if (document.getElementById('P_'+ tagObj +'_No0')) pNo = Number(document.getElementById('P_'+ tagObj +'_No0').innerHTML) - 1;
		if (document.getElementById('P_'+ tagObj +'_No1')) pNo = Number(document.getElementById('P_'+ tagObj +'_No1').innerHTML) - 1;
		if (pNo < 1) pNo = 1;
	}
	else if (pButton == 'Next'){
		if (document.getElementById('P_'+ tagObj +'_No0')) pNo = Number(document.getElementById('P_'+ tagObj +'_No0').innerHTML) + 1;
		if (document.getElementById('P_'+ tagObj +'_No1')) pNo = Number(document.getElementById('P_'+ tagObj +'_No1').innerHTML) + 1;
		if (pNo > pCount) pNo = pCount;
	}
	else if (pButton == 'Last') pNo = pCount;
	else pNo = Number(pButton);
	if (pType == 0){
		for (var i = 1;i <= pCount;i ++ ){
			if (i == pNo) {
				if (document.getElementById('P_'+ tagObj +'_'+ i)) document.getElementById('P_'+ tagObj +'_'+ i).style.display = 'block';
			}
			else {
				if (document.getElementById('P_'+ tagObj +'_'+ i)) document.getElementById('P_'+ tagObj +'_'+ i).style.display = 'none';
			}
		}
	}
	else {
		if (action == 'searchlist') location.href = '#';
		xmlHttpPost(ajaxType,'Loading...',virtualRoot +'/Lib/','action='+ action +'&id='+ tagObj +'&page='+ pNo +'&condition='+ unescape(condition).replace(/ /g,"%20"),0,0,'P_'+ tagObj)
	}
	if (document.getElementById('P_'+ tagObj +'_No0')) document.getElementById('P_'+ tagObj +'_No0').innerHTML = pNo;
	if (document.getElementById('P_'+ tagObj +'_No1')) document.getElementById('P_'+ tagObj +'_No1').innerHTML = pNo;
}

function publicInfo(wid,aTag) {
	location.href = '#'+ aTag;
	if (parent.document.getElementById('progressNum')) parent.document.getElementById('progressNum').innerHTML = wid;
	if (parent.document.getElementById('progress')) parent.document.getElementById('progress').style.width = wid;
	if (document.getElementById('progressNum')) document.getElementById('progressNum').innerHTML = wid;
	if (document.getElementById('progress')) document.getElementById('progress').style.width = wid;
}

function xmlHttpPost(tf,loadImg,url,valueStr,postType,oprateType,id){
	loadImg = '<img style="border:0px;" align="absmiddle" src="/Lib/Images/Loading.gif" alt="Loading..." /> <span style="color:#999999">'+ loadImg +'</span>';
	var postStr = 'POST';
	if (postType == 1) postStr = 'GET';
	var xmlhttp = creatAjaxObject();
	var timeOut;
	xmlhttp.open(postStr,url,tf);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	if (tf == false) {
		xmlhttp.send('now='+ new Date().getTime() +'&'+ valueStr);
		timeOut = setTimeout(function () {if (xmlhttp) xmlhttp.abort();},ajaxTimeOut * 1000);
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			val = unescape(xmlhttp.responseText);
			if (timeOut) clearTimeout(timeOut);
			if (oprateType == 2) return val
			else returnAjaxResult(oprateType,id,val);
		}
	}
	else {
		xmlhttp.onreadystatechange = function() {
			var val = '';
			switch(xmlhttp.readyState){
				case 4 :
					if (xmlhttp.status == 200) val = unescape(xmlhttp.responseText);
					else val = '<span style="color:#ff0000">Err:'+ xmlhttp.status +'</span>';
					if (xmlhttp.status == 0) val = '<span style="color:#ff0000">请求超时</span>';
					break;
				default :
					var a = id.split(',');
					for (i = 0;i < a.length ;i ++ ){
						if (val == '') val = loadImg;
						else val = val +'<!--AjaxSplit-->'+ loadImg;
					}
					break;
			}
			if (timeOut) clearTimeout(timeOut);
			if (oprateType == 2) return val
			else returnAjaxResult(oprateType,id,val);
		}
	}
	if (tf) {
		xmlhttp.send(valueStr);
		timeOut = setTimeout(function () {if (xmlhttp) xmlhttp.abort();},ajaxTimeOut * 1000);
	}
}

function xmlUserHttpPost(tf,loadImg,url,valueStr,postType,oprateType,id){
	loadImg = '<img style="border:0px;" align="absmiddle" src="/Lib/Images/Loading.gif" alt="Loading..." /> <span style="color:#999999">'+ loadImg +'</span>';
	var postStr = 'POST';
	if (postType == 1) postStr = 'GET';
	var xmlhttp = creatAjaxObject();
	var timeOut;
	if (url.indexOf('?') != -1) url = url +'?r='+ Math.random()
	else url +'&r='+ Math.random()
	xmlhttp.open(postStr,url,tf);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	if (tf == false) {
		xmlhttp.send(valueStr);
		timeOut = setTimeout(function () {if (xmlhttp) xmlhttp.abort();},ajaxTimeOut * 1000);
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			val = unescape(xmlhttp.responseText);
			if(val=='False'){LoginForm();return false;}

			if (timeOut) clearTimeout(timeOut);
			if (oprateType == 2) return val
			else returnAjaxResult(oprateType,id,val);
		}
	}
	else {
		xmlhttp.onreadystatechange = function() {
			var val = '';
			switch(xmlhttp.readyState){
				case 4 :
					if (xmlhttp.status == 200){
						val = unescape(xmlhttp.responseText);
						if(val=='False'){LoginForm();return false;}
					}

					else {
						val = '<span style="color:#ff0000">Err:'+ xmlhttp.status +'</span>';
						}
					if (xmlhttp.status == 0) val = '<span style="color:#ff0000">请求超时</span>';
					break;
				default :
					var a = id.split(',');
					for (i = 0;i < a.length ;i ++ ){
						if (val == '') val = loadImg;
						else val = val +'<!--AjaxSplit-->'+ loadImg;
					}
					break;
			}
			if (timeOut) clearTimeout(timeOut);
			if (oprateType == 2) return val
			else returnAjaxResult(oprateType,id,val);
		}
	}
	if (tf) {
		xmlhttp.send(valueStr);
		timeOut = setTimeout(function () {if (xmlhttp) xmlhttp.abort();},ajaxTimeOut * 1000);
	}
}

function creatAjaxObject() {
	var xmlhttp = false;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
			}
		}
	}
	if (!xmlhttp) {
		alert('Can not init XMLHttpRequest!');
		return false;
	}
	return xmlhttp
}

function returnAjaxResult(oprateType,id,val) {
	var v = val.split('<!--AjaxSplit-->');
	var t = id.split(',');
	for (var i = 0 ;i < t.length ;i ++ )
	{
		switch(oprateType){
			case 0 :
				if (document.getElementById(t[i])) {
					document.getElementById(t[i]).innerHTML = v[i];
				}
				break;
			case 1 :
				if (document.getElementById(t[i])) {
					document.getElementById(t[i]).value = v[i];
				}
				break;
			case 2 :
				return v[i];
				break;
			case 3 :
				alert(v[i]);
				break;
			case 4 :
				document.body.innerHTML = v[i];
				break;
			case 5 :
				document.write(v[i]);
			case 6 :
				location.href = v[i];
				break;
			case 7 :
				eval(v[i]);
				break;
			case 8 :
				alert(v[i]);
				location.reload();
				break;
			case 9:
				location.reload();
				break;
			default :
				break;
		}
	}
}

function getAjaxFilePath(url) {
	var temp = '';
	if (url.indexOf('/Lib/') >= 0) temp = url.substring(0,url.indexOf('/Lib/'));
	if (url.indexOf('../Inc/') >= 0) temp = '../';
	return temp;
}

function setCaret(textObj){
	if (textObj.createTextRange) textObj.caretPos = document.selection.createRange().duplicate();
}

function insertAtCaret(textObj,textFeildValue) {
	if(document.all) {
		if (textObj.createTextRange && textObj.caretPos) {
			var caretPos = textObj.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ''?textFeildValue + '' : textFeildValue;
		}
		else textObj.value = textFeildValue;
	}
	else{
		if(textObj.setSelectionRange){
			var rangeStart = textObj.selectionStart;
			var rangeEnd = textObj.selectionEnd;
			var tempStr1 = textObj.value.substring(0,rangeStart);
			var tempStr2 = textObj.value.substring(rangeEnd);
			textObj.value = tempStr1 + textFeildValue + tempStr2;
		}
		else alert("This version of Mozilla based browser does not support setSelectionRange");
	}
}

function GetLength(obj){
	var iLength ;
	if (getOs() == 'Opera') {
		iLength = document.getElementById(obj).value.replace(/[^\x00-\xff]/g,"**").length;
	}
	else {
		var oEditor = FCKeditorAPI.GetInstance(obj) ;
		var oDOM = oEditor.EditorDocument ;
		if ( document.all ) iLength = oDOM.body.innerText.length ;
		else{
			var r = oDOM.createRange() ;
			r.selectNodeContents( oDOM.body ) ;
			iLength = r.toString().length ;
		}
	}
	return iLength;
}

function createEditor(virtualRoot,toolBarSet,wid,hei,tagObj,showType) {
	var oFCKeditor = new FCKeditor('reviewCont_'+ tagObj) ;
	oFCKeditor.Config['CustomConfigurationsPath']	= virtualRoot +'/Lib/Editor/user_fckconfig.js' ;
	oFCKeditor.ToolbarSet							= toolBarSet;
	oFCKeditor.BasePath								= virtualRoot +'/Lib/Editor/' ;
	oFCKeditor.Width								= wid ;
	oFCKeditor.Height								= hei ;
	oFCKeditor.Value								= document.getElementById('reviewCont_'+ tagObj).value ;
	if (getOs() != 'Opera'){
		if (showType == 0) oFCKeditor.Create() ;
		else oFCKeditor.ReplaceTextarea() ;
	}
	if (document.getElementById('reviewSubmit_'+ tagObj)) document.getElementById('reviewSubmit_'+ tagObj).disabled = false;
	if (document.getElementById('reviewReset_'+ tagObj)) document.getElementById('reviewReset_'+ tagObj).disabled = false;
}

function InsertLocalFileToEditer(virtualRoot,filename,extname,filepath,filesize,tag) {
	if (typeof(FCKeditorAPI) == 'undefined') {
		alert('您尚未载入编辑器');
	}
	else {
		switch(extname){
		case 'jpg': case 'gif': case 'jpeg': case 'bmp': case 'png':
			InsertHTML(tag,'<img alt="'+ filename +'" title="'+ filename +'" src="'+ filepath +'" />');
			break;
		default :
			InsertHTML(tag,'<img src="'+ virtualRoot +'/Lib/Images/File/'+ extname +'.gif" style="border:0px; vertical-align:middle;" alt="" /> <a href="'+ unescape(filepath) +'" rel="external">'+ unescape(filename) +'.'+ extname +'</a> ['+ filesize +']');
			break;
		}
	}
}

function InsertHTML(obj,str){
	if (typeof(FCKeditorAPI) == 'undefined') {
		alert('请先将鼠标焦点定位于内容输入文本框以激活编辑器');
		 document.getElementById(obj).focus();
	}
	else {
		var oEditor = FCKeditorAPI.GetInstance(obj) ;
		if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ) oEditor.InsertHtml(str) ;
		else alert( '必须在可视化编辑模式方能插入您选定的内容' ) ;
	}
}

function SetContents(obj,str){
	if (document.getElementById(obj)) {
			var oEditor = FCKeditorAPI.GetInstance(obj) ;
			oEditor.SetHTML(str) ;
	}
}

function GetContents(obj){
	var oEditor = FCKeditorAPI.GetInstance(obj) ;
	var val = oEditor.GetXHTML(true);
	if (val == null) val = '';
	return val ;
}

function ExecuteCommand( obj,commandName ){
	var oEditor = FCKeditorAPI.GetInstance(obj) ;
	oEditor.Commands.GetCommand( commandName ).Execute() ;
}

function CreateFlash(obj,idad, swfurl, wad, had, vs){
	var FlashPic = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	if (wad) FlashPic += 'width="' + wad + '" ';
	if (had) FlashPic += 'height="' + had + '" ';
	FlashPic += 'id="'+ idad +'" align="middle">';
	FlashPic += '<param name="allowScriptAccess" value="always" />';
	FlashPic += '<param name="quality" value="high" />';
	FlashPic += '<param name="menu" value="false" />';
	FlashPic += '<param name="movie" value="'+ swfurl +'" />';
	FlashPic += '<param name="wmode" value="transparent" />';
	FlashPic += '<param name="flashvars" value="'+ vs +'" />';
	FlashPic += '<embed src="'+ swfurl +'" flashvars="'+ vs +'" wmode="transparent" quality="high" ';
	if (wad) FlashPic += 'width="'+ wad +'" ';
	if (had) FlashPic += 'height="'+ had +'" ';
	FlashPic += 'name="'+ idad +'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">';
	FlashPic += "</object>";
	document.getElementById(obj).innerHTML = FlashPic;
}
function LoadFlash(wmode,url,width,Height)
{
document.write('<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,2,0 width=' + width + ' height=' + Height + ' align="middle">');
document.write('<param name="movie" value="' + url + '">');
document.write(' <param name="quality" value="high">');
document.write('  <param name="wmode" value="' + wmode +'">');
document.write(' <embed src="' + url + '" width="' + width + '" height="' + Height + '" align="middle" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent">');
document.write('<param name="menu" value="false"/>');
document.write('</embed>');
document.write(' </object>');
}

function CheckChineseName(str){
	var str = str.substr(0,1);
	var surname = "赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵堪汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董粱杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯咎管卢莫经房裘缪干解应宗宣丁贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄魏加封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘姜詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲台从鄂索咸籍赖卓蔺屠蒙池乔阴郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍郤璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庚终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后江红游竺权逯盖益桓公万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于仲孙太叔申屠公孙乐正轩辕令狐钟离闾丘长孙慕容鲜于宇文司徒司空亓官司寇仉督子车颛孙端木巫马公西漆雕乐正壤驷公良拓拔夹谷宰父谷粱晋楚闫法汝鄢涂钦段干百里东郭南门呼延妫海羊舌微生岳帅缑亢况後有琴梁丘左丘东门西门商牟佘佴伯赏南宫墨哈谯笪年爱阳佟第五言福";
	r = surname.search(str);
	if(r == -1) return false
	else return true
}

function validateRealName(tag) {
	var result = true;
	if (document.getElementById(tag).value != ''){
		if (document.getElementById(tag).value.length <= 1){
			alert("真实姓名必须是两个字或以上！");
			document.getElementById(tag).focus();
			result = false;
		}
		var nnname = document.getElementById(tag).value;
		var reg = /^([\u4E00-\u9FA5])*$/;
		if(arr = nnname.match(reg)){
			if (!CheckChineseName(nnname)) {
				alert("真实姓名必须符合中文姓名规则及百家姓规范");
				document.getElementById(tag).focus();
				result = false;
			}
		}
		else{
			alert("真实姓名必须全部为中文");
			document.getElementById(tag).focus();
			result = false;
		}
	}
	else {
		alert("真实姓名必须是两个字或以上！");
		document.getElementById(tag).focus();
		result = false;
	}
	return result;
}

function validateLinkTel(obj,checkType,nullTF){
	var remark="";
	switch (parseInt(checkType)){
	case 1:
		remark="固定/传真";
		break;
	case 2:
		remark="手机号码";
		break;
	case 3:
		remark="联系电话";
		break;
	default:
		remark="";
		break;
	}
	var a = document.getElementById(obj).value;
	if(a == "" && nullTF == 1){
		alert(remark +'不能为空');
		document.getElementById(obj).focus();
		return false;
	}
	else if(a == "" && nullTF == 0){
		return true;
	}
	else if(a.match(/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/) && (checkType == "1" || checkType == "3")){
		return true;
	}
	else if(a.match(/^((\(\d{3}\))|(\d{3}\-))?13[0-9]\d{8}|18[89]\d{8}|15[0123689]\d{8}/) && (checkType == "2" || checkType == "3")){
		return true;
	}
	else{
		if (nullTF != 2) {
			alert('请填写正确的联系电话格式！\n固话：区号-号码-分机号\n手机：11位格式');
			document.getElementById(obj).focus();
		}
		return false;
	}
}

function validatePwd(tag){
	var a = document.getElementById(tag).value;
	if(a.length <6 || a.length >20){
		alert('密码不能空，或不能少于6位或大于20位');
		document.getElementById(tag).focus();
		return false;
	}else{
		return true;
	}
}

function validateEmail(tag) {
	var a = document.getElementById(tag).value;
	if (a != null && a.length > 4 && a.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
		return true;
	}else{
		alert('邮箱不能为空，且须有效邮箱！');
		document.getElementById(tag).focus();
		return false;
	}
}

Validator = {
	Require : /.+/,
	Email : /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
	Phone : /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/,
	Mobile : /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/,
	Url : /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\/':+!]*([^<>\"\"])*$/,
	IdCard : "this.IsIdCard(value)",
	Currency : /^\d+(\.\d+)?$/,
	Number : /^\d+$/,
	Zip : /^[1-9]\d{5}$/,
	QQ : /^[1-9]\d{4,8}$/,
	Integer : /^[-\+]?\d+$/,
	Double : /^[-\+]?\d+(\.\d+)?$/,
	English : /^[A-Za-z]+$/,
	Chinese :  /^[\u0391-\uFFE5]+$/,
	Username : /^[a-z]\w{3,}$/i,
	UnSafe : /^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*)|.{0,5})$|\s/,
	IsSafe : function(str){return !this.UnSafe.test(str);},
	SafeString : "this.IsSafe(value)",
	Filter : "this.DoFilter(value, getAttribute('accept'))",
	Limit : "this.limit(value.length,getAttribute('min'),  getAttribute('max'))",
	LimitB : "this.limit(this.LenB(value), getAttribute('min'), getAttribute('max'))",
	Date : "this.IsDate(value, getAttribute('min'), getAttribute('format'))",
	Repeat : "value == document.getElementsByName(getAttribute('to'))[0].value",
	Range : "getAttribute('min') < (value|0) && (value|0) < getAttribute('max')",
	Compare : "this.compare(value,getAttribute('operator'),getAttribute('to'))",
	Custom : "this.Exec(value, getAttribute('regexp'))",
	Group : "this.MustChecked(getAttribute('name'), getAttribute('min'), getAttribute('max'))",
	ErrorItem : [document.forms[0]],
	ErrorMessage : ["错误提示：\n"],
	Validate : function(theForm, mode){
		var obj = theForm || event.srcElement;
		var count = obj.elements.length;
		this.ErrorMessage.length = 1;
		this.ErrorItem.length = 1;
		this.ErrorItem[0] = obj;
		for(var i=0;i<count;i++){
			with(obj.elements[i]){
				var _dataType = getAttribute("dataType");
				if(typeof(_dataType) == "object" || typeof(this[_dataType]) == "undefined")  continue;
				this.ClearState(obj.elements[i]);
				if(getAttribute("require") == "false" && value == "") continue;
				switch(_dataType){
					case "IdCard" :
					case "Date" :
					case "Repeat" :
					case "Range" :
					case "Compare" :
					case "Custom" :
					case "Group" :
					case "Limit" :
					case "LimitB" :
					case "SafeString" :
					case "Filter" :
						if(!eval(this[_dataType]))	{
							this.AddError(i, getAttribute("msg"));
						}
						break;
					default :
						if(!this[_dataType].test(value)){
							this.AddError(i, getAttribute("msg"));
						}
						break;
				}
			}
		}
		if(this.ErrorMessage.length > 1){
			mode = mode || 1;
			var errCount = this.ErrorItem.length;
			switch(mode){
			case 2 :
				for(var i=1;i<errCount;i++)
					this.ErrorItem[i].style.color = "red";
			case 1 :
				alert(this.ErrorMessage.join("\n"));
				this.ErrorItem[1].focus();
				break;
			case 3 :
				for(var i=1;i<errCount;i++){
				try{
					var span = document.createElement("SPAN");
					span.id = "__ErrorMessagePanel";
					span.style.color = "red";
					this.ErrorItem[i].parentNode.appendChild(span);
					span.innerHTML = this.ErrorMessage[i].replace(/\d+:/,"* ");
					}
					catch(e){alert(e.description);}
				}
				this.ErrorItem[1].focus();
				break;
			default :
				alert(this.ErrorMessage.join("\n"));
				break;
			}
			return false;
		}
		return true;
	},
	limit : function(len,min, max){
		min = min || 0;
		max = max || Number.MAX_VALUE;
		return min <= len && len <= max;
	},
	LenB : function(str){
		return str.replace(/[^\x00-\xff]/g,"**").length;
	},
	ClearState : function(elem){
		with(elem){
			if(style.color == "red")
				style.color = "";
			var lastNode = parentNode.childNodes[parentNode.childNodes.length-1];
			if(lastNode.id == "__ErrorMessagePanel")
				parentNode.removeChild(lastNode);
		}
	},
	AddError : function(index, str){
		this.ErrorItem[this.ErrorItem.length] = this.ErrorItem[0].elements[index];
		this.ErrorMessage[this.ErrorMessage.length] = this.ErrorMessage.length + ":" + str;
	},
	Exec : function(op, reg){
		return new RegExp(reg,"g").test(op);
	},
	compare : function(op1,operator,op2){
		switch (operator) {
			case "NotEqual":
				return (op1 != op2);
			case "GreaterThan":
				return (op1 > op2);
			case "GreaterThanEqual":
				return (op1 >= op2);
			case "LessThan":
				return (op1 < op2);
			case "LessThanEqual":
				return (op1 <= op2);
			default:
				return (op1 == op2);
		}
	},
	MustChecked : function(name, min, max){
		var groups = document.getElementsByName(name);
		var hasChecked = 0;
		min = min || 1;
		max = max || groups.length;
		for(var i=groups.length-1;i>=0;i--)
			if(groups[i].checked) hasChecked++;
		return min <= hasChecked && hasChecked <= max;
	},
	DoFilter : function(input, filter){
return new RegExp("^.+\.(?=EXT)(EXT)$".replace(/EXT/g, filter.split(/\s*,\s*/).join("|")), "gi").test(input);
	},
	IsIdCard : function(number){
		var date, Ai;
		var verify = "10x98765432";
		var Wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
		var area = ['','','','','','','','','','','','北京','天津','河北','山西','内蒙古','','','','','','辽宁','吉林','黑龙江','','','','','','','','上海','江苏','浙江','安微','福建','江西','山东','','','','河南','湖北','湖南','广东','广西','海南','','','','重庆','四川','贵州','云南','西藏','','','','','','','陕西','甘肃','青海','宁夏','新疆','','','','','','台湾','','','','','','','','','','香港','澳门','','','','','','','','','国外'];
		var re = number.match(/^(\d{2})\d{4}(((\d{2})(\d{2})(\d{2})(\d{3}))|((\d{4})(\d{2})(\d{2})(\d{3}[x\d])))$/i);
		if(re == null) return false;
		if(re[1] >= area.length || area[re[1]] == "") return false;
		if(re[2].length == 12){
			Ai = number.substr(0, 17);
			date = [re[9], re[10], re[11]].join("-");
		}
		else{
			Ai = number.substr(0, 6) + "19" + number.substr(6);
			date = ["19" + re[4], re[5], re[6]].join("-");
		}
		if(!this.IsDate(date, "ymd")) return false;
		var sum = 0;
		for(var i = 0;i<=16;i++){
			sum += Ai.charAt(i) * Wi[i];
		}
		Ai +=  verify.charAt(sum%11);
		return (number.length ==15 || number.length == 18 && number == Ai);
	},
	IsDate : function(op, formatString){
		formatString = formatString || "ymd";
		var m, year, month, day;
		switch(formatString){
			case "ymd" :
				m = op.match(new RegExp("^((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})$"));
				if(m == null ) return false;
				day = m[6];
				month = m[5]*1;
				year =  (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10));
				break;
			case "dmy" :
				m = op.match(new RegExp("^(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))$"));
				if(m == null ) return false;
				day = m[1];
				month = m[3]*1;
				year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10));
				break;
			default :
				break;
		}
		if(!parseInt(month)) return false;
		month = month==0 ?12:month;
		var date = new Date(year, month-1, day);
        return (typeof(date) == "object" && year == date.getFullYear() && month == (date.getMonth()+1) && day == date.getDate());
		function GetFullYear(y){return ((y<30 ? "20" : "19") + y)|0;}
	}
 }

