// Utilities  used by this site



	function goToTheURL () {
	// called by a Select on City/State pages to change the page
	// To add a page add a case statement below and an Option in the Select
	// The value of the option must be the name of the page to go to. RL
		
		switch (document.ListOfURLs.contentSelector.value) {
		
			case "dedicated-quote.html":
				document.location.href = "dedicated-quote.html";
				break;
	
			case "internet-quote.html":
				document.location.href = "internet-quote.html";
				break;
	
			case "integrated-quote.html":
				document.location.href = "integrated-quote.html";
				break;
	
			case "conferencing-quote.html":
				document.location.href = "conferencing-quote.html";
				break;
	
		}
		
	}



	function GetTheURLparms( name ) {
	// used by the theme system
	
		name 		= name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS 	= "[\\?&]"+name+"=([^&#]*)";
		var regex 	= new RegExp( regexS );
		var results = regex.exec( window.location.href );
		
		if( results == null ) {
			return "";
		} else {
			return unescape(results[1]); 
		}
		
	}



/*	====================================================================================================================================
	Validation system
	==================================================================================================================================== */


	// regex globals used for validation on any page
	
		var gNonBlank 		 		= /\w/																					; // must contain at least 1 word character
		var gThreeDigits	 		= /^[0-9][0-9][0-9]$/																	; // used for phone number validation
		var gFourDigits		 		= /^[0-9][0-9][0-9][0-9]$/																; // used for phone number validation
		var gEmailExpression 		= /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/							; // used for email
		var gSingleUSZip 			= /^[\d]{5}$/																			; // US ZipCode, 5 digits and 5 digits only
		var gSingleCanPostalCode 	= /^[ABCEGHJKLMNPRSTVXY][0-9][ABCEGHJKLMNPRSTVWXYZ] ?[0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]$/	; // Can postal code: CharDigitChar DigitCharDigit separated by one optional space ex: T3M 2K7. Validator assumes that the field has been UPPERCASE'd


	function cleanupTheUsersString(theStringToClean) {
	// processes a zip code field's text to prepare it for validation.
	// expects a string, returns a cleaned and uppercased string.
	// Careful! There are cleanupTheUsersString() and cleanupTheUsersEntry()

		var cleanedEntry	= theStringToClean;
			cleanedEntry	= jQuery.trim(cleanedEntry);				// get rid of leading and trailing whitespace
			cleanedEntry	= cleanedEntry.replace(/, +/g,  "," );		// get rid of spaces after commas
			cleanedEntry	= cleanedEntry.replace(/ +,/g,  "," );		// get rid of spaces before commas 
			cleanedEntry	= cleanedEntry.replace(/^,+/,   ""  );		// get rid of any number of leading commas
			cleanedEntry	= cleanedEntry.replace(/ +$/,   ""  )		// retrim trailing whitespace!
			cleanedEntry	= cleanedEntry.replace(/,+$/,   ""  );		// get rid of any number of trailing commas
			cleanedEntry	= cleanedEntry.replace(/,+/g,   "," );		// get rid of multiple commas
			cleanedEntry	= cleanedEntry.toUpperCase();				// uppercase is required for Canadian postal codes
		return cleanedEntry;
	}


	function cleanupTheUsersEntry(theFieldToClean) {
	// expects a reference to an input element (zip/postal code), modifies the value of that element.
	// Careful! There are cleanupTheUsersString() and cleanupTheUsersEntry()

		var cleanedField		= theFieldToClean.value;
		
		// this is a very specific, step by step process...
		cleanedField			= jQuery.trim(cleanedField);				// get rid of leading and trailing whitespace
		cleanedField			= cleanedField.replace(/, +/g,  "," );		// get rid of spaces after commas
		cleanedField			= cleanedField.replace(/ +,/g,  "," );		// get rid of spaces before commas 
		cleanedField			= cleanedField.replace(/^,+/,   ""  );		// get rid of any number of leading commas
		cleanedField			= cleanedField.replace(/ +$/,   ""  );		// retrim trailing spaces!
		cleanedField			= cleanedField.replace(/,+$/,   ""  );		// get rid of any number of trailing commas
		cleanedField			= cleanedField.replace(/,+/g,   "," );		// get rid of multiple commas
		cleanedField			= cleanedField.replace(/,/g,    ", ");		// put a space in after each comma for readability
		theFieldToClean.value	= cleanedField ;							// put the cleaned entry back into the input
	}


	function uppercaseTheZip(whichField) {
	// uppercase the zip code (required by Canadian postal codes). Call this only from a blur handler.
	// if you call it on a keyup handler it will move the insertion point to the end of the text in the field.
		whichField.value = whichField.value.toUpperCase();	
	}


	function blurOneCanPostalCode6to7(whichField) {
	// changes a field with a valid 6 character code to a 7 character canadian postal code
	// expects a DOM reference to a text input
		var zipCodeFieldValidity 	= validateOneZipOnPage1(whichField);
		if (zipCodeFieldValidity && whichField.value.length == 6) {
			whichField.value = whichField.value.substr(0,3) + ' ' + whichField.value.substr(3,5);	
		};			
	}


	function validateOneZipOnPage1(whichField) {
	// validate a single zip code on page 1. This is a test and if successful will be moved into all sites.
	// expects a reference to a DOM element not a jQuery wrapped element.
	
		var zipCodeFieldValidity 	= false
		var zipCodeFieldValidity	= (gSingleUSZip.test(whichField.value) || gSingleCanPostalCode.test(whichField.value.toUpperCase() ));
		return 						zipCodeFieldValidity;

	}




/*	====================================================================================================================================
	page 1 Inline style validation
	- show validation graphic on startup and manage it inline
	==================================================================================================================================== */

	// manage the radio button questions
	
	function manageTheRadioButtonQuestions (whichQuestion) { 
		var theQuestionsID  = $(whichQuestion).parent('div').attr('id');
		var whatToCheck 	= '#' + theQuestionsID + 'Feedback';
		var whatToHide 	    = '#' + theQuestionsID + 'ValidationNote';
		$(whatToCheck).attr("src","resources/validation-check.gif").attr("title","This question is complete");
		$(whatToHide).fadeOut(600);
	}
	

	// manage the zip code

	function validateZipInline(whichField) {
		var theQuestionsID  			= $(whichField).parent('div').attr('id');
		var theImageValidationFeedback 	= '#' + theQuestionsID + 'Feedback';
		var theValidationNoteToManage 	= '#' + theQuestionsID + 'ValidationNote';
		var currentZipValue 			= whichField.value.toUpperCase();	// Canadian postal codes require uppercase. So does our validating regex.

		if ( gSingleUSZip.test(currentZipValue) || gSingleCanPostalCode.test(currentZipValue) ) { 
			$(theImageValidationFeedback).attr("src","resources/validation-check.gif").attr("title","This question is complete");
			$(theValidationNoteToManage).fadeOut(300);
		} else {
			// no valid zip
			$(theImageValidationFeedback).attr("src","resources/validation-arrow.gif").attr("title","Please answer this question. It is required");
			$(theValidationNoteToManage).fadeIn(600);
		}
	}


	function validateTheFormInlineStyle() {

		// validate radio button questions
		var radioButtonQuestionsAreComplete = true;
		
		var radioButtonQuestions				= $("div[id^='Answer']:has(:radio)");
		$(radioButtonQuestions)					.each(function(){ 
			var theCurrentAnswerDiv 			= this.id;
			var selectorWeNeed					= '#' + theCurrentAnswerDiv + ':has(:radio:checked)';
			if ($(selectorWeNeed)				.length == 0) {
				var arrowToShow					= '#' + theCurrentAnswerDiv + 'Feedback';
				var noteToShow 					= '#' + theCurrentAnswerDiv + 'ValidationNote';
				$(arrowToShow)					.fadeIn(600);
				$(noteToShow)					.fadeIn(600);
				radioButtonQuestionsAreComplete = false;
			} else {
				// valid fields 
			}
		});

		// validate the zip/postal code if there is a zip code input
		if ($('#txtZipCode').length) {
	
			var ZipCodeQuestionsIsValid		= false;
			var currentZipValue				= $('#txtZipCode').val();
			currentZipValue					= currentZipValue.toUpperCase();
			var theQuestionsID  			= $('#txtZipCode').parent('div').attr('id');
			var theImageValidationFeedback 	= '#' + theQuestionsID + 'Feedback';
			var theValidationNoteToManage 	= '#' + theQuestionsID + 'ValidationNote';
	
			if ( gSingleUSZip.test(currentZipValue) || gSingleCanPostalCode.test(currentZipValue) ) { 
				$(theImageValidationFeedback).attr("src","resources/validation-check.gif").attr("title","This question is complete");
				$(theValidationNoteToManage).fadeOut(300);
				ZipCodeQuestionsIsValid = true;
			} else {
				// no valid zip
				$(theImageValidationFeedback).attr("src","resources/validation-arrow.gif").attr("title","Please answer this question. It is required");
				$(theValidationNoteToManage).fadeIn(600);
			}
		} else {
			// just the variable to true for the rest of the script
			ZipCodeQuestionsIsValid = true; 
		}

		// return true or alert the user and return false
		if (radioButtonQuestionsAreComplete && ZipCodeQuestionsIsValid) {
			return true;
		} else {
			var noteToShow = "We need more information in order to send you your free quotes.\n\n"
			if (!radioButtonQuestionsAreComplete) {
				noteToShow += "* Please complete all of the required questions.\n"
			}
			if (!ZipCodeQuestionsIsValid) {
				noteToShow += "* Be sure to fill in your 5 digit US Zip code or 6 character Canadian Postal code."
			}
			alert(noteToShow);
			return false;
		}
	}


	
	
	function setupSurveyPage1() {
		var TheTheme = "";
		var TheTheme = GetTheURLparms('theme');
		if (TheTheme != "") { $('span.TheTheme').html(TheTheme) }
		setupPage1InlineStyleValidation();
		SurveyInit();
		Tooltip.init();
	}

	function setupInternetQuotesZip() {
		// historical use only
		var TheTheme = "";
		var TheTheme = GetTheURLparms('theme');
		if (TheTheme != "") { $('span.TheTheme').html(TheTheme) }
		setupPage1InlineStyleValidation();
		SurveyInit();
		Tooltip.init();
	}



	// setup page 1 for inline style validation
	// ====================================================================================================================================

	function setupPage1InlineStyleValidation() {

		$('div.formatradiobuttons :radio')	.bind('click',  function() 		{ manageTheRadioButtonQuestions(this)	});

		$('#goToStep2Btn').hover(
			function(){$(this).attr({src : 'resources/btn_gotostep2_rollover.jpg'	})},
			function(){$(this).attr({src : 'resources/btn_gotostep2.jpg'			})}		);

			// only setup the zip code if there is a zip code field on the form. Some forms do not have a zip code field.
			if ($('#txtZipCode').length) {
				$('#txtZipCode')        .bind('keyup',  function(event) { validateZipInline(this);			 	});
				$('#txtZipCode')       	.bind('blur',   function(event) { uppercaseTheZip(this);				});
				$('#txtZipCode')       	.bind('blur',   function(event) { blurOneCanPostalCode6to7(this);		});
				var startupZipCode =	$('#txtZipCode').val();
				if ( gSingleUSZip.test(startupZipCode) || gSingleCanPostalCode.test(startupZipCode.toUpperCase()) ) {
					var whatToCheck = $('#txtZipCode').parent('div').attr('id');
					whatToCheck 	= '#' + whatToCheck + 'Feedback';
					$(whatToCheck).attr("src","resources/validation-check.gif");
				}
			}

		// if the page happens to load with already selected checkboxes
			$(':radio:checked').each(function() {
					var whatToCheck = $(this).parent('div').attr('id');
					whatToCheck 	= '#' + whatToCheck + 'Feedback';
					$(whatToCheck)	.attr("src","resources/validation-check.gif");
				}
			);

	}




/*	====================================================================================================================================
	Validate Survey page 2.
	- no validation note nor graphic on startup, only after the first submit.
	==================================================================================================================================== */

	// page 2 validation globals. The validity of each field is know and used globally.
		var gFirstName       = false ;
		var gLastName        = false ;
		var gEmailAddress    = false ;
		var gPhoneNumber     = false ;
		var gCompanyName     = false ;
		var gAddress1        = false ;
		var gCity            = false ;
		var gState           = false ;
		var gZIP             = false ;

		var gNormalColor     = '#fff';
		var gAlertColor      = '#e3edfe';

	
	// page 2 validation utility functions

	function validateNotEmpty(whichField) {
	// validate any field that just needs to be not empty. Empty in the sense that it must contain at least one word character.
	// expects a reference to a text input element.

		var theInputToManage = '#' + whichField.id;
		var theHintToManage  = '#' + whichField.id + 'ValidationHint';
		var currentValidity  = false;
		if ( gNonBlank.test(whichField.value) ) {
			currentValidity = true;
		} else {
			currentValidity = false;
		}

		// the following will only HIDE validation hints, not show them. Showing is only done by the submit handler.
		switch ( whichField.id ) {
			case 'FirstName':
				gFirstName     = currentValidity; 
				if (gFirstName) { 
					$(theHintToManage).fadeOut(600);
					$(theInputToManage).css({ backgroundColor: gNormalColor }); 
				};
				break;
			case 'LastName':
				gLastName      = currentValidity; 
				if (gLastName) { 
					$(theHintToManage).fadeOut(600);
					$(theInputToManage).css({ backgroundColor: gNormalColor }); 
				};
				break;
			case 'CompanyName':
				gCompanyName   = currentValidity; 
				if (gCompanyName) { 
					$(theHintToManage).fadeOut(600);
					$(theInputToManage).css({ backgroundColor: gNormalColor }); 
				};
				break;
			case 'Address1':
				gAddress1      = currentValidity; 
				if (gAddress1) { 
					$(theHintToManage).fadeOut(600);
					$(theInputToManage).css({ backgroundColor: gNormalColor }); 
				};
				break;
			case 'City':
				gCity          = currentValidity; 
				if (gCity) { 
					$(theHintToManage).fadeOut(600);
					$(theInputToManage).css({ backgroundColor: gNormalColor }); 
				};
				break;
			default:
				alert('problem with the case statement...');
		}
		checkAllFields();
	}


	// validate the email
	function validateEmail(whichField) {
		var theInputToManage = '#' + whichField.id;
		var theHintToManage  = '#' + whichField.id + 'ValidationHint';
		(gEmailExpression.test(whichField.value) == true) ? (gEmailAddress = true) : (gEmailAddress = false) ;
		if (gEmailAddress) { 
			$(theHintToManage).fadeOut(600);
			$(theInputToManage).css({ backgroundColor: gNormalColor }); 
		};
		checkAllFields();
	}


	function validatePhoneNumber() {
	// validate the 3 phone number fields as one component
	
		var theHintToManage     = '#PhoneNumberValidationHint';

		var AreaCodeValidity	= gThreeDigits.test($('#areacode')   .val());
		var PrefixValidity		= gThreeDigits.test($('#PhonePrefix').val());
		var PhoneNumberValidity	= gFourDigits.test( $('#PhoneNumber').val());
		
		(AreaCodeValidity && PrefixValidity && PhoneNumberValidity ) ?  (gPhoneNumber = true) : (gPhoneNumber = false);
		
		if (AreaCodeValidity   ) { $('#areacode')   .css({ backgroundColor: gNormalColor }) };
		if (PrefixValidity     ) { $('#PhonePrefix').css({ backgroundColor: gNormalColor }) };
		if (PhoneNumberValidity) { $('#PhoneNumber').css({ backgroundColor: gNormalColor }) };
		if (gPhoneNumber) { $(theHintToManage).fadeOut(600) };
		checkAllFields();
	}

	function autoAdvancePhoneNumberFields(whichField) {
		if (whichField.id == 'areacode'    && whichField.value.length == 3) { $('#PhonePrefix')	.focus(); $('#areacode')   .blur(); }
		if (whichField.id == 'PhonePrefix' && whichField.value.length == 3) { $('#PhoneNumber')	.focus(); $('#PhonePrefix').blur(); }
		if (whichField.id == 'PhoneNumber' && whichField.value.length == 4) { $('#ext')			.focus(); $('#PhoneNumber').blur(); }
	}

	// validate the zip code
	function validateZip(whichField) {
		var theInputToManage = '#' + whichField.id;
		var theHintToManage  = '#' + whichField.id + 'ValidationHint';

		var currentZipValue  = whichField.value.toUpperCase();	// Canadian postal codes require uppercase. So does our validating regex.

		(gSingleUSZip.test(currentZipValue) || gSingleCanPostalCode.test(currentZipValue)) ? (gZIP = true) : (gZIP = false) ;
		if (gZIP) { 
			$(theHintToManage).fadeOut(600) 
			$(theInputToManage).css({ backgroundColor: gNormalColor }); 
		};
		checkAllFields();
	}


	// validate the state select
	function validateState(whichField) {
		var theSelectToManage = '#' + whichField.id;
		var theHintToManage   = '#' + whichField.id + 'ValidationHint';
		(whichField.value == -1) ? (gState = false) : (gState = true) ;
		if (gState) { 
			$(theHintToManage).fadeOut(600) 
			$(theSelectToManage).css({ backgroundColor: gNormalColor }); 
		};
		checkAllFields();
	}


	// test overall validity and manage the (1) validation mark
	function checkAllFields() {
		//alert(gFirstName + '  ' + gLastName + '  ' + gEmailAddress + '  ' + gPhoneNumber + '  ' + gCompanyName + '  ' + gAddress1 + '  ' + gCity + '  ' + gState + '  ' + gZIP );
		if ( gFirstName && gLastName && gEmailAddress && gPhoneNumber && gCompanyName && gAddress1 && gCity && gState && gZIP ) {
			$('#ValidationMark')	.attr("src","resources/validation-check.gif")	
									.attr("title","Your contact information is complete and you ready to get quotes.")
									.show();	
		} else {
			$('#ValidationMark')	.hide();	
		}
	}


	function validateAfterSubmitPage2() {
	// when the user clicks the submit button...
	
		// auto-fill does not fire any events so we could get here with the globals being inaccurate.
		// fire all the necessary events just to get the globals in synch with the current field data.

			$('#FirstName')   .keyup();
			$('#LastName')    .keyup();
			$('#EmailAddress').keyup();
			
			$('#areacode')    .blur();
			$('#PhonePrefix') .blur();
			$('#PhoneNumber') .blur();
			
			$('#CompanyName') .keyup();
			$('#Address1')    .keyup();
			$('#City')        .keyup();
			$('#StateId')     .change();
			$('#zip')         .keyup();
	
		if ( gFirstName && gLastName && gEmailAddress && gPhoneNumber && gCompanyName && gAddress1 && gCity && gState && gZIP ) {
			// if all the fields are currently marked as valid, submit the form without comment.
			return true;
		} else {
			// not all the fields are valid so show the dialog and all the attention getting effects.
			
			var theMessage = 'Please be sure to complete all required fields.\r\n\r\nThe following still need to be completed:\r\n'
			
			if (!gFirstName) { 
				$('#FirstNameValidationHint').show();
				$('#FirstName').css({ backgroundColor: gAlertColor });
				theMessage += ' First Name\r\n'; } 
			else { 
				$('#FirstNameValidationHint').hide();
				$('#FirstName').css({ backgroundColor: gNormalColor }); }
			
			if (!gLastName) { 
				$('#LastNameValidationHint').show();
				$('#LastName').css({ backgroundColor: gAlertColor });
				theMessage += ' Last Name\r\n'; } 
			else { 
				$('#LastNameValidationHint').hide();
				$('#LastName').css({ backgroundColor: gNormalColor }); }
			
			if (!gEmailAddress) { 
				$('#EmailAddressValidationHint').show();
				$('#EmailAddress').css({ backgroundColor: gAlertColor });
				theMessage += ' Email\r\n'; } 
			else { 
				$('#EmailAddressValidationHint').hide();
				$('#EmailAddress').css({ backgroundColor: gNormalColor }); }
			
			if (!gPhoneNumber) {
				$('#PhoneNumberValidationHint').show();
				if ( !gThreeDigits.test($('#areacode')   .val()) ) { $('#areacode')   .css({ backgroundColor: gAlertColor }) };
				if ( !gThreeDigits.test($('#PhonePrefix').val()) ) { $('#PhonePrefix').css({ backgroundColor: gAlertColor }) };
				if ( !gFourDigits.test( $('#PhoneNumber').val()) ) { $('#PhoneNumber').css({ backgroundColor: gAlertColor }) };
				theMessage += ' Phone Number\r\n';
			} else {
				$('#PhoneNumberValidationHint').hide() ;
			}
			
			if (!gCompanyName) { 
				$('#CompanyNameValidationHint').show();
				$('#CompanyName').css({ backgroundColor: gAlertColor });
				theMessage += ' Company Name\r\n'; } 
			else { 
				$('#CompanyNameValidationHint').hide();
				$('#CompanyName').css({ backgroundColor: gNormalColor }); }
			
			if (!gAddress1) { 
				$('#Address1ValidationHint').show();
				$('#Address1').css({ backgroundColor: gAlertColor });
				theMessage += ' Street Address\r\n'; } 
			else { 
				$('#Address1ValidationHint').hide();
				$('#Address1').css({ backgroundColor: gNormalColor }); }
			
			if (!gCity) { 
				$('#CityValidationHint').show();
				$('#City').css({ backgroundColor: gAlertColor });
				theMessage += ' City\r\n'; } 
			else { 
				$('#CityValidationHint').hide();
				$('#City').css({ backgroundColor: gNormalColor }); }
			
			if (!gState) { 
				$('#StateIdValidationHint').show();
				$('#StateId').css({ backgroundColor: gAlertColor });
				theMessage += ' State\r\n'; } 
			else { 
				$('#StateIdValidationHint').hide();
				$('#StateId').css({ backgroundColor: gNormalColor }); }
			
			if (!gZIP) { 
				$('#zipValidationHint').show();
				$('#zip').css({ backgroundColor: gAlertColor });
				theMessage += ' ZIP or Postal code\r\n'; } 
			else { 
				$('#zipValidationHint').hide();
				$('#zip').css({ backgroundColor: gNormalColor }); }

			alert(theMessage);
			return false;
		}
	}


	// setup page 2
	// =====================================================================================
	
	function setupSurveyPage2() {
		SurveyInit();
		setupPage2SubmitStyleValidation();
	}

	function setupInternetQuotes2Zip() {
		// historical
		setupPage2SubmitStyleValidation();
		SurveyInit();
	}

	function setupPage2SubmitStyleValidation() {
	
		$('table#SurveyPage2table td:nth-child(2)').css({ width:'256px' });
		$('table#SurveyPage2table td:nth-child(3)').css({ paddingTop:'2px', textAlign:'left' });
		$('table#SurveyPage2table td#zipValidationHintTD').css({ paddingTop:'8px', textAlign:'left', verticalAlign:'top' });
		$('#FirstName').focus();
		$('#getQuotesNowBtn').hover(
			function(){$(this).attr({src : 'resources/btn_GetQuotesNow_rollover.gif'			})},
			function(){$(this).attr({src : 'resources/btn_GetQuotesNow.gif'						})}		);

		$('#FirstName')   .bind('keyup',  function(event) { validateNotEmpty(this); 			});
		$('#LastName')    .bind('keyup',  function(event) { validateNotEmpty(this); 			});
		$('#EmailAddress').bind('keyup',  function(event) { validateEmail(this);    			});
		$('#EmailAddress').bind('blur',   function(event) { validateEmail(this);    			});		// easy to run into autofill here

		$('#areacode')    .bind('blur',   function(event) { validatePhoneNumber();  			});
		$('#areacode')    .bind('keyup',  function(event) { autoAdvancePhoneNumberFields(this);	});
		$('#PhonePrefix') .bind('blur',   function(event) { validatePhoneNumber();				});
		$('#PhonePrefix') .bind('keyup',  function(event) { autoAdvancePhoneNumberFields(this);	});
		$('#PhoneNumber') .bind('blur',   function(event) { validatePhoneNumber();				});
		$('#PhoneNumber') .bind('keyup',  function(event) { autoAdvancePhoneNumberFields(this);	});

		$('#CompanyName') .bind('keyup',  function(event) { validateNotEmpty(this);				});
		$('#Address1')    .bind('keyup',  function(event) { validateNotEmpty(this);				});
		$('#City')        .bind('keyup',  function(event) { validateNotEmpty(this);				});
		$('#StateId')     .bind('change', function(event) { validateState(this);				});
		$('#zip')         .bind('keyup',  function(event) { validateZip(this);					});
		$('#zip')  		  .bind('blur',	  function(event) { blurOneCanPostalCode6to7(this);		});		// rewrite the user's entry from XXXXXX to XXX XXX
		$('#zip')  		  .bind('blur',	  function(event) { uppercaseTheZip(this);				});		

		// the page might load with some existing data so set the validation status accordingly
		if ( gNonBlank.test( $('#FirstName')		.val() ))		{ gFirstName     = true ; };		// all of these are set to false when the page loads this js file.
		if ( gNonBlank.test( $('#LastName')			.val() ))		{ gLastName      = true ; };
		if ( gNonBlank.test( $('#CompanyName')		.val() ))		{ gCompanyName   = true ; };
		if ( gNonBlank.test( $('#Address1')			.val() ))		{ gAddress1      = true ; };
		if ( gNonBlank.test( $('#City')				.val() ))		{ gCity          = true ; };
		if ( $('#StateId')							.val() != -1)	{ gState         = true ; };
		(gEmailExpression.test(  $('#EmailAddress')	.val() ) == true) ? (gEmailAddress = true) : (gEmailAddress = false) ;
		validatePhoneNumber();										// this will set gPhoneNumber appropriately
		var currentZipValue  = $('#zip').val().toUpperCase();		// Canadian postal codes require uppercase. So does our validating regex.
		(gSingleUSZip.test(currentZipValue) || gSingleCanPostalCode.test(currentZipValue)) ? (gZIP = true) : (gZIP = false) ;

	}





/*	====================================================================================================================================
	End of utilities
	==================================================================================================================================== */









