
    //___________________________  BEGIN SIDENAV ___________________________//
    
    //Setup Inital Stuff
//    var navDivs = new Array()
//    var currentNav = null;

    //Search a sepcific div id and get all the div ids within it and put them in the Nav Array
//    function getNavDivs(whichDiv) {
//	    var mainID = document.getElementById(whichDiv);
//	    if (mainID != null) {
//			var subDivs = mainID.getElementsByTagName('div');
//			for (var i=0;i<subDivs.length;i++){
//				navDivs[i] = subDivs[i].id;
//			}
//	    }
//    }
    
    //Search a specific div id and count the links in it
//    function countNavLinks(whichDiv) {
//	    var mainID = document.getElementById(whichDiv);
//		if (mainID != null) {
//			var numberOfLinks = 0;
//			if (mainID) {
//				var links = mainID.getElementsByTagName('a');
//				for (var i=0;i<links.length;i++){
//					numberOfLinks++;
//				}
//			}
//			return numberOfLinks;
//		}
//    }
    
    //Hide all divs in the Nav Array
//    function hideNavDivs() {
//	    for (var i=0;i<navDivs.length;i++){
//		    document.getElementById(navDivs[i]).style.display = 'none';
//	    }
//    }
    
    //Make the div passed magically apear and everything else magically disappear
//    function showNavDiv(divID) {
//        if (divID != "" && divID != ''){
//	        hideNavDivs();
//	        var numberOfLinks = countNavLinks(divID);
//    	    
//	        //Last Opened should be the currently opened section... check if they match
//	        //They dont match... Set divID as current
//	        //They do match.. leave the section closed.. and reset so they can open it again
//	        //Also check number of links in the div.. if no links then we dont want to the nav to open either
//	        if ((currentNav != divID) && (numberOfLinks > 0)){
//	            currentNav = divID;
//	            document.getElementById(divID).style.display = 'block';
//	        }else{
//	            currentNav = null;
//	        }
//	    }
//    }
    
    //___________________________  END SIDENAV ___________________________//




	//___________________________  BEGIN PRODUCT TABS ___________________________//

	//General functions used by other functions
    function changeClass(divID, newClassName) {       
        var d = document.getElementById(divID);
        if(d!=null){d.className = newClassName;}        
	}
	function resetTabs() {
		changeClass('tab1','tab1-off');
		changeClass('tab2','tab2-off');
		changeClass('tab3','tab3-off');
	}
	function resetBoxes() {
		changeClass('box1','infoboxhidden');
		changeClass('box2','infoboxhidden');
		changeClass('box3','infoboxhidden');
	}
	
	//Change the Tabs
	function curTab(whichNav, newImg){
		if (whichNav == 1){
			resetTabs();
			changeClass('tab1','tab1-on');
		}
		else if (whichNav == 2){
			resetTabs();
			changeClass('tab2','tab2-on');
		}
		else if (whichNav == 3){
			resetTabs();
			changeClass('tab3','tab3-on');
		}
	}
	
	//Show and hide infoboxes
	function changeBox(whichBox){
		resetBoxes();
		changeClass(whichBox,'infobox');
	}
	
	// Because someone might want to link to a certain tab in the future... using the Anchor name to display certain info
	function checkProductInfoOnLoad(){
		var isTab = document.URL.indexOf('#');
		if (isTab != -1){ 
			currentTab = document.URL.substring(isTab+1, document.URL.length);
			
			if(currentTab == "ProductInfo"){
				changeBox('box1');
				curTab(1);
			}else if(currentTab == "Ingredients"){
				changeBox('box2');
				curTab(2);
			}else if(currentTab == "NutritionProfile"){
				changeBox('box3');
				curTab(3);
			}
		}
	}
	
	//___________________________  END PRODUCT TABS ___________________________//

	
	
	

    //___________________________  BEGIN ORDER SAMPLE ___________________________//
    
    //Setup Inital Stuff
    var sampleDiv;
    var orderInputs = new Array();
    var orderInputValues = new Array();
    var currentCanNum = 0;
    var currentDoctorNum = 0; 

    //Search a sepcific div id and get all the inputs within it and put them in the Order Array
    function getOrderInputs(whichDiv) {
        sampleDiv = whichDiv;
	    var mainID = document.getElementById(whichDiv);
	    var subDivs = mainID.getElementsByTagName('select');
	    for (var i=0;i<subDivs.length;i++){
	        orderInputs[i] = subDivs[i].id;
	        orderInputValues[i] = subDivs[i].value;
	    }

	    //Get value of the select from 'docNum' div to find out how many doctors there are
	    var docID = document.getElementById('docNum');
        var subDocDivs = docID.getElementsByTagName('select');
        currentDoctorNum = subDocDivs[0].value;
    }
    
    //When someone updates the 'number of cases' dropdowns we need to make sure they dont have too many
    //This is called from 'onchange' on the dropdown lists
    function checkCans() {
        currentCanNum = 0;
        for (var i=0;i<orderInputs.length;i++){
            currentCanNum += Number(document.getElementById(orderInputs[i]).value);
        }
        
        //Check if doctors went over their can limits and let them know if they did
        //If they did reset the boxes back to what they were.. if not get all the dropdown values again to use later
        if ( currentDoctorNum == 1 && currentCanNum > 2){
            showCaseError(currentCanNum - 2);
            //resetInputValues();
        }else if ( currentDoctorNum == 2 && currentCanNum > 4){
            showCaseError(currentCanNum - 4);
            //resetInputValues();
        }else if ( currentDoctorNum == 3 && currentCanNum > 6){
            showCaseError(currentCanNum - 6);
            //resetInputValues();
        } else {        
            getOrderInputs(sampleDiv);
        }
    }
    
    //They tried to choose too many cases so we have to set they dropdowns back to what they were before they tried to change it
    function resetInputValues() {
        for (var i=0;i<orderInputs.length;i++){
            document.getElementById(orderInputs[i]).value = orderInputValues[i];
        }
    
    }
    
    //Error when they have too many
    function showCaseError( num ) {
        if ( num > 1 ) {
            alert( "You have exceeded the cases you are eligible to receive by "+num+" cases. Please remove "+num+" cases from your order." );
        }else { 
            alert( "You have exceeded the cases you are eligible to receive by "+num+" case. Please remove "+num+" case from your order." );
        }
    }
    
    
    //___________________________  END ORDER SAMPLE ___________________________//
    
    
    


    // ___________________________ BEGIN TOPNAV ___________________________ //

    // Show iframe helper for topnav dropdown
    function showIFrame() {
        var iFRef = document.getElementById('dropcover');
        var divRef = document.getElementById('mp'); 
        iFRef.style.width = divRef.offsetWidth;
        iFRef.style.height = divRef.offsetHeight;
        iFRef.style.top = divRef.style.top;
        iFRef.style.left = divRef.style.left;
        iFRef.style.zIndex = divRef.style.zIndex -1;
        iFRef.style.display = "block";
    }

    // TopNav hover function for IE
    tnHover = function() {
	    var topNav = document.getElementById("topnav");
	    if (topNav == null) return;
    	
	    var tnEls = topNav.getElementsByTagName("LI");
	    if (tnEls == null) return;
    	
	    for (var i=0; i<tnEls.length; i++) {
		    tnEls[i].onmouseover=function() {
			    this.className+=" tnhover";
		    }
		    tnEls[i].onmouseout=function() {
			    this.className=this.className.replace(new RegExp(" tnhover\\b"), "");
		    }
	    }
    }
    if (window.attachEvent) window.attachEvent("onload", tnHover);

    // Get user's date for display in top blue area
    function GetMonth(nMonth) {
	    var Months = new Array("1","2","3","4","5","6", "7","8","9","10","11","12");
	    return Months[nMonth] 	  	 
    }
    function GetDayWeek(nDayWeek) {
	    var WeekDays = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	    return WeekDays[nDayWeek] 	  	 
    }
    function DateString() {
	    var Today = new Date();
	    var strDate = GetDayWeek(Today.getDay()) + ", " + GetMonth(Today.getMonth()) + "/" + Today.getDate() + "/" + Today.getFullYear();
	    return strDate
    }

	
//________________________ POPUP WINDOWS ___________________________
//============================================================================
// Description: function to pop up a small window (duh). If offset values are
// not given, then window is centered on the screen.
// Author: Adam Weston
// Usage: popup('page.html', 'name', width, height, toolbars, scrollbars, left_offset, top_offset);
// Omit a value for scrollbars if you need scrollbars.

function popup(loc, name, w, h, tb, sb, x, y) {
	if(!x && !y) {
		var scr_x = screen.width;
		var scr_y = screen.height;
		var x = (scr_x/2)-(w/2);
		var y = (scr_y/2)-(h/2);
	}
	
	var tb = (tb != 'no') ? "yes" : "no";
	var sb = (sb != 'no') ? "yes" : "no";
	var mb = (window.print) ? "no" : "yes";

	popupwin = window.open(loc, name, "toolbar="+tb+",location=no,directories=no,status=no,menubar="+mb+",scrollbars="+sb+",resizable=no,width="+w+",height="+h+",left="+x+",top="+y);
	popupwin.focus();
}

function printPage() {
	window.print();
}


//** Layer Build functions.  The IF verifies that, if a layer doesn't exist **
//** the function will return null instead of a JavaScript error. **
	function refLayer(layerName) {
		var LAYref;
		if (ie) {
			if (document.all[layerName]) {
				LAYref = document.all[layerName];
				HideText = "hidden";
			} else {
				LAYref = null;
			}
		} else {
		    // default to NS6+
			if (document.getElementById(layerName)) {
				LAYref = document.getElementById(layerName);
				HideText = "hidden";
			} else {
				LAYref = null;
			}
		}

		return LAYref;
	}


//********************************
//** Query String Parsing START **
//********************************

	// This loads all variables in a querystring into an associative array named qsVars
	// I.e., qsVars[variable_name] == variable_value when querystring is ?variable_name=variable_value&...
	var qsVars = new Array();

	var queryString = location.search;

	if (queryString != "") {
 		// -- get rid of ? at start --
  		var qsdata = queryString.slice(1,queryString.length);
		var qsvalues = qsdata.split("&");
		for (i=0; i < qsvalues.length; i++) {
			var qsvaluepair = qsvalues[i].split("=");
			//alert(qsvaluepair[0]);
			//alert(qsvaluepair[1]);
			qsVars[qsvaluepair[0]] = qsvaluepair[1];
		}
	}

//********************************
//** Query String Parsing END **
//********************************


//****************************
//** Flash Sniffing START ****
//****************************

	// Check for Flash, set vars if T/F
		var Flash5 = false;
		var Flash6 = false;
		var Flash7 = false;
		var FlashEnabled = false;
	// Default is False, so we only need to set it as True.
		if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ) {
			// Check for Flash in Netscape
			var nsFlash = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
			if (nsFlash) {
				var FlashVer = parseInt(nsFlash.description.substring(nsFlash.description.indexOf(".")-1));
				if (FlashVer >= 7) {
					Flash7 = true;
				} else if (FlashVer == 6) {
					Flash6 = true;
				} else if (FlashVer == 5) {
					Flash5 = true;
				}
			}
		} else if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
			var f5Inst;
			var f6Inst;
			var f7Inst;

			eval('try { f5Inst = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.5"); f6Inst = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); f7Inst = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); } catch (e) { }');

			if (f7Inst != null) {
				Flash7 = true;
			} else if (f6Inst != null) {
				Flash6 = true;
			} else if (f5Inst != null) {
				Flash5 = true;
			}

			f5Inst = null;
			f6Inst = null;
			f7Inst = null;
		}

		if (qsVars['flash'] == 'disabled') {
			Flash5 = false;
			Flash6 = false;
			Flash7 = false;
			// FlashEnabled default is false
		} else if (Flash7 || Flash6) {
			FlashEnabled = true;
		}


//**************************
//** Flash Sniffing END ****
//**************************


//****************************************************
//** Flash Sniffing/Inserter -- USE THIS -- START ****
//****************************************************

/*  SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/  */

if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){
_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+="/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}
_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();
return true;
}else{
if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(_23,_24){
var _25=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_25=new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{
var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){
axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
_25=new deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_23&&_25.major>_23.major){return _25;}
if(!_23||((_23.minor!=0||_23.rev!=0)&&_25.major==_23.major)||_25.major!=6||_24){
try{_25=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}
catch(e){}}}
return _25;};
deconcept.PlayerVersion=function(_29){
this.major=parseInt(_29[0])!=null?parseInt(_29[0]):0;
this.minor=parseInt(_29[1])||0;
this.rev=parseInt(_29[2])||0;};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}return true;};
deconcept.util={getRequestParameter:function(_2b){
var q=document.location.search||document.location.hash;
if(q){
var _2d=q.indexOf(_2b+"=");
var _2e=(q.indexOf("&",_2d)>-1)?q.indexOf("&",_2d):q.length;
if(q.length>1&&_2d>-1){
return q.substring(q.indexOf("=",_2d)+1,_2e);
}}return "";}};
if(Array.prototype.push==null){
Array.prototype.push=function(_2f){
this[this.length]=_2f;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject; // for backwards compatibility
var SWFObject=deconcept.SWFObject;

//**************************************************
//** Flash Sniffing/Inserter -- USE THIS -- END ****
//**************************************************

// requires jquery
function scrollTo(id) {
    var iTop = $("#" + id).offset().top;
    $("html,body").animate({ scrollTop: iTop }, 1000);
}

function ToggleNav(id) {
    $(".subitems").each(function() {        
        if(this.id!=id){
            $("#" + this.id).hide();
        }
    }
    );
    $("#" + id).toggle();
}



//function to set a cookie
function set_cookie(name, value, exp_y, exp_m, exp_d, path, domain, secure) {
    var cookie_string = name + "=" + escape(value);

    if (exp_y) {
        var expires = new Date(exp_y, exp_m, exp_d);
        cookie_string += "; expires=" + expires.toGMTString();
    }

    if (path)
        cookie_string += "; path=" + escape(path);

    if (domain) {
        domain = domain.replace("http://", ".");
        cookie_string += "; domain=" + escape(domain);
    }
    if (secure)
        cookie_string += "; secure";

    document.cookie = cookie_string;
}

//function to delete a cookie by name
function delete_cookie(cookie_name) {
    var cookie_date = new Date();  // current date & time
    cookie_date.setTime(cookie_date.getTime() - 1);
    document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

//function to get a cookie by name
function get_cookie(cookie_name) {
    var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');

    if (results)
        return (unescape(results[2]));
    else
        return null;
}

function getClientBounds() {
    var clientWidth; var clientHeight; 
    switch (Sys.Browser.agent) {
         case Sys.Browser.InternetExplorer:
            clientWidth = document.documentElement.clientWidth;
            clientHeight = document.documentElement.clientHeight; 
            break;
         case Sys.Browser.Safari:
             clientWidth = window.innerWidth; 
             clientHeight = window.innerHeight; 
            break; 
         case Sys.Browser.Opera:
             clientWidth = Math.min(window.innerWidth, document.body.clientWidth);
             clientHeight = Math.min(window.innerHeight, document.body.clientHeight);
             break; 
         default:
            clientWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);
            clientHeight = Math.min(window.innerHeight, document.documentElement.clientHeight); 
            break;
    }
    return new Sys.UI.Bounds(0, 0, clientWidth, clientHeight);
}

function getLocation(element) {
if (element === document.documentElement) {
return new Sys.UI.Point(0,0);}
if (Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version < 7) {
if (element.window === element || element.nodeType === 9 || !element.getClientRects || !element.getBoundingClientRect) return new Sys.UI.Point(0,0);var screenRects = element.getClientRects();if (!screenRects || !screenRects.length) {
return new Sys.UI.Point(0,0);}
var first = screenRects[0];var dLeft = 0;var dTop = 0;var inFrame = false;try {
inFrame = element.ownerDocument.parentWindow.frameElement;} catch(ex) {
inFrame = true;}
if (inFrame) {
var clientRect = element.getBoundingClientRect();if (!clientRect) {
return new Sys.UI.Point(0,0);}
var minLeft = first.left;var minTop = first.top;for (var i = 1;i < screenRects.length;i++) {
var r = screenRects[i];if (r.left < minLeft) {
minLeft = r.left;}
if (r.top < minTop) {
minTop = r.top;}
}
dLeft = minLeft - clientRect.left;dTop = minTop - clientRect.top;}
var ownerDocument = element.document.documentElement;return new Sys.UI.Point(first.left - 2 - dLeft + ownerDocument.scrollLeft, first.top - 2 - dTop + ownerDocument.scrollTop);}
return Sys.UI.DomElement.getLocation(element);}


//Expands the div to the full width and height of the browser
function ShowBackgroundElement(backgroundId) {
    /// <summary>
    /// Set the correct location of the background element to ensure that it is absolutely 
    /// positioned with respect to the browser.
    /// </summary>

    // Background element needs to cover the visible client area completely hence its
    // top and left coordinates need to be 0, and if relatively positioned its getlocation
    // value needs to be 0.
    var backgroundElement = document.getElementById(backgroundId);
    if (backgroundElement != null) {
        var isIE6 = (Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version < 7);
        if (isIE6) {
            var backgroundLocation = getLocation(backgroundElement);
            var backgroundXCoord = backgroundLocation.x;
            if (backgroundXCoord != 0) {
                // offset it by that amount. This is assuming only one level of nesting. If
                // multiple parents with absolute/relative positioning are setup this may not 
                // cover the whole background.
                backgroundElement.style.left = (-backgroundXCoord) + 'px';
            }

            var backgroundYCoord = backgroundLocation.y;
            if (backgroundYCoord != 0) {
                // offset it by that amount. This is assuming only one level of nesting. If
                // multiple parents with absolute/relative positioning are setup this may not 
                // cover the whole background.
                backgroundElement.style.top = (-backgroundYCoord) + 'px';
            }
        }
        var clientBounds = getClientBounds();
        var clientWidth = clientBounds.width;
        var clientHeight = clientBounds.height;
        
        backgroundElement.style.width = Math.max(Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), clientWidth) + 'px';
        backgroundElement.style.height = Math.max(Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), clientHeight) + 'px';

        backgroundElement.style.display = 'block';
        var obj = "test";
    }
}

function HideBackgroundElement(backgroundId) {
    var backgroundElement = document.getElementById(backgroundId);

    if (backgroundElement != null) {
        backgroundElement.style.display = 'none';
    }
}


function AddResizeScrollHandlers(backgroundId) {
    //add resize and scroll event handlers
    $addHandler(window, 'resize', function() { ShowBackgroundElement(backgroundId); });
    $addHandler(window, 'scroll', function() { ShowBackgroundElement(backgroundId); });
}

function RemoveResizeScrollHandlers() {
    $clearHandlers(window);
}

function HideModal(modalId, domain, cookieId) {
    var currentTime = new Date();
    var year = currentTime.getFullYear();
    var month = currentTime.getMonth() + 1;
    
    if (month > 12) {
        month = 1;
        year = year + 1;
    }

    var day = currentTime.getDate();
    if (day > 28) {
        day = 28;
    }
    
//    // only set allergy modal for a day
//    var nextDay = new Date();
//    nextDay.setDate(currentTime.getDate() + 1);
    
    //set the indication cookie
    set_cookie(cookieId, true, year, month, day, "/", domain, null);
    //set_cookie(cookieId, true, year, month, day, "/", domain, null);
    //set_cookie(cookieId, true, nextDay.getFullYear(), nextDay.getMonth(), nextDay.getDate(), "/", domain, null);
    
    RemoveResizeScrollHandlers();

    HideBackgroundElement(modalId)
}

//Initial function called by Flash to display takeover
function ShowModal(modalId, cookieId) {
    
    //determine whether to show the homepage takeover
    //if (!get_cookie("hasSeenModal")) {
    if (!get_cookie(cookieId)) {
        //if we have not yet seen the takeover

        ShowBackgroundElement(modalId);

        AddResizeScrollHandlers(modalId);

        return true;
    }
    else {
        return false;
    }
}

function ShowAllergyModal(modalId, cookieId) {
    if (!get_cookie(cookieId)) {
        ShowBackgroundElement(modalId);
        AddResizeScrollHandlers(modalId);
    }
    else {
        return false;
    }
}




