function checkFormMessage(){
    if(!($("#name").val().match(/^[a-zA-Z\u0391-\uFFE5]{2,8}$/))){
		alert("请输入正确的姓名");
		return false;
	}
    if($("#contact").val() == ""){
        alert("请输入正确的号码");
        return false;
    }
	if(!($("#email").val().match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/))){
		alert("请输入正确的邮箱地址!");
		return false;
	}
	if($("#title").val().trim() == ""){
		alert("标题必须填写");
		return false;
	}
	if($("#content").val().trim() == ""){
		alert("详细内容必须填写");
		return false;
	}
}

function checkFormMailMessage(){
    if(!($("#name").val().match(/^[a-zA-Z\u0391-\uFFE5]{2,8}$/))){
        alert("请输入正确的姓名");
        return false;
    }
    if(!($("#orgName").val().match(/^[a-zA-Z\u0391-\uFFE5]{2,20}$/))){
        alert("请输入正确的单位名称");
        return false;
    }
    if($("#contact").val() == ""){
        alert("请输入号码");
        return false;
    }
    if(!($("#email").val().match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/))){
        alert("请输入正确的邮箱地址!");
        return false;
    }
    if($("#address").val().trim() == ""){
        alert("地址必须填写");
        return false;
    }
	if($("#title").val().trim() == ""){
		alert("主题必须填写");
		return false;
	}
	if($("#content").val().trim() == ""){
		alert("详细内容必须填写");
		return false;
	}
}

//审核状态，回复状态 回显操作
$(document).ready(function(){
	var checkStateValue = $('.checkStateClass').val(); 
	$('select[id="checkStateID"] option[value="' + checkStateValue + '"]').attr({selected: true});	 
	var replyStateValue = $('.replyStateClass').val(); 
	$('select[id="replyStateID"] option[value="' + replyStateValue + '"]').attr({selected: true});	
});

//留言回复
function hasReply(){
	alert("该留言回复请不要重复回复");
}

//批量删除
function delSelect(){
	ids = "";
	$(":checkbox[name='checkOne']").each(function(){
		if($(this).attr("checked") == true){
			ids += $(this).val() + ","; 
		}
	});
    
	if(ids.length<2){
		alert("请至少选择一个");
	}else{//批量留言状态
        if(confirm("确定要删除?"))
        $.ajax({
            type:"post",
            url:"messageInfo/removeSelectMessageInfo.html",
            data:"ids="+ids,
            dataType:"html",
            error:function(){alert("出错了");},
            success:function(){window.location.reload();alert("操作成功");}
        });
	}
}


//成功信息提示
function init(message){
		if(message != '' && message != null)
		alert(message);
}   

//查看领导信箱详细情况
function viewDetailMailMessage(id){
    openLayer('body_div','div_pop_'+id);
}

function viewDetailMailMessageMethod(id, state){
	if(state == 1){
	    $.ajax({
		    type:"post",
		    url:"messageInfo/toViewDetailMailMessageInfo.html",
		    data:"id="+id,
		    dataType:"html",
		    error:function(){alert("出错了");},
		    success:function(){closeLayer();window.location.reload();}
		});
    } else {
        closeLayer();
    }
        
}

//批量阅读状态
function readState1(){
    ids = "";
    $(":checkbox[name='checkOne']").each(function(){
        if($(this).attr("checked") == true){
            ids += $(this).val() + ","; 
        }
    });
    if(ids.length<2){
        alert("请至少选择一个");
    }else{
	    openLayer('body_div', 'div_readState');
        $("#readStateIDS").val(ids);
    }
}

function readState2(){
    stateValue = $(":radio[name='readState'][checked]").val();
    $.ajax({
        type:"post",
        url:"messageInfo/modifyReplyStateMessageInfo.html",
        data:"ids="+ids+"&state="+stateValue,
        dataType:"html",
        error:function(){alert("出错了");},
        success:function(){alert("操作成功");window.location.reload();}
    });
     closeLayer();
}
