//-- Preload images to cure the browser flickering issueif (document.images) {	var aryImages = new Array(		"/images/btn_aqua.png",		"/images/btn_blue.png",		"/images/btn_disabled.png",		"/images/btn_gray.png",		"/images/btn_green.png",		"/images/btn_ltgray.png",		"/images/btn_orange.png",		"/images/btn_red.png",		"/images/btn_yellow.png"	);	var aryPreload = new Array();	for (var img=0; img<aryImages.length; img++) {		aryPreload[img] = new Image();		aryPreload[img].src = aryImages[img];	}}Array.prototype.contains = function(obj) {	var i = this.length;	while (i--) {		if (this[i] === obj) {			return true;		}	}	return false;}function formatPhone(field, event) {	if (field.value.replace(/^\s+|\s+$/g, "") == "") {		return true;	}	var code = 0;	if (event) {		event = event || window.event;		code = event.which || event.keyCode;	}	//-- ignore backspace, tab, shift, ctrl, home, end, arrows, del	var aryCodes = [ 8, 9, 16, 17, 35, 36, 37, 38, 39, 46 ];	if (!aryCodes.contains(code)) {		if (field.value.match(/^[01]?\s?\(\d{1,2}$/) ||			field.value.match(/^[01]?\s?\(\d{3}\)\s\d{1,2}$/) ||			field.value.match(/^[01]?\s?\(\d{3}\)\s\d{3}-\d{1,4}$/) || 			field.value.match(/^[01]?\s?\(\d{3}\)\s\d{3}-\d{4}\s[x]{1}\s[\d]{1,5}$/)		) {			return true;		}		var proceed = true;		if (proceed) proceed = !field.value.match(/^([01])\s$/);		if (proceed) proceed = !field.value.match(/^([01]?\s?)(\()$/);		if (proceed) proceed = !field.value.match(/^([01]?\s?)(\([0-9]{3}\))\s$/);		if (proceed) proceed = !field.value.match(/^([01]?\s?)(\([0-9]{3}\))\s([0-9]{3})\-$/);		if (proceed) proceed = !field.value.match(/^([01]?\s?)(\([0-9]{3}\))\s([0-9]{3})\-([0-9]{4})([ex\s])$/);		if (proceed) {			var temp = field.value.replace(/[^0-9]/g, "");			var cursor = temp.length;			var prefix = temp.replace(/^([01]?)([0-9]*)$/, "$1").length;			temp = temp.replace(/^([01]?)([0-9]{0,3})([0-9]{0,3})([0-9]{0,4})([0-9]*)$/, "$1 ($2) $3-$4 x $5");			if (cursor < (11+prefix)) temp = temp.replace(/\s*x\s*$/, "");			if (cursor < (6+prefix)) temp = temp.replace(/\-\s*$/, "");			if (cursor < (3+prefix)) temp = temp.replace(/\)\s*$/, "");			if (cursor < (1+prefix)) temp = temp.replace(/\s\(*$/, "");			if (!cursor) temp = "";			if (cursor > (15+prefix)) temp = temp.substring(0,temp.length-(cursor-(15+prefix)));			temp = temp.replace(/^\s+|\s+$/g, "");			field.value = temp;		} else {			if (field.value.match(/^([01]?\s?)(\([0-9]{3}\))\s([0-9]{3})\-([0-9]{4})([ex\s])$/)) {				field.value = field.value.replace(/([ex\s])$/, " x ");			} else {				field.value = field.value;			}		}		//field.focus();	}	return true;}function formatNumeric(field, event) {	// Usage: onkeyup="formatNumeric(this,event)"	event = event || window.event;	code = event.which || event.keyCode;	//-- ignore backspace, tab, shift, ctrl, home, end, arrows, del	var aryCodes = [ 8, 9, 16, 17, 35, 36, 37, 38, 39, 46 ];	if (!aryCodes.contains(code)) {		field.value = field.value.replace(/[^0-9\-]/g, "");		field.value = field.value.replace(/^([-][1-9]\d*|\d+)(.*?)$/g, "$1");	}	return true;}function formatAlphaNumeric(field, event) {	// Usage: onkeyup="formatAlphaNumeric(this,event)"	event = event || window.event;	code = event.which || event.keyCode;	//-- ignore backspace, tab, shift, ctrl, home, end, arrows, del	var aryCodes = [ 8, 9, 16, 17, 35, 36, 37, 38, 39, 46 ];	if (!aryCodes.contains(code)) {		field.value = field.value.replace(/[^a-fA-F0-9]/g, "");		field.value = field.value.replace(/^([a-fA-F0-9]{0,6})(.*?)$/g, "$1");	}	return true;}function formatZipCode(field, event) {	// Usage: onkeyup="formatZipCode(this,event)"	if (field.value.replace(/^\s+|\s+$/g, "") == "") {		return true;	}	event = event || window.event;	code = event.which || event.keyCode;	//-- ignore backspace, tab, shift, ctrl, home, end, arrows, del	var aryCodes = [ 8, 9, 16, 17, 35, 36, 37, 38, 39, 46 ];	if (!aryCodes.contains(code)) {		if (!field.value.match(/^[0-9]*$/)) {			field.value = field.value.replace(/[^0-9]/g, "");		}		if (field.value.replace(/^\s*|\s*$/) != "") {			if (!field.value.match(/^([0-9]{1,5})$/)) {				field.value = field.value.replace(/([0-9]{1,5})([0-9]*)$/, "$1");			}		}	}	return true;}function isNumeric(text) {	if (text.replace(/^\s+|\s+$/g, "") == "") {		return false;	}	var objRegExp = /^([-][1-9]\d*|\d+)$/;	return objRegExp.test(text);}function isPhone(text) {	if (text.replace(/^\s+|\s+$/g, "") == "") {		return false;	}	var objRegExp = /^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}(([\s]*(x|ext|ext.){1}[\s]*[0-9]{1,6}[\s]*|[\s]*[0-9]{0,6}[\s]*))$/;	return objRegExp.test(text);}function validateFormField(isValid, theField, strMessage) {	if (isValid && theField) {		var strType = theField.type;		try {			strType = (theField[0].type != undefined ? theField[0].type : strType);		} catch (er) { }		var strValue = "";		var isChecked = false;		if (strType.indexOf("select") < 0) {			if (strType.indexOf("checkbox") < 0 && strType.indexOf("radio") < 0) {				strValue = new String(theField.value);			} else {				for (var i=0; i<theField.length; i++) {					if (theField[i].checked) {						strValue = new String(theField[i].value);						isChecked = true;						break;					}				}			}		} else {			strValue = theField.options[theField.selectedIndex].value;			strValue = (strValue.replace(/^\s+|\s+$/g, "") == "-1" ? "" : strValue);		}		if (strValue.replace(/^\s+|\s+$/g, "") == "" && !isChecked) {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		return true;	}	return isValid;}function validateFormFieldState(isValid, theField, strMessage) {	if (isValid && theField) {		var strValue = new String(theField.value);		if (strValue.replace(/^\s+|\s+$/g, "") == "") {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		var objRegExp = /^[a-zA-Z]{2}$/;		if (!objRegExp.test(strValue)) {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		return true;	}	return isValid;}function validateFormFieldZipCode(isValid, theField, strMessage) {	if (isValid && theField) {		var strValue = new String(theField.value);		if (strValue.replace(/^\s+|\s+$/g, "") == "") {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		var objRegExp = /^[0-9]{5}$/;		if (!objRegExp.test(strValue)) {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		return true;	}	return isValid;}function validateFormFieldEmail(isValid, theField, strMessage) {	if (isValid && theField) {		var strValue = new String(theField.value);		if (strValue.replace(/^\s+|\s+$/g, "") == "") {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		var objRegExp = /^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/;		if (!objRegExp.test(strValue)) {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		return true;	}	return isValid;}function validateFormFieldPhone(isValid, theField, strMessage) {	if (isValid && theField) {		var strValue = new String(theField.value);		if (strValue.replace(/^\s+|\s+$/g, "") == "") {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		var objRegExp = /^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}(([\s]*(x|ext|ext.){1}[\s]*[0-9]{1,6}[\s]*|[\s]*[0-9]{0,6}[\s]*))$/;		if (!objRegExp.test(strValue)) {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		return true;	}	return isValid;}function validateFormFieldPassword(isValid, theField, strMessage) {	if (isValid && theField) {		var strValue = new String(theField.value);		if (strValue.replace(/^\s+|\s+$/g, "") == "") {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		var objRegExp = /^[a-zA-Z0-9_\.\-]{6,}$/;		if (!objRegExp.test(strValue)) {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField.focus();			} catch (er) { }			return false;		}		return true;	}	return isValid;}function validateFormFieldEquals(isValid, theField1, theField2, strMessage) {	if (isValid && theField1 && theField2) {		if (theField1.value.replace(/^\s+|\s+$/g, "") != theField2.value.replace(/^\s+|\s+$/g, "")) {			if (strMessage.replace(/^\s+|\s+$/g, "") != "") { alert(strMessage); }			try {				theField1.focus();			} catch (er) { }			return false;		}		return true;	}	return isValid;}var maxLengthField;function imposeMaxLength(field, event) {	//-- maxlength attribute must be set	//-- onkeyup, onkeydown				return imposeMaxLength(this, event)	//-- onpaste						imposeMaxLength(this, event); this.blur(); this.focus();	//-- oninput, onfocus, onblur		imposeMaxLength(this, event)	try {		if (field.value.replace(/^\s+|\s+$/g, "") == "") {			return true;		}		event = event || window.event;		code = event.which || event.keyCode;		//-- allow backspace, tab, shift, ctrl, home, end, arrows, del		var aryCodes = [ 8, 9, 16, 17, 35, 36, 37, 38, 39, 46 ];		if (aryCodes.contains(code)) {			return true;		}		var maxlen = (field.getAttribute ? parseInt(field.getAttribute("maxlength")) : "");		if (isNaN(maxlen)) {			return true;		}		if (field.value.length >= maxlen) {			field.value = field.value.substring(0, maxlen-1);			maxLengthField = field;			setTimeout("maxLengthField.scrollTop = maxLengthField.scrollHeight;", 0);		}		return (field.value.length < maxlen);	} catch (err) {		//alert(err.description);		return true;	}}function validateSignup(theForm) {	var isValid = true;	isValid = validateFormField(isValid, theForm.strFirstName, "Your first name is required!");	isValid = validateFormField(isValid, theForm.strLastName, "Your last name is required!");	isValid = validateFormField(isValid, theForm.strAddress1, "Your address is required!");	isValid = validateFormField(isValid, theForm.strCity, "Your city is required!");	isValid = validateFormField(isValid, theForm.strState, "Your state is required!");	isValid = validateFormFieldState(isValid, theForm.strState, "Your state is invalid!");	isValid = validateFormField(isValid, theForm.strZip, "Your zip code is required!");	isValid = validateFormFieldZipCode(isValid, theForm.strZip, "Your zip code is invalid!");	isValid = validateFormField(isValid, theForm.strEmail, "Your email address is required!");	isValid = validateFormFieldEmail(isValid, theForm.strEmail, "Your email address is invalid!");	isValid = validateFormField(isValid, theForm.strPhone, "Your phone number is required!");	isValid = validateFormFieldPhone(isValid, theForm.strPhone, "Your phone number is invalid!");	isValid = validateFormField(isValid, theForm.strPassword, "Your password is required!");	isValid = validateFormFieldPassword(isValid, theForm.strPassword, "Your password must be at least 6 characters in length!");	isValid = validateFormField(isValid, theForm.strConfirmPassword, "You must confirm your password!");	isValid = validateFormFieldEquals(isValid, theForm.strPassword, theForm.strConfirmPassword, "Your passwords do not match!");	return isValid;}$(document).ready(function(){	/*	//-- this loads MUCH faster than .each() and seems to work ok?	$("a.thickbox").click(function(){		if (this.rel) {			$("a.thickbox[rel='" + this.rel + "']").colorbox();		} else {			$(this).colorbox();		}	});	*/	$("#bar ul li.navitem, #nav ul li.navitem").hover(		function() {			var thisElement = $(this);			thisElement.clearQueue();			thisElement.delay(thisElement.has("ul").length ? 250 : 0);			thisElement.queue(function(){				thisElement.addClass("hover");				thisElement.dequeue();			});		},		function() {			var thisElement = $(this);			thisElement.clearQueue();			thisElement.delay(thisElement.has("ul").length ? 250 : 0);			thisElement.queue(function(){				thisElement.removeClass("hover");				thisElement.dequeue();			});		}	);	$("#bar ul li.subitem, #nav ul li.subitem").hover(		function() {			var thisElement = $(this);			thisElement.addClass("subhover");			thisElement.children("a, span").addClass("subhover");			thisElement.children("ul").addClass("subactive");		},		function() {			var thisElement = $(this);			thisElement.children("ul").removeClass("subactive");			thisElement.children("a, span").removeClass("subhover");			thisElement.removeClass("subhover");		}	);	//$("#bar ul li ul li:first-child").addClass("top");	//$("#nav ul li.navitem:last-child").addClass("navright");	//-- makes drop-down navigation work on iOS devices	if (navigator.userAgent.match(/Mobile/i) && navigator.userAgent.match(/Safari/i)) {		$(document).bind("touchmove", function(){			$("#bar ul li.hover, #nav ul li.hover").mouseout();		});		$("#bar ul li.navitem, #nav ul li.navitem").has("ul").unbind("mouseenter");		$("#bar ul li.navitem, #nav ul li.navitem").has("ul").children("a.navlink").click(function() {			var parent = $(this).parent("li.navitem");			if (parent.hasClass("hover")) {				return true;			}			parent.clearQueue();			parent.delay(250);			parent.queue(function(){				parent.addClass("hover");				parent.dequeue();			});			return false;		});		$("#bar ul li.navitem, #nav ul li.navitem").has("ul").children("span.navlink").click(function() {			var parent = $(this).parent("li.navitem");			parent.clearQueue();			parent.delay(250);			parent.queue(function(){				parent.toggleClass("hover");				parent.dequeue();			});		});	}});
