<!-- BROWSER DETECTION -->
var browser = getBrowser();
if (browser == "ie6") document.writeln("<link rel=\"stylesheet\" href=\"css/ie6Hack.css\" type=\"text/css\">");
if (browser == "ie7") document.writeln("<link rel=\"stylesheet\" href=\"css/ie7Hack.css\" type=\"text/css\">");

function getBrowser() {
	var userAgent = navigator.userAgent.toLowerCase();
	var retBrowser = "";
	if (contains(userAgent, 'msie') || contains(userAgent, 'internet explorer')) {
		if (contains(userAgent, 'msie 6')) retBrowser = "ie6";
		else if (contains(userAgent, 'msie 7')) retBrowser = "ie7";
		else retBrowser = "ie";
	}
	else if (!contains(userAgent, 'compatible') || contains(userAgent, 'firefox'))
	{
	    retBrowser = "mozilla";
	    if(contains(userAgent, 'firefox')) retBrowser = "firefox";
	} else retBrowser = "unknown";
	return retBrowser;
}

function contains(string, substring)
{
    found = string.indexOf(substring) + 1;
    return found;
} 

<!-- COMMON JAVASCRIPT FUNCTIONS -->
function $(element) {
	return(document.getElementById(element));
}

<!-- JAVASCRIPT FUNCTION TO SET THE PAGE HEIGHT (BACKGROUND STRETCH) -->
function configurePageHeight() {
	var bottomYVal = getTopById("bottomFinder");
	var winHeight = 0;
	if (browser == "ie6" || browser == "ie7" || browser == "ie") {
		winHeight = document.documentElement.clientHeight;
	} else {
		winHeight = window.innerHeight;
	}
	
	if (bottomYVal > winHeight) {
		$("pageArea").style.height = (bottomYVal + 13) + "px";
		$("pageFrame").style.height = (bottomYVal + 13) + "px";
		if ($("videoPopupLayer") != null) {
			$("videoPopupBackground").style.height = (bottomYVal + 13) + "px";
			$("videoPopupLayer").style.height = (bottomYVal + 13) + "px";
		}
	} else {
		$("pageArea").style.height = "100%";
		$("pageFrame").style.height = "100%";
		if ($("videoPopupLayer") != null) {
			$("videoPopupBackground").style.height = "100%";
			$("videoPopupLayer").style.height = "100%";
		}
	}
}

<!-- JAVASCRIPT FUNCTIONS TO SUPPORT THE NAVIGATION ANIMATION -->

function homeLinkOnMouseOverListener() {
	$("homeLinkNormal").style.display = "none";
	$("homeLinkHover").style.display = "block";
	$("homeIndHover").style.display = "block";
}
function homeLinkOnMouseOutListener() {
	$("homeIndHover").style.display = "none";
	$("homeLinkHover").style.display = "none";
	$("homeLinkNormal").style.display = "block";
}

function aboutLinkOnMouseOverListener() {
	var page = $("curPage").value;
	if (page != "about") {
		$("aboutLinkNormal").style.display = "none";
		$("aboutLinkHover").style.display = "block";
	} else {
		$("aboutIndCurrent").style.display = "none";
		$("aboutLinkCurrent").style.display = "none";
		$("aboutLinkCurHover").style.display = "block";
	}
	$("aboutIndHover").style.display = "block";
}
function aboutLinkOnMouseOutListener() {
	var page = $("curPage").value;
	$("aboutIndHover").style.display = "none";
	if (page != "about") {
		$("aboutLinkHover").style.display = "none";
		$("aboutLinkNormal").style.display = "block";
	} else {
		$("aboutIndCurrent").style.display = "block";
		$("aboutLinkCurHover").style.display = "none";
		$("aboutLinkCurrent").style.display = "block";
	}
}

function servicesLinkOnMouseOverListener() {
	var page = $("curPage").value;
	if (page != "services") {
		$("servicesLinkNormal").style.display = "none";
		$("servicesLinkHover").style.display = "block";
	} else {
		$("servicesIndCurrent").style.display = "none";
		$("servicesLinkCurrent").style.display = "none";
		$("servicesLinkCurHover").style.display = "block";
	}
	$("servicesIndHover").style.display = "block";
}
function servicesLinkOnMouseOutListener() {
	var page = $("curPage").value;
	$("servicesIndHover").style.display = "none";
	if (page != "services") {
		$("servicesLinkHover").style.display = "none";
		$("servicesLinkNormal").style.display = "block";
	} else {
		$("servicesIndCurrent").style.display = "block";
		$("servicesLinkCurHover").style.display = "none";
		$("servicesLinkCurrent").style.display = "block";
	}
}

function affiliatesLinkOnMouseOverListener() {
	var page = $("curPage").value;
	if (page != "affiliates") {
		$("affiliatesLinkNormal").style.display = "none";
		$("affiliatesLinkHover").style.display = "block";
	} else {
		$("affiliatesIndCurrent").style.display = "none";
		$("affiliatesLinkCurrent").style.display = "none";
		$("affiliatesLinkCurHover").style.display = "block";
	}
	$("affiliatesIndHover").style.display = "block";
}
function affiliatesLinkOnMouseOutListener() {
	var page = $("curPage").value;
	$("affiliatesIndHover").style.display = "none";
	if (page != "affiliates") {
		$("affiliatesLinkHover").style.display = "none";
		$("affiliatesLinkNormal").style.display = "block";
	} else {
		$("affiliatesIndCurrent").style.display = "block";
		$("affiliatesLinkCurHover").style.display = "none";
		$("affiliatesLinkCurrent").style.display = "block";
	}
}

function buzzLinkOnMouseOverListener() {
	var page = $("curPage").value;
	if (page != "buzz") {
		$("buzzLinkNormal").style.display = "none";
		$("buzzLinkHover").style.display = "block";
	} else {
		$("buzzIndCurrent").style.display = "none";
		$("buzzLinkCurrent").style.display = "none";
		$("buzzLinkCurHover").style.display = "block";
	}
	$("buzzIndHover").style.display = "block";
}
function buzzLinkOnMouseOutListener() {
	var page = $("curPage").value;
	$("buzzIndHover").style.display = "none";
	if (page != "buzz") {
		$("buzzLinkHover").style.display = "none";
		$("buzzLinkNormal").style.display = "block";
	} else {
		$("buzzIndCurrent").style.display = "block";
		$("buzzLinkCurHover").style.display = "none";
		$("buzzLinkCurrent").style.display = "block";
	}
}

function qnaLinkOnMouseOverListener() {
	var page = $("curPage").value;
	if (page != "qna") {
		$("qnaLinkNormal").style.display = "none";
		$("qnaLinkHover").style.display = "block";
	} else {
		$("qnaIndCurrent").style.display = "none";
		$("qnaLinkCurrent").style.display = "none";
		$("qnaLinkCurHover").style.display = "block";
	}
	$("qnaIndHover").style.display = "block";
}
function qnaLinkOnMouseOutListener() {
	var page = $("curPage").value;
	$("qnaIndHover").style.display = "none";
	if (page != "qna") {
		$("qnaLinkHover").style.display = "none";
		$("qnaLinkNormal").style.display = "block";
	} else {
		$("qnaIndCurrent").style.display = "block";
		$("qnaLinkCurHover").style.display = "none";
		$("qnaLinkCurrent").style.display = "block";
	}
}

function contactLinkOnMouseOverListener() {
	var page = $("curPage").value;
	if (page != "contact") {
		$("contactLinkNormal").style.display = "none";
		$("contactLinkHover").style.display = "block";
	} else {
		$("contactIndCurrent").style.display = "none";
		$("contactLinkCurrent").style.display = "none";
		$("contactLinkCurHover").style.display = "block";
	}
	$("contactIndHover").style.display = "block";
}
function contactLinkOnMouseOutListener() {
	var page = $("curPage").value;
	$("contactIndHover").style.display = "none";
	if (page != "contact") {
		$("contactLinkHover").style.display = "none";
		$("contactLinkNormal").style.display = "block";
	} else {
		$("contactIndCurrent").style.display = "block";
		$("contactLinkCurHover").style.display = "none";
		$("contactLinkCurrent").style.display = "block";
	}
}

function blogLinkOnMouseOverListener() {
	$("blogLinkNormal").style.display = "none";
	$("blogLinkHover").style.display = "block";
}
function blogLinkOnMouseOutListener() {
	$("blogLinkHover").style.display = "none";
	$("blogLinkNormal").style.display = "block";
}

function nutriLinkOnMouseOverListener() {
	$("nutriLinkNormal").style.display = "none";
	$("nutriLinkHover").style.display = "block";
}
function nutriLinkOnMouseOutListener() {
	$("nutriLinkHover").style.display = "none";
	$("nutriLinkNormal").style.display = "block";
}

function setupNavListeners() {
	$("homeLink").onmouseover = homeLinkOnMouseOverListener;
	$("homeLink").onmouseout = homeLinkOnMouseOutListener;
	$("aboutLink").onmouseover = aboutLinkOnMouseOverListener;
	$("aboutLink").onmouseout = aboutLinkOnMouseOutListener;
	$("servicesLink").onmouseover = servicesLinkOnMouseOverListener;
	$("servicesLink").onmouseout = servicesLinkOnMouseOutListener;
	$("affiliatesLink").onmouseover = affiliatesLinkOnMouseOverListener;
	$("affiliatesLink").onmouseout = affiliatesLinkOnMouseOutListener;
	$("buzzLink").onmouseover = buzzLinkOnMouseOverListener;
	$("buzzLink").onmouseout = buzzLinkOnMouseOutListener;
	$("qnaLink").onmouseover = qnaLinkOnMouseOverListener;
	$("qnaLink").onmouseout = qnaLinkOnMouseOutListener;
	$("contactLink").onmouseover = contactLinkOnMouseOverListener;
	$("contactLink").onmouseout = contactLinkOnMouseOutListener;

	$("blogLink").onmouseover = blogLinkOnMouseOverListener;
	$("blogLink").onmouseout = blogLinkOnMouseOutListener;
	//$("nutriLink").onmouseover = nutriLinkOnMouseOverListener;
	//$("nutriLink").onmouseout = nutriLinkOnMouseOutListener;
}

function initializeNav() {
	var page = $("curPage").value;
	switch (page) {
		case "home":
			$("homeNav").style.display = "none";
			$("homeFooterLink").style.display = "none";
			$("aboutFooterLink").className = "first";
			break;
		case "about":
			$("aboutLinkNormal").style.display = "none";
			$("aboutLinkCurrent").style.display = "block";
			$("aboutIndCurrent").style.display = "block";
			break;
		case "services":
			$("servicesLinkNormal").style.display = "none";
			$("servicesLinkCurrent").style.display = "block";
			$("servicesIndCurrent").style.display = "block";
			break;
		case "affiliates":
			$("affiliatesLinkNormal").style.display = "none";
			$("affiliatesLinkCurrent").style.display = "block";
			$("affiliatesIndCurrent").style.display = "block";
			break;
		case "buzz":
			$("buzzLinkNormal").style.display = "none";
			$("buzzLinkCurrent").style.display = "block";
			$("buzzIndCurrent").style.display = "block";
			break;
		case "qna":
			$("qnaLinkNormal").style.display = "none";
			$("qnaLinkCurrent").style.display = "block";
			$("qnaIndCurrent").style.display = "block";
			break;
		case "contact":
			$("contactLinkNormal").style.display = "none";
			$("contactLinkCurrent").style.display = "block";
			$("contactIndCurrent").style.display = "block";
			break;
	}
}

<!-- JAVASCRIPT FUNCTIONS TO SUPPORT SUBNAV ANIMATION FOR SERVICES PAGES -->

function fitNavLinkOMOverListener() {
	$("fitNavNormal").style.display = "none";
	$("fitNavHover").style.display = "inline";
}
function fitNavLinkOMOutListener() {
	$("fitNavHover").style.display = "none";
	$("fitNavNormal").style.display = "inline";
}
function wellNavLinkOMOverListener() {
	$("wellNavNormal").style.display = "none";
	$("wellNavHover").style.display = "inline";
}
function wellNavLinkOMOutListener() {
	$("wellNavHover").style.display = "none";
	$("wellNavNormal").style.display = "inline";
}
function connectNavLinkOMOverListener() {
	$("connectNavNormal").style.display = "none";
	$("connectNavHover").style.display = "inline";
}
function connectNavLinkOMOutListener() {
	$("connectNavHover").style.display = "none";
	$("connectNavNormal").style.display = "inline";
}

function setupServiceNavListeners() {
	$("fitNavLink").onmouseover = fitNavLinkOMOverListener;
	$("fitNavLink").onmouseout = fitNavLinkOMOutListener;
	$("wellNavLink").onmouseover = wellNavLinkOMOverListener;
	$("wellNavLink").onmouseout = wellNavLinkOMOutListener;
	$("connectNavLink").onmouseover = connectNavLinkOMOverListener;
	$("connectNavLink").onmouseout = connectNavLinkOMOutListener;
}



<!-- JAVASCRIPT FUNCTIONS TO SUPPORT FEATURE ANIMATION ON HOMEPAGE -->
var calloutIndex = 0;
var calloutsLoaded = false;

function updateCallouts(index) {
	var calloutIndex = index%callouts.length;
	if (!calloutsLoaded || callouts.length > 3) {
		$("callout1").innerHTML = callouts[calloutIndex].html;
		$("callout2").innerHTML = callouts[(calloutIndex+1)%callouts.length].html;
		$("callout3").innerHTML = callouts[(calloutIndex+2)%callouts.length].html;
	}

	calloutsLoaded = true;
}

function rotate() {
	calloutIndex++;
	updateCallouts(calloutIndex);
}

function startRotation() {
	intervalID = setInterval("rotate()", 5000);
}

function initializeCallouts() {
	calloutIndex = Math.floor(Math.random()*(callouts.length+1))
	updateCallouts(calloutIndex);
}

function setupCalloutRotation() {
	initializeCallouts.call();
//	startRotation.call();
}


<!-- JAVASCRIPT TO SUPPORT E-MAIL LIST FORMATTING -->

function emailAddressOnFocusListener() {
	this.value = "";
	this.setAttribute("class", "value");
}
function emailAddressOnBlurListener() {
	if (this.value == "") {
		this.value = "(enter e-mail address)";
		this.setAttribute("class", "hint");
	}
}
function setupEmailListeners() {
	$("emailAddress").onfocus = emailAddressOnFocusListener;
	$("emailAddress").onblur = emailAddressOnBlurListener;
}

<!-- JAVASCRIPT TO SUPPORT VIDEO POP-UPS -->

function configureVideoPopup() {
	var widWidth = 0;
	if (browser == "ie6" || browser == "ie7" || browser == "ie") {
		winWidth = document.documentElement.clientWidth;
	} else {
		winWidth = window.innerWidth;
	}
	$("videoPopupArea").style.left = (winWidth - 582)/2 + "px";
	$("video").style.paddingLeft = ((winWidth - 572)/2 + 31) + "px";
}

function videoLinkOnClickListener() {
	configureVideoPopup();
	$("videoPopupBackground").style.display = "block";
	$("videoPopupLayer").style.display = "block";
}
function closeLinkOnClickListener() {
	$("videoPopupLayer").style.display = "none";
	$("videoPopupBackground").style.display = "none";
}
function setupVideoListeners() {
	$("videoThumbnail").onclick = videoLinkOnClickListener;
	$("videoLink").onclick = videoLinkOnClickListener;
	$("closeLink").onclick = closeLinkOnClickListener;
}

<!-- JAVASCRIPT TO SUPPORT FORM FORMATTING HINTS -->

var selectOverride = false;
function limitedFieldOnSelectListener() {
	selectOverride = true;
}
function autoTab(currentFieldObj, count, nextFieldId, e){
	var key = 0;
	if (browser == "ie") {
		key = event.keyCode;
	} else {
		key = e.which;
	}
	// don't autotab if the user pressed the control key
	if (key != 16) {
		if (!selectOverride) {
			if (currentFieldObj.value.length == count) {
				$(nextFieldId).focus();
			}
		}
		selectOverride = false;
	}
}
function std3CharOnKeyUpListener(e) {
	autoTab(this, 3, getNextInputFieldId(this), e);
}
function getNextInputFieldId (currentFieldObj) {
	var fields = new Array;
	fields = document.getElementsByTagName("input");
	var nextFieldId = "";
	var i = 0;
	for (i = 0; i < fields.length; i++) {
		if (fields[i].id == currentFieldObj.id) {
			nextFieldId = fields[i+1].id;
			break;
		}
	}
	return(nextFieldId);
}
function setupPhoneFieldListeners(fieldRoot) {
	$(fieldRoot + "Area").onkeyup = std3CharOnKeyUpListener;
	$(fieldRoot + "Area").onselect = limitedFieldOnSelectListener;
	$(fieldRoot + "Exchange").onkeyup = std3CharOnKeyUpListener;
	$(fieldRoot + "Exchange").onselect = limitedFieldOnSelectListener;
}

function allowKeyPress(field, maxLength, e) {
	var key = 0;
	if (browser == "ie") {
		key = event.keyCode;
	} else {
		key = e.which;
	}
	if(key >= 32 && key <= 127 && field.value.length >= maxLength) return false;
	return true;
}

function updateCharsRemaining(fieldId, fieldCounterId, maxLength) {
	var counterNode = $(fieldCounterId);
	var newCounterText = (maxLength - $(fieldId).value.length);

	var newCounterNode = document.createElement("span");
	newCounterNode.setAttribute("id", fieldCounterId);
	var newCounter = createChild("text", newCounterNode, newCounterText);

	counterNode.parentNode.replaceChild(newCounterNode, counterNode);
}

function createChild (nodeType, parentNode, nodeValue) {
	var newNodeValue = document.createTextNode(nodeValue);
	var newNode = document.createElement(nodeType);

	newNode.appendChild(newNodeValue);

	if(parentNode) {
		parentNode.appendChild(newNode);
	}

	return newNode;
}


<!-- JAVASCRIPT TO SUPPORT RESIZING UPON ERRORS -->

function getTopById(imgId) {
	return getTopByObj($(imgId));
}
function getTopByObj(objId) {
	yPos = objId.offsetTop;
	tempEl = objId.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	return yPos;
}

<!-- JAVASCRIPT TO SUPPORT POP-UP WINDOWS -->

function popUp(window_URL, target_name, w, h, t, l, tb, mb, sb, rs, d) {
	var width = w || "0";
	var height = h || "0";
	var toolbar = tb || "no";
	var menubar = mb || "no";
	var scrollbars = sb || "no";
	var resizable = rs || "no";
	var dialog = d || "no"
	var top = t || "0";
	var left = l || "0";

	var parameters = "titlebar=no,toolbar=" + toolbar + ",location=no,status=no,menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",dialog=" + dialog + ",copyhistory=no,alwaysRaised=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
	var win = window.open(window_URL, target_name, parameters);
	win.focus();
	return false;
}

function popUpTopRight(window_URL, target_name, w, h, tb, mb, sb, rs, d) {
	var width = w || "0";
	var height = h || "0";
	var top = "0";
	var left = "0";

	var screenWidth = screen.width;
	var screenHeight = screen.height;

	if (width == "0") width = "640";
	if (height == "0") height = "500";

	if (height > screenHeight) {
		height = screenHeight;
	} else {
		top = 10;
	}
	if (width > screenWidth) {
		width = screenWidth;
	} else {
		left = (screenWidth - width - 20);
	}

	return popUp(window_URL, target_name, w, h, top, left, tb, mb, sb, rs, d);
}

	
