//验证留言内容
function checkContent(){
	var title = $j("#wltitle").val();
	if(title==""||title=="title"){
		alert("Title can not be null！");
		$j("#wltitle").focus();
		return false;
	}
	if(title.length > 30){
	 	alert("Title can not exceed 30 words！");
	 	$j("#wltitle").focus();
	 	return false;
	}
	var content = $j("#wlcontent").val();
	if(content==""||content=='content'){
		alert("content can not be null！");
		$j("#wlcontent").focus();
		return false;
	}
	if(content.length > 500){
	 	alert("content can not exceed 500 words！");
	 	$j("#wlcontent").focus();
	 	return false;
	}
	var email = $j("#wlemail").val();
	if(email!=""){
	   if(!isRightEmail(email)){
	   		alert("incorrect Email format! ");
	   		$j("#wlemail").focus();
		   	return false;
	   }
	   if(email.length > 20){
	 		alert("Email can not exceed 20 words！");
	 		$j("#wlemail").focus();
	 		return false;
	    }
	}
	var code=$j('#maskCode').val();
	if(code==''){
		alert("Auth-code can not exceed 10 words！");
	 	$j("#maskCode").focus();
	 	return false;
	}
	return true;
}
function clearInput(obj){
	obj.value="";
}
function ajaxSubmit(){
	if(checkContent() == false){
		return false;
	}else{
		var d="title="+$j("#wltitle").val()+"&content="+$j("#wlcontent").val()+"&email="+$j("#wlemail").val()+"&maskCode="+$j('#maskCode').val();
		$j.ajax({
		type:"post",
		url:rootpath+"/webLwordFrontAction!saveFromIndex.action",
		data:d,
		cache:false,
		datatype:"html",
		success:function(data){
			if(data=="1"){
				alert("Message successful！");
				$j("#wlemail").val("Email");
				$j("#wltitle").val("title");
				$j("#wlcontent").val("content");
				$j('#maskCode').val('');
			}else{
				if(data=="2"){
					alert("Auth-code input error！");
					$j('#maskCode').val('');
				}else{
					alert("Message failed！");
				}
			}
			refresh($j('#yzm'));
	   	}
		});
	}
}
function loadLevaeMsg(){
var action=rootpath+"/webLwordFrontAction!getIndexList.action";
var date=new Date();
action=action+"?t="+getRandom(date.getSeconds());
$j.ajax({
		url:action,
		cache:false,
		datatype:"html",
		success:function(data){
			$j("#message_a3").html(data);
	   	}
		});
}
$j(function(){
	$j('#wltitle').focus(function(){
		if(this.value=='title'){
			clearInput(this);
		}
	}).blur(function(){
		if($j.trim($j(this).val())==''){
			$j(this).val('title');
		}
	});
	$j('#wlcontent').focus(function(){
		if(this.value=='content'){
			clearInput(this);		
		}
	}).blur(function(){
		if($j.trim($j(this).val())==''){
			$j(this).val('content');
		}
	});
	$j('#wlemail').focus(function(){
		if(this.value=='Email'){
			clearInput(this);
		}
	}).blur(function(){
		if($j.trim($j(this).val())==''){
			$j(this).val('Email');
		}
	});
	loadLevaeMsg();
});
