

document.write("<script src=\"/Plugin/Popup/UunetPop.js\" type=\"text/javascript\"></script>");
var jobtypePop;
var industryPop;
var areaPop;
var subjobPop;
var accareapop;
//判断数据是否存在
function CheckValue(ReadValue, GetValue, value) {
    if (value) {
        if (ReadValue != null && ReadValue != "") {
            ReadValue = "&" + ReadValue;
            if (ReadValue.indexOf(",") > -1) {
                ReadValue = ReadValue.replace(/,/g, ",&");
            }

            return ReadValue.indexOf("&" + GetValue);
        }
    } else {
        return ReadValue.indexOf(GetValue);
    }
}
$(document).ready(function() {
    //alert(window.location.href.toLocaleLowerCase());
    if ($("#SubJobTypeID").length > 0) {
        var intvalue = $("#SubJobTypeID").val();
        if (intvalue == 0) {
            $("#SubJobType").val("请选择职位类别");
        } else {
            for (var i = 0; i < func_s.length; i++) {
                for (var n = 0; n < subfunc_s[i].length; n++) {
                    if (intvalue.indexOf(",") > -1) {
                        var intvalues = intvalue.split(',');
                        for (var z = 0; z < intvalues.length; z++) {
                            if (subfunc_v[i][n] == intvalues[z]) {
                                if ($("#SubJobType").val() == "请选择职位类别"||$("#SubJobType").val() =="") {
                                    $("#SubJobType").val(subfunc_s[i][n]);
                                } else {
                                    $("#SubJobType").val($("#SubJobType").val() + "," + subfunc_s[i][n]);
                                }
                            }
                        }
                    }
                    else {
                        if (subfunc_v[i][n] == intvalue) {
                            $("#SubJobType").val(subfunc_s[i][n]);

                        }
                    }
                }
            }
        }
    }
    else {
        $("#SubJobType").val($("#SubJobTypeValue").val() == "" ? "请选择职位类别" : $("#SubJobTypeValue").val());
    }


    if ($("#showjobtypevalue").length > 0) {//通过判断容器的存在来判定弹出层
        // $("#SubJobType").val($("#SubJobTypeValue").val());
        jobtypePop = new PopupLayer({ trigger: "#SubJobType", popupBlk: "#blk1", closeBtn: "#close1", useOverlay: true }); //初始化遮罩层
        $("#showjobtypevalue").empty();
        //获取职位类别
        for (var i = 0; i < func_s.length; i++) {
            $("#showjobtypevalue").html($("#showjobtypevalue").html() + "<li ><a id=\"ShowTypeJobVlaue_" + i + "\" href=\"javascript:void(0)\" onclick=\"Javascript:show(this," + i + ")\">" + func_s[i] + "</a></li>");

            for (var n = 0; n < subfunc_s[i].length; n++) {
                if (CheckValue($("#SubJobType").val(), subfunc_s[i][n], true) > -1) {
                    //showselect($("#CheckBoxList1_" + i + "_" + n + "")[0], i, n, '#selectjobvalue', '#SubJobTypeNum')
                    $("#selectjobvalue").html($("#selectjobvalue").html() + "<li id=\"CheckBoxList1_" + i + "_" + n + "_1li\"><span><input id=\"CheckBoxList1_" + i + "_" + n + "_1\" type=\"checkbox\" class=\"radio_input\" checked name=\"CheckBoxList1_" + i + "_" + n + "\" onclick=\"Cutselect(this)\" value='" + subfunc_s[i][n] + "' title='" + subfunc_v[i][n] + "' /></span><label for=\"CheckBoxList1_" + i + "_" + n + "_1\" id=\"CheckBoxList1_" + i + "_" + n + "_1lable\"\">" + subfunc_s[i][n] + "</label></li>");

                }
            }
        }
    }
    if ($("#showindustry").length > 0) {

        if ($("#SubIndustryID").length > 0) {
            var intvalue = $("#SubIndustryID").val();
            if (intvalue == 0) {
                $("#SubIndustry").val("请选择行业类别");
            } else {
                for (var i = 0; i < ind_s.length; i++) {
                    if (intvalue.indexOf(",") > -1) {
                        var intvalues = intvalue.split(',');
                        for (var z = 0; z < intvalues.length; z++) {
                            if (ind_v[i] == intvalues[z]) {
                                if ($("#SubIndustry").val() == "") {
                                    $("#SubIndustry").val(ind_s[i]);
                                } else {
                                    $("#SubIndustry").val($("#SubIndustry").val() + "," + ind_s[i]);
                                }
                            }
                        }
                    }
                    else {
                        if (ind_v[i] == intvalue) {
                            $("#SubIndustry").val(ind_s[i]);

                        }
                    }
                }
            }
            //$("#SubIndustry").val(intvalue == 0 ? "请选择行业类别" : (for(var i=0;i<ind_s.length;i++){if(ind_v[i]==intvalue){ind_s[i]}}));
        }
        else {
            $("#SubIndustry").val($("#SubIndustryValue").val() == "" ? "请选择行业类别" : $("#SubIndustryValue").val());
        }
        industryPop = new PopupLayer({ trigger: "#SubIndustry", popupBlk: "#blk2", closeBtn: "#close2", useOverlay: true }); //
        //绑定数据之前先清空元素里的值
        $("#showindustry").empty(); //
        //获取行业类别
        for (var i = 0; i < ind_s.length; i++) {
            if (CheckValue($("#SubIndustry").val(), ind_s[i], false) > -1) {//读取页面控件的值 遍历数据时判断已经选中的值
                $("#showindustry").html($("#showindustry").html() + "<li><span><input id=\"ShowIndustryValue_" + i + "\" type=\"checkbox\" class=\"radio_input\" onclick=\"showselect(this,0," + i + ",'#selectindustry','#SubIndustryNum')\" checked value='" + ind_s[i] + "' /></span>" + ind_s[i] + "</li>");
                //showselect($("#ShowIndustryValue_" + i + "")[0], i, '#selectindustry', '#SubIndustryNum');
                $("#selectindustry").html($("#selectindustry").html() + "<li id=\"ShowIndustryValue_" + i + "_1li\"><span><input id=\"ShowIndustryValue_" + i + "_1\" type=\"checkbox\" class=\"radio_input\" checked name=\"ShowIndustryValue_" + i + "\" onclick=\"Cutselect(this)\" title=\"" + ind_v[i] + "\" value='" + ind_s[i] + "' /></span><label for=\"ShowIndustryValue_" + i + "_1\" id=\"ShowIndustryValue_" + i + "_1lable\"\">" + ind_s[i] + "</label></li>");


            }
            else {
                $("#showindustry").html($("#showindustry").html() + "<li><span><input id=\"ShowIndustryValue_" + i + "\" type=\"checkbox\" class=\"radio_input\" onclick=\"showselect(this,0," + i + ",'#selectindustry','#SubIndustryNum')\" value='" + ind_s[i] + "' /></span>" + ind_s[i] + "</li>");
            }
        }
    }
    if ($("#showworkarea").length > 0) {
        $("#SubWorkArea").val($("#SubWorkAreaValue").val());
        areaPop = new PopupLayer({ trigger: "#SubWorkArea", popupBlk: "#blk_3", closeBtn: "#close3", useOverlay: true }); //
        ShowWorkAreas();
    }
    if ($("#AccArea").length > 0) {
        $("#AccArea").val($("#AccAreaValue").val());
        accareapop = new PopupLayer({ trigger: "#AccArea", popupBlk: "#blk_3_1", closeBtn: "#close3_1", useOverlay: true }); //
        ShowAccArea("first");
    }
})
function ShowAccArea(firstornot) {
    //TODO:处理
    $("#showaccarea").empty();
    //$("#selectaccarea").empty();
    if (firstornot == "backoff") {
        for (var i = 0; i < jobarea_s.length; i++) {
            $("#showaccarea").html($("#showaccarea").html() + "<li><span><input id=\"ShowAccareaValue_" + i + "\" type=\"checkbox\" class=\"radio_input\" onclick=\"showselect(this,3000," + i + ",'#selectaccarea','#SubAccAreaNum')\" value='" + jobarea_s[i] + "' /></span>" + jobarea_s[i] + "</li>");

        }
    }
    else {
        
        for (var i = 0; i < jobarea_s.length; i++) {
            if ($("#AccArea").val().split('-')[0] == jobarea_s[i]) {
                $("#showaccarea").empty();
                $("#showaccprovice").val(jobarea_s[i]); //讲选中的 省 保存在层的一个隐藏控件上  点击去点按钮后 将值赋予页面 $("#SubWorkProvice").val($("#showworkprovice").val());
                for (var n = 0; n < subarea_s[i].length; n++) {
                    if ($("#AccArea").val().split('-')[1] == subarea_s[i][n]) {
                        $("#showaccarea").html($("#showaccarea").html() + "<li><span><input id=\"ShowAccareaValue_" + i + "_" + n + "_1\" type=\"checkbox\" class=\"radio_input\" checked name=\"ShowAccareaValue_" + i + "_" + n + "\" onclick=\"showselect(this," + i + "," + n + ",'#selectaccarea','#SubAccAreaNum')\" value='" + subarea_s[i][n] + "' /></span><label for=\"ShowAccareaValue_" + i + "_" + n + "_1\" id=\"ShowAccareaValue_" + i + "_" + n + "_1\"\">" + subarea_s[i][n] + "</label></li>");
                        $("#selectaccarea").html($("#selectaccarea").html() + "<li id=\"ShowAccareaValue_" + i + "_" + n + "_1_1li\"><span><input id=\"ShowAccareaValue_" + i + "_" + n + "_1_1\" type=\"checkbox\" class=\"radio_input\" checked name=\"ShowAccareaValue_" + i + "_" + n + "_1\" onclick=\"Cutselect(this)\" value='" + subarea_s[i][n] + "' /></span><label for=\"ShowAccareaValue_" + i + "_" + n + "_1_1\" id=\"ShowAccareaValue_" + i + "_" + n + "_1_1lable\"\">" + subarea_s[i][n] + "</label></li>");

                    }
                    else {
                        $("#showaccarea").html($("#showaccarea").html() + "<li><span><input id=\"ShowAccareaValue_" + i + "_" + n + "_1\" type=\"checkbox\" class=\"radio_input\"  name=\"ShowAccareaValue_" + i + "_" + n + "\" onclick=\"showselect(this," + i + "," + n + ",'#selectaccarea','#SubAccAreaNum')\" value='" + subarea_s[i][n] + "' /></span><label for=\"ShowAccareaValue_" + i + "_" + n + "_1\" id=\"ShowAccareaValue_" + i + "_" + n + "_1\"\">" + subarea_s[i][n] + "</label></li>");

                    }
                }
                return;
            }
            else {
                $("#showaccarea").html($("#showaccarea").html() + "<li><span><input id=\"ShowAccareaValue_" + i + "\" type=\"checkbox\" class=\"radio_input\" onclick=\"showselect(this,3000," + i + ",'#selectaccarea','#SubAccAreaNum')\" value='" + jobarea_s[i] + "' /></span>" + jobarea_s[i] + "</li>");

            }
        }
    }
}
function ShowWorkAreas() {

//TODO:判定调整以后的数据输出
    $("#showworkarea").empty(); //
    $("#showworkprovice").val("襄阳");
    //获取工作地址
    for (var i = 0; i < xfarea.length; i++) {
        if (CheckValue($("#SubWorkArea").val(), xfarea[i], false) > -1) {

            $("#showworkarea").html($("#showworkarea").html() + "<li><span><input id=\"ShowWorkareaValue_" + i + "\" type=\"checkbox\" class=\"radio_input\" onclick=\"showselect(this,2000," + i + ",'#selectworkarea','#SubWorkAreaNum')\" checked value='" + xfarea[i] + "' /></span>" + xfarea[i] + "</li>");
            showselect($("#ShowWorkareaValue_" + i + "")[0], 2000, i, '#selectworkarea', '#SubWorkAreaNum');

        } else {
        $("#showworkarea").html($("#showworkarea").html() + "<li><span><input id=\"ShowWorkareaValue_" + i + "\" type=\"checkbox\" class=\"radio_input\" onclick=\"showselect(this,2000," + i + ",'#selectworkarea','#SubWorkAreaNum')\" value='" + xfarea[i] + "' /></span>" + xfarea[i] + "</li>");

        }
    }
}
function show(obj, value) {
    $("#showjobtype").empty();
    //获取二级职位类别
    for (var i = 0; i < subfunc_s[value].length; i++) {
        if (CheckValue($("#SubJobType").val(), subfunc_s[value][i], true) > -1) {
            $("#showjobtype").html($("#showjobtype").html() + "<li ><span><input id=\"CheckBoxList1_" + value + "_" + i + "\" type=\"checkbox\" class=\"radio_input\" name=\"CheckBoxList1$" + value + "$" + i + "\" onclick=\"showselect(this," + value + "," + i + ",'#selectjobvalue','#SubJobTypeNum')\" checked value='" + subfunc_s[value][i] + "' /></span><label for=\"CheckBoxList1_" + i + "\">" + subfunc_s[value][i] + "</label></li>");
        } else {
        $("#showjobtype").html($("#showjobtype").html() + "<li ><span><input id=\"CheckBoxList1_" + value + "_" + i + "\" type=\"checkbox\" class=\"radio_input\" name=\"CheckBoxList1$" + value + "$" + i + "\" onclick=\"showselect(this," + value + "," + i + ",'#selectjobvalue','#SubJobTypeNum')\" value='" + subfunc_s[value][i] + "' /></span><label for=\"CheckBoxList1_" + i + "\">" + subfunc_s[value][i] + "</label></li>");
        }

    }
    subjobPop = new PopupLayer({ trigger: "#" + obj.id, popupBlk: "#blk_4", closeBtn: "#close4" });//打开二级层 动态输出数据
}
//通过Value判断层应该输出全国地区还是襄阳地区
function ChangeAreaValue(value) {


    $("#selectworkarea").empty();
    switch (value) {
        case 1: //全国地区
            $("#showworkarea").empty();
            $("#chinaArea").hide();
            $("#XFArea").show();
            for (var i = 0; i < jobarea_s.length; i++) {

                $("#showworkarea").html($("#showworkarea").html() + "<li><span><input id=\"ShowWorkareaValue_" + i + "\" type=\"checkbox\" class=\"radio_input\" onclick=\"showselect(this,1000," + i + ",'#selectworkarea','#SubWorkAreaNum')\" value='" + jobarea_s[i] + "' /></span>" + jobarea_s[i] + "</li>");
            }
            break;
        case 2: //襄阳地区
            $("#showworkarea").empty();
            $("#chinaArea").show()
            $("#XFArea").hide();
            $("#showworkprovice").val("襄阳");
            for (var i = 0; i < xfarea.length; i++) {
                if (CheckValue($("#SubWorkArea").val(), xfarea[i], false) > -1) {

                    $("#showworkarea").html($("#showworkarea").html() + "<li><span><input id=\"ShowWorkareaValue_" + i + "\" type=\"checkbox\" class=\"radio_input\" onclick=\"showselect(this,2000," + i + ",'#selectworkarea','#SubWorkAreaNum')\" checked value='" + xfarea[i] + "' /></span>" + xfarea[i] + "</li>");
                    showselect($("#ShowWorkareaValue_" + i + "")[0], 2000,  i , '#selectworkarea', '#SubWorkAreaNum');

                } else {
                $("#showworkarea").html($("#showworkarea").html() + "<li><span><input id=\"ShowWorkareaValue_" + i + "\" type=\"checkbox\" class=\"radio_input\" onclick=\"showselect(this,2000," + i + ",'#selectworkarea','#SubWorkAreaNum')\" value='" + xfarea[i] + "' /></span>" + xfarea[i] + "</li>");

                }
            }
            break;
    }
}


//obj 第一层选中元素  value 一级分类 intvalue 二级分类 type 获取页面hidden的值循环输出几次
function showselect(obj, value, intvalue, showvalue, type) {
    if (obj.checked) {//判断第一层的一级分类是选中还是取消
        if ($(showvalue).find("li").length < $(type).val()) {
            switch (showvalue) {
                case "#selectjobvalue":
                    $(showvalue).html($(showvalue).html() + "<li id=\"" + obj.id + "_1li\"><span><input id=\"" + obj.id + "_1\" type=\"checkbox\" class=\"radio_input\" checked name=\"" + obj.id + "\" onclick=\"Cutselect(this)\" value='" + subfunc_s[value][intvalue] + "' title='" + subfunc_v[value][intvalue] + "' /></span><label for=\"" + obj.id + "_1\" id=\"" + obj.id + "_1lable\"\">" + subfunc_s[value][intvalue] + "</label></li>");
                    break;
                case "#selectindustry":
                    $(showvalue).html($(showvalue).html() + "<li id=\"" + obj.id + "_1li\"><span><input id=\"" + obj.id + "_1\" type=\"checkbox\" class=\"radio_input\" checked name=\"" + obj.id + "\" onclick=\"Cutselect(this)\" title=\"" + ind_v[intvalue] + "\" value='" + ind_s[intvalue] + "' /></span><label for=\"" + obj.id + "_1\" id=\"" + obj.id + "_1lable\"\">" + ind_s[intvalue] + "</label></li>");
                    break;
                case "#selectworkarea":
                    if (value == 2000) {//value==2000 表示选中的 襄阳市地区
                        $(showvalue).html($(showvalue).html() + "<li id=\"" + obj.id + "_1li\"><span><input id=\"" + obj.id + "_1\" type=\"checkbox\" class=\"radio_input\" checked name=\"" + obj.id + "\" onclick=\"Cutselect(this)\" value='" + xfarea[intvalue] + "' /></span><label for=\"" + obj.id + "_1\" id=\"" + obj.id + "_1lable\"\">" + xfarea[intvalue] + "</label></li>");
                    }
                    else if (value == 1000) {//value==1000 表示选中的 全国
                        $("#showworkarea").empty();
                        $("#showworkprovice").val(jobarea_s[intvalue]); //讲选中的 省 保存在层的一个隐藏控件上  点击去点按钮后 将值赋予页面 $("#SubWorkProvice").val($("#showworkprovice").val());
                        for (var i = 0; i < subarea_s[intvalue].length; i++) {
                            $("#showworkarea").html($("#showworkarea").html() + "<li><span><input id=\"" + obj.id + "_" + i + "_1\" type=\"checkbox\" class=\"radio_input\" name=\"" + obj.id + "_" + i + "\" onclick=\"showselect(this," + intvalue + "," + i + ",'#selectworkarea','#SubWorkAreaNum')\" value='" + subarea_s[intvalue][i] + "' /></span><label for=\"" + obj.id + "_" + i + "_1\" id=\"" + obj.id + "_" + i + "_1\"\">" + subarea_s[intvalue][i] + "</label></li>");
                        }
                    }
                    else {
                        $(showvalue).html($(showvalue).html() + "<li id=\"" + obj.id + "_1li\"><span><input id=\"" + obj.id + "_1\" type=\"checkbox\" class=\"radio_input\" checked name=\"" + obj.id + "\" onclick=\"Cutselect(this)\" value='" + subarea_s[value][intvalue] + "' /></span><label for=\"" + obj.id + "_1\" id=\"" + obj.id + "_1lable\"\">" + subarea_s[value][intvalue] + "</label></li>");
                    }

                    break;
                case "#selectaccarea":
                    if (value == 3000) {
                        $("#showaccarea").empty();
                        $("#showaccprovice").val(jobarea_s[intvalue]); //讲选中的 省 保存在层的一个隐藏控件上  点击去点按钮后 将值赋予页面 $("#SubWorkProvice").val($("#showworkprovice").val());
                        for (var i = 0; i < subarea_s[intvalue].length; i++) {
                            $("#showaccarea").html($("#showaccarea").html() + "<li><span><input id=\"" + obj.id + "_" + i + "_1\" type=\"checkbox\" class=\"radio_input\" name=\"" + obj.id + "_" + i + "\" onclick=\"showselect(this," + intvalue + "," + i + ",'#selectaccarea','#SubAccAreaNum')\" value='" + subarea_s[intvalue][i] + "' /></span><label for=\"" + obj.id + "_" + i + "_1\" id=\"" + obj.id + "_" + i + "_1\"\">" + subarea_s[intvalue][i] + "</label></li>");
                            //showselect($("#" + obj.id + "_" + i + "_1")[0], intvalue, i, '#selectaccarea', '#SubAccAreaNum');
                        }
                    } else {
                    $(showvalue).html($(showvalue).html() + "<li id=\"" + obj.id + "_1li\"><span><input id=\"" + obj.id + "_1\" type=\"checkbox\" class=\"radio_input\" checked name=\"" + obj.id + "\" onclick=\"Cutselect(this)\" value='" + subarea_s[value][intvalue] + "' /></span></span><label for=\"" + obj.id + "_1\" id=\"" + obj.id + "_1lable\"\">" + subarea_s[value][intvalue] + "</label></li>");

                    }
                    break;
            }
        }
        else {
            MsgBox.alert("对不起，一次最多选" + $(type).val() + "个");
            obj.checked = false;
        }
    } else {
        RemoveValue(obj.id + "_1");//从选中的值中删除被取消的值
    }
}
function Cutselect(obj) {
    RemoveValue(obj.id);
    if ($("#" + obj.name).length > 0) {
        $("#" + obj.name).attr("checked", false);
    }
}
function RemoveValue(id) {
    $("#" + id).remove(); //勾选掉已选择的checkbox
    $("#" + id + "lable").remove(); //勾选掉已选择的lable
    $("#" + id + "li").remove(); //勾选掉已选择的li
}
function showselectButton(selector, showselector, value) {
    var showvalue = "";
    $(selector).each(function() {
        if (showvalue == "") {
            showvalue = $(this).val();
        } else {
            showvalue = showvalue + ',' + $(this).val();
        }
    })


//根据value关闭对应的POp
    switch (value) {
        case 1:
            if (showvalue == "") {
                showvalue = "请选择职位类别";
                if ($("#SubJobTypeID").length > 0) {
                    $("#SubJobTypeID").val("");
                }
            }
            else {
                var showtitleID = "";
                $(selector).each(function() {
                    if (showtitleID == "") {
                        showtitleID = $(this).attr("title");
                    } else {
                        showtitleID = showtitleID + ',' + $(this).attr("title");
                    }
                })
                $("#SubJobTypeID").val(showtitleID);
            }
            ClosePop(jobtypePop);
            if (subjobPop != null) {
                subjobPop.popupLayer.hide();
            }

            break;
        case 2:
            if (showvalue == "") {
                showvalue = "请选择行业类别";
                if ($("#SubIndustryID").length > 0) {
                    $("#SubIndustryID").val("");
                }
            }
            else {
                var showtitleID = "";
                $(selector).each(function() {
                    if (showtitleID == "") {
                        showtitleID = $(this).attr("title");
                    } else {
                        showtitleID = showtitleID + ',' + $(this).attr("title");
                    }
                })
                $("#SubIndustryID").val(showtitleID);
            }

            ClosePop(industryPop);
            break;
        case 3:
            if (showvalue == "") {
                showvalue = "请选择地点";
            }
            else {
                if ($("#SubWorkProvice").length > 0) {//判断元素是否存在
                    $("#SubWorkProvice").val($("#showworkprovice").val()); //将 省 保存在遮罩层 确定后将值赋予页面HIDDEN控件
                    showvalue = $("#showworkprovice").val() + "-" + showvalue;
                }
            }
            ClosePop(areaPop);
            break;
        case 4:
            if (showvalue == "") {
                showvalue = "请选择户口所在地";
            }
            else {
                if ($("#SubAccAreaProvice").length > 0) {//判断元素是否存在
                    $("#SubAccAreaProvice").val($("#showaccprovice").val()); //将 省 保存在遮罩层 确定后将值赋予页面HIDDEN控件
                    showvalue = $("#showaccprovice").val() + "-" + showvalue;
                }
            }
            ClosePop(accareapop);
            break;
    }
    var showselectorvalue = showselector + "Value";
    if ($(showselectorvalue).length > 0) {
        $(showselectorvalue).val(showvalue);
    }
    $(showselector).val(showvalue); //讲遮罩层选中的值赋予页面控件
}
function ClosePop(pop) {//关闭按钮事件
    if (pop != null) {
        pop.options.useOverlay ? pop.overlay.hide() : null;
        pop.options.useFx ? pop.doEffects("close") : pop.popupLayer.hide();
    }
}
function CloseButton() {//关闭自己的同时关闭子遮罩层
    jobtypePop.options.useOverlay ? jobtypePop.overlay.hide() : null;
    jobtypePop.options.useFx ? jobtypePop.doEffects("close") : jobtypePop.popupLayer.hide();
    if (subjobPop != null) {
        subjobPop.popupLayer.hide();
    }
}
//***********************
//作者：zzw
//时间：2011-8-13
//**********************
