var changed = false;
var arr = new Array();

function occupation(id, value) {
	this.id = id;
	this.value = value;
}

function addoccupations(idx)
{
	var i = 0;	
	var listbox = document.getElementById('occupation');
	
	var occups = arr[idx];
	/*if (!changed) {
		listbox.options.length = 1;
	}*/
	var startidx = listbox.options.length;
	
	for (i = 0; i < occups.length; i++) {
		listbox.options[i + startidx] = new Option(occups[i].value, occups[i].id)	
	}
	//changed = true;
}

function addoccupations2(catbox) {
	var listbox = document.getElementById('occupation');
	listbox.options.length = 1;
	var loadall = false;
	var i = 0;
	if (catbox.options[0].selected)
		loadall = true;
		
	for (i = 1; i < catbox.options.length; i++) {
		if ((catbox.options[i].selected) && (!loadall)) {
			addoccupations(catbox.options[i].value);
		}
		if (loadall)
			addoccupations(catbox.options[i].value);
	}
	listbox.options[0].selected = true;
	
}

function isChecked() {
	var checked = false;
	el = document.frmSearch.jobids;
	if (typeof(el.length) != 'undefined') {
		for (i = 0; i < el.length; i++) {
			if (el[i].checked) {
				checked = true;
				break;
			}	
		}
	}
	else {
		if (el.checked)
			checked = true;
	}	
	return checked;
}

function viewDetails() {
	if (isChecked()) {
		document.frmSearch.submit();
	}
	else {
		alert('Please select at least one job!');
	}	
}

function applyForJob() {
	if (isChecked()) {
		document.frmSearch.action = "/jobs/register.aspx";
		document.frmSearch.submit();
	}
	else {
		alert('Please select at least one job!');
	}
}

function resetForm() {
	//var frm = document.frmSearch;
	//frm.location.options[0].selected = true;
	window.location.href="/jobs/default.aspx";
}