function findCMSFromTitleSelect(strCMSDomain, strCMSReferral, strCMSPromo)
{
	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 = strCMSPromo
	document.titleselectform.submit();
}

function createJVRFromTitleSelect(strJVRDomain, strJVRReferral, strJVRPromo)
{
	document.titleselectform.action= strJVRDomain + "/jobvaluationreport/layoutscripts/jvrl_sell.asp";
	document.titleselectform.r.value = strJVRReferral;
	document.titleselectform.p.value = strJVRPromo
	document.titleselectform.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 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 displaySearchBox(){
	document.titleselectform.search.value = "1";
	if (document.titleselectform.jobcode.selectedIndex == -1){
		document.titleselectform.jobcode.selectedIndex = 0;
	}
	if (window.titleselectform.jobcode.options[window.titleselectform.jobcode.selectedIndex].value == "")
	{
		document.titleselectform.jobcode.selectedIndex = 0;
	}

	var strJobTitle;
	strJobTitle = document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].text;
	document.titleselectform.jobtitle.value = strJobTitle;

	var strJobCode;
	strJobCode= document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].value;
	document.titleselectform.jobcode.value = strJobCode;

	document.titleselectform.jobcode.selectedIndex = 0;

	document.titleselectform.action = "/salarywizard/layoutscripts/swzl_titleselect.asp";
	document.titleselectform.submit();

}

function changeJob(){

	var strJobTitle;
	strJobTitle = document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].text;
	document.titleselectform.jobtitle.value = strJobTitle;

	var strJobCode;
	strJobCode= document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].value;
	document.titleselectform.jobcode.value = strJobCode;
		
	document.titleselectform.jobcode.selectedIndex = 0;
		
	document.titleselectform.action = "/salarywizard/layoutscripts/swzl_titleselect.asp";
	document.titleselectform.submit();

}


function gotoAdvanceSearch(objForm){

	if(objForm.altername.value == ""){
		alert("Please enter a job title to start searching.");
		objForm.altername.focus();
		return false;
	}
	else{		
		objForm.action = "/salarywizard/layoutscripts/swzl_advancesearch.asp";
		objForm.submit();}
	

}

function gotoResult(){

	if (document.titleselectform.jobcode.selectedIndex == -1){
		document.titleselectform.jobcode.selectedIndex = 0;
	}
	if (document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].value == "")
	{
		document.titleselectform.jobcode.selectedIndex = 0;
	}

	var strJobTitle;
	strJobTitle = document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].text;
	document.titleselectform.jobtitle.value = strJobTitle;

	var strJobCode;
	strJobCode = document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].value;
	document.titleselectform.jobcode.value = strJobCode;
	
	document.titleselectform.action = "/salarywizard/layoutscripts/swzl_compresult.asp";
	document.titleselectform.submit();
	

}


function gotoSellEmployer(){

	if (document.titleselectform.jobcode.selectedIndex == -1){
		document.titleselectform.jobcode.selectedIndex = 0;
	}
	if (document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].value == "")
	{
		document.titleselectform.jobcode.selectedIndex = 0;
	}

	var strJobTitle;
	strJobTitle = document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].text;
	document.titleselectform.jobtitle.value = strJobTitle;

	var strJobCode;
	strJobCode = document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].value;
	document.titleselectform.jobcode.value = strJobCode;
	
	document.titleselectform.action = "/salarywizard/layoutscripts/swzl_sellemployer.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 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 = "700";
var strWidth = "840";
var popunder= strHostName + "/salaryreport/layoutscripts/srpl_overview.asp?r=salfrln";
//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(strNarrowDesc){
	var strJobCode;
	var strJobTitle;
	strJobCode =  window.titleselectform.jobcode.options[window.titleselectform.jobcode.selectedIndex].value;
	strJobTitle =  window.titleselectform.jobcode.options[window.titleselectform.jobcode.selectedIndex].text;
	var strUrl;
	strUrl = "/salarywizard/layoutscripts/swzl_jobdesc.asp?"
	strUrl = strUrl + "jobcode=" + strJobCode
	strUrl = strUrl + "&jobtitle=" + escape(strJobTitle)
	strUrl = strUrl + "&narrowdesc=" + escape(strNarrowDesc)
	if (strJobCode != "")
	{
	
		var jobdescWindow=window.open(strUrl,"JobDescWindow", "toolbar=no,scrollbars=yes, resizable=yes,width=500,height=230,left=0,top=0");
		jobdescWindow.focus();
	}
    	
}

function getSellJobDesc(strNarrowDesc){
	var strJobCode;
	var strJobTitle;
	strJobCode =  window.mainform.jobcode.options[window.mainform.jobcode.selectedIndex].value;
	strJobTitle =  window.mainform.jobcode.options[window.mainform.jobcode.selectedIndex].text;
	var strUrl;
	strUrl = "/salarywizard/layoutscripts/swzl_jobdesc.asp?"
	strUrl = strUrl + "jobcode=" + strJobCode
	strUrl = strUrl + "&jobtitle=" + escape(strJobTitle)
	strUrl = strUrl + "&narrowdesc=" + escape(strNarrowDesc)
	if (strJobCode != "")
	{
	
		var jobdescWindow=window.open(strUrl,"JobDescWindow", "toolbar=no,scrollbars=yes, resizable=yes,width=500,height=230,left=0,top=0");
		jobdescWindow.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=500,height=250,left=0,top=0");
	jobdescWindow.focus();
	
 

}

function emailresult() {
	var thelink;
	thelink="/salarywizard/layoutscripts/swzl_emailresult.asp";
	thelink=thelink + document.location.search;
        openCommonWindow(thelink,'410','500');
}
 
function ValidateEmailResultForm(){
	if(document.mainform.fromemailaddress.value.length==0){
		alert("Please enter your email.");
		document.mainform.fromemailaddress.focus();
		return false;
	}else{
		if(!GoodEmailAddress(document.mainform.fromemailaddress.value)){
			alert("Invalid email address.");
			document.mainform.fromemailaddress.select();
			document.mainform.fromemailaddress.focus();
			return false;
		}
	}

	if(document.mainform.toemailaddress.value.length==0){
		alert("Please enter recipient email.");
		document.mainform.toemailaddress.focus();
		return false;
	}else{
		if(!GoodEmailAddress(document.mainform.toemailaddress.value)){
			alert("Invalid email address.");
			document.mainform.toemailaddress.select();
			document.mainform.toemailaddress.focus();
			return false;
		}
	}

	return true;
		
}

function signupsalaryoptin()
{
	if(document.mainform.fromemailaddress.value.length==0){
		alert("Please enter your email.");
		document.mainform.fromemailaddress.focus();
	}else{
		if(!GoodEmailAddress(document.mainform.fromemailaddress.value))
		{
			alert("Invalid email address.");
			document.mainform.fromemailaddress.select();
			document.mainform.fromemailaddress.focus();
		}
		else
		{
			document.mainform.submit();
		}
	}
}

