﻿// JScript 文件
var MaxIndustryCount = 0;
var IsSingleSelect="";
function ShowIndustryDialog(ObjIDsID,ObjTextsID,isResume,isSingleSelect)
{
    var ObjIDs = $(ObjIDsID);
    var ObjTexts = $(ObjTextsID);
    IsSingleSelect=isSingleSelect;
    //记录保存选择ID列表的控件名称
    ResultSelsStr = ObjIDs.value + ",";
    MaxIndustryCount = parseInt($("HidMaxCountIndustry").value);
    
    //定制标题
    var CaptionStr = "请选择您想选择的行业"; 
    if (MaxIndustryCount > 0)
    {
        CaptionStr += "(最多选择" + MaxIndustryCount + "项)";  
    } 
      
    var IDStr = "DlgIndustry";
    
    var ContentStr = "";
        
    //定制小类选择区域
    var ChdSelDiv = document.createElement("div");
    ChdSelDiv.className = "listblk bx";
    
    var ChdSelTbl = document.createElement("table");
    ChdSelTbl.id = "TblChildIndustry";
    
    CreateCheckBoxList(ChdSelTbl,"Industry","0",ResultSelsStr,"CheckChangeIndustry",3)
    
    ChdSelDiv.appendChild(ChdSelTbl);
    ContentStr += ChdSelDiv.outerHTML;
    
    //定制已经选择区域
    var SelDiv = document.createElement("div");
    SelDiv.className = "layer_jg";
    
    var SelTbl = document.createElement("table");
    SelTbl.id = "TblSelIndustry";
    
    CreateSelCheckBoxList(SelTbl,"Industry",ResultSelsStr,"CheckChangeIndustry",3);
    
    SelDiv.appendChild(SelTbl);
    
    ContentStr += "<h4 style=\" font-size:12px\">您已经选择的行业是：<a href=\"####\" onclick=\"ClearSelectedItems('Industry')\">清空所有选项</a></h4>"
    ContentStr += SelDiv.outerHTML;
    
    //定制按钮区域
    var BtnDiv = document.createElement("div");
    BtnDiv.className = "regtj";
    
    var BtnOK = document.createElement("input");
    BtnOK.id = "BtnIndustryOK";
    BtnOK.type = "button";
    BtnOK.value = "确定";
    BtnOK.setAttribute("onclick", "SaveSels('Industry',ResultSelsStr,$('" + ObjIDs.id + "'),$('" + ObjTexts.id + "'),'"+IsSingleSelect+"');CloseDialog('" + IDStr + "');");
    
    var BtnCancel = document.createElement("input");
    BtnCancel.id = "BtnIndustryCancel";
    BtnCancel.type = "button";
    BtnCancel.value = "取消";
    BtnCancel.setAttribute("onclick", "CloseDialog('" + IDStr + "');");
    
//    td.appendChild(BtnOK);
//    td.appendChild(BtnCancel);
    BtnDiv.appendChild(BtnOK);
    BtnDiv.appendChild(BtnCancel);
    
    ContentStr += BtnDiv.outerHTML;
    
    //显示对话框
    ShowDialog(IDStr, CaptionStr, ContentStr,"700", "400" , true, true,isResume);
    
    
}



//城市选择变化
function CheckChangeIndustry(obj,ChkID)
{        
    if (obj.checked)
    {
        if (MaxIndustryCount > 0)
        {
            //判断是否超过5项       
            if (GetSelsCount(ResultSelsStr) >= MaxIndustryCount)
            {
                alert("对不起，您的选项已经到了" + MaxIndustryCount + "项。请减少已选项，再继续选择。");
                obj.checked = false;
                return;
            }
        }
    }
    
    if (obj.checked)
    {
        if (ChkID == "0" )
        {
            //增加父项，则需要删除对应的子项
            ResultSelsStr = "";       
        }
        
        //增加选项
        if(IsSingleSelect=="False")
        {
        ResultSelsStr += ChkID + ",";
        }
        else
        {
        ResultSelsStr = ChkID;
        }
    }
    else
    {
        //删除选项
        ResultSelsStr = RemoveChd(ResultSelsStr, ChkID);
    }

    if (ChkID == "0")
    {
        //更新小类选择Table
        var ChdSelTbl = $("TblChildIndustry");
        
        CreateCheckBoxList(ChdSelTbl,"Industry","0",ResultSelsStr,"CheckChangeIndustry",3);

    }
    
    //重新生成选择列表框
    CreateSelCheckBoxList($("TblSelIndustry"),"Industry",ResultSelsStr,"CheckChangeIndustry",3)

}


function GetIndustryIDs()    
{    
    return new Array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','58','50','51','52','53','54','55','56','57');   
}

function GetIndustryNames()   
{   
    return new Array('不限','计算机软件','计算机硬件','计算机服务','通信/电信/网络设备','通信/电信运营/增值服务','互联网/电子商务','网络游戏','电子技术/半导体/集成电路','仪器仪表/工业自动化','会计/审计','金融/投资/证券','银行','保险','贸易/进出口','批发/零售','快速消费品(食品/化妆品)','服装/纺织/皮革','家具/家电/工艺品/玩具','办公用品及设备','机械/设备/重工','汽车及零配件','制药/生物工程','医疗/护理/保健/卫生','医疗设备/器械','广告','公关/市场推广/会展','影视/媒体/艺术','文字媒体/出版','印刷/包装','房地产开发','建筑与工程','家居/室内设计/装潢','物业管理/商业中心','中介服务','专业服务(咨询/人力资源)','检测/认证','法律','教育/培训','学术/科研','餐饮业','酒店/旅游','娱乐/休闲/体育','美容/保健','生活服务','交通/运输/物流','航天/航空','石油/化工/矿产','采掘业/冶炼','电力/水利','生产/加工/制造','原材料和加工','政府','非盈利机构','环保','农业/渔业/林业','多元化业务集团公司','其他行业','学生');   
}


//根据职位ID获取职位名字
function GetIndustryNameByID(IndustryID)
{
    var index = 0;
    
    var ParIDs = GetIndustryIDs();
    var ParNames = GetIndustryNames();
    
    for(var m=0; m<ParIDs.length; m++)
    {
        if ( IndustryID == ParIDs[m] )
        {
            return ParNames[m];
        }              
    }
        
}
