<!-- BROWSER DETECTION -->
var browser = getBrowser();
if (browser == "ie") document.writeln("<link rel=\"stylesheet\" href=\"css/ieHack.css\" type=\"text/css\">");

function getBrowser() {
	var userAgent = navigator.userAgent.toLowerCase();
	var retBrowser = "";
	if (contains(userAgent, 'msie') || contains(userAgent, 'internet explorer')) 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 FUNCTIONS TO SUPPORT THE NAVIGATION ANIMATION -->

	function indexLinkOnMouseOverListener() {
		if ($("indexNav").className != "current") {
			$("indexFlowerNormal").style.display = "none";
			$("indexFlowerHover").style.display = "inline";
		}
		$("indexLink").className = "hover";
	}
	function indexLinkOnMouseOutListener() {
		if ($("indexNav").className != "current") {
			$("indexFlowerHover").style.display = "none";
			$("indexFlowerNormal").style.display = "inline";
		}
		$("indexLink").className = "link";
	}
	function authorLinkOnMouseOverListener() {
		if ($("authorNav").className != "current") {
			$("authorFlowerNormal").style.display = "none";
			$("authorFlowerHover").style.display = "inline";
		}
		$("authorLink").className = "hover";
	}
	function authorLinkOnMouseOutListener() {
		if ($("authorNav").className != "current") {
			$("authorFlowerHover").style.display = "none";
			$("authorFlowerNormal").style.display = "inline";
		}
		$("authorLink").className = "link";
	}
	function coachingLinkOnMouseOverListener() {
		if ($("coachingNav").className != "current") {
			$("coachingFlowerNormal").style.display = "none";
			$("coachingFlowerHover").style.display = "inline";
		}
		$("coachingLink").className = "hover";
	}
	function coachingLinkOnMouseOutListener() {
		if ($("coachingNav").className != "current") {
			$("coachingFlowerHover").style.display = "none";
			$("coachingFlowerNormal").style.display = "inline";
		}
		$("coachingLink").className = "link";
	}
	function getInvolvedLinkOnMouseOverListener() {
		if ($("getInvolvedNav").className != "current") {
			$("getInvolvedFlowerNormal").style.display = "none";
			$("getInvolvedFlowerHover").style.display = "inline";
		}
		$("getInvolvedLink").className = "hover";
	}
	function getInvolvedLinkOnMouseOutListener() {
		if ($("getInvolvedNav").className != "current") {
			$("getInvolvedFlowerHover").style.display = "none";
			$("getInvolvedFlowerNormal").style.display = "inline";
		}
		$("getInvolvedLink").className = "link";
	}
	function contactLinkOnMouseOverListener() {
		if ($("contactNav").className != "current") {
			$("contactFlowerNormal").style.display = "none";
			$("contactFlowerHover").style.display = "inline";
		}
		$("contactLink").className = "hover";
	}
	function contactLinkOnMouseOutListener() {
		if ($("contactNav").className != "current") {
			$("contactFlowerHover").style.display = "none";
			$("contactFlowerNormal").style.display = "inline";
		}
		$("contactLink").className = "link";
	}
	function blogLinkOnMouseOverListener() {
		$("blogArrow").style.display = "none";
		$("blogArrow_highlight").style.display = "inline";
	}
	function blogLinkOnMouseOutListener() {
		$("blogArrow_highlight").style.display = "none";
		$("blogArrow").style.display = "inline";
		clearInterval(scrollInterval);
	}

	function setupNavListeners() {
		$("indexLink").onmouseover = indexLinkOnMouseOverListener;
		$("indexLink").onmouseout = indexLinkOnMouseOutListener;
		$("indexFlower").onmouseover = indexLinkOnMouseOverListener;
		$("indexFlower").onmouseout = indexLinkOnMouseOutListener;

		$("authorLink").onmouseover = authorLinkOnMouseOverListener;
		$("authorLink").onmouseout = authorLinkOnMouseOutListener;
		$("authorFlower").onmouseover = authorLinkOnMouseOverListener;
		$("authorFlower").onmouseout = authorLinkOnMouseOutListener;

		$("coachingLink").onmouseover = coachingLinkOnMouseOverListener;
		$("coachingLink").onmouseout = coachingLinkOnMouseOutListener;
		$("coachingFlower").onmouseover = coachingLinkOnMouseOverListener;
		$("coachingFlower").onmouseout = coachingLinkOnMouseOutListener;

		$("getInvolvedLink").onmouseover = getInvolvedLinkOnMouseOverListener;
		$("getInvolvedLink").onmouseout = getInvolvedLinkOnMouseOutListener;
		$("getInvolvedFlower").onmouseover = getInvolvedLinkOnMouseOverListener;
		$("getInvolvedFlower").onmouseout = getInvolvedLinkOnMouseOutListener;

		$("contactLink").onmouseover = contactLinkOnMouseOverListener;
		$("contactLink").onmouseout = contactLinkOnMouseOutListener;
		$("contactFlower").onmouseover = contactLinkOnMouseOverListener;
		$("contactFlower").onmouseout = contactLinkOnMouseOutListener;

		$("blogLink").onmouseover = blogLinkOnMouseOverListener;
		$("blogLink").onmouseout = blogLinkOnMouseOutListener;
	}
	
<!-- JAVASCRIPT FUNCTIONS TO SUPPORT SCROLLING -->

	var scrollInterval;
	
	function moreLinkOnClickListener() {
		$("contentBoxText").scrollTop += 14;
	}
	
	function moreLinkOnMouseDownListener() {
		moreLinkOnClickListener();
		scrollInterval = setInterval("moreLinkOnClickListener();", 50);
	}
	function moreLinkOnMouseUpListener() {
		clearInterval(scrollInterval);
	}
	function moreLinkOnMouseOverListener() {
		$("arrow").style.display = "none";
		$("arrow_highlight").style.display = "inline";
	}
	function moreLinkOnMouseOutListener() {
		$("arrow_highlight").style.display = "none";
		$("arrow").style.display = "inline";
		clearInterval(scrollInterval);
	}

	function setupScrollListeners() {
		$("moreLink").onmouseover = moreLinkOnMouseOverListener;
		$("moreLink").onmouseout = moreLinkOnMouseOutListener;
		$("moreLink").onclick = moreLinkOnClickListener;
		$("moreLink").onmousedown = moreLinkOnMouseDownListener;
		$("moreLink").onmouseup = moreLinkOnMouseUpListener;
	}

<!-- JAVASCRIPT FUNCTIONS TO SUPPORT CALLOUT ANIMATION -->

	function shareCalloutOnMouseOverListener() {
		$("shareLink").style.display = "none";
		$("shareLinkHover").style.display = "inline";
	}
	function shareCalloutOnMouseOutListener() {
		$("shareLinkHover").style.display = "none";
		$("shareLink").style.display = "inline";
	}
	function subscribeCalloutOnMouseOverListener() {
		$("subscribeLink").style.display = "none";
		$("subscribeLinkHover").style.display = "inline";
	}
	function subscribeCalloutOnMouseOutListener() {
		$("subscribeLinkHover").style.display = "none";
		$("subscribeLink").style.display = "inline";
	}
	function compCoachCalloutOnMouseOverListener() {
		$("compCoachLink").style.display = "none";
		$("compCoachLinkHover").style.display = "inline";
	}
	function compCoachCalloutOnMouseOutListener() {
		$("compCoachLinkHover").style.display = "none";
		$("compCoachLink").style.display = "inline";
	}

	function setupCalloutListeners() {
		$("shareCallout").onmouseover = shareCalloutOnMouseOverListener;
		$("shareCallout").onmouseout = shareCalloutOnMouseOutListener;
		$("subscribeCallout").onmouseover = subscribeCalloutOnMouseOverListener;
		$("subscribeCallout").onmouseout = subscribeCalloutOnMouseOutListener;
		$("compCoachCallout").onmouseover = compCoachCalloutOnMouseOverListener;
		$("compCoachCallout").onmouseout = compCoachCalloutOnMouseOutListener;
	}


<!-- JAVASCRIPT TO SUPPORT 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) + " characters remain)";

	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;
}
	