	var messageNum;
	var messageStr;
	var individualWin = null;
	var editorWin = null;
	var novelWin = null;
	var articleWin = null;
	var messageWin = null;
	
	/*
	window.onbeforeunload = function() {
		if (individualWin!=null && individualWin.open) individualWin.close();
		if (editorWin!=null && editorWin.open) editorWin.close();
		if (novelWin!=null && novelWin.open) novelWin.close();
		if (articleWin!=null && articleWin.open) articleWin.close();
		if (messageWin!=null && messageWin.open) messageWin.close();
		window.event.cancelBubble = false;
	}
	*/
	
	function onIndividual(contextPath) {
		var url = contextPath + "/backend/userindex.jsp";
		individualWin = window.open(url,'win1','depended=yes,scrollbars=yes,toolbar=yes,titlebar=yes,resizable=yes,menubar=yes,location=yes,status=yes');
		return false;
	}
	
	function onEditor(contextPath) {
		var url = contextPath + "/backend/index.jsp";
		editorWin = window.open(url,'win2','depended=yes,scrollbars=yes,toolbar=yes,titlebar=yes,resizable=yes,menubar=yes,location=yes,status=yes');
		return false;
	}
	
	function onNovel(contextPath) {
		var url = contextPath + "/backend/userindex.jsp?oct=addnovel";
		novelWin = window.open(url,'win3','depended=yes,scrollbars=yes,toolbar=yes,titlebar=yes,resizable=yes,menubar=yes,location=yes,status=yes');
		return false;
	}
	
	function onArticle(contextPath) {
		var url = contextPath + "/backend/userindex.jsp?oct=addarticle";
		articleWin = window.open(url,'win4','depended=yes,scrollbars=yes,toolbar=yes,titlebar=yes,resizable=yes,menubar=yes,location=yes,status=yes');
		return false;
	}

	function onCorpus(contextPath,username) {
		var url = contextPath + "/Corpus.do?action=search&actionType=author&authorName="+username;
		articleWin = window.open(url);
		return false;
	}
		
	function sendMessage(contextPath) {
		var w = 630;
		var h = 425;
		if (document.all)
			var xMax = screen.width, yMax = screen.height;
		else if (document.layers)
			var xMax = window.outerWidth, yMax = window.outerHeight;
		else
			var xMax = 640, yMax=480;
		
		var xOffset = (xMax - w)/2, yOffset = (yMax - h)/2;
		var url = contextPath + "/message.do?action=bfedit&actionType=WRITE";
		messageWin = window.open(url,'win5','depended=yes,scrollbars=no,resizable=no,width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
		return false;
	}
	
	/*
	function onExit(contextPath, position) {
		if (individualWin!=null && individualWin.open) individualWin.close();
		if (editorWin!=null && editorWin.open) editorWin.close();
		if (novelWin!=null && novelWin.open) novelWin.close();
		if (articleWin!=null && articleWin.open) articleWin.close();
		if (messageWin!=null && messageWin.open) messageWin.close();
		window.location.href = contextPath + "/logoff.do?position=" + position;
		//location.replace(contextPath + "/logoff.do?position=" + position);
		return false;
	}
	*/
	
	function CheckForm() {
		if (document.all.item("userName").value=="") {
			alert("用户名不能为空!");
			document.all.item("userName").focus();
			return false;
		}
		if (document.all.item("password").value == "") {
			alert("密码不能为空!");
			document.all.item("password").focus();
			return false;
		}
		/*
		if (document.all.item("checkCode").value == "") {
			alert("验证码不能为空!");
			document.all.item("checkCode").focus();
			return false;
		}
		*/
	}
	
	function openScript(url, width, height) {
		var Win = window.open(url,"UserControlPad",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=yes,status=yes' );
	}
		
	function centerWindow(url,w,h,flag) {
		if (document.all)
			var xMax = screen.width, yMax = screen.height;
		else if (document.layers)
			var xMax = window.outerWidth, yMax = window.outerHeight;
		else
			var xMax = 640, yMax=480;
		
		var xOffset = (xMax - w)/2, yOffset = (yMax - h)/2;
		window.open(url,'centerwindow', 'scrollbars=YES,resizable='+flag+',width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+', top='+yOffset+',left='+xOffset+'');
		return false;
	}
    	
	function detectMessage(contextPath,pos,username) {
		try {
		xml = new ActiveXObject("Microsoft.XMLHTTP"); 
		var post="";
		xml.open("POST",contextPath+"/system/impulseMessage.jsp?username="+username,false);
		xml.setrequestheader("content-length",post.length); 
		xml.setrequestheader("content-type","application/x-www-form-urlencoded"); 
		xml.send(post);
		var res = xml.responseText;
		document.getElementById(pos).innerHTML=res;
		setTimeout("detectMessage('"+contextPath+"','"+pos+"','"+username+"')",60000);
		} catch (e) { }
		//setTimeout("detectMessage()",5000);
	}
	
	function popMessageAndRefresh(contextPath,pos,username) {
		try {
		centerWindowNoBar(contextPath+'/message.do?action=detail&incept='+username,630,425,'no');
		xml = new ActiveXObject("Microsoft.XMLHTTP"); 
		var post="";
		xml.open("POST",contextPath+"/system/impulseMessage.jsp?username="+username,false);
		xml.setrequestheader("content-length",post.length); 
		xml.setrequestheader("content-type","application/x-www-form-urlencoded"); 
		xml.send(post);
		var res = xml.responseText;
		document.getElementById(pos).innerHTML=res;
		} catch (e) { }
		return false;	
	}
	
	function onlinePing(contextPath) {
		try {
		xml = new ActiveXObject("Microsoft.XMLHTTP"); 
		var post="";
		xml.open("POST",contextPath+"/system/onlinePing.jsp",false);
		xml.setrequestheader("content-length",post.length); 
		xml.setrequestheader("content-type","application/x-www-form-urlencoded"); 
		xml.send(post);
		//var res = xml.responseText;
		//document.getElementById(pos).innerHTML=res;
		setTimeout("onlinePing()",60000*5);
		} catch (e) { }
	}

