
function submitJobSearch() {
	showStatus(true);
	var formname = 'jobsearchform';
	var formobj = document.getElementById(formname);
		
	// get the locations
	if ( formobj.selected_states.value != '' ) {
		var fname = getLocalValue('JOB_SEARCH_STATES_N');
		var farray = formobj.selected_states.value.split(',');
		for ( var i = 0; i < farray.length; i++ ) {
			var value = farray[i];
			var cname = fname.replace('<x>', (i+1));
			var fobj = getFormElement(formname, cname);
			if ( fobj != null ) {
				fobj.value = value;
			}
		}
	}
	
	// get the job codes
	if ( formobj.selected_jobcodes.value != '' ) {
		var fname = getLocalValue('JOB_SEARCH_JOBCODES_N');
		var farray = formobj.selected_jobcodes.value.split(',');
		for ( var i = 0; i < farray.length; i++ ) {
			var value = farray[i];
			var cname = fname.replace('<x>', (i+1));
			var fobj = getFormElement(formname, cname);
			if ( fobj != null ) {
				fobj.value = value;
			}
		}
	}
	
	// get the job skills
	if ( formobj.selected_skills.value != '' ) {
		var fname = getLocalValue('JOB_SEARCH_SKILLS_N');
		var farray = formobj.selected_skills.value.split(',');
		for ( var i = 0; i < farray.length; i++ ) {
			var value = farray[i];
			var cname = fname.replace('<x>', (i+1));
			var fobj = getFormElement(formname, cname);
			if ( fobj != null ) {
				fobj.value = value;
			}
		}
	}
	
	// submit the form
	formobj.submit();
	
	showStatus(false);
}

function openJobDetails(reference, context, allowapply) {
	showStatus(true);	

	var baseurl = getGlobalValue('SITE_CONTEXT');
	window.location.href = baseurl + '/' + context + '/jobdetails_view.jsp?reference='+reference + '&apply=' + allowapply;	
}

function applyForJob(reference, context) {
	showStatus(true);
	var formName = document.getElementById('jobdetailssearchform');
	var baseurl = getGlobalValue('SITE_CONTEXT');
	var LOGIN_ID = getGlobalValue('LOGIN_ID');
	
	if ( context == 'quicksearch' ){
		window.location.href = baseurl + '/login/candregistration_view.jsp?applyjob=' + reference;
		return;
	}
	else {
		window.location.href = baseurl + '/' + context + '/jobapply_view.jsp?&reference=' + reference;
	}
	//This throws an error in ie because the location of the page has already moved
	//formName.submit();
	return false;
}