function ValidateZipCode()
{
	var bsubmit;
	var binput = parseInt(document.newsearchform.zipcode.value);
	bsubmit = true;
	
	if (isNaN(document.newsearchform.zipcode.value) || binput < 0)
	{
		alert("Please enter a non-negative numeric value for your ZIP code.");
		document.newsearchform.zipcode.focus();
		bsubmit= false;
	}
	
	if (bsubmit)
	{
		document.newsearchform.submit();
	}
}	
function ValidateBrowseYearsofExp()
{
	var strZip;
	var bsubmit;
	var strValidChars;
	var i;
	var strChar;
	var bZip;
	bZip = true;
	strZip = document.newbrowseform.zipcode.value;
	bsubmit = true;
	strValidChars= "0123456789";
			
	if (strZip == "")
	{	
		bsubmit = false;
		bZip = false;
	}
	if (isNaN(strZip))
	{	
		bsubmit = false;
		bZip = false;
	}
	if (strZip.length != 5)
	{
		bsubmit = false;
		bZip = false;
	}	
	else
	{
		for (i=0 ; i < strZip.length; i++) 
		{
			strChar = strZip.charAt(i);
			if (strValidChars.indexOf(strChar) == -1)
			{
				bsubmit = false;
				bZip = false;
				
			}
		}
	}
	
	
	if(document.newbrowseform.narrowcode.options[document.newbrowseform.narrowcode.selectedIndex].value == ""){
		alert("Please select a job category.");
		document.newbrowseform.narrowcode.focus();
		bsubmit = false;
	}
	else{
		var strNarrowDesc;
		strNarrowDesc = document.newbrowseform.narrowcode.options[document.newbrowseform.narrowcode.selectedIndex].text;
		document.newbrowseform.narrowdesc.value = strNarrowDesc;
		
	}
	if (bZip)
	{
		if (bsubmit)
		{
			document.newbrowseform.submit();
			return true;
		}
		else
		{
			return false;
		}
	}	
	else
	{
		alert("Please enter a valid ZIP Code");
		document.newbrowseform.zipcode.focus();
		return false;
	}
	
	
		
	
	
}
function validateNational()
{
	var strZip;
	var bsubmit;
	var strValidChars;
	var i;
	var strChar;
	
	strZip = document.nationalform.zipcode.value;
	bsubmit = true;
	strValidChars= "0123456789";
			
	if (strZip == "")
	{	
		bsubmit = false;
	}
	if (isNaN(strZip))
	{	
		bsubmit = false;
	}
	if (strZip.length != 5)
	{
		bsubmit = false;
	}	
	else
	{
		for (i=0 ; i < strZip.length; i++) 
		{
			strChar = strZip.charAt(i);
			if (strValidChars.indexOf(strChar) == -1)
			{
				bsubmit = false;
			}
		}
	}
	if (bsubmit)
	{
		document.nationalform.submit();
	}
	else
	{
		alert("Please enter a valid ZIP Code");
		document.nationalform.zipcode.focus();
	}

	
	//document.nationalform.submit();
		
		
}

function validateLocal()
{
	var iSelectedIndex;
	iSelectedIndex = document.localform.educationcode1.selectedIndex;
			
	if (iSelectedIndex == 0)
	{	alert("You must enter a relevant degree.");
		return false;
	}

//document.localform.submit();
}	
function ValidateJobTitle()
{	
	document.localform.action = "/salarywizard/layoutscripts/swzl_newsearchexp.asp";
	document.localform.submit();	
}
function gotoSWP(strMySalaryHost, strReferralCode){
	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.r.value = strReferralCode;
	document.titleselectform.s.value = "default";
	
	document.titleselectform.action = strMySalaryHost + "/salarywizardprofessional/layoutscripts/swpl_defineneeds.asp"
	document.titleselectform.submit();
	

}
function gotoHRWizard(strHRWizardHost){

	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 = "http://" + strHRWizardHost + "/salarywizard/layoutscripts/swzl_titleselect.asp";
	document.titleselectform.submit();
	

}
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 gotoTitleSelectFromKeyWord(){
	if(document.titleselectform.narrowcode.options[document.titleselectform.narrowcode.selectedIndex].value == ""){
		alert("Please select a job category.");
		document.titleselectform.narrowcode.focus();
		return false;
	}
	else{
		var strNarrowDesc;
		strNarrowDesc = document.titleselectform.narrowcode.options[document.titleselectform.narrowcode.selectedIndex].text;
		document.titleselectform.narrowdesc.value = strNarrowDesc;
 		return true;
	}
	

}
function gotoKeywordTitleSelect(){
	//if(document.keywordsearchform.searchtextvalue.value == ""){
	//	alert("Please enter jobtitle or keyword.");
	//	document.keywordsearchform.searchtextvalue.focus();
	//	return false;
	//}
	return true;
}

function gotoKeywordTitleSelectExp(){
	//if(document.keywordsearchform.searchtextvalue.value == ""){
	//	alert("Please enter jobtitle or keyword.");
	//	document.keywordsearchform.searchtextvalue.focus();
	//	return false;
	//}
	if (ValidateZipCode())
	  return true;
	else
	  return false;
}

function gotoJobTitleSelect()
{
	if(document.newsearchform.altername.value == "")
	{
		alert("Please select a job title to start searching.");
		document.newsearchform.altername.focus();
		return false;
	}
}

function displaySearchBox(){
	document.titleselectform.search.value = "1";
	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.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;
	}
	if(objForm.altername.value == "Enter search term"){
		alert("Please enter a job title to start searching.");
		objForm.altername.focus();
		return false;
	}
	
	return true;

}

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 = "http://secure.salary.com/salaryreport/layoutscripts/srpl_overview.asp";
	document.titleselectform.submit();
	

}


function tellafriend() {
	var thelink;
	thelink="/salarywizard/layoutscripts/swzl_tellafriend.asp";
	thelink=thelink + document.location.search;
        openCommonWindow(thelink,'400','500');
}

function getNationalRangeBellPage(strAction, strPageNumber)
{
	window.onunload = null;
	document.nationalform.pagenumber.value = strPageNumber;
	document.nationalform.action = strAction;
	document.nationalform.submit();
}

function getLocalRangeBellPage(strAction, strPageNumber)
{
	window.onunload = null;
	document.localform.pagenumber.value = strPageNumber;
	document.localform.action = strAction;
	document.localform.submit();
}
function getResultPage(strAction, strPageNumber)
{
	window.onunload = null;
	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&p=050205_psr_495";
//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 =  document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].value;
	strJobTitle =  document.titleselectform.jobcode.options[document.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 getJobDescAltTitles(strJobCode, strJobAdvancedTitle, strNarrowDesc){
//	var strJobCode;
//	var strJobTitle;
//	strJobCode =  document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].value;
//	strJobTitle =  document.titleselectform.jobcode.options[document.titleselectform.jobcode.selectedIndex].text;
	var strUrl;
	strUrl = "/salarywizard/layoutscripts/swzl_jobdescAltTitle.asp?"
	strUrl = strUrl + "jobcode=" + strJobCode
	strUrl = strUrl + "&advancedjobtitle=" + escape(strJobAdvancedTitle)
	strUrl = strUrl + "&narrowdesc=" + escape(strNarrowDesc)
	if (strJobCode != "")
	{
	
		var jobdescWindow=window.open(strUrl,"JobDescWindow", "toolbar=no,scrollbars=yes, resizable=yes,width=500,height=350,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();
		}
	}
}

// here begins the part for paycheck estimate
function calculate(strPageNumber)
{
	if(document.resultform.paycheckstate.value.length==0){
		alert("Please choose a state.");
		document.resultform.paycheckstate.focus();
		return;
	}
	if(document.resultform.grosspay.value.length==0){
		alert("Please enter gross pay.");
		document.resultform.grosspay.focus();
		return;
	}
	else if(isNaN(document.resultform.grosspay.value)){
		alert("Please enter a number as gross pay.");
		document.resultform.grosspay.focus();
		return;
	}
	else if(parseInt(document.resultform.grosspay.value) < 0 || parseInt(document.resultform.grosspay.value) - 100000000 > 0){
		alert("Please enter a valid number as gross pay.");
		document.resultform.grosspay.focus();
		return;
	}
	else if(isNaN(document.resultform.grossytd.value)){
		alert("Please enter a number as gross salary YTD or keep it blank.");
		document.resultform.grossytd.focus();
		return;
	}
	else if(document.resultform.grossytd.value.length > 0) {
		if(parseInt(document.resultform.grossytd.value) < 0 || parseInt(document.resultform.grossytd.value) - 10000000 > 0){
			alert("Please enter a valid number as gross salary YTD.");
			document.resultform.grossytd.focus();
			return;
		}
	}
	else if(isNaN(document.resultform.fedexemps.value)){
		alert("Please enter a number as federal allowance.");
		document.resultform.fedexemps.focus();
		return;
	}
	else if(parseInt(document.resultform.fedexemps.value) < 0 || parseInt(document.resultform.fedexemps.value) - 99 > 0){
		alert("Please enter a number between 0 to 99 as federal allowance.");
		document.resultform.fedexemps.focus();
		return;
	}
	else if(isNaN(document.resultform.additionalfit.value)){
		alert("Please enter a number as additional federal withholding.");
		document.resultform.additionalfit.focus();
		return;
	}
	else if(parseInt(document.resultform.additionalfit.value) < 0 || parseInt(document.resultform.additionalfit.value) - 1000000 > 0){
		alert("Please enter a valid number as additional federal withholding.");
		document.resultform.additionalfit.focus();
		return;
	}
	else if(isNaN(document.resultform.stateexemps.value)){
		alert("Please enter a number as state exemption.");
		document.resultform.stateexemps.focus();
		return;
	}
	else if(parseInt(document.resultform.stateexemps.value) < 0 || parseInt(document.resultform.stateexemps.value) - 99 > 0){
		alert("Please enter a number between 0 to 99 as state exemption.");
		document.resultform.stateexemps.focus();
		return;
	}
	else if(isNaN(document.resultform.additionalsit.value)){
		alert("Please enter a number as additional state withholding.");
		document.resultform.additionalsit.focus();
		return;
	}
	else if(parseInt(document.resultform.additionalsit.value) < 0 || parseInt(document.resultform.additionalsit.value) - 100000000 > 0){
		alert("Please enter a valid number as additional state withholding.");
		document.resultform.additionalsit.focus();
		return;
	}
	
	var i;
	for (i=1; i-document.resultform.deductionnum.value<=0; i++)
	{
		if(isNaN(document.resultform.elements["deductionamt_"+i].value)){
			alert("Please enter a number as deduction amount.");
			document.resultform.elements["deductionamt_"+i].focus();
			return;
		}
		else if(parseInt(document.resultform.elements["deductiontype_"+i].value) <= 2) {
			if(parseInt(document.resultform.elements["deductionamt_"+i].value) < 0 || parseInt(document.resultform.elements["deductionamt_"+i].value) - 100000000 > 0){
				alert("Please enter a valid number as deduction amount.");
				document.resultform.elements["deductionamt_"+i].focus();
				return;
			}
		}
		else if(parseInt(document.resultform.elements["deductiontype_"+i].value) > 2) {
			if(parseInt(document.resultform.elements["deductionamt_"+i].value) < 0 || parseInt(document.resultform.elements["deductionamt_"+i].value) - 100 > 0){
				alert("Please enter a valid number as deduction amount.");
				document.resultform.elements["deductionamt_"+i].focus();
				return;
			}
		}
	}
	document.resultform.paycheckcalc.value = "1";
	getResultPage("/salarywizard/layoutscripts/swzl_compresult.asp", strPageNumber);
}

function refreshPage(strPayCheckCalc, strAction, strPageNumber)
{
	document.resultform.paycheckcalc.value = strPayCheckCalc;
	getResultPage(strAction, strPageNumber);
}

function newCalc(strAction, strPageNumber)
{
	document.resultform.paycheckcalc.value = "n";
	getResultPage(strAction, strPageNumber);
}

function clearCalculate(strPayCheckCalc, strAction, strPageNumber)
{
	document.resultform.taxyear.value = "";
	document.resultform.paycheckstate.value = "";
	document.resultform.grossfreq.value = "";
	document.resultform.paypd.value = "";
	document.resultform.fedstatus.value = "";
	document.resultform.statestatus.value = "";
	
	document.resultform.roundfed[0].checked = false;
	document.resultform.roundfed[1].checked = true;
	
	document.resultform.grosspay.value = "";
	document.resultform.grossytd.value = "";
	document.resultform.fedexemps.value = "";
	document.resultform.additionalfit.value = "";
	document.resultform.stateexemps.value = "";
	document.resultform.additionalsit.value = "";
	
	var i;
	for (i=1; i-document.resultform.deductionnum.value<=0; i++)
	{
		document.resultform.elements["deductiondrop_"+i].value = "";
		document.resultform.elements["deductionname_"+i].value = "";
		document.resultform.elements["deductionamt_"+i].value = "";
		document.resultform.elements["deductiontype_"+i].value = "";
		
		document.resultform.elements["checkfederal_"+i].value = "";
		document.resultform.elements["checkfica_"+i].value = "";
		document.resultform.elements["checkstate_"+i].value = "";
		document.resultform.elements["checklocal_"+i].value = "";
	}
	refreshPage(strPayCheckCalc, strAction, strPageNumber);
}

function PurchasePSR(strRefCode)
{
	document.resultform.r.value = strRefCode;
	SubmitToSellEmployer();
}

function mouseOverPayCheck(strPageNumber)
{
	window.status="javascript:getResultPage('/salarywizard/layoutscripts/swzl_compresult.asp','" + strPageNumber + "');";
}
// end of paycheck estimate

function getJobDescription(strJobCode, strJobTitle, strNarrowDesc){
	var strUrl;
	strUrl = "/salarywizard/layoutscripts/swzl_jobdescription.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=450,height=370,left=0,top=0");
		jobdescWindow.focus();
	}
    	
}

function calculateexp(strPageNumber)
{
	if(document.localform.paycheckstate.value.length==0){
		alert("Please choose a state.");
		document.localform.paycheckstate.focus();
		return;
	}
	if(document.localform.grosspay.value.length==0){
		alert("Please enter gross pay.");
		document.localform.grosspay.focus();
		return;
	}
	else if(isNaN(document.localform.grosspay.value)){
		alert("Please enter a number as gross pay.");
		document.localform.grosspay.focus();
		return;
	}
	else if(parseInt(document.localform.grosspay.value) < 0 || parseInt(document.localform.grosspay.value) - 100000000 > 0){
		alert("Please enter a valid number as gross pay.");
		document.localform.grosspay.focus();
		return;
	}
	else if(isNaN(document.localform.grossytd.value)){
		alert("Please enter a number as gross salary YTD or keep it blank.");
		document.localform.grossytd.focus();
		return;
	}
	else if(document.localform.grossytd.value.length > 0) {
		if(parseInt(document.localform.grossytd.value) < 0 || parseInt(document.localform.grossytd.value) - 10000000 > 0){
			alert("Please enter a valid number as gross salary YTD.");
			document.localform.grossytd.focus();
			return;
		}
	}
	else if(isNaN(document.localform.fedexemps.value)){
		alert("Please enter a number as federal allowance.");
		document.localform.fedexemps.focus();
		return;
	}
	else if(parseInt(document.localform.fedexemps.value) < 0 || parseInt(document.localform.fedexemps.value) - 99 > 0){
		alert("Please enter a number between 0 to 99 as federal allowance.");
		document.localform.fedexemps.focus();
		return;
	}
	else if(isNaN(document.localform.additionalfit.value)){
		alert("Please enter a number as additional federal withholding.");
		document.localform.additionalfit.focus();
		return;
	}
	else if(parseInt(document.localform.additionalfit.value) < 0 || parseInt(document.localform.additionalfit.value) - 1000000 > 0){
		alert("Please enter a valid number as additional federal withholding.");
		document.localform.additionalfit.focus();
		return;
	}
	else if(isNaN(document.localform.stateexemps.value)){
		alert("Please enter a number as state exemption.");
		document.localform.stateexemps.focus();
		return;
	}
	else if(parseInt(document.localform.stateexemps.value) < 0 || parseInt(document.localform.stateexemps.value) - 99 > 0){
		alert("Please enter a number between 0 to 99 as state exemption.");
		document.localform.stateexemps.focus();
		return;
	}
	else if(isNaN(document.localform.additionalsit.value)){
		alert("Please enter a number as additional state withholding.");
		document.localform.additionalsit.focus();
		return;
	}
	else if(parseInt(document.localform.additionalsit.value) < 0 || parseInt(document.localform.additionalsit.value) - 100000000 > 0){
		alert("Please enter a valid number as additional state withholding.");
		document.localform.additionalsit.focus();
		return;
	}
	
	var i;
	for (i=1; i-document.localform.deductionnum.value<=0; i++)
	{
		if(isNaN(document.localform.elements["deductionamt_"+i].value)){
			alert("Please enter a number as deduction amount.");
			document.localform.elements["deductionamt_"+i].focus();
			return;
		}
		else if(parseInt(document.localform.elements["deductiontype_"+i].value) <= 2) {
			if(parseInt(document.localform.elements["deductionamt_"+i].value) < 0 || parseInt(document.localform.elements["deductionamt_"+i].value) - 100000000 > 0){
				alert("Please enter a valid number as deduction amount.");
				document.localform.elements["deductionamt_"+i].focus();
				return;
			}
		}
		else if(parseInt(document.localform.elements["deductiontype_"+i].value) > 2) {
			if(parseInt(document.localform.elements["deductionamt_"+i].value) < 0 || parseInt(document.localform.elements["deductionamt_"+i].value) - 100 > 0){
				alert("Please enter a valid number as deduction amount.");
				document.localform.elements["deductionamt_"+i].focus();
				return;
			}
		}
	}
	document.localform.paycheckcalc.value = "1";
	getResultPageexp("/salarywizard/layoutscripts/swzl_localrangebellcha.asp", strPageNumber);
}
function getResultPageexp(strAction, strPageNumber)
{
	window.onunload = null;
	document.localform.pagenumber.value = strPageNumber;
	document.localform.action = strAction;
	document.localform.submit();
}

function refreshPageexp(strPayCheckCalc, strAction, strPageNumber)
{
	document.localform.paycheckcalc.value = strPayCheckCalc;
	getResultPageexp(strAction, strPageNumber);
}
function newCalcexp(strAction, strPageNumber)
{
	document.localform.paycheckcalc.value = "n";
	getResultPageexp(strAction, strPageNumber);
}

function clearCalculateexp(strPayCheckCalc, strAction, strPageNumber)
{
	document.localform.taxyear.value = "";
	document.localform.paycheckstate.value = "";
	document.localform.grossfreq.value = "";
	document.localform.paypd.value = "";
	document.localform.fedstatus.value = "";
	document.localform.statestatus.value = "";
	
	document.localform.roundfed[0].checked = false;
	document.localform.roundfed[1].checked = true;
	
	document.localform.grosspay.value = "";
	document.localform.grossytd.value = "";
	document.localform.fedexemps.value = "";
	document.localform.additionalfit.value = "";
	document.localform.stateexemps.value = "";
	document.localform.additionalsit.value = "";
	
	var i;
	for (i=1; i-document.localform.deductionnum.value<=0; i++)
	{
		document.localform.elements["deductiondrop_"+i].value = "";
		document.localform.elements["deductionname_"+i].value = "";
		document.localform.elements["deductionamt_"+i].value = "";
		document.localform.elements["deductiontype_"+i].value = "";
		
		document.localform.elements["checkfederal_"+i].value = "";
		document.localform.elements["checkfica_"+i].value = "";
		document.localform.elements["checkstate_"+i].value = "";
		document.localform.elements["checklocal_"+i].value = "";
	}
	refreshPageexp(strPayCheckCalc, strAction, strPageNumber);
}
function PurchasePSRexp(strRefCode)
{
	document.localform.r.value = strRefCode;
	SubmitToSellEmployer();
}

function calculateNationalexp(strPageNumber)
{
	if(document.nationalform.paycheckstate.value.length==0){
		alert("Please choose a state.");
		document.nationalform.paycheckstate.focus();
		return;
	}
	if(document.nationalform.grosspay.value.length==0){
		alert("Please enter gross pay.");
		document.nationalform.grosspay.focus();
		return;
	}
	else if(isNaN(document.nationalform.grosspay.value)){
		alert("Please enter a number as gross pay.");
		document.nationalform.grosspay.focus();
		return;
	}
	else if(parseInt(document.nationalform.grosspay.value) < 0 || parseInt(document.nationalform.grosspay.value) - 100000000 > 0){
		alert("Please enter a valid number as gross pay.");
		document.nationalform.grosspay.focus();
		return;
	}
	else if(isNaN(document.nationalform.grossytd.value)){
		alert("Please enter a number as gross salary YTD or keep it blank.");
		document.nationalform.grossytd.focus();
		return;
	}
	else if(document.nationalform.grossytd.value.length > 0) {
		if(parseInt(document.nationalform.grossytd.value) < 0 || parseInt(document.nationalform.grossytd.value) - 10000000 > 0){
			alert("Please enter a valid number as gross salary YTD.");
			document.nationalform.grossytd.focus();
			return;
		}
	}
	else if(isNaN(document.nationalform.fedexemps.value)){
		alert("Please enter a number as federal allowance.");
		document.nationalform.fedexemps.focus();
		return;
	}
	else if(parseInt(document.nationalform.fedexemps.value) < 0 || parseInt(document.nationalform.fedexemps.value) - 99 > 0){
		alert("Please enter a number between 0 to 99 as federal allowance.");
		document.nationalform.fedexemps.focus();
		return;
	}
	else if(isNaN(document.nationalform.additionalfit.value)){
		alert("Please enter a number as additional federal withholding.");
		document.nationalform.additionalfit.focus();
		return;
	}
	else if(parseInt(document.nationalform.additionalfit.value) < 0 || parseInt(document.nationalform.additionalfit.value) - 1000000 > 0){
		alert("Please enter a valid number as additional federal withholding.");
		document.nationalform.additionalfit.focus();
		return;
	}
	else if(isNaN(document.nationalform.stateexemps.value)){
		alert("Please enter a number as state exemption.");
		document.nationalform.stateexemps.focus();
		return;
	}
	else if(parseInt(document.nationalform.stateexemps.value) < 0 || parseInt(document.nationalform.stateexemps.value) - 99 > 0){
		alert("Please enter a number between 0 to 99 as state exemption.");
		document.nationalform.stateexemps.focus();
		return;
	}
	else if(isNaN(document.nationalform.additionalsit.value)){
		alert("Please enter a number as additional state withholding.");
		document.nationalform.additionalsit.focus();
		return;
	}
	else if(parseInt(document.nationalform.additionalsit.value) < 0 || parseInt(document.nationalform.additionalsit.value) - 100000000 > 0){
		alert("Please enter a valid number as additional state withholding.");
		document.nationalform.additionalsit.focus();
		return;
	}
	
	var i;
	for (i=1; i-document.nationalform.deductionnum.value<=0; i++)
	{
		if(isNaN(document.nationalform.elements["deductionamt_"+i].value)){
			alert("Please enter a number as deduction amount.");
			document.nationalform.elements["deductionamt_"+i].focus();
			return;
		}
		else if(parseInt(document.nationalform.elements["deductiontype_"+i].value) <= 2) {
			if(parseInt(document.nationalform.elements["deductionamt_"+i].value) < 0 || parseInt(document.nationalform.elements["deductionamt_"+i].value) - 100000000 > 0){
				alert("Please enter a valid number as deduction amount.");
				document.nationalform.elements["deductionamt_"+i].focus();
				return;
			}
		}
		else if(parseInt(document.nationalform.elements["deductiontype_"+i].value) > 2) {
			if(parseInt(document.nationalform.elements["deductionamt_"+i].value) < 0 || parseInt(document.nationalform.elements["deductionamt_"+i].value) - 100 > 0){
				alert("Please enter a valid number as deduction amount.");
				document.nationalform.elements["deductionamt_"+i].focus();
				return;
			}
		}
	}
	document.nationalform.paycheckcalc.value = "1";
	getResultPageNationalexp("/salarywizard/layoutscripts/swzl_nationalrangebell.asp", strPageNumber);
}
function getResultPageNationalexp(strAction, strPageNumber)
{
	window.onunload = null;
	document.nationalform.pagenumber.value = strPageNumber;
	document.nationalform.action = strAction;
	document.nationalform.submit();
}

function refreshPageNationalexp(strPayCheckCalc, strAction, strPageNumber)
{
	document.nationalform.paycheckcalc.value = strPayCheckCalc;
	getResultPageNationalexp(strAction, strPageNumber);
}
function newCalcNationalexp(strAction, strPageNumber)
{
	document.nationalform.paycheckcalc.value = "n";
	getResultPageNationalexp(strAction, strPageNumber);
}

function clearCalculateNationalexp(strPayCheckCalc, strAction, strPageNumber)
{
	document.nationalform.taxyear.value = "";
	document.nationalform.paycheckstate.value = "";
	document.nationalform.grossfreq.value = "";
	document.nationalform.paypd.value = "";
	document.nationalform.fedstatus.value = "";
	document.nationalform.statestatus.value = "";
	
	document.nationalform.roundfed[0].checked = false;
	document.nationalform.roundfed[1].checked = true;
	
	document.nationalform.grosspay.value = "";
	document.nationalform.grossytd.value = "";
	document.nationalform.fedexemps.value = "";
	document.nationalform.additionalfit.value = "";
	document.nationalform.stateexemps.value = "";
	document.nationalform.additionalsit.value = "";
	
	var i;
	for (i=1; i-document.nationalform.deductionnum.value<=0; i++)
	{
		document.nationalform.elements["deductiondrop_"+i].value = "";
		document.nationalform.elements["deductionname_"+i].value = "";
		document.nationalform.elements["deductionamt_"+i].value = "";
		document.nationalform.elements["deductiontype_"+i].value = "";
		
		document.nationalform.elements["checkfederal_"+i].value = "";
		document.nationalform.elements["checkfica_"+i].value = "";
		document.nationalform.elements["checkstate_"+i].value = "";
		document.nationalform.elements["checklocal_"+i].value = "";
	}
	refreshPageNationalexp(strPayCheckCalc, strAction, strPageNumber);
}
function PurchaseNationalPSRexp(strRefCode)
{
	document.nationalform.r.value = strRefCode;
	SubmitToSellEmployer();
}
function submitlocalrange (){
	document.alertform.submit();
}