
var callingsCount;
callings = new Array();
callingsCount=34;
//定义数组
callings[0]= new Array("3300", "旅游、酒店、餐饮、娱乐", "Tourism, Catering/Entertainment/Hotels" ), 
callings[1]= new Array("1000", "互联网、电子商务", "Internet and e-Commerce"), 
callings[2]= new Array("1100", "计算机业（软件、数据库、系统集成）","Computers ( Software, Database, System Integration)" ), 
callings[3]= new Array("1200", "计算机业（硬件、网络设备）", "Computers ( Hardware, Network Device )" ), 
callings[4]= new Array("1300", "电子、微电子技术", "Electrical, Micro-electronics" ), 
callings[5]= new Array("1400", "通讯、电信业", "Telecommunications"), 
callings[6]= new Array("1500", "家电业","Electrical home appliances"), 
callings[7]= new Array("1600", "批发零售(百货、超市、购物中心、专卖店…)","Sales" ), 
callings[8]= new Array("1700", "贸易、商务、进出口", "Trading, Commerce ,Imports and Exports"), 
callings[9]= new Array("1800", "电气","Electric"  ), 
callings[10]= new Array("1900", "电力、能源、矿产业", "Electric Power, Energy, Mining"), 
callings[11]= new Array("2000", "石油、化工业", "Petroleum, Chemical Engineering"), 
callings[12]= new Array("2100", "生物工程、制药、环保", "Biology Engineering, Pharmacy, Environmental Protection"), 
callings[13]= new Array("2200", "机械制造、机电设备、重工业","Machine-building, Machine, Heavy industry"  ), 
callings[14]= new Array("2300", "汽车、摩托车","Automobile, Autocycle"  ), 
callings[15]= new Array("2400", "仪器仪表、电工设备","Apparatus, Electric Devices"  ), 
callings[16]= new Array("2500", "广告、公关、设计", "Advertising, Public Relations, Design" ),	
callings[17]= new Array("2600", "艺术、文化传播、媒体、影视制作、新闻出版", "Arts, Culture Transmit, Media, Movie facture, Publishing" ), 
callings[18]= new Array("2700", "快速消费品（食品、饮料、粮油、化妆品、烟酒…）","Fast consumable ( Food, Drink, Cosmetic etc. )" ), 
callings[19]= new Array("2800", "纺织品业（服饰、鞋类、家纺用品、皮具…）","Textile industry"  ), 
callings[20]= new Array("2900", "咨询业（顾问、会计师、审计师、法律）","Consultation ( Consultant, Accountant, Audit, Lawyer)"  ), 
callings[21]= new Array("3000", "金融业（投资、保险、证券、银行、基金）", "Finance ( Banking, Venture Capital, Insurance )" ), 
callings[22]= new Array("3100", "建筑、房地产、物业管理、装潢","Architectural Services"  ),		
callings[23]= new Array("3200", "运输、物流、快递", "Transportation, Distribution" ), 

callings[24]= new Array("3400", "办公设备、文化体育休闲用品、家居用品","OA Devices, Culture Articles, Home Articles"  ), 
callings[25]= new Array("3500", "印刷、包装、造纸", "Press, Casing, Paper making" ), 
callings[26]= new Array("3600", "生产、制造、加工", "Manufacturing" ), 
callings[27]= new Array("3700", "教育、培训、科研院所","Education, Training, Research" ), 
callings[28]= new Array("3800", "医疗、保健、卫生服务", "Medical Treatment, Health, Sanitation" ), 
callings[29]= new Array("3900", "人才交流、中介", "Human Resources" ), 
callings[30]= new Array("4000", "协会、社团、政府公用事业、社区服务","Community, Social Services, Government,  Nonprofit" ), 
callings[31]= new Array("4100", "农、林、牧、副、渔业","Agriculture, Forestry, Animal husbandry, Fishery" ), 
callings[32]= new Array("4200", "法律", "law" ),	
callings[33]= new Array("9900", "其他" ,"Other" )

//输出选项
function writeCallings()
{
    with(document)
    {
        for (var i=0; i<callingsCount; i++) 
            write("<option value='"+callings[i][0]+"'>"+callings[i][1]+"</option>");
    }
}

//添加方法
function append_selected_item(obj1, obj2)
{
    var len, txt, val;
    if(typeof(obj1.options[obj1.selectedIndex])=="unknown")
    {
        alert("系统提示:请选择您想要添加的资料项!");
        obj1.focus();
        return;
    }

    clear_list(obj1, obj2);

    //取长度
    len = obj2.length;
    if (len>2)
    {
        alert("您已经添加了三项,不能更添加了!");
        return;
    }

    //生成一个新元素
    var opt = document.createElement("OPTION");
    opt.text = obj1.options[obj1.selectedIndex].text;
    opt.value = obj1.options[obj1.selectedIndex].value;

    if (len==0)
    {
        obj2.add(opt);
        document.thisForm.calling1.value = opt.value; //应先检测对象有无存在
        return;
    }

    //说明选了不限,但已经选有明细项,不能添加成功(有)
    if (opt.value=='0'||opt.value=='') 
    {
        alert('您已经选有至少一项行业类别,不能再选行业类别不限!');
        return;
    }

    //先清原值  
    document.thisForm.calling1.value = '';
    document.thisForm.calling2.value = '';
    document.thisForm.calling3.value = '';

    //检查有无重复项
    for(i=0; i<obj2.length; i++)
    {
        txt = obj2.options[i].text;
        val = obj2.options[i].value;
        //提前传值
        if (i==0) document.thisForm.calling1.value = obj2.options[0].value;
        if (i==1) document.thisForm.calling2.value = obj2.options[1].value;
        if (i==2) document.thisForm.calling3.value = obj2.options[2].value;

        //检测值(说明选了不限:不再添加)
        if (val=='0'||val=='') { return; }
        
        //说明该项已被选择,不再操作
        if (opt.value==val)  { return; }
    }

    //增加这一选项,并给hidden传值.
    obj2.add(opt);
    //仅为新增项
    if (len==0) document.thisForm.calling1.value = obj2.options[0].value;
    if (len==1) document.thisForm.calling2.value = obj2.options[1].value;
    if (len==2) document.thisForm.calling3.value = obj2.options[2].value;
}

//移除选项
function remove_selected_item(obj)
{
    if(typeof(obj.options[obj.selectedIndex])=="unknown")
    {
        alert("系统提示:请选择您想要移除的资料项!");
        obj.focus();
    }

    if (obj.selectedIndex>-1)
    {
        obj.remove(obj.selectedIndex);

        //先清原值  
        document.thisForm.calling1.value = '';
        document.thisForm.calling2.value = '';
        document.thisForm.calling3.value = '';
    }

    //重新置参数
    for(i=0; i<obj.length; i++)
    {
        if (i==0) document.thisForm.calling1.value = obj.options[0].value;
        if (i==1) document.thisForm.calling2.value = obj.options[1].value;
        if (i==2) document.thisForm.calling3.value = obj.options[2].value;
    }
}


//添加方法
function clear_list(obj1, obj2)
{
    var len, txt, val;
    //选中,并且两个都是列表
    if (typeof(obj1.options[obj1.selectedIndex])=="unknown")  return;
    if (typeof(obj2)!="object") return;

    //取长度(无数据退出)
    len = obj2.length;
    if (len==0) return;

    //生成一个新元素
    txt = obj1.options[obj1.selectedIndex].text;
    val = obj1.options[obj1.selectedIndex].value;

    //检查添加的数据是否是不限:是:清除目标列表数据;否:下一步
    if (val=='' || val=='0')
    {
        for (var i=len-1; i>-1; i--) { obj2.remove(i); }
    }
    else
    {
        val = obj2.options[0].value;
        if (val=='' || val=='0') obj2.remove(0);
    }
}