function getAnswer(strMyHRDomain, strJVRReferral, strSWPReferral, strSWPPromoCode, strJVRPromoCode)
{
	var numfte = trim(document.resultform.fte.value);
	if(numfte == "" || isNaN(numfte))
	{
		alert("Please input a valid number of employee.");
		
		return
	}
	
	if(numfte > 200)
	{
		document.resultform.action= strMyHRDomain + "/jobvaluationreport/layoutscripts/jvrl_sell.asp";
		document.resultform.r.value = strJVRReferral;
		document.resultform.p.value = strJVRPromoCode;
		document.resultform.submit();
	}
	else
	{
		document.resultform.action= strMyHRDomain + "/salarywizardprofessional/layoutscripts/swpl_sell.asp";
		document.resultform.r.value = strSWPReferral;
		document.resultform.p.value = strSWPPromoCode;		
		document.resultform.submit();
	}
}

function openTinyWin(strUrl,strWindowName,strWidth,strHeight){		
			
	 var subWin = window.open(strUrl,strWindowName,
							"toolbar=no,scrollbars=no," + 
								"resizable=no,width=" + strWidth + "," +
									"height=" + strHeight + ",left=0,top=0");		
		
	if(subWin!=null) subWin.focus;
	    	
}


function findCMS(strCMSDomain, strCMSReferral, strCMSPromoCode)
{
	document.resultform.action= strCMSDomain + "/compmarketstudies/layoutscripts/cmsl_sell.asp";
	document.resultform.previndustryfamilyalternatecode.value = document.resultform.industryfamilyalternatecode.value;
	document.resultform.geocode.value = document.resultform.metrocode.value;
	document.resultform.r.value = strCMSReferral;
	document.resultform.p.value = strCMSPromoCode;	
	document.resultform.submit();
}

function createJVR(strJVRDomain, strJVRReferral, strJVRPromocode)
{
	document.resultform.action= strJVRDomain + "/jobvaluationreport/layoutscripts/jvrl_sell.asp";
	document.resultform.previndustryfamilyalternatecode.value = document.resultform.industryfamilyalternatecode.value;
	document.resultform.r.value = strJVRReferral;
	document.resultform.p.value = strJVRPromocode;	
	document.resultform.submit();
}

function findCMSFromTitleSelect(strCMSDomain, strCMSReferral, strCMSPromocode)
{
	document.titleselectform.action= strCMSDomain + "/compmarketstudies/layoutscripts/cmsl_sell.asp";
	document.titleselectform.geocode.value = document.titleselectform.metrocode.value;
	document.titleselectform.r.value = strCMSReferral;
	document.titleselectform.p.value = strCMSPromocode;	
	document.titleselectform.submit();
}

function createJVRFromTitleSelect(strJVRDomain, strJVRReferral, strPromoCode)
{
	document.titleselectform.action= strJVRDomain + "/jobvaluationreport/layoutscripts/jvrl_sell.asp";
	document.titleselectform.r.value = strJVRReferral;
	document.titleselectform.p.value = strPromoCode;	
	document.titleselectform.submit();
}

function findJVRFromTitleSelect(strJVRDomain, strReferralCode, strPromoCode)
{
	//document.titleselectform.action= strJVRDomain + "/jobvaluationreport/layoutscripts/jvrl_sell.asp";
	document.titleselectform.action= strJVRDomain + "/salaryreport/layoutscripts/srpl_overview_pu.asp?r=" +strReferralCode+ "&p=" +strJVRPromoCode;
	document.titleselectform.geocode.value = document.titleselectform.metrocode.value;
	document.titleselectform.submit();
}

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 = "/salarywizard/layoutscripts/swzl_titleselect.asp";
	document.titleselectform.submit();

}

function refreshIndustry()
{
	document.resultform.action="/salarywizard/layoutscripts/swzl_compresult.asp#industry";
	document.resultform.submit();
}

function selectJobFromDesc(strJobCode, strJobTitle)
{	
	document.mainform.jobtitle.value = strJobTitle;
	document.mainform.jobcode.value = strJobCode;
	document.mainform.action = "/salarywizard/layoutscripts/swzl_titleselect.asp";
	document.mainform.submit();
}

function viewCategoryJobDesc()
{	
	document.titleselectform.action = "/salarywizard/layoutscripts/swzl_jobdescbycategory.asp";
	document.titleselectform.submit();
}

function backToTitleSelect()
{	
	document.mainform.action = "/salarywizard/layoutscripts/swzl_titleselect.asp";
	document.mainform.submit();
}

function displaySearchBox(strIsEdit){
	document.titleselectform.search.value = "1";
	document.titleselectform.isedit.value = strIsEdit;
	var strJobTitle;
	strJobTitle = document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].text;
	document.titleselectform.jobtitle.value = strJobTitle;

	var strJobCode;
	strJobCode= document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].value;
	document.titleselectform.jobcode.value = strJobCode;

	document.titleselectform.jobcodeedit.selectedIndex = 0;

	document.titleselectform.action = "/salarywizard/layoutscripts/swzl_titleselect.asp";
	document.titleselectform.submit();

}

function changeJob(){

	var strJobTitle;
	strJobTitle = document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].text;
	document.titleselectform.jobtitle.value = strJobTitle;

	var strJobCode;
	strJobCode= document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].value;
	document.titleselectform.jobcode.value = strJobCode;
		
	document.titleselectform.jobcodeedit.selectedIndex = 0;
		
	document.titleselectform.action = "/salarywizard/layoutscripts/swzl_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 = "/salarywizard/layoutscripts/swzl_titleselect.asp";
	document.titleselectform.submit();

}


function gotoAdvanceSearch(objForm){
	var bSubmit=true;
	if(objForm.altername){
		if(objForm.altername.value == ""){
			alert("Please enter a job title to start searching.");
			objForm.altername.focus();
			bSubmit = false;
		}
	}
	if(bSubmit){	
		objForm.action = "/salarywizard/layoutscripts/swzl_advancesearch.asp";
		objForm.submit();}
	

}

function gotoResult(){

	var bSubmit=true;
	if(document.titleselectform.narrowcodeedit){
		if(document.titleselectform.narrowcodeedit.options[document.titleselectform.narrowcodeedit.selectedIndex].value == ""){
			alert("Please select a job category.");
			document.titleselectform.narrowcodeedit.focus();
			bSubmit = false;
		}
		else{ 
			if(document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].value == ""){
			alert("Please select a job title.");
			document.titleselectform.jobcodeedit.focus();
			bSubmit = false;}
		}
	}
		
	else {
		if(document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].value == ""){
			alert("Please select a job title.");
			document.titleselectform.jobcodeedit.focus();
			bSubmit = false;}
	}

	if(bSubmit) {
	
		var strJobTitle;
		strJobTitle = document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].text;
		document.titleselectform.jobtitle.value = strJobTitle;

		var strJobCode;
		strJobCode = document.titleselectform.jobcodeedit.options[document.titleselectform.jobcodeedit.selectedIndex].value;
		document.titleselectform.jobcode.value = strJobCode;
	
		document.titleselectform.action = "/salarywizard/layoutscripts/swzl_compresult.asp";
		document.titleselectform.submit();
	}
	

}



function tellafriend() {
	var thelink;
	thelink="/salarywizard/layoutscripts/swzl_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 = "/salarywizard/layoutscripts/swzl_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 = "/salarywizard/layoutscripts/swzl_compresult.asp";
			document.resultform.submit();
		}

	}
	else{	
		document.resultform.iscompare.value = strIsCompare;
		document.resultform.comparetype.value = strCompareType;
		document.resultform.pagenumber.value = strPageNumber;
		document.resultform.action = "/salarywizard/layoutscripts/swzl_compresult.asp";
		document.resultform.submit();
	}
}

function openNewLocations()
{
	document.resultform.openlink.value = "loc";
	document.resultform.action = "/salarywizard/layoutscripts/swzl_compresult.asp#compare";
	document.resultform.submit();
}
function openRelatedJobs()
{
	document.resultform.openlink.value = "job";
	document.resultform.action = "/salarywizard/layoutscripts/swzl_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's 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 "";
}

function openPSRpopWindow(strHostName){
var strHeight = "660";
var strWidth = "740";
var popunder= strHostName + "/salaryreport/layoutscripts/srpl_overview.asp?r=swz";
//var popunder="/salaryreport/layoutscripts/srpl_overview.asp"

PSRWindow=window.open(popunder,"PSRWindow",
								"toolbar=yes,scrollbars=yes,status=yes," + 
									"resizable=yes,width=" + strWidth + "," +
										"height=" + strHeight + ",left=0,top=0");
PSRWindow.focus();
}

function openSecureWin(strLink, strWidth, strHeight){

	var secureWin=window.open(strLink,"secureWindow","toolbar=yes,scrollbars=yes,status=yes,resizable=yes,width=" + strWidth + "," + "height=" + strHeight + ",left=0,top=0");
	secureWin.focus();	
}


function getJobDesc(strJobCode, strJobTitle, strNarrowDesc){
	var strUrl;
	strUrl = "/salarywizard/layoutscripts/swzl_jobdesc.asp?"
	strUrl = strUrl + "jobcode=" + strJobCode
	strUrl = strUrl + "&jobtitle=" + escape(strJobTitle)
	strUrl = strUrl + "&narrowdesc=" + escape(strNarrowDesc)

	
	var subWin = window.open(strUrl,"jobDescWin","toolbar=yes,scrollbars=yes,resizable=yes,width=530,height=300,left=0,top=0");		
	if(subWin!=null) subWin.focus();
    	
}

function gotoLogin(strMySalaryHost){

	document.overviewregform.action= strMySalaryHost + "/salaryreport/layoutscripts/srpl_login.asp";
	document.overviewregform.submit();
}	

function checkoverviewregform(){

	if(document.overviewregform.email.value.length==0){
			alert("Please enter your email address.");
			document.overviewregform.email.focus();
			return false;
	}
	else{
			if(!GoodEmailAddress(document.overviewregform.email.value)){
				alert("Your email address is invalid.");
				document.overviewregform.email.focus();
				return false;
			}
			else{
				if((document.overviewregform.email.value)!=(document.overviewregform.confirmemail.value)){
				alert("Please confirm your email address.");
				document.overviewregform.confirmemail.focus();
				return false;
				}
			}
	}
	
	if(document.overviewregform.password.value.length==0){
			alert("Please enter a password.");
			document.overviewregform.password.focus();
			return false;
	}
	if(document.overviewregform.confirmpassword.value.length==0){
			alert("Please confirm your password.");
			document.overviewregform.confirmpassword.focus();
			return false;
	}
	if(document.overviewregform.confirmpassword.value!=document.overviewregform.password.value){
			alert("Your passwords did not match. Please try again.");
			document.overviewregform.confirmpassword.focus();
			return false;
	}
	
	if(document.overviewregform.firstname.value.length==0){
			alert("Please enter your first name.");
			document.overviewregform.firstname.focus();
			return false;
	}

	if(document.overviewregform.lastname.value.length==0){
			alert("Please enter your last name.");
			document.overviewregform.lastname.focus();
			return false;
	}
	
	return true;
}

function launchJobDescPopup(strNarrowCode, strNarrowDesc, strJobCode, strJobTitle, strMetroCode, strIsForCompanalyst){
	var strDestLink = "/salarywizard/layoutscripts/swzl_jobdesc_psr.asp?";
	strDestLink = strDestLink + "jobcode=" + strJobCode;
	strDestLink = strDestLink + "&jobtitle=" + escape(strJobTitle);
	strDestLink = strDestLink + "&narrowcode=" + strNarrowCode;
	strDestLink = strDestLink + "&metrocode=" + strMetroCode;
	strDestLink = strDestLink + "&narrowdesc=" + escape(strNarrowDesc);
	strDestLink = strDestLink + "&isforcompanalyst=" + strIsForCompanalyst;

	var jobdescWindow=window.open(strDestLink ,"JobDescWindow", "toolbar=no,scrollbars=yes, resizable=yes,width=245,height=420,left=0,top=0");
	jobdescWindow.focus();
}


// add one more paramete strSWPReferral to function gotoPage(strAction,strSWPReferral)   katie jin 8/19/2004

function gotoPage(strAction, strSWPReferral, strPromoCode)
{
	document.resultform.action = strAction;
	document.resultform.r.value = strSWPReferral;
	document.resultform.p.value = strPromoCode;	
	
	document.resultform.submit();
}

 