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_sell.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 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 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 getResultPageexp(strAction, strPageNumber)
{
	window.onunload = null;
	document.resultform.pagenumber.value = strPageNumber;
	document.resultform.action = strAction;
	document.resultform.submit();
}

function refreshPageexp(strPayCheckCalc, strAction, strPageNumber)
{
	document.resultform.paycheckcalc.value = strPayCheckCalc;
	getResultPageexp(strAction, strPageNumber);
}
function newCalcexp(strAction, strPageNumber)
{
	document.resultform.paycheckcalc.value = "n";
	getResultPageexp(strAction, strPageNumber);
}
function clearCalculateexp(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 = "";
	}
	refreshPageexp(strPayCheckCalc, strAction, strPageNumber);
}

function calculateexp(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";
	getResultPageexp("/salarywizard/layoutscripts/swzl_compresult.asp", strPageNumber);
}