// Browser Detection 
function BrowserCheck() {
	var b = navigator.appName;	
	if (b=="Netscape") this.b = "ns";
	else if (b=="Microsoft Internet Explorer") this.b = "ie";
	else this.b = b;
	this.version = navigator.appVersion;
	//if (this.version.indexOf('Win')>0) this.os = "PC";
	//else if (this.version.indexOf('Mac')>0) this.os = "Mac";	
	this.WinOs = (this.version.indexOf('Win')>0);
	this.v = parseInt(this.version);
	this.ns = (this.b=="ns" && this.v>=4);
	this.ns4 = (this.b=="ns" && this.v==4);
	this.ns5 = (this.b=="ns" && this.v>=5);
	this.ie = (this.b=="ie" && this.v>=4);
	this.ie4 = (this.version.indexOf('MSIE 4')>0);
	this.ie5 = (this.version.indexOf('MSIE 5')>0);
	this.ie6 = (this.version.indexOf('MSIE 6')>0);
	this.min = (this.ns||this.ie);
}
var browser = new BrowserCheck();

function resetGuides(){	
	var height_difference = 100;
	if (browser.ns){ 		
		window_height = self.innerHeight;		
	}else if (browser.ie6){
		window_height = parseInt(document.documentElement.clientHeight);		
	}else{
		window_height = parseInt(document.body.clientHeight)		
	}	
	center_row_height = window_height - height_difference; 
	if (getElmtRef('content').offsetHeight < center_row_height && getElmtRef('sideNav').offsetHeight < center_row_height){
		center_row_height = window_height - getElmtRef('mainLogo').offsetHeight - getElmtRef('footer').offsetHeight - height_difference; 
		getElmtRef('content').style.height = center_row_height + 'px';
	}
}
	
	

//window.onload = new Function("displayCorrectHeader();");
//window.onresize = new Function("resetGuides();");

var allcookies = document.cookie;


function getElmtRef(strElmtId) {
	if (!document.getElementById) {
		return document.all[strElmtId];
	} else {
		return document.getElementById(strElmtId);
	}
}

//IMAGE ROLLOVERS
function imgOn(imgName) { document[imgName].src = eval(imgName + "_on.src"); }
function imgOff(imgName) { document[imgName].src = eval(imgName + "_off.src"); }
function hightLightOn(imgName,highlightName){ 
	document[imgName].src = eval(highlightName + "_hlight.src"); 
}
function hightLightOff(imgName,highlightName){ 
	document[imgName].src = eval(highlightName + "_hlight.src"); 
}

//IMAGE CACHING
var oImgPath = new Object();
oImgPath.leftnav = "img/left_nav/";
oImgPath.globalnav = "img/shared/";
oImgPath.nutrition = "img/nutrition_facts/";
oImgPath.simpPleasure = "img/simp_pleasure/";
oImgPath.sweetRecipes = "img/sweet_recipes/";

function cacheImg(name,src,rollover,type){
	if (!type) var type = "gif";
	if (rollover==true){
		eval(name + "_off =  new Image");
		eval(name + "_off.src = \'" + src + name + "_off." + type + "\'");
		eval(name + "_on =  new Image");
		eval(name + "_on.src = \'" + src + name + "_on." + type + "\'");
		eval(name + "_hlight =  new Image");
		eval(name + "_hlight.src = \'" + src + name + "_hlight." + type + "\'");
		eval("home" + name + "_hlight =  new Image");
		eval("home" + name + "_hlight.src = \'" + src + "home" +name + "_hlight." + type + "\'");
	} else {
		eval(name + " = new Image");
		eval(name + ".src = \'"+src+name+"."+type+"\'");
	}
}

navoff_hlight = new Image;
navoff_hlight.src = oImgPath.leftnav + 'navoff_hlight.gif';

homenavoff_hlight = new Image;
homenavoff_hlight.src = oImgPath.leftnav + 'homenavoff_hlight.gif';

cacheImg('navenjoy',oImgPath['leftnav'],true);
cacheImg('navlearn',oImgPath['leftnav'],true);
cacheImg('navshop',oImgPath['leftnav'],true);
cacheImg('navrecipes',oImgPath['leftnav'],true);

cacheImg('global_consumers',oImgPath['globalnav'],true);
cacheImg('global_distributors',oImgPath['globalnav'],true);
cacheImg('global_healthProf',oImgPath['globalnav'],true);

cacheImg('recipes_beverages',oImgPath['sweetRecipes'],true);
cacheImg('recipes_sauces',oImgPath['sweetRecipes'],true);
cacheImg('recipes_baked',oImgPath['sweetRecipes'],true);

cacheImg('calories',oImgPath['nutrition'],true);
cacheImg('serving',oImgPath['nutrition'],true);
cacheImg('sugaralcohol',oImgPath['nutrition'],true);
cacheImg('totalcarb',oImgPath['nutrition'],true);
cacheImg('totalfat',oImgPath['nutrition'],true);

cacheImg('mind',oImgPath['simpPleasure'],true);
cacheImg('body',oImgPath['simpPleasure'],true);
cacheImg('spirit',oImgPath['simpPleasure'],true);

cacheImg('beverages',oImgPath['sweetRecipes'],true);
cacheImg('sauces',oImgPath['sweetRecipes'],true);
cacheImg('baked',oImgPath['sweetRecipes'],true);


function leftNavOn(ctl){
	if(onSection != "null"){
		if (onSection == "home"){
			imgOn(ctl);
			hightLightOn('highlight',"home"+ctl);
		}else{
			imgOn(ctl);
			imgOff(onSection);
			hightLightOn('highlight',ctl);
		}		
	}else{
		imgOn(ctl);
		hightLightOn('highlight',ctl);
	}	
}
function leftNavOff(ctl){
	if(onSection != "null"){
		if (onSection == "home"){
			imgOff(ctl);
			hightLightOff('highlight','homenavoff');
		}else{
			imgOff(ctl);
			imgOn(onSection);
			hightLightOn('highlight',onSection);
		}			
	}else{
		imgOff(ctl);
		hightLightOff('highlight','navoff');
	}
	
}	

function globalOn(ctl, ctl2){
	document[ctl].src = eval(ctl2 + "_on.src");
}

function globalOff(ctl, ctl2){
	document[ctl].src = eval(ctl2 + "_off.src");
}

function noFlashUpgrade(url){
	document.cookie = "userFlashUpgrade=False";
	window.location.replace(url);	
}

function openWinNew(html, name, params ) 
{ 


    var n=open (html, name,params); 
    n.focus(); 
   
} 