<!--

function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}

function changeImages() {
    if (document.images && (preloadFlag == true)) {
        for (var i=0; i<changeImages.arguments.length; i+=2) {
            document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
        }
    }
}

var preloadFlag = false;
function preloadImages() {
    if (document.images) {
        button_friend_over = newImage("/images/button-friend-over.gif");
        button_contact_over = newImage("/images/button-contact-over.gif");        
        button_help_over = newImage("/images/button-help-over.gif");
        button_home_over = newImage("/images/button-home-over.gif");
        bullet_over = newImage("/images/bullet-over.gif");
		// gf news mod
        button_gf_over = newImage("/images/button-go-over.gif");
        quick_meals_over = newImage("/images/recipe/quick-meals-over.gif");
		// dvine
		button_friend_dvine_over = newImage("/images/button-friend-divine-over.gif");
		button_go_dvine_over = newImage("/images/button-go-over-divine.gif");
		// waterplus
		button_friend_water_over = newImage("/images/products/water/button-friend-water-over.gif");
		// dairy-alt
		// so good
		// organics
        preloadFlag = true;
    }
}

// homepage
function goToProduct() {
   if ( document.showViewHomeForm.productList.selectedIndex >= 1 ) {
        var selInd;
        var url;
        selInd = document.showViewHomeForm.productList.selectedIndex;
        url = document.showViewHomeForm.productList.options[selInd].value;
        top.location.href = url;
    }
}

function goToProduct2() {
    var list = document.productForm.productList;
    if ( list.selectedIndex >= 1 ) {
        var selInd;
        var url;
        selInd = list.selectedIndex;
        url = list.options[selInd].value;
        top.location.href = url;
    }
}

function goToQaas() {
    if ( document.showViewHomeForm.qaaCat.selectedIndex >= 1 ) {
        var selInd;
        var catId;
        selInd = document.showViewHomeForm.qaaCat.selectedIndex;
        catId = document.showViewHomeForm.qaaCat.options[selInd].value;
        var goURL = "/qa/qaas.do?cat-id=" + catId;
        top.location.href = goURL;
    }
}


// questions and answers
function goToQaaTopic() {
    // grab index number of the selected option
    var selInd = document.ViewQAAHomeForm.lifeTopic.selectedIndex;
    // get the category id from the selected option
    var catId = document.ViewQAAHomeForm.lifeTopic.options[selInd].value;
    if ( catId != document.ViewQAAHomeForm.noJump.value ) {
        goURL = "/qa/qaas.do?cat-id=" + catId;
        top.location.href = goURL;
    }
}

// articles and information
function goToTopic() {
    if ( document.showViewArticleHomeForm.lifeTopic.selectedIndex >= 1 ) {
        var selInd;
        var catId;
        selInd = document.showViewArticleHomeForm.lifeTopic.selectedIndex;
        catId = document.showViewArticleHomeForm.lifeTopic.options[selInd].value;
        goURL = "/article/articles.do?cat-id=" + catId;
        top.location.href = goURL;
    }
}

// show/hide div
function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

//-->

/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;

