/**
 * Ajax用户注册验证 JS
*/
//XMLHttpRequest 





	var xmlhttp = false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	
	function Username_Ajax(data,myform,c_submit){	
		xmlhttp.open("GET","check_key.php?to_username="+data,true);
		xmlhttp.send(null);
	    document.getElementById('username_notice').innerHTML = process_request;//显示状态
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
				var responseText = xmlhttp.responseText;
				   if (responseText=="true" ){
				   ck_user("true",myform,c_submit);
				      }
				   else{
				   ck_user("false",myform,c_submit);
				   }
				}else{
					alert("发生错误!");
				}
			}
		}
	}
	
	
/////////////////////////////////////////

	function SendAnApology_Username_Ajax(obj,myform,c_submit,notice,notice_text){
		
		var data=obj.value;
	
		xmlhttp.open("GET","check_key.php?to_username="+data,true);
		xmlhttp.send(null);
	    document.getElementById(notice).innerHTML = process_request;//显示状态
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
				var responseText = xmlhttp.responseText;
				   if (responseText=="true" ){
						showInfo(notice,msg_can_rg);
						change_submit("false",myform,c_submit);//可用提交按钮
				      }
				   else if(responseText==""){
						showInfo(notice,"× This is required!");
						change_submit("true",myform,c_submit);//禁用提交按钮
				   }
				   else
				   {
						showInfo(notice,notice_text);
						change_submit("true",myform,c_submit);//禁用提交按钮
				   }
				}else{
					alert("发生错误!");
				}
			}
		}
	}

////////////////////////////
	
	
	function email_Ajax(data,myform,c_submit){	
		xmlhttp.open("GET","check_key.php?email="+data,true);
		xmlhttp.send(null);
	    document.getElementById('email_notice').innerHTML = process_request;//显示状态
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
				var responseText = xmlhttp.responseText;
				   if (responseText=="true" ){
				   ck_email("true",myform,c_submit);
				      }
				   else{
				   ck_email("false",myform,c_submit);
				   }
				}else{
					alert("发生错误!");
				}
			}
		}
	}
	

//--------------用户名检测---------------------//
function ck_user(result,myform,c_submit)
{
  if ( result == "true" )
  {  
    //document.getElementById('username').className = "FrameDivWarn";
	showInfo("username_notice",msg_un_registered);
    change_submit("true",myform,c_submit);//禁用提交按钮
  }
  else
  { 
    //document.getElementById('username').className = "FrameDivPass";
	showInfo("username_notice",msg_can_rg);
    change_submit("false",myform,c_submit);//可用提交按钮
  }
}

function checks(t){
    szMsg="[#%&'\",;:=!^@]";
     //alertStr="";
    for(i=1;i<szMsg.length+1;i++){
     if(t.indexOf(szMsg.substring(i-1,i))>-1){
      //alertStr="请勿包含非法字符如[#_%&'\",;:=!^]";
      return false;
     }
    }
	
	
if( /^\d.*$/.test( t ) ){
  return false;
}
if(! /^.{6,80}$/.test( t ) ){
  return false;
}
if(! /^[\w_]*$/.test( t ) ){
  return false;
}
if(! /^([a-z]|[A-Z])[\w_]{5,19}$/.test( t ) ){
  return false;
}

    return true;
   }
//-----------EMAIL检测--------------------------------//
function ck_email(result,myform,c_submit)
{
  if ( result == "true" )
  {  
    //document.getElementById('email').className = "FrameDivWarn";
	showInfo("email_notice",msg_email_registered);
    change_submit("true",myform,c_submit);//禁用提交按钮
  }
  else
  { 
   // document.getElementById('email').className = "FrameDivPass";
	showInfo("email_notice",msg_can_rg);
    change_submit("false",myform,c_submit);//可用提交按钮
  }
}

//-----------输入时EMAIL检测格式--------------------------------//

function chek_email_invalid1(obj,myform,c_submit,form_notice,msg_un_format) {  

			 if (chekemail1(obj.value)==false)
			
			  {
				//obj.className = "FrameDivWarn";
				showInfo(form_notice,msg_un_format);
				change_submit("true",myform,c_submit);  
			 } 
			 else{
			 
			   // obj.className = "FrameDivPass";
				showInfo(form_notice,info_right);
				change_submit("false",myform,c_submit);//允许提交按钮

			 }
			 
}

function chek_email2_invalid1(obj,myform,c_submit,form_notice,msg_un_format) {  

			 if (chekemail12(obj.value)==false)
			
			  {
				//obj.className = "FrameDivWarn";
				showInfo(form_notice,msg_un_format);
				change_submit("true",myform,c_submit);  
			 } 
			 else{
			 
			   // obj.className = "FrameDivPass";
				showInfo(form_notice,info_right);
				change_submit("false",myform,c_submit);//允许提交按钮

			 }
			 
}
function chekemail12(temail) {  
	if(temail!="")
	{
		 temail= temail.split(','); 
		for(i=0;i<temail.length;i++){
			 var pattern = /^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,4}$/i;  
			 if(pattern.test(temail[i])) {  
			  var a=1;
			 }  
			 else { 
			 
			  var a=0;
			 } 
		 }
		 
		 if (a==1)
		 { return true;  }
		 else
		 {
		  return false; 	 
		 }
	}
} 

function chekemail1(temail) {  
	if(temail!="")
	{
		 var pattern = /^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,4}$/i;  
		 if(pattern.test(temail)) {  
		  return true;  
		 }  
		 else { 
		 
		  return false;  
		 }  
	}
} 

function chek_email_invalid(obj,myform,c_submit,form_notice,msg_un_format) {  

			 if (chekemail(obj.value)==false)
			
			  {
				//obj.className = "FrameDivWarn";
				showInfo(form_notice,msg_un_format);
				change_submit("true",myform,c_submit);  
			 } 
			 else{
			 
			   // obj.className = "FrameDivPass";
				showInfo(form_notice,info_right);
				change_submit("false",myform,c_submit);//允许提交按钮

			 }
			 
}

function chekemail(temail) {  
    var pattern = /^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,4}$/i;  
		 if(pattern.test(temail)) {  
		  return true;  
		 }  
		 else { 
		 
		  return false;  
		 }  
	
} 



//* *--------------------检测密码强度-----------------------------* *//

function checkIntensity(pwd)
{
	
  var Mcolor = "#FFF",Lcolor = "#FFF",Hcolor = "#FFF";
  var m=0;

  var Modes = 0;
  for (i=0; i<pwd.length; i++)
  {
    var charType = 0;
    var t = pwd.charCodeAt(i);
    if (t>=48 && t <=57)
    {
      charType = 1;
    }
    else if (t>=65 && t <=90)
    {
      charType = 2;
    }
    else if (t>=97 && t <=122)
      charType = 4;
    else
      charType = 4;
    Modes |= charType;
  }

  for (i=0;i<4;i++)
  {
    if (Modes & 1) m++;
      Modes>>>=1;
  }

  if (pwd.length<=4)
  {
    m = 1;
  }

  switch(m)
  {
    case 1 :
      Lcolor = "2px solid red";
      Mcolor = Hcolor = "2px solid #DADADA";
    break;
    case 2 :
      Mcolor = "2px solid #f90";
      Lcolor = Hcolor = "2px solid #DADADA";
    break;
    case 3 :
      Hcolor = "2px solid #3c0";
      Lcolor = Mcolor = "2px solid #DADADA";
    break;
    case 4 :
      Hcolor = "2px solid #3c0";
      Lcolor = Mcolor = "2px solid #DADADA";
    break;
    default :
      Hcolor = Mcolor = Lcolor = "";
    break;
  }
  document.getElementById("pwd_lower").style.borderBottom  = Lcolor;
  document.getElementById("pwd_middle").style.borderBottom = Mcolor;
  document.getElementById("pwd_high").style.borderBottom   = Hcolor;

}
//-----------输入时file检测格式--------------------------------//

function chek_g_invalid(obj,myform,c_submit,form_notice,msg_un_format) {  

			 if(obj.value=="")
				{
				//obj.className = "FrameDivWarn";
				
				showInfo(form_notice,msg_un_format);
				change_submit("true",myform,c_submit);  
				}
			 else
				{
						var fileType=obj.value;
						fileType=fileType.charAt(fileType.length-3)+fileType.charAt(fileType.length-2)+fileType.charAt(fileType.length-1);
						fileType=fileType.toUpperCase();
						if(fileType!="JPG"&&fileType!="GIF"&&fileType!="PNG"&&fileType!="BMP"){
						showInfo(form_notice,msg_un_format);
						change_submit("true",myform,c_submit);  
						}			 
						else{
			            
						document.getElementById(form_notice).innerHTML = process_request;//显示状态
						document.myform6.action="upload_image.php?path=upload/background/";
                        document.myform6.submit(); 			
						
						
							   
						}
				}
			
			 
}

//-----------输入时file检测格式--------------------------------//

function chek_m_invalid(obj,myform,c_submit,form_notice,msg_un_format) {  

			 if(obj.value=="")
				{
				//obj.className = "FrameDivWarn";
				
				showInfo(form_notice,msg_un_format);
				change_submit("true",myform,c_submit);  
				}
			 else
				{
						var fileType=obj.value;
						fileType=fileType.charAt(fileType.length-3)+fileType.charAt(fileType.length-2)+fileType.charAt(fileType.length-1);
						fileType=fileType.toUpperCase();
						if(fileType!="MP3"&&fileType!="RM"&&fileType!="RA"&&fileType!="RAM"&&fileType!="MID"&&fileType!="WMA"){
						showInfo(form_notice,msg_un_format);
						change_submit("true",myform,c_submit);  
						}			 
						else{
			            
						document.getElementById(form_notice).innerHTML = process_request;//显示状态
						document.myform7.action="upload_music.php?path=upload/music/";
                        document.myform7.submit(); 			
						
						
							   
						}
				}
			
			 
}
//-----------输入时file检测格式--------------------------------//

function chek_pic_invalid(obj,myform,c_submit,form_notice,msg_un_format) {  

			 if(obj.value=="")
				{
				//obj.className = "FrameDivWarn";
				showInfo(form_notice,msg_un_format);
				change_submit("true",myform,c_submit);  
				}
			 else
				{
						var fileType=obj.value;
						fileType=fileType.charAt(fileType.length-3)+fileType.charAt(fileType.length-2)+fileType.charAt(fileType.length-1);
						fileType=fileType.toUpperCase();
						if(fileType!="JPG"&&fileType!="GIF"&&fileType!="PNG"&&fileType!="BMP"){
						
						//obj.className = "FrameDivWarn";
						showInfo(form_notice,msg_un_format);
						change_submit("true",myform,c_submit);  
		
						}			 
						else{
						//obj.className = "FrameDivPass";
						//showInfo(form_notice,info_right);
						//change_submit("false",myform,c_submit);//允许提交按钮
						
			            
						document.getElementById(form_notice).innerHTML = process_request;//显示状态
						document.myform.action="upload.php?path=upload/pictures/&action=pictures";
                        document.myform.submit(); 

						
						
						
						
						
		
						///--------------------------------------------							
						/*
						 var data = "" ; 
						 var spliter = "-------7d8d733180846";
						     data = data + spliter + "\r\n";   
						     data = data + "Content-Disposition: form-data; name=\"file\"; filename=\""+obj.value+"\"\r\n" ; 
						     data = data + "Content-Type: image/pjpeg" + "\r\n" + "\r\n"  ; 
						     //data = data + "Content-Type: text/plain" + "\r\n" + "\r\n"  ; 
						 //text = "My name is Wilson Lin."  
						 var postLength = data.length + 2 + spliter.length + 4  ; 
						 var postStr = data + "\r\n" + spliter + "--\r\n"   ;
						
						   
						   /////////////////////////////////////////
						   
						
					         xmlhttp.open("POST","upload.php",false);    
							 xmlhttp.setRequestHeader("Content-Type", "multipart/form-data; boundary=-----7d8d733180846"); 
							 //xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
							 xmlhttp.setRequestHeader("Content-Length", postLength);   
							 xmlhttp.send(postStr);
							 $(form_notice).innerHTML = process_request;//显示状态
							 
							 // 显示服务器返回的信息
							// alert(xmlhttp.ResponseText);    
							 //result.innerHTML=xmlhttp.ResponseText;   

						  

								
								
									
									var responseText =xmlhttp.ResponseText;  
									
									String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,"")}
								   responseText=responseText.trim();
									
									
									   if (responseText!="" ){
							obj.className = "FrameDivPass";
							showInfo(form_notice,info_right);
							change_submit("false",myform,c_submit);//允许提交按钮
							$("pic_div").style.display="";
							$("pic").src=responseText;
							   
							
										  }
									   else{
							showInfo(form_notice,msg_un_format);
							obj.className = "FrameDivWarn";
							change_submit("true",myform,c_submit);//禁用提交按
							return false;
									   }
								
							*/
							//-----------------------------
										
										
										
						
						
						
							   
						}
				}
			
			 
}

function chek_file_invalid(obj,myform,c_submit,form_notice,msg_un_format) {  

			 if(obj.value=="")
				{
				//obj.className = "FrameDivWarn";
				showInfo(form_notice,msg_un_format);
				change_submit("true",myform,c_submit);  
				}
			 else
				{
						var fileType=obj.value;
						fileType=fileType.charAt(fileType.length-3)+fileType.charAt(fileType.length-2)+fileType.charAt(fileType.length-1);
						fileType=fileType.toUpperCase();
						if(fileType!="FLV" && fileType!="AVI" && fileType!="WMV" && fileType!="MPEG" && fileType!="MPG" && fileType!="MOV" && fileType!="MP4" && fileType!="QT" && fileType!="RM"){
						
						//obj.className = "FrameDivWarn";
						showInfo(form_notice,msg_un_format);
						change_submit("true",myform,c_submit);  
		
						}			 
						else{
						//obj.className = "FrameDivPass";
						//showInfo(form_notice,info_right);
						//change_submit("false",myform,c_submit);//允许提交按钮
						
			            
						document.getElementById(form_notice).innerHTML = process_request;//显示状态
						document.myform.action="upload.php?action=videos";
                        document.myform.submit(); 

							   
						}
				}
			
			 
}



//-----------------------检测表单输入是否正确-------------------//



	function check_conform(obj,num1,num2,username,password,re_password,email,number,chk_key,agreement,myform,c_submit,form_notice,msg_un_format){
	     if(obj.value.length<num1 && agreement!=true){
			//obj.className = "FrameDivWarn";			
			showInfo(form_notice,msg_un_format);
            change_submit("true",myform,c_submit);
		}

		else if(obj.value.length>num2 && agreement!=true){
			//obj.className = "FrameDivWarn";
			showInfo(form_notice,msg_un_format);
            change_submit("true",myform,c_submit);
		}
		
		else if(username==true){
			
			 if (checks(obj.value)== false)
			  {
				//obj.className = "FrameDivWarn";			
				showInfo(form_notice,msg_un_format);
				change_submit("true",myform,c_submit);
			  }
			
			else{
				//调用Ajax函数,向服务器端发送查询
				Username_Ajax(obj.value,myform,c_submit);
			 }			

        }	
		
		else if(password==true){
			
			
		
				showInfo(form_notice,info_right);
				//obj.className = "FrameDivPass";
				change_submit("false",myform,c_submit);//允许提交按钮
			
			
			    checkIntensity(obj.value,myform,c_submit);
		}
		
		else if(re_password==true){
			
		       var password = document.getElementById('password').value;
			
			
			if ( obj.value!= password)
			{
				showInfo(form_notice,confirm_password_invalid);
				//obj.className = "FrameDivWarn";
				change_submit("true",myform,c_submit);//禁用提交按
			}
			else
			{   
				//obj.className = "FrameDivPass";
				showInfo(form_notice,info_right);
				change_submit("false",myform,c_submit);//允许提交按钮
			}			
		}
		
		else if(email==true){
			
			 if (chekemail(obj.value)==false)
			
			  {
				//obj.className = "FrameDivWarn";
				showInfo(form_notice,msg_un_format);
				change_submit("true",myform,c_submit);  
			 } 
			 
			else
			   {
				email_Ajax(obj.value,myform,c_submit);
			   }
		}
		
		else if(number==true)//输入内容是否为数字
		{
			if(checknumber(obj.value)) 
			{ 
			//obj.className = "FrameDivWarn";
			
			showInfo(form_notice,msg_un_format);
            change_submit("true",myform,c_submit);
			} 
			else
			{   
				//obj.className = "FrameDivPass";
				showInfo(form_notice,info_right);
				change_submit("false",myform,c_submit);//允许提交按钮
			}		
			

		}
		
		else if(chk_key==true){
			
		   var checkkey=obj.value;	   
		   var url ="check_key.php?action=key";
		   var postStr ="numbers="+ checkkey ;
		  
			xmlhttp.open("POST", url, true);
			xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlhttp.send(postStr);
			$(form_notice).innerHTML = process_request;//显示状态
			xmlhttp.onreadystatechange=function(){
				if (4==xmlhttp.readyState){
					if (200==xmlhttp.status){
					var responseText = xmlhttp.responseText;
					   if (responseText=="true" ){
			//obj.className = "FrameDivPass";
			showInfo(form_notice,info_right);
			change_submit("false",myform,c_submit);//允许提交按钮
						  }
					   else{
			showInfo(form_notice,msg_un_format);
			//obj.className = "FrameDivWarn";
			change_submit("true",myform,c_submit);//禁用提交按
			return false;
					   }
					}else{
						alert("发生错误!");
					}
				}
			}
	
		}
		
		else if(agreement==true){
			
			 if (obj.checked==false)
			  {
				 showInfo(form_notice,msg_un_format);
				 change_submit("true",myform,c_submit);//允许提交
			  }
			  else
			  {
				showInfo(form_notice,info_right);
				change_submit("false",myform,c_submit);//允许提交按
			  }
	
		}
		
		else
		{   
			//obj.className = "FrameDivPass";
			showInfo(form_notice,info_right);
			change_submit("false",myform,c_submit);//允许提交按钮
		}		

	}


//-----------------------检测表单输入是否为数字-------------------//
	function checknumber(String) 
	{ 
	var Letters = "1234567890"; 
	var i; 
	var c; 
	for( i = 0; i < String.length; i ++ ) 
	{ 
	c = String.charAt( i ); 
	if (Letters.indexOf( c ) ==-1) 
	{ 
	return true; 
	} 
	} 
	return false; 
	} 



//* *--------------------检测验证码-----------------------------* *//

function check_key( check_key,myform,c_submit )
{

		
	   var checkkey=$("checkkey").value;
	   
	   var url ="check_key.php?action=key&numbers="+ checkkey;
       var postStr ="numbers="+ checkkey ;
	  
		xmlhttp.open("POST", url, true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlhttp.send(postStr);
	    $("key_notice").innerHTML = process_request;//显示状态
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
				var responseText = xmlhttp.responseText;
				   if (responseText=="true" ){
	    check_key.className = "FrameDivPass";
		showInfo("key_notice",info_right);
		change_submit("false",myform,c_submit);//允许提交按钮
				      }
				   else{
	    showInfo("key_notice",PostCode_empty);
		check_key.className = "FrameDivWarn";
		change_submit("true",myform,c_submit);//禁用提交按
        return false;
				   }
				}else{
					alert("发生错误!");
				}
			}
		}

	
	
	
}
//* *--------------------检测验证码 end-----------------------------* *//



//* *--------------------删除-----------------------------* *//

function del( url,table,notice,href)
{

	if(!confirm('Are you sure? Any delete to this data will be lost?')) return false;

       var url =url+"&table="+ table ;
	  
		xmlhttp.open("post", url, true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlhttp.send(null);
	    $(notice).innerHTML = process_request;//显示状态
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
				var responseText = xmlhttp.responseText;
				   if (responseText=="true" ){
	    $(notice).innerHTML = "Deleted successfully.";//显示状态
		if(href==true)	window.location.href   =   (window.location.href.indexOf('?')>-1)?(window.location.href):(window.location.href)
}
				   else{
             return false;
				   }
				}else{
					alert("发生错误!");
				}
			}
		}

	
	
	
}
//* *--------------------删除 end-----------------------------* *//



//-------------处理数据程序-----------------------------//
function update(obj,url,to_url,table,formitem,validateitem,myform,c_submit,agreement,agreement_num,FCK) {

	   var a= new Array();  
	   var postStr;
	   var postform;
	   
	   
	   	//------------------------是否有编辑器-----------------//
	if(FCK!=""){
		
	  document.getElementById(FCK).value=FCKeditorAPI.GetInstance(FCK).GetXHTML();	
		
	}
	
	   
	       if(validateitem!="")
		   {
			   a=validateitem.split(",");
				
				if(a!=undefined && a!="")
				{
	
						for (var i=0;i<(validateitem.split(",").length);i++)
					  {      
					 
							  if(document.getElementById(a[i]).value=="")
							  { 
								//showclass(a[i],"FrameDivWarn");
								showInfo(a[i]+'_notice',invalid);
								
								document.getElementById(a[i]).focus();
								return false;
				  
							  }	
							
								 
					 }
				}
		   }
			
			       
						 var b= new Array();  
						     b=formitem.split(",");
						
								for (var i=0;i<(formitem.split(",").length)-1;i++)
							  {
									  if(table=="apologymessages" && i==4 && document.getElementById(b[i]).value!="")
									  {
										  if(chekemail(document.getElementById(b[i]).value)==false )
										  {
											showInfo(b[i]+'_notice','×You must enter a correct email address.'); 
											document.getElementById(b[i]).focus();
											return false;
										  }
									  }
									  if(table=="user" && i==0)
									  {
											if( /^\d.*$/.test( document.getElementById(b[i]).value ) ){
												  return false;
												}
												
												if(! /^.{1,80}$/.test( document.getElementById(b[i]).value ) ){
												 return false;
												}
												
												if(! /^[\w_]*$/.test( document.getElementById(b[i]).value ) ){
												  return false;
												}
												if(! /^([a-z]|[A-Z])[\w_]{1,19}$/.test( document.getElementById(b[i]).value ) ){
												  return false;
												}  
									  }
									  
							  }	  
											
	
	
	//--------------注册协议复选框状态检测---------------------//
	if (agreement==true)
	{
		if(document.getElementById(a[agreement_num]).checked==false){
				
			  showInfo(a[agreement_num]+'_notice',invalid);
               change_submit("true",myform,c_submit);//允许提交
               return false;
			 }
	
	}
		  Post_Ajax(obj,url,to_url,table,formitem,validateitem,myform,c_submit);


}


function Post_Ajax(obj,url,to_url,table,formitem,validateitem,myform,c_submit){
	
var opt = {
	method: 'get',
	onSuccess: function(t) 
	{
			
		
		 if(to_url!=""){
			// change_submit("true",myform,c_submit);//禁用提交按
			 document.getElementById("loading").innerHTML = process_request;//显示状态
			

		 }
		 
		m=t.responseText;
		

				   if (m=="true" ){
					   if(to_url!="") location = to_url;
				      }
				   else{
				   
						 var a= new Array();  
						     a=validateitem.split(",");
						
								for (var i=0;i<(validateitem.split(",").length)-1;i++)
							  {

										//showclass(a[i],"FrameDivWarn");
										//showInfo(a[i]+'_notice',invalid);
										
										
							 }
							document.getElementById("loading").innerHTML = "";//显示状态
							
							
  
				   
				   }        
	},
	on404: function(t)
	{
		document.getElementById("loading").innerHTML='error';
		return false;
	},
	onFailure: function(t)
	{
		document.getElementById("loading").innerHTML='error：' + t.status  + t.statusText;
		return false;
	},
	asynchronous:true
}
var ajax=new Ajax.Request(url+"&"+getRequestBody(obj)+"&table="+table+"&formitem="+formitem, opt);	
}

function getRequestBody(oForm) 
{
	var aParams = new Array();
	for (var i=0 ; i < oForm.elements.length; i++) {
	var sParam = encodeURIComponent(oForm.elements[i].name);
	sParam += "=";
	sParam += encodeURIComponent(oForm.elements[i].value);
	aParams.push(sParam);
	}	
	return aParams.join("&");
}

//-----------------




function login(obj,url,to_url,table,formitem,validateitem,Remember,myform,c_submit) {
	   
	   var a= new Array();  
	   var postStr;
	   var postform;
	   
           a=validateitem.split(",");

	   	for (var i=0;i<(validateitem.split(",").length);i++)
	  {
			  
			  
			
			  if(document.getElementById(a[i]).value=="")
			  {
				showclass(a[i],"FrameDivWarn");
				showInfo(a[i]+'_notice',invalid);
				document.getElementById(a[i]).focus();
				return false;
  
			  }
			
			
				 
	}
	

		  login_Post_Ajax(obj,url,to_url,table,formitem,validateitem,Remember,myform,c_submit);


}




function login_Post_Ajax(obj,url,to_url,table,formitem,validateitem,Remember,myform,c_submit){
		   
var opt = {
	method: 'get',
	onSuccess: function(t) 
	{
		$("loading").innerHTML = process_request;//显示状态
		m=t.responseText;

				   if (m=="true" ){
					   location = to_url;
				      }
				   else{
				   
						 var a= new Array();  
						     a=validateitem.split(",");
						
								for (var i=0;i<(validateitem.split(",").length)-1;i++)
							  {
									  
										//showclass(a[i],"FrameDivWarn");
										showInfo(a[i]+'_notice',invalid);
										
										
							 }
							document.getElementById("loading").innerHTML = "<span style='COLOR:#ff0000'> Invalid username or password!</span>";//显示状态

				   
				   }        
	},
	on404: function(t)
	{
		document.getElementById("loading").innerHTML='error';
		return false;
	},
	onFailure: function(t)
	{
		document.getElementById("loading").innerHTML='error：' + t.status  + t.statusText;
		return false;
	},
	asynchronous:true
}




       if(Remember!="")
	   {	 			   
			   if(document.getElementById(Remember).checked==false){
	           var ajax=new Ajax.Request(url+"&"+getRequestBody(obj)+"&table="+table+"&formitem="+formitem, opt);	
			   }
			   else{
				  
				  var ajax=new Ajax.Request(url+"&"+getRequestBody(obj)+"&table="+table+"&formitem="+formitem+"&Remember=yes", opt);	
				  
				  
			   }
		}
		else{
			var ajax=new Ajax.Request(url+"&"+getRequestBody(obj)+"&table="+table+"&formitem="+formitem, opt);	
			
		}
		


	
}





function reset_pass(obj,url,to_url,table,formitem,validateitem,myform,c_submit) {
	
		  
	   
	   var a= new Array();  
	   var postStr;
	   var postform;
	   
           a=validateitem.split(",");

	   	for (var i=0;i<(validateitem.split(",").length);i++)
	  {
			  
			  
			
			  if($(a[i]).value=="")
			  {
				//showclass(a[i],"FrameDivWarn");
				showInfo(a[i]+'_notice',invalid);
				$(a[i]).focus();
				return false;
  
			  }
			
			
				 
	}
	

	reset_pass_Post_Ajax(obj,url,to_url,table,formitem,validateitem,myform,c_submit);


}


function reset_pass_Post_Ajax(obj,url,to_url,table,formitem,validateitem,myform,c_submit){
    
var opt = {
	method: 'get',
	onSuccess: function(t) 
	{
		$("loading_2").innerHTML = process_request;//显示状态
		m=t.responseText;

				   if (m=="true" ){
					   location = to_url;
				      }
				   else{
				   
						 var a= new Array();  
						     a=validateitem.split(",");
						
								for (var i=0;i<(validateitem.split(",").length)-1;i++)
							  {
									  
									//	showclass(a[i],"FrameDivWarn");
										showInfo(a[i]+'_notice',invalid);
										
										
							 }
							$("loading_2").innerHTML = "<span style='COLOR:#ff0000'> Invalid Email!</span>";//显示状态

				   
				   }        
	},
	on404: function(t)
	{
		$("loading").innerHTML='error';
		return false;
	},
	onFailure: function(t)
	{
		$("loading").innerHTML='error：' + t.status  + t.statusText;
		return false;
	},
	asynchronous:true
}


     
var ajax=new Ajax.Request(url+"&"+getRequestBody(obj)+"&table="+table+"&formitem="+formitem, opt);	
			
	
}



//-----------------




//------------ 按钮状态设置-----------------------------//
function change_submit(zt,myform,c_submit)
{ 
     if (zt == "true")
     {
   document.forms[myform].elements[c_submit].disabled = 'disabled';
     }
   else
     {
   document.forms[myform].elements[c_submit].disabled = '';
     }
}
//------公用程序------------------------------------//
	function showInfo(target,Infos){
    document.getElementById(target).innerHTML = Infos;
	}
	function showclass(target,Infos){
    document.getElementById(target).className = Infos;
	}
	
	
	
//---------------radio------------------------------------//

	var check_flag="false";
	function notifychk(field,to_obj,h)
	{
	
		if (check_flag== "false")
		 {
			for (i = 0; i < field.length; i++)
			 {
			field.checked = true;
			}
		
		//check_flag= "true";
		$(to_obj).value=h;
	
		}
		
		else
		 {
			for (i = 0; i < field.length; i++)
			 {
			field.checked = false;
			 }
		check_flag= "false";
		$(to_obj).value="";
	
		return "true"; 
		}
	
	}

	
var process_request = "<img src='images/loading.gif' width='16' height='16' border='0' align='absmiddle'>loading...";
var confirm_password_invalid = "<span style='COLOR:#ff0000'> × Re-type password. Please verify your password again.</span>";
var agreement = "<span style='COLOR:#ff0000'> × </span>";
var msg_un_registered = "<span style='COLOR:#ff0000'> × The username is not available.</span>";
var msg_can_rg = "<span style='COLOR:#006600'> √</span>";
var msg_email_registered = " × The email is not available.";
var invalid="×";
var pictures_invalid="×You are not upload pictures in the paper.Please upload pictures in JPG format or GIF format or PNG format or BMP format.";

var info_can="<span style='COLOR:#006600'> √ </span>";
var info_right="<span style='COLOR:#006600'> √ </span>";



/////////////////////////////////////


function showCommentBox() {
	document.getElementById('commentArea').style.display='inline'; 
	document.getElementById('nobodyCommented').style.display='none';
	//return false;
}

function hideCommentBox() {
	document.getElementById('commentArea').style.display='none'; 
	document.getElementById('nobodyCommented').style.display='inline';
	//return false;
}

function clearText(element) {
	if (element.initialClick == null)
		element.initialClick = true;
		
	if (element.initialClick) {
		element.value = "";
		element.initialClick = false;
	}
}

function editcomment(CommentID)
{
	
document.getElementById("commentArea").style.display="inline" ;  
document.getElementById("commentButto_1").style.display="none" ;  
document.getElementById("commentButto_2").style.display="" ;  
document.getElementById("id").value=CommentID ; 

var commentText;
var text;
commentText=document.getElementById("comm_"+CommentID).innerHTML ;


//alert(commentText.split("<BR>").length);


	   var a= new Array();  
	   
           a=commentText.split("<BR>");

	   	for (var i=0;i<(commentText.split("<BR>").length);i++)
	  {
			
		if(text!=undefined&&text!="")	{
			text=text+"\r\n"+a[i];
		}
		else{
			text=a[i];
		}
	  
	}
	



document.getElementById("comment").value=text; 


//document.getElementById("comment").innerHTML=document.getElementById("comm_"+CommentID).innerHTML ;
document.getElementById("comments_list").style.display="none" ;
document.getElementById("addCommentLink").style.display="none" ;
document.getElementById("comment").onfocus="" ;




 
}

function editcommentCancel()
{
	
document.getElementById("commentArea").style.display="none" ;  
document.getElementById("commentButto_1").style.display="" ;  
document.getElementById("commentButto_2").style.display="none" ;  
document.getElementById("id").value="" ; 
document.getElementById("comment").value="" ;
document.getElementById("comments_list").style.display="" ;  
document.getElementById("addCommentLink").style.display="" ;
//document.getElementById("comment").onfocus="clearText(this)" ;
 
}

function sendAction(obj,userid,id,table,validateitem)
{
	if(obj.ImageOptions.value=="profile")
	{
		
	sendaction_ajax(obj,'code.php?action=update&id='+userid,'user','profileimage',userid,validateitem,'Your profile image has been updated.');
	
		
	}
	else if(obj.ImageOptions.value=="delete")
	{
		
		if(table=="pictures") {
			 var profileimage=document.getElementById("profileimage").value;
			del('code.php?action=del&userid='+userid+'&profileimage='+profileimage+'&pic_video=true&id='+id,table,validateitem,false);
			
			}
		else{
			del('code.php?action=del&pic_video=true&id='+id,table,validateitem,false);
		   }
	}
}
//////////////////////////////////////////////////////////////////////////////////////////



function sendaction_ajax(obj,url,table,formitem,userid,validateitem,notice)
{
		//alert(validateitem);
if(userid=='' || userid==undefined)
{
$(validateitem).innerHTML = "Please <a href=login.php>login</a> to add favorites.";//显示状态
}
else
{
	var opt = {
		method: 'get',
		onSuccess: function(t) 
		{
			
			
			$(validateitem).innerHTML = process_request;//显示状态
			
			m=t.responseText;
			//alert("发生错误!");	
	 
					   if (m=="true" ){
						   $(validateitem).innerHTML = notice;//显示状态
						   
						  }
					   else{
					   
								 $(validateitem).innerHTML = "";//显示状态
								 
	
					   
					   }        
		},
		on404: function(t)
		{
			$(validateitem).innerHTML='error';
			return false;
		},
		onFailure: function(t)
		{
			$(validateitem).innerHTML='error：' + t.status  + t.statusText;
			return false;
		},
		asynchronous:true
	}
	var ajax=new Ajax.Request(url+"&"+getRequestBody(obj)+"&table="+table+"&formitem="+formitem, opt);		
	
}
}


/////////////////////////////////////////////

	function sendrating(url,table,formitem,id,ratinguserid,rating){
		//alert(rating);
		
		xmlhttp.open("GET",url+"&table="+table+"&formitem="+formitem+"&id="+id+"&ratinguserid="+ratinguserid+"&rating="+rating,true);
		xmlhttp.send(null);
	    $('ratingArea').innerHTML = process_request;//显示状态
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
				var responseText = xmlhttp.responseText;
				   if (responseText=="true" ){
				   $('ratingArea').innerHTML ="Rated Successfully";
				      }
				   else{
				   
				       }
				}else{
					alert("发生错误!");
				}
			}
		}
	}
/////////////////////////////////////////////

	function sendRequestfriends(url,table,formitem,to_userid,from_userid,toid){
		//alert(rating);
		
		xmlhttp.open("GET",url+"&table="+table+"&formitem="+formitem+"&to_userid="+to_userid+"&from_userid="+from_userid,true);
		xmlhttp.send(null);
	    $(toid).innerHTML = process_request;//显示状态
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
				var responseText = xmlhttp.responseText;
				   if (responseText=="true" ){
				   $(toid).innerHTML ="Request Pending";
				      }
				   else{
				   
				       }
				}else{
					alert("发生错误!");
				}
			}
		}
	}
