
function submitJobSearch() {
	showStatus(true);
	var formname = 'jobsearchform';
	var formobj = document.getElementById(formname);
		

/* ----- find the values searched on for displaying search criteria ----*/
		var strBody='';

		var searchTitle = getLocalValue('JOB_SEARCH_TITLE');
		//try catch if its not dk
		try{
			var jotitle = formobj[searchTitle].value;	
			if(jotitle != ''){
				strBody = getLocalValue('LBL_JOB_SEARCH_CONTAINS') +': '+ jotitle +'<BR>';
			}
		}
		catch (error){
				//job title not used in this search
		}

		try{
			var perm = formobj.permjob.checked;
			var temp = formobj.tempjob.checked;
			if(perm == true || temp ==true){
				strBody += getLocalValue('LBL_JOB_SEARCH_TYPE')+': ' 
				strBody += (perm == true)?getLocalValue('LBL_JOB_SEARCH_TYPE_PERM'):'';
				strBody += (temp == true)? (perm == true)?', ':'':'';
				strBody += (temp == true)? getLocalValue('LBL_JOB_SEARCH_TYPE_CONTRACT'):'';
				strBody += '<BR>';
			}
		}
		catch (error){
			//perm and temp not used
		}
		
		//Branches
		//var strCode ="";
		//if( formobj.branches_to.length > 0){
		//	for(i=0; i<formobj.branches_to.length; i++){
		//		if( i == formobj.branches_to.length - 1){
		//			strCode += (formobj.branches_to.options[i].text);
		//		}else{
		//			strCode += (formobj.branches_to.options[i].text)+", ";
		//		}
		//	}
		//}
		//if(strCode != ''){
		//	strBody += getLocalValue('LBL_JOB_SEARCH_BRANCH')+': ' +strCode +'<br/>';
		//}
		//Job Codes
		strCode="";
		if( formobj.jobcodes_to.length > 0){
			for(i=0; i<formobj.jobcodes_to.length; i++){
				if( i == formobj.jobcodes_to.length - 1){
					strCode += (formobj.jobcodes_to.options[i].text);
				}else{
					strCode += (formobj.jobcodes_to.options[i].text)+", ";
				}
			}
		}
		if(strCode != ''){
			strBody += getLocalValue('LBL_JOB_SEARCH_JOBCAT')+': ' +strCode+"<br>";
		}
		
		//Geo Locations
		strCode = "";
		if( formobj.geocodes_to.length > 0){
			for(i=0; i<formobj.geocodes_to.length; i++){
				if( i == formobj.geocodes_to.length - 1){
					strCode += (formobj.geocodes_to.options[i].text);
				}else{
					strCode += (formobj.geocodes_to.options[i].text)+", ";
				}
			}
		}
		if(strCode != ''){
			strBody += getLocalValue('LBL_JOB_SEARCH_GEOGRAPHICAL')+': ' +strCode +"<br>";
		}
		
		
		var strSearch = getLocalValue('LBL_JOB_SEARCH_SUMMARY');
		if(strBody != ''){
			strSearch += strBody +"<BR>";
		}else{
			strSearch += getLocalValue('LBL_JOB_SEARCH_ALLCRITERIA');
		}
		setCookie('scriteria',strSearch,1)

/* ----- fill out the elements the search needs ----*/
	// Get the locations
	//if ( formobj.selected_branches.value != '' ) {
	//	var fname = getLocalValue('JOB_SEARCH_BRANCH');
	//	var farray = formobj.selected_branches.value.split(',');
	//	for ( var i = 0; i < farray.length; i++ ) {
	//		var value = farray[i];
	//		if( i == 0 ){
	//			var cname = fname.replace('<x>', '');
	//		}else{
	//			var cname = fname.replace('<x>', (i+1));
	//		}
	//		var fobj = getFormElement(formname, cname);
	//		if ( fobj != null ) {
	//			fobj.value = value;
	//			//alert(fobj.name +"="+fobj.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 geo codes
	if ( formobj.selected_geocodes.value != '' ) {
		var fname = getLocalValue('JOB_SEARCH_AREA_N');
		var farray = formobj.selected_geocodes.value.split(',');
		for ( var i = 0; i < farray.length; i++ ) {
			var value = farray[i].trim();
			var cname = fname.replace('<x>', (i+1));
			var fobj = getFormElement(formname, cname);
			if ( fobj != null ) {
				fobj.value = value;
			}
		}
	}
	
	try{
		if ( !(formobj.permjob.checked)  && !(formobj.tempjob.checked) ){
			alert(getLocalValue('MSG_JOB_SEARCH_SELECTTYPE'));
			showStatus(false);
			return; 
		}
		var jobtypename = getLocalValue('JOB_SEARCH_TYPE_N');
		var temp = getLocalValue('JOB_SERVICE_TEMP');
		var perm = getLocalValue('JOB_SERVICE_PERM');
		if( formobj.permjob.checked  && formobj.tempjob.checked  ){
			//Waiting on config to search on both job types
		}else if (formobj.permjob.checked){
			formobj[jobtypename].value = perm;
		}else if (formobj.tempjob.checked ){
			formobj[jobtypename].value = temp;
		}
	}
	catch(error){
		//its dk and perm and temp not used
	}

	// submit the form
	formobj.submit();
	showStatus(false);
}

function openJobDetails(id, context, allowapply) {
	showStatus(true);	
	var fmObj = document.holder;
		if( fmObj.tcid != undefined || fmObj.tcid != null ){
			var fmObj = document.secondholder;
		}
		fmObj.reference.value = id;
		fmObj.apply.value = allowapply;
		fmObj.submit();

}

function applyForJob(reference, context) {
	showStatus(true);
	var formName = document.getElementById('jobdetailssearchform');
	var baseurl = getGlobalValue('SITE_CONTEXT');
	formName['context'].value = context;
	var actionPath = '';
	if ( context == 'quicksearch' ){
		//window.location.href = baseurl + '/login/candregistration_view.jsp?applyjob=' + reference;
		//return;
		formName.action = baseurl + '/login/candregistration_view.jsp';
		formName['applyjob'].value = reference;
	}
	else {
		//window.location.href = baseurl + '/' + context + '/jobapply_view.jsp?&reference=' + reference + '&context=' + context;
		formName.action = baseurl + '/' + context + '/jobapply_view.jsp'
		formName['reference'].value = reference;
	}
	formName.submit();
	return false;
}

function emailfriend(){
	var formname = 'emailjob';
	var formobj = document.getElementById(formname);
	var baseurl = getGlobalValue('SITE_CONTEXT');
	// validate out going email
	if ( formobj.Friends_Name.value == '' ){
		alert(getLocalValue('MSG_JOB_EMAIL_FRIENDNAME'));
		return;
	}
	if ( formobj.Friends_Email.value == '' ){
		alert(getLocalValue('MSG_JOB_EMAIL_FRIENDEMAIL'));
		return;
	}
	if ( formobj.Your_Name.value == '' ){
		alert(getLocalValue('MSG_JOB_EMAIL_YOURNAME'));
		return;
	}
	if ( formobj.Subject.value == '' ){
		alert(getLocalValue('MSG_JOB_EMAIL_SUBJECT'));
		return;
	}
	formobj.action = baseurl+"/common/emailjob.jsp";
	formobj.submit();
		
}