﻿
//创建js类
var Class = {   
	create:function(){   
		return function(){   
			this.initialize.apply(this,arguments);   
		}   
	}   
}

var c_strToken_Level0="~`$^"; //通用ajax返回数据分割符
var c_strToken_Level1="#^"; //通用ajax返回数据分割符

function $G() {
	return document.getElementById(arguments[0]);
}

function LTrim(str){
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(0)) != -1){
        var j=0, i = s.length;
        while (j < i && whitespace.indexOf(s.charAt(j)) != -1){
            j++;
        }
        s = s.substring(j, i);
    }
    return s;
}
function RTrim(str){
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1){
	    var i = s.length - 1;
        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1){
            i--;
        }
        s = s.substring(0, i+1);
    }
    return s;
}
function Trim(str){
	return RTrim(LTrim(str));
}

function genStrLen(str){
	var len=0;	
	if(str != null && str.length>0){		
		for(var i=0;i<str.length;i++){
			char = str.charCodeAt(i);
			if(!(char>255)){
				len = len + 1;
			}else {
				len = len + 2;
			}
		}
	}
	return len;
} 

function genTxtIsNull(strTxt){
	if( strTxt==null || strTxt=="" ){
		return true;
	}else if (Trim(strTxt)==""){
		return true;
	}else{
		return false;
	}
}

function HTMLEncode(sVal) {
	if ( typeof( sVal ) != "string" ) {
		sVal = sVal.toString() ;
	}
	sVal = sVal.replace(/\n/g, "<br />");
	return sVal ;
}
function HTMLDecode(sVal) {
	if ( typeof( sVal ) != "string" ) {
		sVal = sVal.toString() ;
	}
	sVal = sVal.replace(/&amp;/g, "&") ;
	sVal = sVal.replace(/&quot;/g, '"') ;
	sVal = sVal.replace(/&lt;/g, "<") ;
	sVal = sVal.replace(/&gt;/g, ">") ;
	sVal = sVal.replace(/&#39;/g, "'") ;
	return sVal ;
}

//格式化日期
//参数就是日期的具体格式，例如:yyyy-MM-dd hh:mm:ss
Date.prototype.format = function(format)
{
    var o =
    {
        "M+" : this.getMonth()+1, //month
        "d+" : this.getDate(),    //day
        "h+" : this.getHours(),   //hour
        "m+" : this.getMinutes(), //minute
        "s+" : this.getSeconds(), //second
        "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
        "S" : this.getMilliseconds() //millisecond
    }
    if(/(y+)/.test(format))
    format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));
    for(var k in o)
    if(new RegExp("("+ k +")").test(format))
    format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
    return format;
}

Array.prototype.del=function(arrItem){
	for(var i=0; i<this.length ; i++){
		if(this[i]==arrItem){
			this.splice(i,1);
		}
	}
	return this;
}

Array.prototype.indexOf=function(object) {
    for (var i = 0; i < this.length; i++)
      if (this[i] == object) return i;
    return -1;
}

// 显示倒计时
function genShowCountDown(strExpireTime,strContainHtmlID){
	if( $G(strContainHtmlID)!=null){
		var dtExpire=new Date(strExpireTime);
		var dtNow=new Date();
		var nTimeDiff=(dtExpire.getTime()-dtNow.getTime());
		var nDiffSecond=nTimeDiff/1000
		var strSecondDiff=Math.floor(nDiffSecond);
		var nPerDay=24*60*60*1000
		var nDiffDays=nTimeDiff/nPerDay
		var strDaysOldDiff=Math.floor(nDiffDays);
		var strHrsDiff=(nDiffDays-strDaysOldDiff)*24;
		var strHrsOldDiff=Math.floor(strHrsDiff);
		var strMinDiff=(strHrsDiff-strHrsOldDiff)*60;
		var strMinOldDiff=Math.floor((strHrsDiff-strHrsOldDiff)*60);
		var strSecDiff=Math.floor((strMinDiff-strMinOldDiff)*60);
		if (strDaysOldDiff<0 || strHrsOldDiff<0 || strMinOldDiff<0 || strSecDiff<0) {
			$G(strContainHtmlID).innerHTML=genLang.HasExpire
			return;
		}
		$G(strContainHtmlID).innerHTML=strDaysOldDiff+genLang.Day+strHrsOldDiff+genLang.Hour+strMinOldDiff+genLang.Minute+"<span class='COMMON_CountDown_Second_span'>"+strSecDiff+"</span>"+genLang.Second;
		window.setTimeout("genShowCountDown('"+strExpireTime+"','"+strContainHtmlID+"')", 1000);
	}
}

function genIsNumber(oNum) {
	if(!oNum) return false;
	var strP=/^\d+(\.\d+)?$/;
	if(!strP.test(oNum)) return false;
	try{
		if(parseFloat(oNum)!=oNum) return false;
	} catch(ex) {
		return false;
	}
	return true;
}

function genIsValidUserName(strNick)
{
	var patrn=/^[A-Za-z]|[^u4E00-u9FA5]|[A-Za-z0-9_]+[A-Za-z0-9]$/;
	if (!patrn.exec(strNick)){
		alert(genLang.AlertInvalidNick);
		return false;
	}else{
		return true;
	}
}
function genIsValidLabelName(strLabelName)
{
	//var patrn=/["]/;	
	if (strLabelName.indexOf('\"')!=-1 || strLabelName.indexOf("\'")!=-1 ){
		alert(genLang.AlertInvalidLabel);
		return false;
	}else{
		//alert(strLabelName.indexOf('\"'));
		return true;
	}
}
function genHtmlIsBlank(strText)
{
	var patrn=/^<+[Pp]+>+[&#160;]+<+\/[Pp]+>$/;
	if (!patrn.exec(strText)){
		return false;
	}else{
		return true;
	}
}

function genIsValidEmail(strEmail){
	var patrn=/^[\w-\.]+@([\w-]+\.)+[a-zA-Z]{2,4}$/;
	if (!patrn.exec(strEmail)){ 
		alert(genLang.AlertInvalidEmail);
		return false;
	}else{
		return true;
	}	
}

function genCreateCookie(name,value,days) {
	var expires;
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
    	expires= "; expires="+date.toGMTString();
	}else{
		expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function genReadCookie(name,bchild) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = unescape(ca[i]);
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) {			
			if(bchild==null||bchild==false) return c.substring(nameEQ.length,c.length);
		}else{
			if(bchild){
				var cca=c.split('&');
				for(var j=0;j < cca.length;j++) {
					var cc = unescape(cca[j]);
					while (cc.charAt(0)==' ') cc = cc.substring(1,cc.length);
					if (cc.indexOf(nameEQ) == 0) {			
						return cc.substring(nameEQ.length,cc.length);
					}
				}
			}
		}
	}
	return null;
}

function genEraseCookie(name) {
	genCreateCookie(name,"",-1);
}

function genCopyText(obj) {
	ie = (document.all)? true:false
	if (ie){
		var rng = document.body.createTextRange();
		rng.moveToElementText(obj);
		rng.scrollIntoView();
		rng.select();
		rng.execCommand("Copy");
		rng.collapse(false);
	}
}

function genGetElementHeight(strHtmlID){
	var emDes=$G(strHtmlID);
	var nDesHeight=0;
	if( emDes!=null){
		var strBrowser=navigator.appName;
		if (strBrowser=="Microsoft Internet Explorer"){
			nDesHeight=emDes.currentStyle.height;
		}else{
			nDesHeight=window.getComputedStyle(emDes,null).height;
		}	
		nDesHeight=nDesHeight.substring(0,nDesHeight.length-2);
		nDesHeight=nDesHeight-0;
	}	
	return nDesHeight;
}

function genReCode(strText){
	return String(strText).replace(/\+/g,"%2B");
}

function genEscape(strText){
	return genReCode(encodeURIComponent(strText));
}

function genTextNotNullInit(emParent){
	if( emParent==null) emParent=document;
	var arremText=emParent.getElementsByTagName("INPUT");
	for (i=0;i<arremText.length;i++){
		if (arremText[i].className=="COMMON_NotNull_text") {
			genAddEvent(arremText[i],"focus",genTextNotNullRetClass);
		}
	}
}

function genTextNotNullRetClass(evt){
    evt = evt ? evt : (window.event ? window.event : null);
	if (window.event) {
		if( evt.srcElement.className=="COMMON_Alert_text"){
			evt.srcElement.className="COMMON_NotNull_text";
		}
	}else{
		if( evt.target.className=="COMMON_Alert_text"){
			evt.target.className="COMMON_NotNull_text";
			evt.preventDefault();
		}
	}
}
function genTextCheckNotNull(strParentHtmlID,strParamPrefix){
	var emParent=$G(strParentHtmlID);
	if( emParent==null){
		return false;
	}
	
	var arremTemp=emParent.getElementsByTagName("INPUT");	
	var bOK=true;
	var strReqForm="";
	var strParamName="";
	for (i=0;i<arremTemp.length;i++){
		if( arremTemp[i].type=="text" || arremTemp[i].type=="password" ){
			if( (arremTemp[i].className=="COMMON_NotNull_text" || arremTemp[i].className=="COMMON_Alert_text") && (genTxtIsNull(arremTemp[i].value)==true)){
				bOK=false;
				arremTemp[i].className="COMMON_Alert_text";				
			}else{
				if(strParamPrefix==""){
					strParamName=arremTemp[i].id;
				}else{
					strParamName=strParamPrefix+(i+1);
				}
				strReqForm+="&"+strParamName+"="+genEscape(arremTemp[i].value);
			}
		} else if (arremTemp[i].type=="checkbox") {
			if (arremTemp[i].className=="COMMON_NotNull_checkbox") {
				if(strParamPrefix==""){
					strParamName=arremTemp[i].id;
				}else{
					strParamName=strParamPrefix+(i+1);
				}
				var nGenCheckBoxCheckStat;
				nGenCheckBoxCheckStat = 0;
				if (arremTemp[i].checked) {
					nGenCheckBoxCheckStat = 1
				}
				strReqForm+="&"+strParamName+"="+nGenCheckBoxCheckStat;
			}
		}
	}
	if(bOK==false){
		alert(genLang.AlertNotNull);
		return false;
	}else{
		return strReqForm;
	}
}

function genAddEvent(obj, evenTypeName, fn){
 if (obj.addEventListener){
    obj.addEventListener(evenTypeName, fn, true);
    return true;
 } else if (obj.attachEvent){
    return obj.attachEvent("on"+evenTypeName, fn);
 } else {
    return false;
 }
}
function genRemoveEvent(obj, evenTypeName, fn){
	if (obj.removeEventListener){
		obj.removeEventListener(evenTypeName, fn, true);
		return true;
	} else if (obj.detachEvent){
		var r = obj.detachEvent("on"+evenTypeName, fn);
		return r;
	} else {
		alert("Handler could not be removed");
	}
}

function genRetPromptClear(strHtmlID){
	genDelElement(strHtmlID);
}
function genRetPrompt(strPrompt,strParentHtmlID,bNotDisplay){
	var emParent=$G(strParentHtmlID);
	if( emParent!=null){
		var strPromptHtmlID=strParentHtmlID+"_prompt";
		var emPrompt=$G(strPromptHtmlID);
		if(emPrompt!=null){
			emPrompt.innerHTML=strPrompt;			
		}else{
			emParent.innerHTML=emParent.innerHTML+"<div class=\"COMMON_CenterRow_div\" id=\""+strPromptHtmlID+"_out\"><div class=\"COMMON_Prompt_div\" id=\""+strPromptHtmlID+"\">"+strPrompt+"</div></div>";
		}
		if (bNotDisplay != true) {
			var strTemp="genRetPromptClear('"+strPromptHtmlID+"_out')";
			window.setTimeout(strTemp,10000);
		}
	}
}	

function CopyToClipboard(_id){
	var o=$G(_id);
	if(o==null) return;
	o.focus();
	o.select(); 
	CopiedTxt = document.selection.createRange();
	CopiedTxt.execCommand("Copy");
}

function genDrawAvatar(emImage){ 
	var objImage=new Image(); 
	objImage.src=emImage.src;
	alert(objImage.width);
}

function genDrawImage(emImage,nMaxWidth){ 
	var objImage=new Image(); 
	objImage.src=emImage.src;
	if(objImage.width>0 && objImage.height>0 ){
		if( (nMaxWidth<=0 || nMaxWidth==null)){
			nMaxWidth=screen.width*0.7;
		}		
		if(emImage.width>=nMaxWidth){ 
			emImage.width=nMaxWidth;
			emImage.height=(objImage.height*nMaxWidth)/objImage.width;
		}
	}
	//emImage.style.padding='2px';
} 

function genSetElementHeight(strHtmlID,nHeight){
	var emDes=$G(strHtmlID);
	if( emDes!=null){
		emDes.style.height=nHeight+"px";
		emDes.style.minHeight=nHeight+"px";				
	}	
}

function genChangeElementDisplay(strHtmlID,bDesStatus) {
	var emDes = $G(strHtmlID);
	if (emDes !=null) {
		if (bDesStatus==true) {
			emDes.style.display="";	
		} else {
			emDes.style.display="none";
		}	
	}
}
function genSwitchElementDisplay(strHtmlID) {
	$G(strHtmlID).style.display = $G(strHtmlID).style.display == "none" ? "" : "none";
}

function genShowHide(strHtmlID,_o,css){
	genSwitchElementDisplay(strHtmlID);
	if(_o!=null){		
		if($G(strHtmlID).style.display == "none")
			_o.className=css+"hide";
		else
			_o.className=css+"show";
	}
}

function genChangeElementBold(strHtmlID,bDesStatus) {
	var emDes = $G(strHtmlID);
	if (emDes != null) { 
		if (bDesStatus==false){
			emDes.style.fontWeight="";
		} else {
			emDes.style.fontWeight="bold";
		}
	}
}
function genDelElement(strHtmlID) {
	var emDes = $G(strHtmlID);
	if (emDes !=null) {
		emDes.parentNode.removeChild(emDes);
	}
}

function genCreateElement(cID,pID) {
	var emC=document.createElement("div");	
	var emP = $G(pID);
	emC.setAttribute("id",cID);
	if (emP !=null) {
		emP.appendChild(emC);
	}
}

function genChangeAHref(strHtmlID,strDesUrl) {
	var emDes = $G(strHtmlID);
	if (emDes != null) {
		emDes.href = strDesUrl;	
	}
}

function genChangeElementClass(strHtmlID,strDesClassName) {
	var emDes = $G(strHtmlID);
	if (emDes != null) {
		emDes.className = strDesClassName;	
	}
}

function genPromptTextOnBlur(emText){
	if (emText.value.length==0 || emText.className =="COMMON_PromptEdit_Idle_text"){
		emText.className ="COMMON_PromptEdit_Idle_text";
		emText.value = emText.title;
	}
}

function genPromptTextOnFocus(emText){
	if (emText.className=="COMMON_PromptEdit_Idle_text"){
		if(emText.value == emText.title){
	   		emText.value='';
		}
	   emText.className ="COMMON_PromptEdit_Normal_text";
	}
}

function genTextOnKeyDown(e,pEnterFunc,strParam,strAuxParam){
	e = e || event ;
	if( e.keyCode ==13)	{
		if(strAuxParam!=null)
			pEnterFunc(strParam,strAuxParam);
		else
			pEnterFunc(strParam);
	}
}

function genChangeRowsCheckStatus(strCheckHtmlName,bChecked,nLevel){
	var arremRowCheck=document.getElementsByName(strCheckHtmlName);
	if( arremRowCheck!=null){
		for (var i=0;i<arremRowCheck.length;i++) {
			arremRowCheck[i].checked=bChecked;
			genRowCheckOnClick(arremRowCheck[i],nLevel);
		}
	}
}

function genGetCheckedRowsValues(strCheckHtmlName,strToken){
	var bDesStatus=false;
	var strCheckedRowstrHtmlIDs = "";
	var strTemp = "";
	var arremRowCheck = document.getElementsByName(strCheckHtmlName);
	for (i=0;i<arremRowCheck.length;i++){
		if (arremRowCheck[i].checked){
			bDesStatus=true;
			strCheckedRowstrHtmlIDs += strTemp+arremRowCheck[i].value;
			strTemp=strToken;
		}
	}
	if ( strCheckedRowstrHtmlIDs==""){
		strCheckedRowstrHtmlIDs=arremRowCheck.value;	
	}
	if(arremRowCheck.checked==true||bDesStatus==true){
		return strCheckedRowstrHtmlIDs;
	} else {
		return "";
	}
}

function genRowCheckOnClick(emRowCheck,nLevel){
	if( nLevel>0){
		var emRow=emRowCheck;
		for(var i=0;i<nLevel;i++){
			emRow = emRow.parentNode;
		}
		genRowSetCheckStatus(emRow,emRowCheck.checked);
	}
}

function genRowSetCheckStatus(emRow,bchecked){
	if(bchecked) {
		emRow.style.background="#FFFFCE";
	} else {
		emRow.style.background="";
	}
}

function genRowClearFoucs(strHtmlID){
	var emRow=$G(strHtmlID);
	if( emRow!=null){
		genRowSetCheckStatus(emRow,false);
	}
}

function genRowSetFocus(strHtmlID){
	var emRow=$G(strHtmlID);
	if( emRow!=null){
		genRowSetCheckStatus(emRow,true);
		var strTemp="genRowClearFoucs('"+strHtmlID+"')";
		window.setTimeout(strTemp,3000);
	}
}

function genGetElemsByName(strName,strTagName){
	var emObj=document.getElementsByName(strName);
	if(emObj.length>0) {
	}else{
		emObj= new Array();
		var e = document.getElementsByTagName(strTagName);
		for(var i = 0; i < e.length; i++) {
			if(e[i].getAttribute("name") == strName) {
				emObj[emObj.length] = e[i];
			}
		}
	}
	return emObj;
}

// 切换展开区域的显示
function genSwitchExpandArea(strSwitchHtmlID,strAreaHtmlID,strSwitchCloseClass,strSwitchOpenClass){
	var objLoginTxtBox=$G("svAObj_LoginNickName_span");
	// 设置两种状态对应的单元显示状态
    var	strCloseDesDisplayStatus = "none";
    var	strOpenDesDisplayStatus = "";
	var emMsgPostButton = $G("uMs_MsgPost_Bt");	
	var nCurStatus = 0;
	var emSwitch = $G(strSwitchHtmlID);
	if(emMsgPostButton!=null){
		emMsgPostButton.disabled=false;	
	}
	if( emSwitch ==null){
		return;
	}
	var strDesName = emSwitch.innerHTML.replace(/\&nbsp\;/g, "");
	var emDes = $G(strAreaHtmlID);
	if (emDes != null) {
		if( genTxtIsNull(strSwitchCloseClass)==true) strSwitchCloseClass="COMM0N_Expand_Switch_Close_a";
		if( genTxtIsNull(strSwitchOpenClass)==true) strSwitchOpenClass="COMM0N_Expand_Switch_Open_a";
		if (emDes.style.display == strOpenDesDisplayStatus) {
			nCurStatus = 0;
			emDes.style.display = strCloseDesDisplayStatus;
			if( emSwitch !=null){
				emSwitch.className =strSwitchCloseClass ;
				emSwitch.title = genLang.ClickDisplay+strDesName;			
			}
		} else {
			nCurStatus = 1;
			emDes.style.display = strOpenDesDisplayStatus;
			if( emSwitch !=null){
				emSwitch.className=strSwitchOpenClass;
				emSwitch.title = genLang.ClickHide+strDesName;
			}
		}
	}	
	//return nCurStatus;
	if(objLoginTxtBox!=null){
		if(nCurStatus==1){
			objLoginTxtBox.innerHTML=genLang.UserName + ":";
			if($G("sv_AObj_Comm_PostAuthor_text")!=null){
				$G("sv_AObj_Comm_PostAuthor_text").value="";
			}
			if($G("av_Comm_PostAuthor_text")!=null){
				$G("av_Comm_PostAuthor_text").value="";
			}
		}
		else{
			objLoginTxtBox.innerHTML=genLang.VisitorID + ":";
			if($G("sv_AObj_Comm_PostAuthor_text")!=null){
				$G("sv_AObj_Comm_PostAuthor_text").value=genLang.Visitor;
			}
			if($G("av_Comm_PostAuthor_text")!=null){
				$G("av_Comm_PostAuthor_text").value=genLang.Visitor;				
			}
		}
	}
}

// 动态切换展开对象区域，如果还不存在，则先请求
function genDynamicSwitchExpandArea(strSwitchHtmlID,strAreaHtmlID,strReqURL,strReqForm,strSwitchCloseClass,strSwitchOpenClass){
	var emArea = $G(strAreaHtmlID);
	if(strAreaHtmlID=="uMs_Msg0_Post_Area_div"){
		if($G("uMs_Msg1_Post_Area_div")!=null){
			$G("uMs_Msg1_Post_Area_div").style.display="none";
		}
	}
	if(strAreaHtmlID=="uMs_Msg1_Post_Area_div"){
		if($G("uMs_Msg0_Post_Area_div")!=null){
			$G("uMs_Msg0_Post_Area_div").style.display="none";
		}
	}
	if(emArea.style.display=="none" && emArea.innerHTML=="" ){
		// 向服务器申请构造对应编辑操作界面
		function responseProcess(strResponseHtml){
			emArea.innerHTML = strResponseHtml;
			genSwitchExpandArea(strSwitchHtmlID,strAreaHtmlID,strSwitchCloseClass,strSwitchOpenClass);
		}		
		genXMLHttpReq(1,strReqURL,strReqForm,responseProcess);
	}else{
		genSwitchExpandArea(strSwitchHtmlID,strAreaHtmlID,strSwitchCloseClass,strSwitchOpenClass);
	}
}

function genGetViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}
function genGetViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

function genShowLoader(){
	var emLoad=$G("loader_div");
	if( emLoad!=null){ 
		var theBody = document.documentElement;
		
		var scTop = parseInt(theBody.scrollTop,10)+10;
		var scLeft = parseInt(theBody.scrollLeft,10)+10;
						
		emLoad.style.top = (scTop ) + "px";
		emLoad.style.left =  (scLeft+(genGetViewportWidth()*7/8)) + "px";
		emLoad.style.display="block";
	}
}

function genHideLoader(){
	var emLoad=$G("loader_div");
	if( emLoad!=null){ 		
		emLoad.style.display="none";
	}
}

function genCreateXMLHTTP(){
	var objXMLHTTP=null;
	if (window.XMLHttpRequest) {
    	objXMLHTTP = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
    	objXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHTTP;
}

function genXMLHttpReq(nReqType,strReqOpenUrl,strReqParam,pResponseFunc,bNoLoader){
	if( nReqType<0 || nReqType>1)
		return;
	var objXMLHTTP = genCreateXMLHTTP();
	if (objXMLHTTP!=null){
		function responseProcess() {
			if (objXMLHTTP.readyState==4){
				pResponseFunc(objXMLHTTP.responseText);
				genHideLoader();
			}else{
				if(bNoLoader!=true){
					genShowLoader();
				}
			}
		}
		objXMLHTTP.onreadystatechange = responseProcess;
		if( nReqType==0){
			objXMLHTTP.open("GET",strReqOpenUrl,true);
			objXMLHTTP.send(null);
		}else{
			objXMLHTTP.open("POST",strReqOpenUrl,true);
			objXMLHTTP.setRequestHeader("content-type","application/x-www-form-urlencoded");
			objXMLHTTP.send(strReqParam);
		}		
	}
}

//=================提醒加亮样式================
var arrNotice = new Array();
var objNoticeClass = new Object();
var tmpNotices = new Array();;
var tiNotice = new Array();
var ctNotices = 4;

function genNoticeInput(obj,hTarget){
	var noticeObj= $G(obj);
	if (noticeObj) {
		try{if (arrNotice[obj].status) {return}}catch(e){}
		with(noticeObj.style){
			objNoticeClass.backgroundColor=backgroundColor;
			objNoticeClass.borderColor=borderColor;
			objNoticeClass.borderStyle=borderStyle;
			objNoticeClass.hiddenTarget=$G(hTarget);
			objNoticeClass.status=true;
		}
		arrNotice[obj]=objNoticeClass;
		noticeObj.style.backgroundColor = "#ff9";
		noticeObj.style.borderColor = "#f60";
		noticeObj.style.borderStyle = "solid";
		noticeObj.select();
		genAddEvent(noticeObj,"keydown",genNoticeClear);
		window.clearInterval(tiNotice[obj]);
		tmpNotices[obj]=1;
		genNoticeAction(obj);
		tiNotice[obj] = window.setInterval("genNoticeAction('"+obj+"')",400)
	}
}

function genNoticeAction(obj){
	var noticeObj= $G(obj);
	if (tmpNotices[obj]>=ctNotices) {window.clearInterval(tiNotice[noticeObj.id]);return}
	with(noticeObj.style){
		if (Math.pow(-1,tmpNotices[obj])<0) {
			backgroundColor = "#ff9";
			borderColor = "#f60";
			borderStyle = "solid";
		}
		else
		{
			backgroundColor = arrNotice[noticeObj.id].backgroundColor;
			borderColor = arrNotice[noticeObj.id].borderColor;
			borderStyle = arrNotice[noticeObj.id].borderStyle;
		}

	}
	tmpNotices[obj]++;
}

function genNoticeClear(evt){
	var evtSrc;
    evt = evt ? evt : (window.event ? window.event : null);
	if (window.event) evtSrc=evt.srcElement; else evtSrc=evt.target; 
		with(evtSrc.style){
			window.clearInterval(tiNotice[evtSrc.id]);
			backgroundColor = arrNotice[evtSrc.id].backgroundColor;
			borderColor = arrNotice[evtSrc.id].borderColor;
			borderStyle = arrNotice[evtSrc.id].borderStyle;
			if (arrNotice[evtSrc.id].hiddenTarget) {arrNotice[evtSrc.id].hiddenTarget.style.display="none"}
			arrNotice[evtSrc.id].status=false;
		}
		genRemoveEvent(evtSrc,"keydown",genNoticeClear);
}

function genPopSelectSwitch(strCurItemHtmlID,strSwitchHtmlID,strValueHtmlID,strOldValue,strNewValue,pReturnFunc){
	var emCurItem=$G(strCurItemHtmlID);
	var emSwitch=$G(strSwitchHtmlID);
	emSwitch.innerHTML=emCurItem.innerHTML;
	var strTemp=emSwitch.href;
	strTemp=strTemp.replace(strOldValue,strNewValue);	
	emSwitch.href=strTemp;
	var emValue=$G(strValueHtmlID);
	if( emValue!=null){
		emValue.value=strNewValue;
	}
	if( pReturnFunc!=null){
		pReturnFunc(strOldValue,strNewValue,emCurItem);
	}
	genPopSelectClose(null,1);
}

function genGetPos(emDes){
	this.Left=0;
	this.Top=0;
	var strTempLeft="";  
	this.Width=emDes.offsetWidth;
	this.Height=emDes.offsetHeight;
	while (emDes.tagName.toLowerCase()!="body"){
		this.Left+=emDes.offsetLeft;
		this.Top+=emDes.offsetTop;
		emDes=emDes.offsetParent;
		strTempLeft+=emDes.offsetLeft+",";
	}
}

function genPopSelectOpenByID(strSwithcHtmlID,strContentHtmlID){
	  var emSwitch=$G(strSwithcHtmlID);
	  if( emSwitch != null) {
		  	genPopSelectOpen(emSwitch,strContentHtmlID);
	  }	
}

function genPopSelectOpen(emSwitch,strContentHtmlID){
	var strPopInHtml=$G(strContentHtmlID).innerHTML;
	genPopSelectOpenInner(emSwitch,strPopInHtml);
}
function genPopSelectOpenInner(emSwitch,strPopInHtml){
	var getAPos=new genGetPos(emSwitch);
	var emPopSelect=$G("ps_Container_div");
	if (emPopSelect!=null) {
		emPopSelect.parentNode.removeChild(emPopSelect);
	}
	var emPopSelect=document.createElement("DIV");
	emPopSelect.id="ps_Container_div";
	emPopSelect.className="PS_Container_div";
	emPopSelect.innerHTML=strPopInHtml;
	emPopSelect.style.position="absolute";
	emPopSelect.style.zIndex="201";
	emPopSelect.style.left=getAPos.Left+"px"; 
	emPopSelect.style.width=108+"px";
	emPopSelect.style.top=getAPos.Top+getAPos.Height-1+"px";
	document.body.appendChild(emPopSelect);
	genAddEvent(document.body,"mousedown",genPopSelectClose)
}

function genPopSelectClose(evt,n){	
	var emPopSelect=$G("ps_Container_div");
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
    if (emPopSelect!=null) emPopSelect.parentNode.removeChild(emPopSelect);
	genRemoveEvent(document.body,"mousedown",genPopSelectClose);
}

function genIsOnPopArea(evt,n,emPopSelect){
	evt = genGetEvent(evt);
	var theBody = document.documentElement;
	if(emPopSelect==null) return;
	if (!n && parseFloat(emPopSelect.style.left)<parseFloat(evt.clientX) && (parseFloat(emPopSelect.style.left)+parseFloat(emPopSelect.offsetWidth))>parseFloat(evt.clientX) && parseFloat(emPopSelect.style.top)<(parseFloat(evt.clientY)+parseFloat(theBody.scrollTop)) && (parseFloat(emPopSelect.style.top)+parseFloat(emPopSelect.offsetHeight))>(parseFloat(evt.clientY)+parseFloat(theBody.scrollTop))) {
		return false;
	}else{
		return true;
	}
}

function genSubjPopSelectClose(evt,n){
	var strHtmlIDPrefix,emPopSelect;
	if($('.CLUB_SortAux_div')!=null){
		strHtmlIDPrefix=$('.CLUB_SortAux_div').attr("sel");
		emPopSelect=$G(strHtmlIDPrefix+"_SortAux_div");
	}
	if($('.PS_Container_div')!=null){
		strHtmlIDPrefix=$('.PS_Container_div').attr("sel");
		emPopSelect=$G(strHtmlIDPrefix+"_Container_div");
	}
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.style.display="none";
	genRemoveEvent(document.body,"mousedown",genSubjPopSelectClose)
}

function genEditSubjPopSelClose(evt,n){
	var emPopSelect=$G("se_Title_Prompt_span");
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.style.display="none";
	genRemoveEvent(document.body,"mousedown",genEditSubjPopSelClose)
}

function genRolGroupPopSelClose(evt,n){
	var emPopSelect=$G("se_RoleGroup_div");
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.style.display="none";
	genRemoveEvent(document.body,"mousedown",genRolGroupPopSelClose)
}

function genMoreSelClose(evt,n){
	var emPopSelect=$G("club_MoreSelect_div");
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.style.display="none";
	genRemoveEvent(document.body,"mousedown",genMoreSelClose)
}

function genMoreSelItemClose(evt,n){
	var emPopSelect=$G("club_MoreSelectItem_div");
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.style.display="none";
	genRemoveEvent(document.body,"mousedown",genMoreSelItemClose)
}

function genCrSubjAlertClose(evt,n){
	var emPopSelect=$G("se_CrSubjRight_div");
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.style.display="none";
	genRemoveEvent(document.body,"mousedown",genCrSubjAlertClose)
}

function genUserSubjClose(evt,n){
	var emPopSelect=$G("uTASK_ExpUserSubjInfo"+$G("uTASK_CurUserID_hidden").value+"_div");
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.style.display="none";
	genRemoveEvent(document.body,"mousedown",genUserSubjClose)
}

function genSubjInfoClose(evt,n){
	var emPopSelect=$G("uTASK_ExpSubjInfo"+$G("uTASK_SelSubjID_hidden").value+"_div");
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.style.display="none";
	genRemoveEvent(document.body,"mousedown",genSubjInfoClose)
}

function genRemoveKeyW(){
	var parentNode=$G("pagehead_div");
	var emPopDiv=$G("pagehead_AllKeyword_div");
	if (emPopDiv!=null) parentNode.removeChild(emPopDiv);
}

function genAllKeywDivRemove(evt,n){
	var parentNode=$G("pagehead_div");
	var emPopSelect=$G("pagehead_AllKeyword_div");
	if (emPopSelect==null) return;
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.parentNode.removeChild(emPopSelect);
	genRemoveEvent(document.body,"mousedown",genAllKeywDivRemove)
}

function genVersionDivRemove(evt,n){
	var parentNode=$G("pagehead_div");
	var emPopSelect=$G("pagehead_Version_div");
	if (emPopSelect==null) return;
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.parentNode.removeChild(emPopSelect);
	genRemoveEvent(document.body,"mousedown",genVersionDivRemove)
}

function genAllRoleListDivRemove(evt,n){
	var parentNode=$G("pagemain_div");
	var emPopSelect=$G("aUs_AllRoleList_div");
	if (emPopSelect==null) return;
	if(!genIsOnPopArea(evt,n,emPopSelect)) return;	
	
    if (emPopSelect!=null) emPopSelect.parentNode.removeChild(emPopSelect);
	genRemoveEvent(document.body,"mousedown",genAllRoleListDivRemove)
}

function genGetEvent(evt){
	evt=evt?evt:(window.event?window.event:null);
	return evt
}

function genInplaceEditSwitch(strHtmlIDPrefix,nObjID,strHtmlIDSuffix,strTagName,pFunc,strReqOpenUrl,strReqForm){
	var emSrcRow=$G(strHtmlIDPrefix+nObjID+strHtmlIDSuffix);	
	var emEditRow=$G(strHtmlIDPrefix+nObjID+"_Edit"+strHtmlIDSuffix);
	if( emEditRow.style.display=="none"){
		function responseProcess(strResponseHtml){
			strResponseHtml+="&nbsp;<input type=\"button\" class=\"COMMON_button\" onclick=\"genInplaceEditSwitch('"+strHtmlIDPrefix+"',"+nObjID+",'"+strHtmlIDSuffix+"','"+strTagName+"','');\" value=\""+genLang.Cancel+"\">";			
			emEditRow.innerHTML=strResponseHtml;
			genTextNotNullInit(emEditRow);
			emEditRow.style.display="";		
			if( emSrcRow!=null)	emSrcRow.style.display="none";
		}
		if( genTxtIsNull(strReqOpenUrl)==true){
			var strTemp="",strTextFlag="",strTextClass="COMMON_text";
			var arremItem = emSrcRow.getElementsByTagName(strTagName);	
			for (var i=0; i<arremItem.length; i++ ){ 
				if( arremItem[i].id !="" ){
					if( arremItem[i].getAttribute("notnull")=="1"){
						strTextFlag="<font color=\"#FF0000\">*</font>";
						strTextClass="COMMON_NotNull_text";
					}else{
						strTextFlag="";
						strTextClass="COMMON_text";
					}
					strTemp+="&nbsp;"+arremItem[i].title+strTextFlag+"<input id=\""+arremItem[i].id+"_text\" type=\"text\" class=\""+strTextClass+"\" title=\""+arremItem[i].title+"\" value=\""+Trim(arremItem[i].innerHTML)+"\"/>&nbsp;"
				}
			}		
			strTemp+="<input type=\"button\" class=\"COMMON_button\" onclick=\""+pFunc+";\" value=\"";
			if (nObjID>0){
				strTemp+=genLang.Update;
			}else{
				strTemp+=genLang.New;
			}
			strTemp+="\">"
			responseProcess(strTemp);
		}else{
			genXMLHttpReq(1,strReqOpenUrl,strReqForm,responseProcess);
		}		
	}else{
		if( emSrcRow!=null && parseInt(emEditRow.getAttribute("mID"))>0) {
			emSrcRow.style.display="";		
		}
		emEditRow.style.display="none";	
	}
}


/*tooltip*/
// Extended Tooltip Javascript
// copyright 9th August 2002, 3rd July 2005
// by Stephen Chapman, Felgall Pty Ltd

// permission is granted to use this javascript provided that the below code is not altered/
var DH = 0;var an = 0;var al = 0;var ai = 0;
if (document.getElementById) {
	ai = 1; DH = 1;
}else {
	if (document.all) {
		al = 1; DH = 1;
	} else { 
		browserVersion = parseInt(navigator.appVersion); 
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			an = 1; DH = 1;
		}
	}
} 
function fd(oi, wS) {
	if (ai) return wS ? $G(oi).style:$G(oi); 
	if (al) return wS ? document.all[oi].style: document.all[oi]; 
	if (an) return document.layers[oi];
}
function pw() {
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}
function mouseX(evt) {
	evt=genGetEvent(evt);
	if (evt.pageX!=null) 
		return evt.pageX; 
	else if (evt.clientX!=null)
		return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); 
	else
		return null;
}
function mouseY(evt) {
	evt=genGetEvent(evt);
	if (evt.pageY!=null) 
		return evt.pageY; 
	else if (evt.clientY!=null)
		return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
	else return 
		null;
}
function genTipPopUp(evt,oi) {
	if (DH) {
		var wp = pw(); 
		ds = fd(oi,1); 
		dm = fd(oi,0); 
		st = ds.visibility; 
		if (dm.offsetWidth) 
			ew = dm.offsetWidth; 
		else if (dm.clip.width) 
			ew = dm.clip.width; 
		if (st == "visible" || st == "show") { 
			ds.visibility = "hidden"; 
		} else {
			tv = mouseY(evt) + 20; 
			lv = mouseX(evt) - (ew/4); 
			if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2; 
			if (!an) {lv += 'px';tv += 'px';} 
			ds.left = lv; 
			ds.top = tv;
			ds.visibility = "visible";
		}
	}
}
//上传判断是否合法通用函数
function genCheckUpload(patrn,strUploadValue) {
	var strUploadValue=strUploadValue.substring(strUploadValue.lastIndexOf('.'),strUploadValue.length).toLowerCase();
	return patrn.test(strUploadValue)
}


//////////窗体打开函数/////////////

function pwGetViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}
function pwGetViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

var gPopupContainer = null;
var gPopFrame = null;
var gpRetFunc;
var gPopupIsShown = false;
var gHideSelects = false;

var gTabIndexes = new Array();
var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");	

function pwLocationReload(){
	location.reload();
}

function pwInit() {
	gPopupMask = document.getElementById("popupMask");
	gPopupContainer = document.getElementById("popup_Container_div");
	gPopFrame = document.getElementById("popup_Frame_iframe");	
	
	var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
	if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
		gHideSelects = true;
	}
}
genAddEvent(window, "load", pwInit);

function pwShow(url, width, height,nPos,pRetFunc,strRetFuncParam) {
	if(gPopupContainer==null){
		pwInit();
	}
	gPopupIsShown = true;
	pwDisableTabIndexes();
	if(gPopupMask) gPopupMask.style.display = "block";
	if(gPopupContainer) gPopupContainer.style.display = "block";
	pwSetPos(width, height,nPos);
	document.getElementById("popup_Title_div").innerHTML=genLang.Loading;
	var nTitleBarHeight = parseInt(document.getElementById("popup_TitleBar_div").offsetHeight, 10);
	if (navigator.product == 'Gecko') { width = width + 6; height = height+6; }
	
	gPopupContainer.style.width = width + "px";
	gPopupContainer.style.height = (height+nTitleBarHeight) + "px";
	gPopFrame.style.width =parseInt(document.getElementById("popup_TitleBar_div").offsetWidth, 10) + "px";
	gPopFrame.style.height = parseInt(height)-4 + "px";
	gPopFrame.src = url;
	
	gpRetFunc = pRetFunc;
	gstrRetFuncParam=strRetFuncParam;
	
	if (gHideSelects == true) {
		pwHideSelectBoxes();
	}
	
	window.setTimeout("pwSetTitle();", 2000);
}

var gi = 0;
function pwSetPos(width, height,nPos) {
	if( nPos==null){
		nPos=1;
	}
	if (gPopupIsShown == true) {
		if (width == null || isNaN(width)) {
			width = gPopupContainer.offsetWidth;
		}
		if (height == null) {
			height = gPopupContainer.offsetHeight;
		}
		
		var fullHeight = pwGetViewportHeight();
		var fullWidth = pwGetViewportWidth();
		
		var theBody = document.documentElement;
		
		var scTop = parseInt(theBody.scrollTop,10);
		var scLeft = parseInt(theBody.scrollLeft,10);
				
		gPopupMask.style.height = fullHeight + "px";
		gPopupMask.style.width = fullWidth + "px";
		gPopupMask.style.top = scTop + "px";
		gPopupMask.style.left = scLeft + "px";
		
		window.status = gPopupMask.style.top + " " + gPopupMask.style.left + " " + gi++;
						
		var nTitleBarHeight = parseInt(document.getElementById("popup_TitleBar_div").offsetHeight, 10);
		
		gPopupContainer.style.top = (scTop + ((fullHeight - (height+nTitleBarHeight)) / 2)) + "px";
		
		var nLeftOffset=0;
		switch(nPos){
		case 0: // 靠左
			nLeftOffset=0;	
			break;
		case 1: // 居中
			nLeftOffset=(fullWidth - width) / 2
			break;
		case 2: // 靠右
			nLeftOffset=(fullWidth - width)-25;	
			break;
		default:
			break;
		}
	
		gPopupContainer.style.left =  (scLeft + nLeftOffset) + "px";
	}
}
genAddEvent(window, "resize", pwSetPos);
//genAddEvent(window, "scroll", pwSetPos);
window.onscroll = pwSetPos;

function pwHide(callpRetFunc) {
	gPopupIsShown = false;
	pwRestoreTabIndexes();
	if (gPopupMask == null) {
		return;
	}
	gPopupMask.style.display = "none";	
	if (gPopupContainer == null) {
		return;
	}
	gPopFrame.src = '/Common/cmPopWinLoading.html';
	gPopupContainer.style.display = "none";
	if (callpRetFunc == true && gpRetFunc != null) {

		gpRetFunc(gstrRetFuncParam,window.frames["popup_Frame_iframe"].returnVal);
	}
	if (gHideSelects == true) {
		pwDisplaySelectBoxes();
	}
}

function pwSetTitle() {
	if (window.frames["popup_Frame_iframe"].document.title == null) {
		window.setTimeout("pwSetTitle();", 10);
	} else {
		document.getElementById("popup_Title_div").innerHTML = window.frames["popup_Frame_iframe"].document.title;
	}
}

function pwKeyDownHandler(e) {
    if (gPopupIsShown && e.keyCode == 9)  return false;
}
if (!document.all) {
	document.onkeypress = pwKeyDownHandler;
}

function pwDisableTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				gTabIndexes[i] = tagElements[k].tabIndex;
				tagElements[k].tabIndex="-1";
				i++;
			}
		}
	}
}

function pwRestoreTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				tagElements[k].tabIndex = gTabIndexes[i];
				tagElements[k].tabEnabled = true;
				i++;
			}
		}
	}
}

function pwHideSelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if(document.forms[i].elements[e].tagName == "SELECT") {
				document.forms[i].elements[e].style.visibility="hidden";
			}
		}
	}
}

function pwDisplaySelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if(document.forms[i].elements[e].tagName == "SELECT") {
			document.forms[i].elements[e].style.visibility="visible";
			}
		}
	}
}

function getMouseOffset(target, ev){
	ev = ev || window.event;
	var docPos = getPos(target);
	var mousePos = getmousePos(ev);
	return {x:mousePos.x - docPos.x,y:mousePos.y - docPos.y};
}

function getPos(e){
	var left = 0;
	var top = 0;
	if(!(document.all?true:false)){		
		while (e.offsetParent)
		{
			left += e.offsetLeft + (e.Style?(parseInt(e.Style.borderLeftWidth)).NaN0():0);
			top += e.offsetTop + (e.Style?(parseInt(e.Style.borderTopWidth)).NaN0():0);
			e = e.offsetParent;
		}
		left += e.offsetLeft + (e.Style?(parseInt(e.Style.borderLeftWidth)).NaN0():0);
		top += e.offsetTop + (e.Style?(parseInt(e.Style.borderLeftWidth)).NaN0():0);
		return {x:left, y:top};
	}else{
		while (e.offsetParent)
		{
			left += e.offsetLeft;
			top += e.offsetTop;
			//alert(e.offsetParent.tagName+"/"+left+"/"+top);
			e = e.offsetParent;
		}
		left += e.offsetLeft;
		top += e.offsetTop;		
		return {x:left, y:top};
	}
}
function getmousePos(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	if(document.body){
		return {
			x:ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft,
			y:ev.clientY + document.documentElement.scrollTop  - document.documentElement.clientTop
		};
	}else{		
		return {
			x:ev.clientX - 2,
			y:ev.clientY - 2
		};
	}
}

function oeGetKWArr(strGetKWs,bIsTrim) {
	if (bIsTrim==true) {
		strGetKWs=RTrim(LTrim(strGetKWs));
		strGetKWs=strGetKWs.replace(/(\s+)/g,' ');
	}
	var strGetKWTemp=strGetKWs.replace(/[ ]/g,'');
	if (strGetKWTemp !='' && strGetKWTemp !=null ) {
		return strGetKWs.split(/[ ]/g);
		//return strGetKWs.split(/[,\.\|\  ]/g);
	} else {
		return null;
	}
}

function genRplEmToImg(txt){
	txt=txt.replace(/\[em\d\d\]/g,'<img/>');
	return txt;
}
			
function genCtrlElemInScreen(_o,_x,_y,_xw,_yh){
	if(_x+_xw>document.documentElement.clientWidth+document.documentElement.scrollLeft) 
		_o.style.left=_x-_xw+"px";
	else 
		_o.style.left=_x+"px";
	if(_y+_yh>document.documentElement.clientHeight+document.documentElement.scrollTop) 
		_o.style.top=_y-_yh+"px";	
	else	
		_o.style.top=_y+"px";
}

function genCreateShadow(obj){
	emPop=document.createElement("DIV");
	emPop.id="im_shadow";
	emPop.className="im_shadow";
	emPop.style.zIndex="50005";
	emPop.style.position="absolute";
	emPop.style.width=obj.clientWidth+"px"; 
	emPop.style.height=obj.clientHeight+"px";
	emPop.style.left=obj.style.left; 
	emPop.style.top=obj.style.top;
	document.body.appendChild(emPop);
}
function genCountLeftLetter(_o,nTotal){
	var oeL=$G("LCount");
	if(oeL==null) return;
	var nCurLen=_o.value.length;
	if(nCurLen>nTotal) {
		_o.value=_o.value.slice(0,nTotal);
		_o.scrollTop = _o.scrollHeight;
		return;
	}
	oeL.innerHTML=nTotal-nCurLen;
}

function drag(o,s,dr){
	var nscrollTop=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop; 
	var nscrollLeft=document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft; 
	var _o=null;
	if(o=="mcs_im") {
		_o=$G("x-tool-move");		
	}else if(o=="pop_grp") {
		_o=$G("x-tool-move-grp");
	}else if(o=="pop_fri") {
		_o=$G("x-tool-move-fri");
	}else if(o=="pop_str") {
		_o=$G("x-tool-move-str");
	}else{
		_o=$G("x-tool-move-"+o.toString());		
	}	
	if (typeof o == "string") o = $G(o);
	else if(typeof o=="number") o = $G("pop_window_"+o.toString());
	o.orig_x = parseInt(o.style.left) - document.documentElement.scrollLeft;
	o.orig_y = parseInt(o.style.top) - document.documentElement.scrollTop;
	o.orig_index = o.style.zIndex;
	if(dr&&_o!=null){
		_o.onmousedown = function(a){
			genCreateShadow(o);
			emPop=$G("im_shadow");
			var d=document;
			if(!a)a=window.event;
			var mP=getmousePos(a);
			var x = mP.x+d.documentElement.scrollLeft-o.offsetLeft;
			var y = mP.y+d.documentElement.scrollTop-o.offsetTop;
			//author: www.longbill.cn		
	
			if(emPop.setCapture)
				emPop.setCapture();
			else if(window.captureEvents)
				window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
			d.onmousemove = function(evt){
				d.ondragstart = "return false;"
				d.onselectstart = "return false;"
				d.onselect = "document.selection.empty();"
				emPop=$G("im_shadow");
				if(!evt)evt=window.event;
				mP=getmousePos(evt);
				//alert(mP.x+"/"+mP.y);
				emPop.style.left = mP.x+d.documentElement.scrollLeft-x+"px";
				emPop.style.top = mP.y+d.documentElement.scrollTop-y+"px";	 
				o.orig_x = parseInt(emPop.style.left) - d.documentElement.scrollLeft;
				o.orig_y = parseInt(emPop.style.top) - d.documentElement.scrollTop;
			}
			d.onmouseup = function(){
				emPop=$G("im_shadow");
				o.style.left = parseInt(emPop.style.left)+"px";
				o.style.top = parseInt(emPop.style.top)+"px";
			
				if(emPop.releaseCapture)
					emPop.releaseCapture();
				else if(window.captureEvents)
					window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
				emPop.parentNode.removeChild(emPop);
				d.onmousemove = null;
				d.onmouseup = null;
				d.ondragstart = null;
				d.onselectstart = null;
				d.onselect = null;
				o.style.cursor = "normal";
			}
		}
	}
	if (s){	
		var orig_scroll = window.onscroll?window.onscroll:function (){};
		window.onscroll = function (){
			orig_scroll();	   
			o.style.left = o.orig_x + document.documentElement.scrollLeft+"px";
			o.style.top = o.orig_y + document.documentElement.scrollTop+"px";	   
		}
	}
}

function genDrag(o,s,dr){
	var _o=$G("x-tool-move");	
	o.orig_x = parseInt(o.style.left) - document.documentElement.scrollLeft;
	o.orig_y = parseInt(o.style.top) - document.documentElement.scrollTop;
	o.orig_index = o.style.zIndex;
	if(dr&&_o!=null){
		_o.onmousedown = function(a){
			genCreateShadow(o);
			emPop=$G("im_shadow");
			var d=document;
			if(!a)a=window.event;
			var mP=getmousePos(a);
			var x = mP.x+d.documentElement.scrollLeft-o.offsetLeft;
			var y = mP.y+d.documentElement.scrollTop-o.offsetTop;
				
			if(emPop.setCapture)
				emPop.setCapture();
			else if(window.captureEvents)
				window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
			d.onmousemove = function(evt){
				d.ondragstart = "return false;"
				d.onselectstart = "return false;"
				d.onselect = "document.selection.empty();"
				emPop=$G("im_shadow");
				if(!evt)evt=window.event;
				mP=getmousePos(evt);
				//alert(mP.x+"/"+mP.y);
				emPop.style.left = mP.x+d.documentElement.scrollLeft-x+"px";
				emPop.style.top = mP.y+d.documentElement.scrollTop-y+"px";	 
				o.orig_x = parseInt(emPop.style.left) - d.documentElement.scrollLeft;
				o.orig_y = parseInt(emPop.style.top) - d.documentElement.scrollTop;
			}
			d.onmouseup = function(){
				emPop=$G("im_shadow");
				o.style.left = parseInt(emPop.style.left)+"px";
				o.style.top = parseInt(emPop.style.top)+"px";
			
				if(emPop.releaseCapture)
					emPop.releaseCapture();
				else if(window.captureEvents)
					window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
				emPop.parentNode.removeChild(emPop);
				d.onmousemove = null;
				d.onmouseup = null;
				d.ondragstart = null;
				d.onselectstart = null;
				d.onselect = null;
				o.style.cursor = "normal";
			}
		}
	}
	if (s){	
		var orig_scroll = window.onscroll?window.onscroll:function (){};
		window.onscroll = function (){
			orig_scroll();	   
			o.style.left = o.orig_x + document.documentElement.scrollLeft+"px";
			o.style.top = o.orig_y + document.documentElement.scrollTop+"px";	   
		}
	}
}

//绝对剧中（水平方向）div，垂直方向是偏上一点，这样好看一点
function floatAbsMiddle(_oDiv,s,d){
	if(s==null) s=true;
	if(d==null) d=true;
	_oDiv.style.display="";
	setBgroundGray();
	_oDiv.style.left=(genGetViewportWidth()-_oDiv.offsetWidth)/2+document.documentElement.scrollLeft+"px";
	_oDiv.style.top=(genGetViewportHeight()-_oDiv.offsetHeight)/2-42+document.documentElement.scrollTop+"px";
	_oDiv.style.zIndex="50002";
	genDrag($G("_odiv"),s,d);
}

function clearBgroundGray(){	
	var _o=$G("bgDiv");
	if(_o!=null) {
		_o.parentNode.removeChild(_o);
	}
}

function avCloseReBox(){
	var _o=$G("_odiv");
	if(_o!=null) _o.parentNode.removeChild(_o);
	clearBgroundGray();	
}