<!--
function search() {
	try {
		var keyword = $("#keyword");
		if(keyword.val() == null || keyword.val() == "") {
			keyword.focus();
			return false;
		} else {
			$("#searchForm").submit();
		}
	}catch(e){
		return false;
	}
}

function resetComplain() {
	$("#title").val("");
	$("#content").val("");
	$("#name").val("游客");
	$("#phone").val("");
	$("#title").focus();
}

function resetArticle() {
	$("#title").val("");
	$("#content").val("");
	$("#author").val("游客");
}

function complain() {
	try {
		var title = $("#title");
		var content = $("#content");
		var name = $("#name");
		var phone = $("#phone");

		if(isNull(title)) {
			alert('投诉标题不能为空');
			title.focus();
			return false;
		} else if(isNull(content)) {
			alert('投诉内容不能为空');
			content.focus();
			return false;
		} else if(isNull(name)) {
			alert('您的呢称不能为空');
			name.focus();
			return false;
		} else if(isNull(phone)) {
			alert('联系方式不能为空');
			phone.focus();
			return false;
		} else {
			$.ajax({
				type:'POST',
				dataType:'text',
				url:'/index.shtml',
				data:'method=complain&title='+encode(title)+'&content='+encode(content)+'&name='+encode(name)+'&phone='+encode(phone)+'&t='+new Date().getTime(),
				success:function(data){
					if(data == "suc"){
						alert('游客投诉成功');
						resetComplain();
						return false;
					} else {
						alert(data);
						return false;
					}
				}
			});
		}
		return false;
	}catch(e){}
}

function article() {
	try {
		var title = $("#title");
		var author = $("#author");
		
		var editor = FCKeditorAPI.GetInstance('content');
		//alert(editor.GetXHTML(true)); 获取HTML内容
		//alert(editor.EditorDocument.body.innerText); //获取文字内容
		//var content = editor.EditorDocument.body.innerText;
		var content = null;
		if(content == null || content == "") {
			content = editor.GetXHTML(true);
		}
		if(isNull(title)) {
			alert('文章标题不能为空');
			title.focus();
			return false;
		} else if(content == null || content == "") {
			alert('文章内容不能为空');
			return false;
		} else if(isNull(author)) {
			alert('您的呢称不能为空');
			author.focus();
			return false;
		} else {
			$.ajax({
				type:'POST',
				dataType:'text',
				url:'/index.shtml',
				data:'method=article&title='+encode(title)+'&content='+encodeURI(encodeURI(content))+'&author='+encode(author)+'&t='+new Date().getTime(),
				success:function(data){
					if(data == "suc"){
						alert('在线投稿成功');
						resetArticle();
						return false;
					} else {
						alert(data);
						return false;
					}
				}
			});
		}
		return false;
	}catch(e){}
}

/**
 * 对JQuery的encode方法进行二次封装
 */
function encode(value) {
	try {
		var value = $(value);
		return encodeURI(encodeURI(value.val()));
	}catch(e){}
}

/**
 * 验证指定的jQuery对象里面的value是否为空
 * @param value 要验证的jQuery对象
 * @result 如果结果为空,则返回true , 如果不为空,则返回false
 */
function isNull(value) {
	try {
		var value = $(value);
		if($.trim(value.val()) == null || $.trim(value.val()) == "") {
			return true;
		} else {
			return false;
		}
	}catch(e){}
}
/**
 * 阻止事件传播
 */
function stopBubble(e) {  
  try {
  	var e = e ? e : window.event;  
	if (window.event) { // IE  
	    e.cancelBubble = true;
	} else { // FF  
	    e.preventDefault();   
	    e.stopPropagation();   
	}  
  }catch(e){
  } 
} 

/*
 * 检查是否是数字
 */
function is_number(str)
{
	exp=/[^0-9()-]/g;
	if(str.search(exp) != -1)
	{
		return false;
	}
	return true;
}
/*
 * 检查是否是是电子邮件
 */
function is_email(str)
{ if((str.indexOf("@")==-1)||(str.indexOf(".")==-1))
{
	
	return false;
	}
	return true;
}
/*
 * 验证留言表单
 */
function ValidateMessage(){
    var form = document.getElementById("form");
	if(form.name.value==''){
		alert("请填写您的留言昵称！");
		form.name.focus();
		return false;
	}
	else if(form.name.value.length>30){
		alert("昵称不能超过30个字符！");
		form.name.focus();
		return false;
	}
	else if(form.title.value==''){
		alert("请填写留言标题！");
		form.title.focus();
		return false;
	}
	else if(form.email.value != '') {
		if(!is_email(form.email.value)) {
			alert("您的EMail地址是错误的！");
			form.email.focus();
			return false;
		}					
	}
	else if(!is_number(form.qq.value)){
		alert("QQ号只能是数字哦！");
		form.qq.focus();
		return false;
	}
	else if(form.address.value==''){
		alert("请您填写您的通讯地址！");
		form.address.focus();
		return false;
	}
	else if(form.content.value==''){
		alert("请您填写您的留言内容！");
		form.content.focus();
		return false;
	}
	else if(form.messagecode.value=='') {
		alert("请输入验证码！");
		form.messagecode.focus();
		return false;				
	}
	else {
		return true;
	}
}
//-->
