//------------------------Home JavaScript Document----------------------------
String.prototype.lrtrim = function(){ 
	return this.replace(/(^\s+)|(\s+$)/g,"");
}
String.prototype.trim = function(){
	return this.replace(/\s+/g,""); 
}
String.prototype.ltrim = function(){
	return this.replace(/(^\s+)/g,"");
}
String.prototype.rtrim = function(){
	return this.replace(/(\s+$)/g,"");
}
var homeCommon = new function(){ 
  this.commentContent=new String; 
	this.msg=new String; 
	this.url=new String; 
	this.ID=new String; 
	this.GetID=function(str){homeCommon.ID=str;};
	this.msg="验证码输入错误,请您重新输入。";
	this.getCommentData=function(url,str,parameter){
		this.commentContent=str;
		Request.reSend(url,parameter,this.commentBack); 
	};
	this.commentBack=function(Obj){
		var nowtime=new Date().getTime();
		if(Obj.responseText=="false3"){
			alert("您还没有登陆或登陆已超时!请先登陆!");
			//$("imgRandom").innerHTML='<img src="/home/RandomNumberblog.asp?i='+nowtime+'" width="50" height="18" align="absmiddle" />';
			$("sendmsg").disabled=false;
		}else if(Obj.responseText=="false4"){
			alert("免费会员不能进行此操作！");
			$("sendmsg").disabled=false;
		}else if(Obj.responseText=="false"){
			//alert(homeCommon.msg);
			$("imgRandom").innerHTML='<img src="RandomNumberblog.asp?rndstr='+nowtime+'" width="50" height="18" align="absmiddle" style="cursor:pointer" onclick="this.src=\'RandomNumberblog.asp?rndstr=\'+new Date().getTime()" alt="点击换一个!" />';
			$("sendmsg").disabled=false;
		}else{
			$(homeCommon.commentContent).innerHTML=Obj.responseText;
		}
	};
	this.randomBack=function(Obj){
		var nowtime=new Date().getTime();
		if(Obj.responseText=="false"){
			alert(homeCommon.msg);
			$("imgRandom").innerHTML='<img src="RandomNumberblog.asp?i='+nowtime+'" width="50" height="18" align="absmiddle" />';
			$("sendmsg").disabled=false;
		}else if(Obj.responseText=="true"){
			window.location.href=homeCommon.url;	
		}else{
			//alert(Obj.responseText);
			$(homeCommon.commentContent).innerHTML=Obj.responseText; 
		}
	};
	this.InputFilter=function(Obj_Str,Filter_Str){
		return $(Obj_Str).value.replace(Filter_Str,"")	;
	}
	this.CheckMinInput=function(str,MinLen,num){
		if(arguments.length!=3){
			num=0;
		}
		if(num==0){
			if($(str).value.length < MinLen){
				return  false;
			}
		}else if(num==2){
			if($(str).innerHTML.length < MinLen){
				return  false;
			}
		}
		return  true;
	}
	this.CheckMaxInput=function(str,MaxLen,num){
		if(arguments.length!=3){
			num=0;
		}
		switch(num){
			case 0:	
				if($(str).value.length > (MaxLen-1)){
					$(str).value = $(str).value.substring(0, MaxLen);
					return  false;
				}
				break;
			case 1:	  
				return  event.keyCode>=48&&event.keyCode<=57;  //数字
				break;
			case 2:
			  if($(str).innerHTML.length > (MaxLen-1)){
					$(str).innerHTML = $(str).innerHTML.substring(0, MaxLen);
					return  false;
			  }
				break;
			case 4:	
				$(str).value = this.InputFilter(str,/[\W]/g); //英文和数字
				break;
			case 5:	
				if($(str).value.length<2 && ($(str).value !=this.InputFilter(str,/[\d]/g))){
					alert("不能以数字开头！");
				};
				$(str).value = this.InputFilter(str,/^[\d]|[\W]/g);//开头不能为数字
				break;
			default:
				//alert("ok");
				return true;
		}
		return true;
	};
	
	this.CheckEmptyInnerHTML=function(str,suggestion,num){ 
		//var CheckStr=$(str).innerHTML.trim();
		var CheckStr=$(str).value;
//		if(arguments.length!=3){
//			num=0;
//		}
		//var CheckStr=document.getElementsByTagName("textarea")[num].value;
		if(CheckStr.trim()==""){
			alert(suggestion); 
			$(str).select();
			return false;
		}
		return true;  
	}
	this.CheckEmptyValue=function(str,suggestion){
		var CheckStr=jQuery("#"+str).val();
		if(CheckStr==""){
			alert(suggestion);
			$(str).select();
			return false;
		} 
		return true;  
	}
	/////////////////检查项目名称中是否含有办证等内容
	this.CheckFilterStrValue=function(str,suggestion){
		var CheckStr=jQuery("#"+str).val();
		var FilterStr= new Array("办证","办証","办證","辦证","瓣證","辦証","辦證","办学位","刻章","发票","文凭","身份证","龙虎机","老虎机","解码器","人民币","假钱","假钞","假人民币","遥控器","定位器","破解器","破解","作弊器","做弊器","假币");
		for(i=0;i<=25;i++)
        {
		if(CheckStr.indexOf(FilterStr[i]) != -1){
			alert(suggestion);
			$(str).select();
			return false;
		} 
		}
		return true;  
	}
	/////////////////////////////结束
	this.Hind=function(str){
		$(str).style.display='none';
	};
	this.Show=function(str){
		$(str).style.display='block';
	};
	this.AllSelect=function(){
		var Len=$("SelectForm").SelectName.length;
		if(Len>1){
			for(var i=0;i<Len;i++){
			 $("SelectForm").SelectName(i).checked	=true;
			}
		}else{
			$("SelectForm").SelectName.checked=true; 	
		}
	};
	this.CancelSelect=function(){
		var Len=$("SelectForm").SelectName.length;
		if(Len>1){
			for(var i=0;i<Len;i++){
				$("SelectForm").SelectName(i).checked	=false;
			}
		}else{
			$("SelectForm").SelectName.checked	=false; 	
		}
	};
	this.Alert=function(str){
		var IsDelete=window.confirm(str);
		if(IsDelete){
			return true;
		}else{
			return false; 
		}
	};
	this.BackAlert=function(Obj){
		if(Obj.responseText.indexOf('|')>0){
			alert(Obj.responseText.substring(0,Obj.responseText.indexOf('|')));
			return false;
		}else if(Obj.responseText=="false"){
		  alert(homeCommon.msg);
			return false;
		}else if(Obj.responseText.trim()!=''){
			alert(Obj.responseText);
			return false;
		}
  };
  this.filterCode=function(str){
		if(str==null) return '';
		var len=str.length;
		var re=/none/g;
		str=str.lrtrim();
		var filterCode=str;
		for(var i=0;i<len;i++){
			if(str.charCodeAt(i)>=161 && str.charCodeAt(i)!=173 && str.charCodeAt(i)<20000){
				re=eval('/'+str.substring(i,i+1)+'/g');	
				filterCode=filterCode.replace(re,"&#"+str.charCodeAt(i)+";"); 
			}
		}	
		return filterCode;
  }
	this.checkEmail=function(str,suggestion){   
		var mail=jQuery("#"+str).val();   
		var t=/^\w+@\w+(\.\w+)+/;   
	  var g=/^\w+\.\w+@\w+(\.\w+)+/;   
		if(t.test(mail)==false && g.test(mail)==false){ 
		  alert(suggestion); 
			$(str).select();
			return false;   
		}
		return true;
	}
	this.checkCookie=function(url){
		//Detect whether the cookie is opened
		var cookieEnabled=(navigator.cookieEnabled)? true : false    
    //If the version of navigator is under the ie4 or the ns6
		if (typeof(navigator.cookieEnabled)=="undefined" && !cookieEnabled){ 
		  document.cookie="testcookie=1"
		  cookieEnabled=(this.getCookie("testcookie")=="1")? true : false
		  document.cookie="testcookie=''" 
		}

    if(!cookieEnabled){
			window.status="您的浏览器禁止了所有Cookie,因此有些功能您无法使用!";
			//alert("您的浏览器禁止了所有Cookie,因此有些功能您无法使用!");
			//The navigator forbits all cookies
	  }else{
		  Request.reSend(url,"",homeCommon.BackAlert);
		}
	}

};
function checkMessage(id){
  //window.status="The readyState property is " + document.readyState;	
	if(document.readyState=="complete"){
	  Request.reSend("CheckMessage.asp?AccountID="+id,"",messageCallBack);
  }else{
    window.clearInterval(messageInterval);
		messageInterval=setInterval("checkMessage("+id+")",10000);	
		return;
	}
	window.clearInterval(messageInterval);
	messageInterval=setInterval("checkMessage("+id+")",30000);	
};
//Return statistics of the messages and the local mail
function messageCallBack(obj){
	if(obj.responseText==""){return ;};
	var msgData=null;
	try{
		msgData=eval(obj.responseText);
	}
	catch(e){		
		return ;
	}
	if(!msgData)return ;	
	var ln=msgData.length;
	for(var i=0;i<ln;i++){
		 if(msgData[i].type==1){	
			if(!Home.msg.messages["_msgEmail"]){
				 new Home.msg.message("_msgEmail",msgData[i].count,1);
			}
			else if(msgData[i].count!=Home.msg.messages["_msgEmail"].message){		
				var msgEl=$("_msgEmail");
				if(msgEl!=null){
					Home.msg.messages["_msgEmail"].message=msgData[i].count;
					var msgInner=Home.msg.panel.shortMessage(Home.msg.messages["_msgEmail"]);
					msgEl.innerHTML=msgInner.innerHTML;
				}
				else if(msgData[i].count>Home.msg.messages["_msgEmail"].message){					
					 new Home.msg.message("_msgEmail",msgData[i].count,1);
				}
			}
		 }
		 else if(msgData[i].type==2){	
				 new Home.msg.message("_msg"+Home.msg.sum,{imgSrc:msgData[i].imgSrc,name:msgData[i].name,time:msgData[i].time,content:msgData[i].content,fromid:msgData[i].fromid},2);				 
		 }
	}
};




