﻿function clkIndustry(){
		var industry = document.getElementById('tbIndustry');
		
		var cmd = new RemoteCommand('JobFare', 'GetIndustry');
        var html = cmd.Execute().ReturnValue;
		
		ShowWinLayer(520, 330, html);
		SetCheckBox('Industry');
	}
function clkPosition(){
	var position = document.getElementById('tbPosition');
	
	var val = document.getElementById('hdIndustry').value;
	var msg = GetResources('JobFare_Resume_SelectIndustry');
	if(!alertNull(document.getElementById('tbIndustry'), msg)){
        return;
    }
	
	var cmd = new RemoteCommand('JobFare', 'GetPosition');
    cmd.SetParameter('industryId', val);
    var html = cmd.Execute().ReturnValue;
    
	ShowWinLayer(520, 330, html);
	SetCheckBox('Position');
}
function AddIndustryPosition(t){
    var vals = '';
    var names = '';
	var chks = document.getElementsByName('ckb'+ t);
	for(i=0; i<chks.length; i++){
		if(chks[i].checked){
			vals += ','+ chks[i].value;
			if(navigator.appName.indexOf("Explorer") > -1){
                 names += ','+ chks[i].parentNode.innerText;
            }else{
                 names += ','+ chks[i].parentNode.textContent;
            }
		}
	}
	names = names.substr(1);
	vals = vals.substr(1);
	document.getElementById('hd'+ t).value = vals;
	document.getElementById('tb'+ t).value = names;
	
	if(t == 'Industry'){
	    document.getElementById('hdPosition').value = '';
	    document.getElementById('tbPosition').value = '';
	}
}
function SetCheckBox(t){
	var ids = document.getElementById('hd'+ t).value;
	if(ids != null && ids.length != 0){
	    var ckbId = ids.split(',');
	    for(var i=0; i<ckbId.length; i++){
	        document.getElementById('ckb' + t + '_' +ckbId[i]).checked = true;
	    }
	}
}

/* job picker */
function JobPicker(type, target, sync){
    if(sync != null){
        dialogSync = sync;
    }
    OpenDialog('/MyAdmin/JobFare/Picker.aspx?type='+ type +'&target='+ target, 500, 400);
}

/* JobFareIndustryChange */
function JobFareIndustryChange(val){
    var cmd = new RemoteCommand('JobFare', 'IndustryPosition');
    cmd.SetParameter('industryId', val);

    var xml = cmd.Execute().ReturnValue;
    var oXml = LoadXmlDoc(xml);
    
    var nodelist1 = null;
    if(document.all)
    {
        nodelist1 = oXml.selectNodes('/jobfare/position');
    }
    else
    {
        nodelist1 = oXml.documentElement.getElementsByTagName('position');
    }
    
    var ddl = document.getElementById('ddlPosition');
    ddl.options.length = 1;
    
    var value = null;
    var text = null;
    var length = nodelist1.length;
    for(i=0; i<length; i++){
        value = nodelist1[i].getAttribute("id");
        text = nodelist1[i].getAttribute("name");
        ddl.options[i+1] = new Option(text, value);
    }
}

/* check member is login apply job chenwenyuan 2007-9-29 */
function Jobapply(okUrl, cancelUrl){
    var message = GetResources("JobFare_Apply_IsSaveAsAnonymity");
    var memberId = HttpUrlCommand('/js/system/MemberId.aspx?', null, null);
    if(memberId == 'D57AE4DB0EB04A8B' || memberId.length > 16){
        url = '/Member/Login.aspx?url=' + okUrl;
        if(confirm(message)){
          window.open(url);
          return false;
        } else {
            window.open(cancelUrl);
            return false;
        }
    }
    window.open(okUrl);
    return false;
}

/* Bind Position DropDownList */
function PositionChange(val){
    var cmd = new RemoteCommand('JobFare', 'IndustryPosition');
    cmd.SetParameter('industryId', val);

    var xml = cmd.Execute().ReturnValue;
    var oXml = LoadXmlDoc(xml);
    
    var nodelist1 = null;
    if(document.all)
    {
        nodelist1 = oXml.selectNodes('/jobfare/position');
    }
    else
    {
        nodelist1 = oXml.documentElement.getElementsByTagName('position');
    }
        
    var ddl = document.getElementById('ddlPosition');
    ddl.options.length = 1;
    ddl.options[0].selected = true;
    
    var value = null;
    var text = null;
    var length = nodelist1.length;
    for(i=0; i<length; i++){
        value = nodelist1[i].getAttribute("id");
        text = nodelist1[i].getAttribute("name");
        ddl.options[i+1] = new Option(text, value);
    }
}
