﻿function get_all_news_clss(obj_id, obj_id1) {
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "../../WebService.asmx/get_all_news_clss",
        //strDepartId 参数名称 collegeId 参数值
        data: "{objid:'" + obj_id + "',objid1:'" + obj_id1 + "'}",
        dataType: "json",
        success: function(result) {
            try {
                if (result) {
                    if (!$("#news_div").length > 0) {
                        //创建一个层
                        $("body").append("<div class=\"sheng\" id=\"news_div\"  title=\"请选择所需要的分类！\" icon=\"icon-save\" style=\"padding:5px;width:600px;height:300px;\"><div id='news_div_count'>" + result.d.toString() + "</div></div>");
                        $("#news_div").ready(function() {
                        $('#news_div').dialog();
                        $('#news_div li').mouseover(function() {

                        $('#news_div li').removeClass("shengchose");
                        $(this).addClass("shengchose");
                            })

                        })
                    } else {
                    $('#news_div_count').attr("innerHTML", result.d.toString());
                    $('#news_div').dialog();
                    $('#news_div li').mouseover(function() {
                    $('#news_div li').removeClass("shengchose");
                     $(this).addClass("shengchose");
                        })

                    } //if
                }
            }
            catch (e) {
                alert("错误>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });
}

function get_gg(kj_id, gg_id) {
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "WebService.asmx/get_gg",
        //strDepartId 参数名称 collegeId 参数值
        data: "{id:1}",
        dataType: "json",
        success: function(result) {
            varjson = null
            try {
                if (result) {
                    $("#" + kj_id).attr("src", result.d);
                }
            }
            catch (e) {
                alert("错误>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });
}

function get_img(kj_id,gg_id) {
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "/WebService.asmx/get_img",
        //strDepartId 参数名称 collegeId 参数值
        data: "{img_key:'" + gg_id + "',cls:0}",
        dataType: "json",
        success: function(result) {
            varjson = null
            try {
                if (result) {
                     //  alert(result.d.toString());
                   var msg= result.d.toString().split("#|#");
                   var tmp_str="";
                 for(var i=0;i<=msg.length-1;i++){
                    tmp_str+="<img border=1 src="+msg[i]+" width=100 height=100/>";
                 }
                     //判断图片的大小
                       try{
                         $("#" + kj_id).attr("innerHTML",tmp_str);
                        }catch(e1){}
                }
            }
            catch (e) {
                alert("错误1>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });
}


function get_all_jx_msg_mb() {
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "../../WebService.asmx/get_all_jx_msg_mb",
        //strDepartId 参数名称 collegeId 参数值
        data: "{}",
        dataType: "json",
        success: function(result) {
            varjson = null
            try {
                if (result) {
                    if (!$("#mb").length > 0) {
                        //创建一个层
                        $("body").append("<div class=\"sheng\" id=\"mb\"  title=\"请选择合适的模板！\" icon=\"icon-save\" style=\"padding:5px;width:600px;height:300px;\"><div id='mb_count'><ul>" + result.d.toString() + "</ul></div></div>");
                        $("#mb").ready(function() {
                            $('#mb').dialog();
                            $('#mb li').mouseover(function() {

                                $('#mb li').removeClass("shengchose");
                                $(this).addClass("shengchose");
                            })

                        })
                    }

                    else {
                        $('#mb_count').attr("innerHTML", result.d.toString());
                        $('#bm').dialog();
                        $('#mb li').mouseover(function() {
                            $('#bm li').removeClass("shengchose");
                            $(this).addClass("shengchose");
                        })
                    
                    
                     } 
                }
            }
            catch (e) {
                alert("错误2>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });

}

function fill_jx_mb_msg(id_) {
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "../../WebService.asmx/get_jx_msg",
        //strDepartId 参数名称 collegeId 参数值
        data: "{id_:" + id_ + "}",
        dataType: "json",
        success: function(result) {
            try {
                SetEditorContents($("input[id$='txtJX_FYBH']").attr("id"), result.d._JX_FYBH.toString());
                SetEditorContents($("input[id$='txtJX_FYBBH']").attr("id"), result.d._JX_FYBBH.toString());
                SetEditorContents($("input[id$='txtJX_BMTJ']").attr("id"), result.d._JX_BMTJ.toString());
                SetEditorContents($("input[id$='txtJX_BMXZ']").attr("id"), result.d._JX_BMXZ.toString());
                SetEditorContents($("input[id$='txtJX_BMLXFS']").attr("id"), result.d._JX_BMLXFS.toString());
                SetEditorContents($("input[id$='txtJX_ZYSX']").attr("id"), result.d._JX_ZYSX.toString());
            }
            catch (e) {
                alert("错误>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });

}

// 设置编辑器中内容
function SetEditorContents(EditorName, ContentStr) {
    var oEditor = FCKeditorAPI.GetInstance(EditorName);
    oEditor.SetHTML(ContentStr);
}

function login(kj_id, gg_id) {
    kj_id = encodeURI(kj_id);
    gg_id = encodeURI(gg_id);
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "../WebService.asmx/ck_user",
        //strDepartId 参数名称 collegeId 参数值
        data: "{username:'" + kj_id + "',userpwd:'" + gg_id + "'}",
        dataType: "json",
        success: function(result) {
            try {
                if (result) {
                    eval(result.d.toString());
                }
            }
            catch (e) {
                alert("错误>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });
}


//get_gg("gg01",1);

//获得省数据 
function get_sheng(obj_id,obj_id1) {
    //判断#w是否存在如果则不再记载
    if ($("#w").length > 0) {
        $('#w').dialog('open');
        return;
    }
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "../../WebService.asmx/get_sheng",
        //strDepartId 参数名称 collegeId 参数值
        data: "{objid:'" + obj_id + "',objid1:'" + obj_id1 + "'}",
        dataType: "json",
        success: function(result) {
            try {
                if (result) {
                    //创建一个层
                    if (!$("#w").length > 0) {
                        $("body").append("<div class=\"sheng\" id=\"w\"  title=\"请选择所需要的省份！\" icon=\"icon-save\" style=\"padding:5px;width:600px;height:300px;\">" + result.d.toString() + "</div>");
                        $("#w").ready(function() {
                            $('#w').dialog();
                            $('#w li').mouseover(function() {

                                $('#w li').removeClass("shengchose");
                                $(this).addClass("shengchose");
                            })

                        })
                    }
                    else {
                        $('#w_count').attr("innerHTML", result.d.toString());
                        $('#w').dialog();
                        $('#w li').mouseover(function() {
                            $('#w li').removeClass("shengchose");
                            $(this).addClass("shengchose");
                        })


                    }

                }
            }
            catch (e) {
                alert("错误>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });
}


//get_gg("gg01",1);

function get_shi(obj_id, obj_id1, kj_id) {
    if (kj_id == null || kj_id == "") {
        alert("请选择所在省！");
        return;
    }
    kj_id = encodeURI(kj_id);
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "../../WebService.asmx/get_shi",
        //strDepartId 参数名称 collegeId 参数值
        data: "{objid:'" + obj_id + "',objid1:'" + obj_id1 + "',sheng_id:" + kj_id + "}",
        dataType: "json",
        success: function(result) {
            try {
                if (result) {
                    if (!$("#s").length > 0) {
                        //创建一个层
                        $("body").append("<div class=\"sheng\" id=\"s\"  title=\"请选择所需要的市！\" icon=\"icon-save\" style=\"padding:5px;width:600px;height:300px;\"><div id='s_count'>" + result.d.toString() + "</div></div>");
                        $("#s").ready(function() {
                            $('#s').dialog();
                            $('#s li').mouseover(function() {

                                $('#s li').removeClass("shengchose");
                                $(this).addClass("shengchose");
                            })

                        })
                    } else {
                        $('#s_count').attr("innerHTML", result.d.toString());
                        $('#s').dialog();
                        $('#s li').mouseover(function() {
                            $('#s li').removeClass("shengchose");
                            $(this).addClass("shengchose");
                        })

                    } //if
                }
            }
            catch (e) {
                alert("错误>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });
}



//get_gg("gg01",1);

function get_dq(obj_id, obj_id1, kj_id) {
    if (kj_id == null||kj_id =="") {
        alert("请选择所在城市！");
        return;
    }
    kj_id = encodeURI(kj_id);
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "../../WebService.asmx/get_dq",
        //strDepartId 参数名称 collegeId 参数值
        data: "{objid:'" + obj_id + "',objid1:'" + obj_id1 + "',shi_id:" + kj_id + "}",
        dataType: "json",
        success: function(result) {
            try {
                if (result) {
                    if (!$("#q").length>0) {
                    //创建一个层
                    $("body").append("<div class=\"sheng\" id=\"q\"  title=\"请选择所需要的市！\" icon=\"icon-save\" style=\"padding:5px;width:600px;height:300px;\"><div id='q_count'>" + result.d.toString() + "</div></div>");
                    $("#q").ready(function() {
                        $('#q').dialog();
                        $('#q li').mouseover(function() {

                            $('#q li').removeClass("shengchose");
                            $(this).addClass("shengchose");
                        })

                    })
                    } else {
                    $('#q_count').attr("innerHTML", result.d.toString());
                        $('#q').dialog();
                        $('#q li').mouseover(function() {
                            $('#q li').removeClass("shengchose");
                            $(this).addClass("shengchose");
                        })

                    } //if
                }
            }
            catch (e) {
                alert("错误>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });
}

function get_jx(obj_id, obj_id1) {
    $.ajax({
        type: "POST",
        //注明 返回Json
        contentType: "application/json;utf-8",
        //CollegeDepartWebServices.asmx web服务名 /GetCollegeDepart 方法名
        url: "../../WebService.asmx/get_all_jx",
        //strDepartId 参数名称 collegeId 参数值
        data: "{objid:'" + obj_id + "',objid1:'" + obj_id1 + "'}",
        dataType: "json",
        success: function(result) {
            try {
                if (result) {
                    if (!$("#jx").length>0) {
                    //创建一个层
                        $("body").append("<div class=\"sheng\" id=\"jx\"  title=\"请选择所需要的市！\" icon=\"icon-save\" style=\"padding:5px;width:600px;height:300px;\"><div id='jx_count'>" + result.d.toString() + "</div></div>");
                    $("#jx").ready(function() {
                    $('#jx').dialog();
                    $('#jx li').mouseover(function() {

                    $('#jx li').removeClass("shengchose");
                            $(this).addClass("shengchose");
                        })

                    })
                    } else {
                    $('#jx_count').attr("innerHTML", result.d.toString());
                    $('#jx').dialog();
                    $('#jx li').mouseover(function() {
                    $('#jx li').removeClass("shengchose");
                            $(this).addClass("shengchose");
                        })

                    } //if
                }
            }
            catch (e) {
                alert("错误>>" + e.message);
                return;

            }

        },
        error: function(data) {
            alert(data.status + ">>>" + data.statusText);
        }
    });
}
function fill_sheng_data(t1, t2, t3,t4) {
    try {
        $("input[id$=" + t1 + "]").attr("value", t3);
        $("input[id$=" + t2 + "]").attr("value", t4);
    } catch (exception) { }

    $("#w").dialog('close');
}

function fill_news_cls_data(t1, t2, t3, t4) {
    try {
        $("input[id$=" + t1 + "]").attr("value", t3);
        $("input[id$=" + t2 + "]").attr("value", t4);
    } catch (exception) { }

    $("#news_div").dialog('close');
}

function fill_shi_data(t1, t2, t3, t4) {
    try {
        $("input[id$=" + t1 + "]").attr("value", t3);
        $("input[id$=" + t2 + "]").attr("value", t4);
    } catch (exception) { }

    $("#s").dialog('close');
}

function fill_dq_data(t1, t2, t3, t4) {
    try {
        $("input[id$=" + t1 + "]").attr("value", t3);
        $("input[id$=" + t2 + "]").attr("value", t4);
    } catch (exception) { }

    $("#q").dialog('close');
}

function fill_jx_data(t1, t2, t3, t4) {
    try {
        $("input[id$=" + t1 + "]").attr("value", t3);
        $("input[id$=" + t2 + "]").attr("value", t4);
    } catch (exception) { }

    $("#jx").dialog('close');
}


function chose_this(t1) {
    try {
        fill_jx_mb_msg(t1);
    } catch (exception) { }
    $("#mb").dialog('close');
}


