$(document).ready(function(){
    KeyWord();
});

function init(message){
    if(message != '')
        alert(message);
}

 function viewMoreNewsInfo(id){
$('#paramID').val(id);
$('#searchMoreForm').submit();
 }
 
//修改资讯状态
function modifyNewsStateDiv(cover, show){
    ids = "";
    $(":checkbox[name='chk']").each(function(){
        if($(this).attr("checked") == true){
            ids += $(this).val() + ","; 
        }
    });
    if(ids.length<2){
        alert("请至少选择一个!");
    }else{
        openLayer(cover, show);
    }
}

function modifyNewsStateMethod(){
    var flag = false;
	$(":checkbox[name='chk']").each(function(){if($(this).attr('checked')==true)flag = true;})
	if(!flag){alert("请选择你要操作的选项");	return false;}
	var str ="";
	$(":checkbox[name='chk']").each(function(){if($(this).attr('checked')==true)	str = str+$(this).val()+",";})
    var ids = str;
    stateValue = $(":radio[name='newsState'][checked]").val();
        $.ajax({
            type:"post",
            url:"modifyStateAndSortNewsInfo.html",
            data:"ids="+ids+"&state="+stateValue,
            dataType:"html",
            error:function(){alert("出错了");},
            success:function(){closeLayer();location.href='toModifyListNewsInfo.html';alert("操作成功");}
        });  
}

//修改资讯序号
function modifyNewsSortDiv(cover, show){
    ids = "";
    $(":checkbox[name='chk']").each(function(){
        if($(this).attr("checked") == true){
            ids += $(this).val() + ","; 
        }
    });
    if(ids.length<2){
        alert("请至少选择一个!");
    }else{
        openLayer(cover, show);
        $("#newsSortIDS").val(ids);
    }
}

function modifyNewsSortMethod(){
    ids = $("#newsSortIDS").val();
    sortValue = $("#sortId").val();
    if($.trim(sortValue) == ""){
        alert("序号不能为空");
    }else{
        $.ajax({
            type:"post",
            url:"modifyStateAndSortNewsInfo.html",
            data:"ids="+ids+"&sort="+sortValue,
            dataType:"html",
            error:function(){alert("出错了");},
            success:function(){closeLayer();window.location.reload();alert("操作成功");}
        });  
    }
}

//删除资讯
function delNews(id){
    var ids = "";
    $(":checkbox[name='chk']").each(function(){
        if($(this).attr("checked") == true){
            ids += $(this).val() + ","; 
        }
    });
    if(id != 'IDS'){
        ids = id;
    }
    if(ids.length < 2){
        alert("请至少选择一个!");
    }else{
        if(confirm('确定要删除？')){
	        $.ajax({
	            type:"post",
	            url:"modifyStateAndSortNewsInfo.html",
	            data:"ids="+ids+"&state=4",
	            error:function(){alert("出错了");},
	            success:function(){window.location.reload();alert("操作成功");}
	        });  
        }

    }
}

function viewDetailFAQ(id){
            $.ajax({
                type:"post",
                url:"viewDetailFAQNewsInfo.html",
                data:"id="+id,
                dataType:"html",
                error:function(){alert("出错了");},
                success:function(){window.location.reload();}
            });
            ShowBox('contentBox_'+id,1);
}

