function menuToggle(id) {
	//first, make sure no brand nav dropdowns are open
	//they don't close automagically because of the cancelBubble attached to the main Product anchor
	closeInnerMenus();
	
	//next, grab the state and giv'er
	state=document.getElementById(id).style.display;
	switch (state) {
		case "block":
			document.getElementById(id).style.display="none";
			break;
		case "none":
			document.getElementById(id).style.display="block";
			break;
	}
}

function showhide(state,id){
	
	var cacheobj=document.getElementById(id).style
	if (state==0 || cacheobj.display=="block") { 
	closeInnerMenus();
	document.getElementById('productDrop').style.display="none";
	} else {
	closeInnerMenus();
	document.getElementById('productDrop').style.display="none";
	cacheobj.display=cacheobj.display=="none"? "block" : "none"
	}
}
document.onclick=function(){closeInnerMenus()}

function menuClose(id) {
	//just close the damn thing
	document.getElementById(id).style.display="none";
	
}

function closeInnerMenus() {
	
	
	/*
	// close all the innermenu divs - the dhtml brand dropdowns.
	if (document.getElementById('innermenu1')) {
		document.getElementById('innermenu1').style.display="none";
	}
	if (document.getElementById('innermenu2')) {
		document.getElementById('innermenu2').style.display="none";
	}
	if (document.getElementById('innermenu3')) {
		document.getElementById('innermenu3').style.display="none";
	}
	if (document.getElementById('innermenu4')) {
		document.getElementById('innermenu4').style.display="none";
	}
	
	*/
	for (i=1; i<=20 ; ++i)
	{
    	if (document.getElementById('innermenu' + i)) {
	    	document.getElementById('innermenu'+ i).style.display="none";
	    	}
	}
}

function clearStates() {
	//grab all the links in the menu and close them
	var allTheLinks=document.getElementById('productDrop').getElementsByTagName('a');
	for (x=0;x<allTheLinks.length;x++) {
		if (allTheLinks[x].id && allTheLinks[x].id!='link16') { //link19 is the All Products link so shouldn't have an arrow
			//alert(allTheLinks[x].id + " = " + id);
			allTheLinks[x].style.background="#fff url(/images/nav/arrow_off_james.gif) 95% 50% no-repeat";
		}else if (allTheLinks[x].id=='link16') {
			//alert(allTheLinks[x].id + " = " + id);
			allTheLinks[x].style.background="#fff";
		}
	}
} // end clearStates()

function changeState(id) {
	//controls the hover state of main product dropdown items while user browses the category flyouts
/*	
	//grab all the links in the menu and close them
	var allTheLinks=document.getElementById('productDrop').getElementsByTagName('a');
	for (x=0;x<allTheLinks.length;x++) {
		if (allTheLinks[x].id && allTheLinks[x].id!='link19') { //link19 is the All Products link so shouldn't have an arrow
			//alert(allTheLinks[x].id + " = " + id);
			allTheLinks[x].style.background="#fff url(/images/nav/arrow_off_james.gif) 95% 50% no-repeat";
		}else if (allTheLinks[x].id=='link19') {
			//alert(allTheLinks[x].id + " = " + id);
			allTheLinks[x].style.background="#fff";
		}
	}
*/

	clearStates();

	//now activate the hover on the cureently selected category, unless it's the All Products one
	if (id && id!='link16') { //link19 is the All Products link so shouldn't have an arrow
		document.getElementById(id).style.background="#DCEDFD url(/images/nav/arrow_on_james.gif) 95% 50% no-repeat";
	}else if (id=='link16') {
		document.getElementById(id).style.background="#DCEDFD";
	}	
}

/* Eolas Patent Workaround */

function CreateControl (divID, objID, url, w, h , wmode, vers, qual, bg, noFlashStr) {
	wmode = (wmode=='') ? '':'<param name="wmode" value="' + wmode + '" />'; 
	vers = (vers=='') ? '':'<param name="version" value="' + vers + '" />'; 
	qual = (qual=='') ? '':'<param name="quality" value="' + qual + '" />'; 
	bg = (bg=='') ? '':'<param name="bgcolor" value="' + bg + '" />'; 

  var d = document.getElementById(divID);

  d.innerHTML = 
	'<object id="'+objID+'" type="application/x-shockwave-flash"  data="'+url+'" width="'+w+'" height="'+h+'" >' +
	'<param name="movie" value="'+url+'" />' +
	wmode + vers + qual + bg +
	noFlashStr + '</object>';

}

// suckerfish stuff for the flyouts
sfHover = function() {
    if (document.getElementById("productDrop") == undefined || document.getElementById("productDrop") == null) return false;
	var sfEls = document.getElementById("productDrop").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function popper(url) {
	window.open("/usercontrols/products/popup.aspx?pUrl="+url,"Product_Popup","width=600,height=550,resizable=no,directories=no,copyhistory=no,status=no,scrollbars=yes");
	}

function resize(which, max) {
  var elem = document.getElementById(which);
  if (elem == undefined || elem == null) return false;
  if (max == undefined) max = 100;
  if (elem.width > elem.height) {
    if (elem.width > max) elem.width = max;
  } else {
    if (elem.height > max) elem.height = max;
  }
}


function NewWindow_No_loc(mypage, myname, w, h, scroll) 
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable,location=no'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function showPop(el) {
            if (document.getElementById(el).style.display=="block") {
                document.getElementById(el).style.display="none";
            } else {
                document.getElementById(el).style.display="block";
            }
        }
        
function makeMail(lang, textStr) {
    if (lang=="en") { // THIS REQUEST IS ENGLISH, SO MAKE AN ENGLISH WEBMASTER LINK
        var BrowserDetect = {
	        init: function () {
		        this.language = "%20[??]";
                        this.browser = this.searchString(this.dataBrowser) || "unknown%20browser";
		        this.version = this.searchVersion(navigator.userAgent)
			        || this.searchVersion(navigator.appVersion)
			        || "unknown%20version";
		        this.OS = this.searchString(this.dataOS) || "unknown%20OS";
	        },
	        searchString: function (data) {
		        for (var i=0;i<data.length;i++)	{
			        var dataString = data[i].string;
			        var dataProp = data[i].prop;
			        this.versionSearchString = data[i].versionSearch || data[i].identity;
			        if (dataString) {
				        if (dataString.indexOf(data[i].subString) != -1)
					        return data[i].identity;
			        }
			        else if (dataProp)
				        return data[i].identity;
		        }
	        },
	        searchVersion: function (dataString) {
		        var index = dataString.indexOf(this.versionSearchString);
		        if (index == -1) return;
		        return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	        },
	        dataBrowser: [
		        {
			        string: navigator.vendor,
			        subString: "Apple",
			        identity: "Safari"
		        },
		        {
			        prop: window.opera,
			        identity: "Opera"
		        },
		        {
			        string: navigator.vendor,
			        subString: "iCab",
			        identity: "iCab"
		        },
		        {
			        string: navigator.vendor,
			        subString: "KDE",
			        identity: "Konqueror"
		        },
		        {
			        string: navigator.userAgent,
			        subString: "Firefox",
			        identity: "Firefox"
		        },
		        {	// for newer Netscapes (6+)
			        string: navigator.userAgent,
			        subString: "Netscape",
			        identity: "Netscape"
		        },
		        {
			        string: navigator.userAgent,
			        subString: "MSIE",
			        identity: "Microsoft%20Internet%20Explorer",
			        versionSearch: "MSIE"
		        },
		        {
			        string: navigator.userAgent,
			        subString: "Gecko",
			        identity: "Mozilla",
			        versionSearch: "rv"
		        },
		        { 	// for older Netscapes (4-)
			        string: navigator.userAgent,
			        subString: "Mozilla",
			        identity: "Netscape",
			        versionSearch: "Mozilla"
		        }
	        ],
	        dataOS : [
		        {
			        string: navigator.platform,
			        subString: "Win",
			        identity: "Windows"
		        },
		        {
			        string: navigator.platform,
			        subString: "Mac",
			        identity: "Mac"
		        },
		        {
			        string: navigator.platform,
			        subString: "Linux",
			        identity: "Linux"
		        }
	        ]

        };
        BrowserDetect.init();
        //alert("lang=" + navigator.browserLanguage);
        if (navigator.browserLanguage) {
	        var language = navigator.browserLanguage; 
        } else if (navigator.language) {
	        var language = navigator.language; 
        }
        if (language.indexOf('en') > -1) BrowserDetect.language = ("%20[EN]"); 
        if (language.indexOf('fr') > -1) BrowserDetect.language = ("%20[FR]"); 

        document.write("<A HREF=mailto:webmaster@ca.nestle.com?subject=Technical%20Issue&body=")
        document.write("In%20order%20to%20better%20assist%20you%2c%20please%20include%20a%20detailed%20description%20of%20the%20problem%20you%20encountered%20on%20our%20site%2e");
        document.write("%0d%0dFor%20example%2c%20the%20system%20will%20not%20accept%20my%20UPC%2fPin%20code%2e%20Or%2c%20system%20will%20not%20accept%20my%20email%20address%2e"); 
        document.write("%0d%0dThank%20you%20for%20your%20help.%20Best%20Regards%2c"); 
        document.write("%0d%0dWebmaster%2c%20Nestlé Canada%20Inc%2e"); 
        document.write("%0d***********************************************************************************"); 
        document.write("%0d%0dEnter%20problem%20here%3a"); 
        document.write("%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a");
        document.write("Technical%20Information%3a%20"+BrowserDetect.browser);
        document.write("%20"+BrowserDetect.version);
        document.write("%20["+BrowserDetect.OS+"]");
        document.write(BrowserDetect.language);
        document.write("%0d%0aRefering%20URL:%20"+location.href+"%0d%0a");
        document.write(">"+textStr+"</A>")
        
     }else { //IS FRENCH, SO MAKE A FRENCH WEBMASTER LINK 
            
            var BrowserDetect = {
	        init: function () {
		        this.language = "%20[??]";
                        this.browser = this.searchString(this.dataBrowser) || "unknown%20browser";
		        this.version = this.searchVersion(navigator.userAgent)
			        || this.searchVersion(navigator.appVersion)
			        || "unknown%20version";
		        this.OS = this.searchString(this.dataOS) || "unknown%20OS";
	        },
	        searchString: function (data) {
		        for (var i=0;i<data.length;i++)	{
			        var dataString = data[i].string;
			        var dataProp = data[i].prop;
			        this.versionSearchString = data[i].versionSearch || data[i].identity;
			        if (dataString) {
				        if (dataString.indexOf(data[i].subString) != -1)
					        return data[i].identity;
			        }
			        else if (dataProp)
				        return data[i].identity;
		        }
	        },
	        searchVersion: function (dataString) {
		        var index = dataString.indexOf(this.versionSearchString);
		        if (index == -1) return;
		        return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	        },
	        dataBrowser: [
		        {
			        string: navigator.vendor,
			        subString: "Apple",
			        identity: "Safari"
		        },
		        {
			        prop: window.opera,
			        identity: "Opera"
		        },
		        {
			        string: navigator.vendor,
			        subString: "iCab",
			        identity: "iCab"
		        },
		        {
			        string: navigator.vendor,
			        subString: "KDE",
			        identity: "Konqueror"
		        },
		        {
			        string: navigator.userAgent,
			        subString: "Firefox",
			        identity: "Firefox"
		        },
		        {	// for newer Netscapes (6+)
			        string: navigator.userAgent,
			        subString: "Netscape",
			        identity: "Netscape"
		        },
		        {
			        string: navigator.userAgent,
			        subString: "MSIE",
			        identity: "Microsoft%20Internet%20Explorer",
			        versionSearch: "MSIE"
		        },
		        {
			        string: navigator.userAgent,
			        subString: "Gecko",
			        identity: "Mozilla",
			        versionSearch: "rv"
		        },
		        { 	// for older Netscapes (4-)
			        string: navigator.userAgent,
			        subString: "Mozilla",
			        identity: "Netscape",
			        versionSearch: "Mozilla"
		        }
	        ],
	        dataOS : [
		        {
			        string: navigator.platform,
			        subString: "Win",
			        identity: "Windows"
		        },
		        {
			        string: navigator.platform,
			        subString: "Mac",
			        identity: "Mac"
		        },
		        {
			        string: navigator.platform,
			        subString: "Linux",
			        identity: "Linux"
		        }
	        ]

        };
        BrowserDetect.init();
        //alert("lang=" + navigator.browserLanguage);
        if (navigator.browserLanguage) {
	        var language = navigator.browserLanguage; 
        } else if (navigator.language) {
	        var language = navigator.language; 
        }
        if (language.indexOf('en') > -1) BrowserDetect.language = ("%20[EN]"); 
        if (language.indexOf('fr') > -1) BrowserDetect.language = ("%20[FR]"); 
        document.write("<A HREF=mailto:webmaster@ca.nestle.com?subject=Probl%e9me%20technique&body=")
        document.write("Afin%20de%20pouvoir%20mieux%20vous%20aider%2c%20nous%20vous%20demandons%20d%27inclure%20une%20description%20d%e9taill%e9e%20du%20probl%e8me%20que%20vous%20avez%20eu%20sur%20notre%20site.");
        document.write("%0d%0dPar%20exemple%2c%20le%20syst%e8me%20n%27accepte%20pas%20mon%20code%20%e0%20barres%2fNIP%20ou%20le%20syst%e8me%20n%27accepte%20pas%20mon%20adresse%20%e9lectronique."); 
        document.write("%0d%0dMerci%20de%20votre%20aide%2e%20Cordiales%20salutations%2e"); 
        document.write("%0d%0dWebmestre%2c%20Nestl%e9%20Canada%20Inc%2e"); 
        document.write("%0d***********************************************************************************"); 
        document.write("%0d%0dIndiquez%20votre%20probl%e8me%20ici%3a"); 
        document.write("%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a");
        document.write("Technical%20Information:%20"+BrowserDetect.browser);
        document.write("%20"+BrowserDetect.version);
        document.write("%20["+BrowserDetect.OS+"]");
        document.write(BrowserDetect.language);
        document.write("%0d%0aRefering%20URL:%20"+location.href+"%0d%0a");
        document.write(">"+textStr+"</A>")
    }// END LANGUAGE DETECT
}//END makeMail SCRIPT