// primepay.js - include by reference in marketing sites
function notYet( sMsg ) {
	alert( 'The ' + sMsg + ' option is not yet implemented.' );
} // function

function checkedEnable( oCheck, sTagId ){
	var oTag = document.getElementById( sTagId )
	
	if( oCheck.checked == true ){
		oTag.disabled = false;
		oTag.focus();
	}
	else{
		oTag.disabled = true;
	}
}

function isLoginOk() {
	if ( document.theForm.k1.value != "" || document.theForm.k4.value != "" ) {
		if ( document.getElementById( "sniffBrowser" ) ) {
			//document.getElementById( "sniffBrowser" ).value = sniffBrowser();
		}

		document.theForm.submit();
	}
	else {
		alert( "If you do not yet have a user name\nand password for this site, please\nRegister to request them now." );
	}
} // function

function isReturnToLogin(){
	window.location = "login.aspx"; 
}

function isRegisterOk(){
	var oForm = document.theForm;

	if ( 
		validate( oForm, "sContact",   true ) == true 
			&& 
		validate( oForm, "sLegalName", true ) == true 
			&& 
		validate( oForm, "sCity",      true ) == true 
			&& 
		validate( oForm, "sState",     true ) == true 
			&& 
		( 
		 	( oForm.sPhoneCell && isSomething( oForm.sPhoneCell.value ) == true && validate( oForm, "sPhoneCell", true ) == true ) 
				||
			( isSomething( oForm.sPhone.value ) == true && validate( oForm, "sPhone", true ) == true ) 
				||
			( alert( "Please enter an Office Phone Number and / or Cell Phone Number" ) )
		)
			&&
		validate( oForm, "sEmail",     true ) == true 
			&&
		validate( oForm, "sEmail_2",   true ) == true 
	) {
		isDirtyPage( false );
		document.theForm.submit();
	}
}

function isDirtyPage( bIsDirty ) {
	g_bIsDirtyPage = bIsDirty;
	return true;
}

function confirmExit( sUrl ) {
	if ( 
		( g_bIsDirtyPage == false ) || 
		confirm( 
			"You have clicked a link to leave this page\n" + 
			"without submitting your data in this form.\n\n" + 
			"Do you want to discard your entries?" ) 
		) {
		window.location = sUrl;
	}
}

function displayToggle( sId ) {
	var oElementThis = document.getElementById( sId ); 

	if ( oElementThis.style.display == "none" )  {
		oElementThis.style.display = "";
	}
	else {
		oElementThis.style.display = "none";
	}
}

function displayToggleFAQ( sId ) {
	var oElementThis = document.getElementById( 'a' + sId ); 
	var bIsHidden = ( oElementThis.style.display == "none" );

	// hide all answers
	if ( document.getElementById('a01') ) document.getElementById('a01').style.display = "none";
	if ( document.getElementById('a02') ) document.getElementById('a02').style.display = "none";
	if ( document.getElementById('a03') ) document.getElementById('a03').style.display = "none";
	if ( document.getElementById('a04') ) document.getElementById('a04').style.display = "none";
	if ( document.getElementById('a05') ) document.getElementById('a05').style.display = "none";
	if ( document.getElementById('a06') ) document.getElementById('a06').style.display = "none";
	if ( document.getElementById('a07') ) document.getElementById('a07').style.display = "none";
	if ( document.getElementById('a08') ) document.getElementById('a08').style.display = "none";
	if ( document.getElementById('a09') ) document.getElementById('a09').style.display = "none";
	if ( document.getElementById('a10') ) document.getElementById('a10').style.display = "none";
	if ( document.getElementById('a11') ) document.getElementById('a11').style.display = "none";
	if ( document.getElementById('a12') ) document.getElementById('a12').style.display = "none";
	if ( document.getElementById('a13') ) document.getElementById('a13').style.display = "none";
	if ( document.getElementById('a14') ) document.getElementById('a14').style.display = "none";
	if ( document.getElementById('a15') ) document.getElementById('a15').style.display = "none";
	if ( document.getElementById('a16') ) document.getElementById('a16').style.display = "none";
	if ( document.getElementById('a17') ) document.getElementById('a17').style.display = "none";
	if ( document.getElementById('a18') ) document.getElementById('a18').style.display = "none";
	if ( document.getElementById('a19') ) document.getElementById('a19').style.display = "none";
	if ( document.getElementById('a20') ) document.getElementById('a20').style.display = "none";
	if ( document.getElementById('a21') ) document.getElementById('a21').style.display = "none";
	
	if ( bIsHidden == true ) {
		oElementThis.style.display = "";
		document.getElementById( 'a' + sId ).focus();
	}
	else {
		document.getElementById( 'q' + sId ).focus();
	}
}

function displayToggleAdditionalResources( sId ) {
	var oElementThis = document.getElementById( sId ); 
	var oElementThat
	
	if ( sId == "forms" ) {
		oElementThat = document.getElementById( "feds" ); 
	}
	else {
		oElementThat = document.getElementById( "forms" ); 
	}
	 
	if (oElementThis.style.display == "none" )  {
		oElementThis.style.display = "";
	}
	 
	else {
		oElementThis.style.display = "none";
	}

	if (oElementThat.style.display == "")  {
		oElementThat.style.display = "none";
	}
}

function numberString( sString ) {
	sString = sString.replace( /\D/g,"");
	return sString	
}

function isSomething( sString ) {
	var bIsSomething = false;
	
	if ( sString.length > 0 ) {
		bIsSomething = true;
	}

	return bIsSomething;
}

function isPhone( sPhone ) {
	var sTest = /^(1[-\s.]?)?[(]?\d{3}[)]?[-\s.]?\d{3}[-\s.]?\d{4}$/; // 2005.11.12 DD: check for matching () & delimiters
	return sTest.test( sPhone );
}

function isEmail( sEmail ) {
	var sTest = /^[^@\s]+@[^@\s]+[.]{1}[a-zA-Z]+$/;  // 2005.11.12 DD: embellish to prohibit ".."
	return sTest.test( sEmail );
}

function calendarPicker( formName, inputField, focusField ){
	var sUrl = '/~common/vb/DatePicker.aspx?formName=' + formName + '&inputField=' + inputField + '&focusField=' + focusField
	window.open( sUrl, 'calendarPopup', 'width=250, height=190, resizable=yes' );
}

function isValidHelpRequest(){ 
	var oForm = document.theForm;

	if ( 
		validate( oForm, "sContact",       true ) == true && 
		validate( oForm, "sLegalName",     true ) == true && 
		validate( oForm, "sCity",          true ) == true &&
		validate( oForm, "sState",         true ) == true && 
		validate( oForm, "sEmail",         true ) == true && 
		validate( oForm, "sPhone",         true ) == true && 
		validate( oForm, "sTopic",         true ) == true && 
		validate( oForm, "sPhoneOrEmail",  true ) == true 
		) {
	oForm.submit();
	}
} // function

function isSubmitOKActivationForm( sPromotion ){
	var oForm = document.theForm;
	
	if (
		validate( oForm, "sLegalName",       true ) == true && 
		validate( oForm, "sEin",             true ) == true && 
		validate( oForm, "sAddress",         true ) == true && 
		validate( oForm, "sCity",            true ) == true &&
		validate( oForm, "sState",           true ) == true && 
		validate( oForm, "sZip",             true ) == true && 
		validate( oForm, "sContact",         true ) == true && 
		validate( oForm, "sPhone",           true ) == true && 
		validate( oForm, "sExt",             true ) == true && 
		validate( oForm, "sEmail",           true ) == true && 
		validate( oForm, "sFax",             true ) == true && 
		( ( ( sPromotion != "Aetna-ARC" ) && ( sPromotion != "ColdStoneCreamery" ) ) || validate( oForm, "iLocs", true ) == true ) &&
		validate( oForm, "iEmpPerLoc",       true ) == true && 
		validate( oForm, "sFirstCheck",      true ) == true && 
		validate( oForm, "sCurrentProvider", true ) == true && 
		validate( oForm, "sFrequency",       true ) == true && 
		validate( oForm, "sTimeToCall",      true ) == true && 
		validate( oForm, "sTimeZone",        true ) == true
		) {
		oForm.submit();
	}
}

function isValidPPContactUs() {
	var oForm = document.theForm;
	
	if ( 
		validate( oForm, "sContact",       	true ) == true && 
		validate( oForm, "sLegalName",     	true ) == true && 
		validate( oForm, "sCity",          	true ) == true &&
		validate( oForm, "sState",         	true ) == true &&
		validate( oForm, "sZip",			true ) == true &&
		validate( oForm, "sPhone",         	true ) == true &&
		validate( oForm, "sEmail",  		true ) == true &&
		validate( oForm, "sEmail_2",  		true ) == true 
		) {
		oForm.submit();
	}
} // function

function isValidPPServiceInquiry() {
	var oForm = document.theForm;
	
	if ( 
		validate( oForm, "sContact",       	true ) == true && 
		validate( oForm, "sLegalName",     	true ) == true && 
		validate( oForm, "sCity",          	true ) == true &&
		validate( oForm, "sState",         	true ) == true &&
		validate( oForm, "sZip",			true ) == true &&
		validate( oForm, "sPhone",         	true ) == true &&
		validate( oForm, "sEmail",  		true ) == true &&
		validate( oForm, "sEmail_2",  		true ) == true 
		) {
		oForm.submit();
	}
} // function

function isValidPPSupportInquiry() {
	var oForm = document.theForm;
	
	if ( 
		validate( oForm, "sContact",       	true ) == true && 
		validate( oForm, "sLegalName",     	true ) == true && 
		validate( oForm, "sCity",          	true ) == true &&
		validate( oForm, "sState",         	true ) == true &&
		validate( oForm, "sZip",			true ) == true &&
		validate( oForm, "sPhone",         	true ) == true &&
		validate( oForm, "sEmail",  		true ) == true &&
		validate( oForm, "sEmail_2",  		true ) == true &&
		validate( oForm, "sClientNum",      true ) == true && 
		validate( oForm, "sProcOffice",     true ) == true
		) {
		oForm.submit();
	}
} // function

function isValidPPBusinessInquiry() {
	var oForm = document.theForm;
	
	if ( 
		validate( oForm, "sContact",       	true ) == true && 
		validate( oForm, "sLegalName",     	true ) == true && 
		validate( oForm, "sCity",          	true ) == true &&
		validate( oForm, "sState",         	true ) == true &&
		validate( oForm, "sZip",			true ) == true &&
		validate( oForm, "sPhone",         	true ) == true &&
		validate( oForm, "sEmail",  		true ) == true &&
		validate( oForm, "sEmail_2",  		true ) == true 
		) {
		oForm.submit();
	}
} // function

function isValidPPGeneralInquiry() {
	var oForm = document.theForm;
	
	if ( 
		validate( oForm, "sContact",       	true ) == true && 
		validate( oForm, "sLegalName",     	true ) == true && 
		validate( oForm, "sCity",          	true ) == true &&
		validate( oForm, "sState",         	true ) == true &&
		validate( oForm, "sZip",			true ) == true &&
		validate( oForm, "sPhone",         	true ) == true &&
		validate( oForm, "sEmail",  		true ) == true &&
		validate( oForm, "sEmail_2",  		true ) == true 
		) {
		oForm.submit();
	}
} // function

function isValidHDContactUs(){
	var oForm = document.theForm;
	

		oForm.submit();
	
}

function isValidIHRSAContactUs(){
	var oForm = document.contactForm;
	
	if ( 
		validate( oForm, "sContact",       	true ) == true && 
		validate( oForm, "sLegalName",     	true ) == true && 
		validate( oForm, "sCity",          	true ) == true &&
		validate( oForm, "sState",         	true ) == true &&
		validate( oForm, "sZip",			true ) == true &&
		validate( oForm, "sPhone",         	true ) == true &&
		validate( oForm, "sEmail",  		true ) == true &&
		validate( oForm, "sEmail_2",  		true ) == true
		) {
		oForm.submit();
	}
}

function isValidPFContactUs() {
	var oForm = document.theForm;
	
	if ( 
		validate( oForm, "sContact",       	true ) == true && 
		validate( oForm, "sLegalName",     	true ) == true && 
		validate( oForm, "sCity",          	true ) == true &&
		validate( oForm, "sState",         	true ) == true &&
//		validate( oForm, "sZip",			true ) == true &&
		validate( oForm, "sPhone",         	true ) == true &&
		validate( oForm, "sEmail",  		true ) == true &&
		validate( oForm, "sEmail_2",  		true ) == true) {
		oForm.submit();
	}
} // function

function isValidQuote() {
	var oForm = document.theForm;
	
	if ( 
		validate( oForm, "sContact",       	true ) == true && 
		validate( oForm, "sLegalName",     	true ) == true && 
		validate( oForm, "sCity",          	true ) == true &&
		validate( oForm, "sState",         	true ) == true &&
		validate( oForm, "sZip",			true ) == true &&
		validate( oForm, "sPhone",         	true ) == true &&
		validate( oForm, "sEmail",  		true ) == true &&
		validate( oForm, "sEmail_2",  		true ) == true) {
		oForm.submit();
	}
} // function

function isValidFranchiseForm( sPromotion ){
	var oForm = document.theForm;
	
	if (
		validate( oForm, "sLegalName",       true ) == true &&
		validate( oForm, "sContact",         true ) == true && 
		validate( oForm, "sCity",            true ) == true &&
		validate( oForm, "sState",           true ) == true && 
		validate( oForm, "sZip",             true ) == true && 
		validate( oForm, "sPhone",           true ) == true && 
		validate( oForm, "sEmail",           true ) == true && 
		validate( oForm, "sEmail_2",         true ) == true && 
		validate( oForm, "sFrequency",       true ) == true && 
		validate( oForm, "sEmployees",       true ) == true
		) {
		oForm.submit();
	}
}

function isValidKumonForm(){
	var oForm = document.theForm;
	
	if (
		validate( oForm, "sContact",         true ) == true && 
		validate( oForm, "sLegalName",       true ) == true &&
		validate( oForm, "sCity",            true ) == true &&
		validate( oForm, "sState",           true ) == true && 
		validate( oForm, "sPhone",           true ) == true && 
		validate( oForm, "sEmail",           true ) == true 
		) {
		oForm.submit();
	}
}

function isValidSEMContact(){ 
	var oForm = document.theForm;

	if ( 
		validate( oForm, "sFirstName",          true ) == true && 
		validate( oForm, "sLastName",           true ) == true && 
		validate( oForm, "sLegalName",          true ) == true &&
		validate( oForm, "sZip",                true ) == true && 
		validate( oForm, "sEmail",              true ) == true && 
		validate( oForm, "sPhone",              true ) == true && 
		validate( oForm, "sNumberofEmployees",  true ) == true
		) {
	oForm.submit();
	}
} // function


function validate( oForm, sItem, bIsSubmit ) { // validate each field separately in case we want to add specific logic
	var bIsOk;
	var sTest; // RegEx 

	bIsOk = checkIllegalInputChars( document.getElementById( sItem ) )

	if ( bIsOk ){
		switch ( sItem ) { // append " && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) " to validation test to set dirty flag only if the validation test is performed
			
			case "sClientNum":
				sTest = /^\d{4}$/; 
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sClientNum.value ) == false ) || ( sTest.test( oForm.sClientNum.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) ) ;
				
				if ( !bIsOk ) {
					alert( "Please enter your four-digit client number." );
					oForm.sClientNum.focus();
				}
	
				break;
				
			case "sProcOffice":
				sTest = /^[A-Za-z ]+, [A-Z]{2}$/;
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sProcOffice.value ) == false ) || ( sTest.test( oForm.sProcOffice.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) ) ;
				
				if ( !bIsOk ) {
					alert( "Please select the PrimePay office that processes your payroll." );
					oForm.sProcOffice.focus();
				}
	
				break;
			
			case "iEmpPerLoc":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.iEmpPerLoc.value ) == false ) || ( numberString( oForm.iEmpPerLoc.value ) > 0 && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter the Average Number of Employees on Payroll." );
					oForm.iEmpPerLoc.focus();
				}
				
				break;
	
			case "iLocs":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.iLocs.value ) == false ) || ( numberString( oForm.iLocs.value ) > 0 && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter the Number of Locations under this EIN." );
					oForm.iLocs.focus();
				}
				
				break;
	
			case "sAdditionalInfo":
				bIsOk = true;
				isDirtyPage( true );
				break;
	
			case "sAddress":
				sTest = /\w+\s+\w+/;
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sAddress.value ) == false ) || ( sTest.test( oForm.sAddress.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter your Street Address." );
					oForm.sAddress.focus();
				}
				
				break;
	
			case "sCity":
				sTest = /[a-zA-Z]+/; // need more restrictive pattern for sCity
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sCity.value ) == false ) || ( sTest.test( oForm.sCity.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter your City." );
					oForm.sCity.focus();
				}
				
				break;
			
			case "sNumberofEmployees":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sNumberofEmployees.value ) == false ) || ( numberString( oForm.sNumberofEmployees.value ) > 0 && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter the Number of Employees on Payroll." );
					oForm.sNumberofEmployees.focus();
				}
				
				break;
			
			case "sFirstName":
				sTest = /./; // need more restrictive pattern for sLegalName
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sFirstName.value ) == false ) || ( sTest.test( oForm.sFirstName.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );

				if ( !bIsOk || oForm.sFirstName.value == "First Name" ) {
					alert( "Please enter your First Name." );
					oForm.sFirstName.focus();
				}
				
				break;

			case "sLastName":
				sTest = /./; // need more restrictive pattern for sLegalName
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sLastName.value ) == false ) || ( sTest.test( oForm.sLastName.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );

				if ( !bIsOk || oForm.sLastName.value == "Last Name" ) {
					alert( "Please enter your Last Name." );
					oForm.sLastName.focus();
				}
				
				break;


			case "sLegalName":
				sTest = /./; // need more restrictive pattern for sLegalName
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sLegalName.value ) == false ) || ( sTest.test( oForm.sLegalName.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );

				if ( !bIsOk || oForm.sLegalName.value == "Company") {
					alert( "Please enter the Company Name." );
					oForm.sLegalName.focus();
				}
				
				break;

			case "sContact":
				sTest = /^[a-zA-Z]+\s+[a-zA-Z]+$/; 
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sContact.value ) == false ) || ( sTest.test( oForm.sContact.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter Contact person's first name and last name." );
					oForm.sContact.focus();
				}
	
				break;
	
			case "sCurrentProvider":
				bIsOk =  ( ( bIsSubmit == false && isSomething( oForm.sCurrentProvider.value ) == false ) || ( isSomething( oForm.sCurrentProvider.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
					
				if ( !bIsOk ) {
					alert( "Please select your Current Payroll Provider." );
					oForm.sCurrentProvider.focus();
				}
				
				break;
	
			case "sDba":
				sTest = /./; // need more restrictive pattern for sDba
				bIsOk = ( ( isSomething( oForm.sDba.value ) == false ) || ( sTest.test( oForm.sDba.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter the DBA." );
					oForm.sDba.focus();
				}
				
				break;
	
			case "sEmail":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sEmail.value ) == false ) || ( isEmail( oForm.sEmail.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
	
				if ( !bIsOk ) {
					alert( "Please enter the contact Email Address." );
					oForm.sEmail.focus();
				}
				
				break;
	
			case "sEmail_2":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sEmail_2.value ) == false ) || ( ( isEmail( oForm.sEmail_2.value ) == true && isEmail( oForm.sEmail.value ) == true ) && oForm.sEmail_2.value == oForm.sEmail.value && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
	
				if ( !bIsOk ) {
					alert( "Please re-enter the Email Address." );
					oForm.sEmail.focus();
				}
				
				break;
	
			case "sEin":
				sTest = /^\d{9}$/; 
				bIsOk =  ( ( bIsSubmit == false && isSomething(  oForm.sEin.value ) == false ) || ( sTest.test( oForm.sEin.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) ) ;
				
				if ( !bIsOk ){
					alert( "Please enter your 9 digit Federal ID#." );
					oForm.sEin.focus();
				}
				
				break;
	
			case "sExt":
				sTest = /^\d+$/; // 1 or more digits
				bIsOk = ( ( isSomething( oForm.sExt.value ) == false ) || ( sTest.test( oForm.sExt.value )  && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter a blank or numeric phone Extention." );
					oForm.sExt.focus();
				}
				
				break;
	
			case "sFax":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sFax.value ) == false ) || isPhone( oForm.sFax.value )  && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) );
		
				if ( !bIsOk ) {
					alert( "Please enter a Fax Number, including area code." );
					oForm.sFax.focus();
				}
				
				break;
	
			case "sFirstCheck":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sFirstCheck.value ) == false ) || ( isSomething( oForm.sFirstCheck.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
	
				if ( !bIsOk ) {
					alert( "Please enter the Anticipated First Check Date with PrimePay.");
					oForm.datePicker.focus();
				}
				
				break;
	
			case "sFrequency":
					bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sFrequency.value ) == false ) || ( isSomething( oForm.sFrequency.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
	
				if ( !bIsOk ) {
					alert( "Please select your Payroll Frequency." );
					oForm.sFrequency.focus();
				}
				
				break;
	
			case "sGroupId":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sGroupId.value ) == false ) || ( isSomething( oForm.sGroupId.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
	
				if ( !bIsOk ) {
					alert( "Please enter your Employer/Group ID." );
					oForm.sGroupId.focus();
				}
				
				break;
				
			case "sIsClientYes":
				sTest = /^Yes$/;
				
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sIsClientYes.value ) == false ) || (sTest.test(oForm.sIsClientYes.value) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );

				if ( !bIsOk ) {
					alert( "Please indicate whether or not you are a current PrimePay client." );
					oForm.sIsClientYes.focus();
				}
				
				break;
			
			case "sIsClientNo":
				sTest = /^No$/;
				
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sIsClientNo.value ) == false ) || (sTest.test(oForm.sIsClientNo.value) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );

				if ( !bIsOk ) {
					alert( "Please indicate whether or not you are a current PrimePay client." );
					oForm.sIsClientNo.focus();
				}
				
				break;
				
			case "sLegalName":
				sTest = /./; // need more restrictive pattern for sLegalName
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sLegalName.value ) == false ) || ( sTest.test( oForm.sLegalName.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );

				if ( !bIsOk ) {
					alert( "Please enter the Legal Company Name." );
					oForm.sLegalName.focus();
				}
				
				break;
	
			case "sOwnerName":
				sTest = /^[a-zA-Z]+\s+[a-zA-Z]+$/; 
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sOwnerName.value ) == false ) || ( sTest.test( oForm.sOwnerName.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter Owner's first name and last name." );
					oForm.sOwnerName.focus();
				}
	
				break;
	
			case "sPhone":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sPhone.value ) == false ) || ( isPhone( oForm.sPhone.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter a Phone Number, including area code." );
					oForm.sPhone.focus();
				}
				
				break;
	
			case "sPhoneCell":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sPhoneCell.value ) == false ) || ( isPhone( oForm.sPhoneCell.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter a Cell Phone Number, including area code." );
					oForm.sPhoneCell.focus();
				}
				
				break;
	
			case "sPhoneOrEmail":
				var iOption = -1;
				var iIndex;
				
				for ( iIndex=0; iIndex<oForm.sPhoneOrEmail.length; iIndex++ ) {
					if ( oForm.sPhoneOrEmail[iIndex].checked ) {
						iOption = iIndex;
					}
				}
				
				if ( iOption > -1 ) {
					bIsOk = true;
				}
				else {
					bIsOk = false;
					alert( "Please choose to be contacted by either Phone or Email.");
				}
				
				isDirtyPage( true );
				break;
				
			case "sRequestorName":
				sTest = /^[a-zA-Z]+/; // need more restrictive pattern for sRequestorName
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sRequestorName.value ) == false ) || ( sTest.test( oForm.sRequestorName.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) ) ;
				
				if ( !bIsOk ){
					bIsOk = false;
					alert( "Please enter Your Name." );
					oForm.sRequestorName.focus();
				}
				
				break;
	
			case "sState":
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sState.value ) == false ) || ( isSomething( oForm.sState.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
	
				if ( !bIsOk ) {
					alert( "Please select your State." );
					oForm.sState.focus();
				}
				
				break;
	
			case "sStoreNumber":
				sTest = /^[a-zA-Z0-9]+$/; // need more restrictive pattern for sStoreNumber
				bIsOk = ( ( bIsSubmit == false &&  isSomething( oForm.sStoreNumber.value ) == false ) || ( sTest.test( oForm.sStoreNumber.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
		
				if ( !bIsOk ) {
					alert( "Please enter the Store Number." );
					oForm.sStoreNumber.focus();
				}
				
				break;
	
			case "sTimeToCall":
				sTest = /^[0-2]?[0-9][\s:.-]?[0-5]?[0-9]?\s?(am|pm)?$/i; // 2005.11.12 DD: improve time matching
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sTimeToCall.value ) == false ) || ( sTest.test( oForm.sTimeToCall.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) ) ;
	
				if (!bIsOk ) {
					alert( "Please enter the best time to reach you.");
					oForm.sTimeToCall.focus();
				}
				
				break;
	
			case "sTimeZone":
				var iOption = -1;
				var iIndex;
				
				for ( iIndex=0; iIndex<oForm.sTimeZone.length; iIndex++ ) {
					if ( oForm.sTimeZone[iIndex].checked ) {
						iOption = iIndex;
					}
				}
				
				if ( iOption > -1 ) {
					bIsOk = true;
				}
				else {
					alert( "Please enter your time zone.");
					bIsOk = false;
				}
				
				isDirtyPage( true );
				break;
	
			case "sTopic":
				bIsOk =  ( ( bIsSubmit == false && isSomething( oForm.sTopic.value ) == false ) || ( isSomething( oForm.sTopic.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) );
				
				if ( !bIsOk ) {
					alert( "Please enter the topic with which you need help.");
					oForm.sTopic.focus();
				}
				
				break;
	
			case "sZip":
				sTest = /^\d{5}(-[\d]{4})?$/; 
				bIsOk = ( ( bIsSubmit == false && isSomething( oForm.sZip.value ) == false ) || ( sTest.test( oForm.sZip.value ) && isDirtyPage( ( g_sBlurFieldValue != g_sFocusFieldValue ) ) ) ) ;
				
				if ( !bIsOk ) {
					alert( "Please enter your 5 or 9 digit Zip Code." );
					oForm.sZip.focus();
				}
	
				break;
	
		} // switch
	}
	

	
	if ( sItem != "sIsClient" && !bIsOk ) {
		document.getElementById( sItem ).focus()
	}
	
	return bIsOk
} // function

function controlFocusTextFieldValue( oFormField ) {
	g_sBlurFieldValue  = g_sFocusFieldValue; // push value existing onblur 
	g_sFocusFieldValue = oFormField.value;   // preserve value existing onfocus 
}

function checkIllegalInputChars( oFormField ){
	//alert( oFormField.name );
	var sErrMsg = 'Data values may not include any of the following characters:\n\n\'  single quote (apostrophe) - use ` instead\n\"  double quote - use ` instead\n<  greater than\n>  less than\n=  equals';
	var sTest = /["'<=>`|]/;
	var sMatch = oFormField.value;
	var bIsLegal = !sTest.test( sMatch );

	if ( !bIsLegal ){
		if ( oFormField.value == g_sFocusFieldValue ){ // found pre-existing illegal characters 
			if ( confirm( sErrMsg + '\n\nDo you want the system to update this field to replace prohibited characters with ` ?' ) ){
				oFormField.value = oFormField.value.replace( /['"<>]/g, "`" ) ;
			}
			
			else {
				oFormField.focus();
			}
		}
			
		else { // check for newly entered illegal characters
			alert( sErrMsg );
			oFormField.value = g_sFocusFieldValue; // restore global field value saved on focus() 
			oFormField.focus();
		}
	}
	
	return bIsLegal;
}

function openPopup( sUrl, sPopupName, nWidth, nHeight, bScroll ) {
	var oWin = open( sUrl, sPopupName, "toolbar=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=" + (bScroll?"yes":"no") + ",width=" + nWidth + ",height=" + nHeight );

	if ( oWin != null ) { // i.e. open() succeeded
		oWin.focus(); // activate the popup
	}
}// function

function openNewWindow( sUrl, sName ) {
	var oWin = open( sUrl, sName );

	if ( oWin != null ) { // i.e. open() succeeded
		oWin.focus(); // activate the popup
	}
}// function

function searchBG () {
	var input = document.getElementById('searchBox')
		if(input.value=='') {
			input.style.backgroundImage="url('/images/search_bg.gif')";
		}
		
		else{
			input.style.backgroundImage="";
		}
}

function searchTest () {
	alert("Yes!");
}

function randomImage() {
	var randomnumber=Math.floor(Math.random()*10)
	
	if (randomnumber == 0) {
		document.getElementById('subMenuContent').innerHTML = "<a href='/contact/payroll-quote.aspx'> <img src='/images/submenu_payroll.gif' /> </a>";
	}
	
	else if (randomnumber == 1) {
		document.getElementById('subMenuContent').innerHTML = "<a href='http://blog.primepay.com/sample-employee-handbook-download/?utm_campaign=Sample-Handbook-Call-to-Action-from-primepay.com&utm_source=Redirect%20from%20primepay.com%20to%20Landing%20Page' target='_blank'> <img src= '/images/submenu_handbook.jpg' /> </a>";
	}
		
	else if (randomnumber == 2) {
		document.getElementById('subMenuContent').innerHTML = "<a href='/contact/services.aspx'> <img src='/images/submenu_insurance.gif' /> </a>";
	}
	
	else if (randomnumber == 3) {
		document.getElementById('subMenuContent').innerHTML = "<a href='/demos/online-document-center-demo.aspx'> <img src='/images/submenu_odc.gif' /> </a>";
	}
	
	else if (randomnumber == 4) {
		document.getElementById('subMenuContent').innerHTML = "<a href='/demos/web-payroll-demo.aspx'> <img src='/images/submenu_tools.gif' /> </a>";
	}

	else if (randomnumber == 5) {
		document.getElementById('subMenuContent').innerHTML = "<a href='http://blog.primepay.com/payroll-business-experts-blog/bid/36044/10-Illegal-Job-Interview-Questions?utm_campaign=10-Illegal-Call-to-Action-from-primepay.com&utm_source=Redirect%20from%20primepay.com%20to%20Blog' target='_blank'> <img src='/images/submenu_questions.jpg' /> </a>";
	}

	else if (randomnumber == 6) {
		document.getElementById('subMenuContent').innerHTML = "<a href='http://blog.primepay.com/payroll-business-experts-blog/bid/37043/How-the-HIRE-Act-May-Impact-Your-Business?utm_campaign=HIRE-Act-Call-to-Action-from-primepay.com&utm_source=Redirect%20from%20primepay.com%20to%20Blog' target='_blank'> <img src='/images/submenu_hire.jpg' /> </a>";
	}
	
	else if (randomnumber == 7) {
		document.getElementById('subMenuContent').innerHTML = "<a href='http://blog.primepay.com/payroll-business-experts-blog/bid/40300/Using-Red-Ink-Can-Get-You-into-Hot-Water-With-ICE?utm_campaign=I-9-Audit-Call-to-Action-from-primepay.com&utm_source=Redirect%20from%20primepay.com%20to%20Blog' target='_blank'> <img src='/images/submenu_audit.jpg' /> </a>";
	}
	

	else if (randomnumber == 8) {
		document.getElementById('subMenuContent').innerHTML = "<a href='http://blog.primepay.com/2010-job-forecast-download/?utm_campaign=2010-Job-Forecast-Call-to-Action-from-primepay.com&utm_source=Redirect%20from%20primepay.com%20to%20Landing%20Page' target='_blank'> <img src='/images/submenu_forecast.jpg' /> </a>";
	}
	
	else if (randomnumber == 9) {
		document.getElementById('subMenuContent').innerHTML = "<div class='menuTop'>&nbsp;</div> <div class='subMenu'><h2>Subscribe</h2> <p>Follow PrimePay through our Blog, Twitter, LinkedIn, YouTube & RSS Feeds.</p> <p><a href=' http://blog.primepay.com/?utm_campaign=Blog-Tab-Redirect-from-primepay.com&utm_source=Redirect%20from%20primepay.com%20to%20Blog' target='_blank' class='socialLink'> <img alt='Follow Us on our Payroll & Business Experts Blog' src='/images/icon_primepay.gif' /> <span>Blog</span> </a> <a href='http://www.twitter.com/PrimePayPayroll' target='_blank' class='socialLink'> <img alt='Follow us on Twitter' src='/images/icon_twitter.png' /> <span>Twitter</span> </a> <a href='http://www.linkedin.com/companies/primepay' target='_blank' class='socialLink'> <img alt='Follow us on LinkedIn' src='/images/icon_linkedin.png' /> <span>LinkedIn</span> </a> <a href='http://www.youtube.com/user/PrimePayPayroll' target='_blank' class='socialLink'> <img alt='Follow us on YouTube' src='/images/icon_youtube.png' /> <span>YouTube</span> </a> <a href='http://blog.primepay.com/CMS/UI/Modules/BizBlogger/rss.aspx?moduleid=292405' target='_blank' class='socialLink'> <img alt='Follow us through RSS Feeds' src='/images/icon_rss.png' /> <span>RSS </span> </a></p></div> <div class='menuBottom'>&nbsp;</div>";
	}
		
}
	