
function submitPage(strAction, objForm)
{
	objForm.action = strAction;
	objForm.submit();
	
}

function gotoTitleSelect(){
	if(document.newsearchform.narrowcode.options[document.newsearchform.narrowcode.selectedIndex].value == ""){
		alert("Please select a job category.");
		document.newsearchform.narrowcode.focus();
		return false;
	}
	else{
		var strNarrowDesc;
		strNarrowDesc = document.newsearchform.narrowcode.options[document.newsearchform.narrowcode.selectedIndex].text;
		document.newsearchform.narrowdesc.value = strNarrowDesc;
 
		return true;
	}
	

}
function setEdit(){
	document.titleselectform.isedit.value = "1";
	document.titleselectform.action = "/csalarywizard/layoutscripts/cswzl_titleselect.asp";
	document.titleselectform.submit();

}

function changeJob(){

	var strJobTitle;
	strJobTitle = document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].text;

	var strJobCode;
	strJobCode= document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].value;


	document.titleselectform.jobcode.value = strJobCode;
	document.titleselectform.jobtitle.value = strJobTitle;

	
	document.titleselectform.jobcodeedit.selectedIndex = 0;
	
	document.titleselectform.action = "/csalarywizard/layoutscripts/cswzl_titleselect.asp";
	document.titleselectform.submit();

}
function changeJobCategory(){
	var strNarrowDesc;
	strNarrowDesc = document.titleselectform.narrowcodeedit.options[document.titleselectform.narrowcodeedit.selectedIndex].text;
	document.titleselectform.narrowdesc.value = strNarrowDesc;

	var strNarrowCode;
	strNarrowCode = document.titleselectform.narrowcodeedit.options[document.titleselectform.narrowcodeedit.selectedIndex].value;
	document.titleselectform.narrowcode.value = strNarrowCode;

	document.titleselectform.narrowcodeedit.selectedIndex = 0;
	document.titleselectform.action = "/csalarywizard/layoutscripts/cswzl_titleselect.asp";
	document.titleselectform.submit();

}


function gotoAdvanceSearch(){
	if(document.titleselectform.altername.value == ""){
		alert("Please enter a job title to start searching.");
		document.titleselectform.altername.focus();
	}
	else{		
		document.titleselectform.action = "/csalarywizard/layoutscripts/cswzl_advancesearch.asp";
		document.titleselectform.submit();}

}

function gotoResult(){
	if(document.titleselectform.narrowcodeedit){
		if(document.titleselectform.narrowcodeedit.options[document.titleselectform.narrowcodeedit.selectedIndex].value == ""){
			alert("Please select a job category.");
			document.titleselectform.narrowcodeedit.focus();
			return false;
		}
	}
	
	if(document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].value == ""){
		alert("Please select a job title.");
		document.titleselectform.jobcodeedit.focus();
		return false;
	}
	
	var strJobTitle;
	strJobTitle = document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].text;

	var strJobCode;
	strJobCode = document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].value;
	document.titleselectform.jobtitle.value = strJobTitle;
	document.titleselectform.jobcode.value = strJobCode;
	return true;
	

}



function tellafriend() {
	var thelink;
	thelink="/csalarywizard/layoutscripts/cswzl_tellafriend.asp";
	thelink=thelink + document.location.search;
        openCommonWindow(thelink,'400','500');
}

function getResultPage(strAction, strPageNumber)
{
	document.resultform.pagenumber.value = strPageNumber;
	document.resultform.action = strAction;
	document.resultform.submit();
}

function getCompareResultPage(strIsCompare,strCompareType, strPageNumber)
{
	var strJobTitle;
	var strGeo;
	//compare to national average
	//if (strCompareType=="0"){
	//	document.resultform.openlink.value = "";
	//	
	//}

	//compare to different jobs
	if (strCompareType=="1"){
		if(document.resultform.jobcodecomp.options[document.resultform.jobcodecomp.selectedIndex].value == ""){
			alert("Please select a job title to compare.");
			document.resultform.jobcodecomp.focus();
		}
		else{
			strJobTitle = document.resultform.jobcodecomp.options[document.resultform.jobcodecomp.selectedIndex].text;
			document.resultform.jobtitlecomp.value = strJobTitle;
			document.resultform.iscompare.value = strIsCompare;
			document.resultform.comparetype.value = strCompareType;
			document.resultform.pagenumber.value = strPageNumber;
			document.resultform.action = "/csalarywizard/layoutscripts/cswzl_compresult.asp";
			document.resultform.submit();
		}
	}

	//compare to different locations
	else if (strCompareType=="2"){
		if(document.resultform.metrocodecomp.options[document.resultform.metrocodecomp.selectedIndex].value == ""){
			alert("Please select a location to compare.");
			document.resultform.metrocodecomp.focus();
		}
		else{
			strGeo = document.resultform.metrocodecomp.options[document.resultform.metrocodecomp.selectedIndex].text;
			document.resultform.geocomp.value = strGeo;
			document.resultform.iscompare.value = strIsCompare;
			document.resultform.comparetype.value = strCompareType;
			document.resultform.pagenumber.value = strPageNumber;
			document.resultform.action = "/csalarywizard/layoutscripts/cswzl_compresult.asp";
			document.resultform.submit();
		}

	}
	else{	
		document.resultform.iscompare.value = strIsCompare;
		document.resultform.comparetype.value = strCompareType;
		document.resultform.pagenumber.value = strPageNumber;
		document.resultform.action = "/csalarywizard/layoutscripts/cswzl_compresult.asp";
		document.resultform.submit();
	}
}

function openNewLocations()
{
	document.resultform.openlink.value = "loc";
	document.resultform.action = "/csalarywizard/layoutscripts/cswzl_compresult.asp#compare";
	document.resultform.submit();
}
function openRelatedJobs()
{
	document.resultform.openlink.value = "job";
	document.resultform.action = "/csalarywizard/layoutscripts/cswzl_compresult.asp#compare";
	document.resultform.submit();
}

function openCommonWindow(strUrl,strWidth,strHeight){		
		
		 var subWin = window.open(strUrl,"SalWizWindow",
								"toolbar=yes,scrollbars=yes," + 
									"resizable=yes,width=" + strWidth + "," +
										"height=" + strHeight + ",left=0,top=0");		
	
		if(subWin!=null) subWin.focus();
    	
}	

function ValidateTellaFriendForm(){
	if(document.tellafriendform.fromname.value.length==0){
		alert("Please enter your Name.");
		document.tellafriendform.fromname.focus();
		return false;
	}
	if(document.tellafriendform.fromaddress.value.length==0){
		alert("Please enter your Email.");
		document.tellafriendform.fromaddress.focus();
		return false;
	}else{
		if(!GoodEmailAddress(document.tellafriendform.fromaddress.value)){
			alert("Invalid Email address.");
			document.tellafriendform.fromaddress.select();
			document.tellafriendform.fromaddress.focus();
			return false;
		}
	}
	if(document.tellafriendform.toname.value.length==0){
		alert("Please enter your friend name.");
		document.tellafriendform.toname.focus();
		return false;
	}
	if(document.tellafriendform.toaddress.value.length==0){
		alert("Please enter your friend's email.");
		document.tellafriendform.toaddress.focus();
		return false;
	}else{
		if(!GoodEmailAddress(document.tellafriendform.toaddress.value)){
			alert("Invalid Email address.");
			document.tellafriendform.toaddress.select();
			document.tellafriendform.toaddress.focus();
			return false;
		}
	}
	return true;
		
}
			
function GoodEmailAddress(strEmail){
	strEmail = trim(strEmail);
	if (strEmail.indexOf(" ")>0 && strEmail.indexOf(" ")<strEmail.length-1){return false;}
	if (strEmail.length < 5) {return false;}
	if (strEmail.indexOf("@") < 1) {return false;}//there must be at least one '@'
	//there can not be two '@' or more
	if (strEmail.indexOf(".",strEmail.indexOf("@")) < strEmail.indexOf("@")){return false;}
	if (strEmail.lastIndexOf("@") != strEmail.indexOf("@")) {return false;}
	if (strEmail.lastIndexOf(".") == strEmail.length-1) {return false;}
	return true;	
}			
			


function trim(strValue) {
	return trimRight(trimLeft(strValue));	
}

function trimLeft(strValue) {
	if (strValue == null) return null;
	if (strValue.length == 0) return strValue;
	for (i=0; i<strValue.length; i++) {
		if (strValue.charAt(i) != ' ')
			return strValue.substr(i);
	}
	return "";
}

function trimRight(strValue) {	
	if (strValue == null) return null;
	if (strValue.length == 0) return strValue;
	for (i=strValue.length-1; i>=0; i--) {
		if (strValue.charAt(i) != ' ')
			return strValue.substring(0, i+1);
	}
	return "";
}


 