<!--//
/* TOP NAVIGATION ROLLOVERS */
var topnavNames = ["essay", "tanning_tool", "trend_report", "products", "sample", "tell_a_friend", "glow_girl"];
var maxTopnav = topnavNames.length;
var topnavOn = new Array(maxTopnav);
var topnavOff = new Array(maxTopnav);
var topnavPath = "images/";
var topnavPrefix = "nav_";
var topnavType = ".gif";
var currTopnav = 0;
var currProduct = 0;

if (document.images){
	for (var i = 0; i < maxTopnav; i++){
		topnavOn[i] = new Image();
		topnavOn[i].src = topnavPath + topnavPrefix + topnavNames[i] + "_over" + topnavType;
		topnavOff[i] = new Image();
		topnavOff[i].src = topnavPath + topnavPrefix + topnavNames[i] + topnavType;
	}
}
	
function light(imgNum){
	if (document.images && (imgNum != 0)){
		document.images["tnav" + imgNum].src = topnavOn[imgNum - 1].src;
	}
}
	
function dim(imgNum){
	if (document.images && (currTopnav != imgNum)){
		document.images["tnav" + imgNum].src = topnavOff[imgNum - 1].src;
	}
}

function lightProduct(imgNum){
	var navItem = getObjectByID("pnav" + imgNum);
	navItem.className = "products_sm_on";
}

function lightCurrent(){
	light(currTopnav);
}

function lightCurrentProduct(){
	light(currTopnav);
	lightProduct(currProduct);
}

function setCurrent(imgNum){
	if (imgNum != currTopnav){
		var temp = currTopnav;
		currTopnav = imgNum;
		light(currTopnav);
		dim(temp);
	}
}

//Cross Browser Object Retrieval
function getObjectByID(objectID){
	if (document.all!=null){
		return document.all[objectID];
	} else if (document.getElementById){
		return document.getElementById(objectID);
	}
}

function toggleDiv(divName){
	var ingredDiv = getObjectByID(divName);
	if (ingredDiv.style.display == "block"){
		ingredDiv.style.display = "none";
	} else {
		ingredDiv.style.display = "block";
	}
	switch (divName) {
		case 'quick_search':
			getObjectByID('displayQuickSearch').value = ingredDiv.style.display;
			break;
		case 'view_selections':
			getObjectByID('displayTopic').value = ingredDiv.style.display;
			break;
		case 'choose_criteria':
			getObjectByID('displayCriteria').value = ingredDiv.style.display;
			break;
		case 'search_ingred':
			getObjectByID('displayIngredients').value = ingredDiv.style.display;
			break;
		case 'search_products':
			getObjectByID('displayProduct').value = ingredDiv.style.display;
			break;
	}
}

function toggleImg(imgName){
 var theImage = document.images[imgName];
 var imgSrc = theImage.src;
 var off = "";
 var on = "_on";
 
 var suffixPos = imgSrc.indexOf(on);
 var periodPos = imgSrc.lastIndexOf(".");
 
 if (suffixPos != -1){
  imgSrc = imgSrc.substring(0, suffixPos) + imgSrc.substring(periodPos);
 } else {
  imgSrc = imgSrc.substring(0, periodPos) + on + imgSrc.substring(periodPos);
 }
 
 theImage.src = imgSrc;
}



if (location.href.indexOf("/product_") != -1){
	window.onload = lightCurrentProduct;
} else {
	window.onload = lightCurrent;
}
//-->