
function goToPage(page) {
	document.location.href = page;
}

// nav bg change on mouse over and out
function changebgover(menuitem){
    menuitem.style.backgroundImage = "url(/esp/images/leftnav/n_home_2.gif)"
}

function changebgout(menuitem){
    menuitem.style.backgroundImage = "url(/esp/images/leftnav/n_home_1.gif)"
}

function resetForm() {
	
	document.forms[0].reset();
	
	for (var i=0; i < document.forms[0].elements.length; i++) {
					
		if(document.forms[0].elements[i].type == "select-one") {
			document.forms[0].elements[i].selectedIndex = 0;
		}
		if(document.forms[0].elements[i].type == "text") { 
			document.forms[0].elements[i].value = "";
		}
		if(document.forms[0].elements[i].type == "checkbox") { 
			document.forms[0].elements[i].checked = false;
		}
		if(document.forms[0].elements[i].type == "radio") { 
			document.forms[0].elements[i].checked = false;
		}
	}
}

function popUpWindow(strURL, intWidth, intHeight) {
	window.open( strURL, "_blank", "status=1, height=" + intHeight + ", width=" + intWidth + ", resizable=1, scrollbars=1, toolbar=1, location=1" )
}

function popUpWindowNoScroll(strURL, intWidth, intHeight) {
	window.open( strURL, "_blank", "status=1, height=" + intHeight + ", width=" + intWidth + ", resizable=0, scrollbars=0, toolbar=0, location=0" )
}

// clickButton() function
// This function is used to make sure the "Enter" key submits the correct form button
// based on which form the focus is on
function clickButton(e, buttonid)
{
	var bt = document.getElementById(buttonid);	

	if (typeof bt == 'object')
	{
		if(navigator.appName.indexOf("Netscape")>(-1))
		{
			if (e.keyCode == 13)
			{
				bt.click();
				return false;
			}
		}
		if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		{
			if (event.keyCode == 13)
			{
				//bt.focus();
				bt.click();
				return false;
			}
		}
	} 
}

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function changeImages(strImageID, strType) {
	if ((document.images) && (strImageID != '')) {
		try
		{
			strNewImagePath = eval(strType + ".src").toString();
			document[strImageID].src = strNewImagePath;
		}
		catch(e)
		{
			// We'll get errors if this rollover code is executed
			//  while the page is still loading.  We can ignore them.
		}
	}
}

// Dynamically create the objects used for the left nav rollover.  It searches for 
// images with the "rollover" class and adds them to the global variables.  The 
// images must end with "_on.gif" or "_off.gif"

function cacheNavItems() {
	// Don't bother if the browser can't display images
	if (!document.images) return;
		
	// Get array of items with "rollover" class
	var navItems = getElementsByClassName("rollover");
	
	// Loop through array and allocate/cache each image + rollover
	for (var i=0; i<navItems.length; i+=1) {
		eval("this." + navItems[i].name + "off = new Image();");
		eval(navItems[i].name + "off.src = \"" + (navItems[i].src).replace("_on.gif", "_off.gif") + "\";");
		eval("this." + navItems[i].name + "on = new Image();");
		eval(navItems[i].name + "on.src = \"" + (navItems[i].src).replace("_off.gif", "_on.gif") + "\";");
	}
}

// Executes a function when the page loads, preserving any previous onLoad functions 
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

// Add onLoad events
addLoadEvent(cacheNavItems);


//FAQ Show/Hide

function showFAQ(name, id)
{
	hideAllFAQ();
	document.getElementById(name).style.display = 'block';
	document.getElementById(id).style.color = '#D63900';
	
}

function hideAllFAQ()
{
	document.getElementById('faqCholesterol').style.display = 'none';
	document.getElementById('faqAthero').style.display = 'none';
	document.getElementById('faqCrestor').style.display = 'none';
	document.getElementById('col').style.color = '#F47621';
	document.getElementById('atero').style.color = '#F47621';
	document.getElementById('crs').style.color = '#F47621';
}