// Establish Browser Version according to implementation of DOM
// NS 4 and up uses "document.layers[whichLayer]"
// IE 4 and up uses "document.all[whichLayer]"
var n = (navigator.appName == "Netscape")
var n4 = (document.layers) ? 1:0
var ie = (navigator.appName == "Microsoft Internet Explorer")
var ie4 = (document.all) ? 1:0
var browserName = navigator.appName;


// NS 3 and up and IE 4 and up have rollover capability
var rolloversOK = 0;
browserVer = parseInt(navigator.appVersion);
if (n && browserVer >= 3) rolloversOK = 1;
else if (ie && browserVer >= 4) rolloversOK = 1;


// Test for Unix NS4 version & Mac IE4 version and don't allow DHTML elements in it
// These browser versions for Unix & Mac don't function properly with this DHTML
if (n4) {
	if (navigator.appVersion.indexOf("X11") >= 0) {
		n4 = 0;
	}
}
else if (ie4) {
 	if ((navigator.appVersion.indexOf("Macintosh") >= 0) || (navigator.appVersion.indexOf("Mac_") >= 0)) {
		ie4 = 0;
	}
}

//More Variables

// times out pop-up nav layer after mouseOut
var theTimeout = setTimeout("","1");

// position of pop-up nav layer is different for IE and NS					 
var top_adjust = 0;

var version = "no";		
var offset;
var browserWidth;
var browserOffset;
var pageWidth = 600;

// NS 4 pop-up position must be adjusted by 4 pixels
if (n4) {								
	version = "ok";
	top_adjust = 0;
}

// IE 4 pop-up position must be adjusted by 2 pixels
else if (ie4) {							
        version = "ok";
        top_adjust = 0;
}

// The Popup Menu Variables
//////////// This will need to be customized for each individual brand ///////////////////
// total number of pop-up layers
var totalMenus = 1;

// var doesn't change according to layer number
var menuPosX = 1;

// moves pop-up menu over to left
var moveOver = 0;

// designates color of td selected
var bgHot = "#FFFFFF";

// The Above color is different for each Nav Bar
var bgNormal = "#E696B4";

var menuPosY = new Array(totalMenus);		//var to determine y coordinate of menu
var itemsOnMenu = new Array(totalMenus);	//var to determine number of items in a particular menu
var menuItems = new Array(totalMenus);		//array that contains text of what is in the menus
var urlLinks = new Array(totalMenus);		//url links for text of what is in the menus
var lastMenu = -99;
var lastHotItem = -99;

// MENU 0: Robitussin Home
menuPosY[0] = 0 + top_adjust;
itemsOnMenu[0] = 0;

menuItems[0] = new Array(itemsOnMenu[0]);
urlLinks[0] = new Array(itemsOnMenu[0]);


// MENU 1: Robitussin Cough
//menuPosY[1] = 122 + top_adjust;
//itemsOnMenu[1] = 2;

//menuItems[1] = new Array(itemsOnMenu[1]);
//urlLinks[1] = new Array(itemsOnMenu[1]);

//menuItems[1][0] = "All Family";	                				urlLinks[1][0] = "/cough/cough1.asp";
//menuItems[1][1] = "Extra Strength";	        					urlLinks[1][1] = "/cough/cough2.asp";
//menuItems[1][2] = "Honey Remedies";	    						urlLinks[1][2] = "/honey/index.asp";
//menuItems[1][3] = "Liqui-Gels&reg;";	    					urlLinks[1][3] = "/cough/cough3.asp";


// MENU 2: Robitussin Honey Remedies
//menuPosY[2] = 140  + top_adjust;
//itemsOnMenu[2] = 3;

//menuItems[2] = new Array(itemsOnMenu[2]);
//urlLinks[2] = new Array(itemsOnMenu[2]);


//menuItems[2][0] = "Robitussin Honey Cough DM";	        		urlLinks[2][0] = "/honey/honeycough.asp";
//menuItems[2][1] = "Robitussin Honey Cough &amp; Cold";	    urlLinks[2][1] = "/honey/honeycough.asp";
//menuItems[2][2] = "Robitussin Honey Flu";					urlLinks[2][2] = "/honey/honeycough.asp";



// MENU 3: Robitussin Children's Cough
menuPosY[3] = 160 + top_adjust;
itemsOnMenu[3] = 2

menuItems[3] = new Array(itemsOnMenu[3])
urlLinks[3] = new Array(itemsOnMenu[3])

menuItems[3][0] = "Robitussin Children's Stubborn Cough DM";	        	urlLinks[3][0] = "/children/index.asp";
menuItems[3][1] = "Robitussin Children's Cough &amp; Cold ";	urlLinks[3][1] = "/children/index.asp";

// MENU 4: Cold & Flu Information
menuPosY[4] = 174 + top_adjust;
itemsOnMenu[4] = 0

menuItems[4] = new Array(itemsOnMenu[3])
urlLinks[4] = new Array(itemsOnMenu[3])


// MENU 5: Robitussin Formula Finder
menuPosY[5] = 195 + top_adjust;
itemsOnMenu[5] = 0

menuItems[5] = new Array(itemsOnMenu[5])
urlLinks[5] = new Array(itemsOnMenu[5])



// POPUP MENU FUNCTIONS

function doPopup (whichMenu, whichHotItem) {
		// doesn't do pop-ups if not DHTML browser
		if (version != "ok") {return} 
        
		// Moves menu over from left of window
        if (whichMenu == 0) { moveOver = 115; }
        else if (whichMenu == 1) { moveOver = 115; }
        else if (whichMenu == 2) { moveOver = 115; }
        else if (whichMenu == 3) { moveOver = 115; }
        else if (whichMenu == 4) { moveOver = 115; }
		else if (whichMenu == 5) { moveOver = 115; }
		else if (whichMenu == 6) { moveOver = 115; }
		else if (whichMenu == 7) { moveOver = 115; }
		else if (whichMenu == 8) { moveOver = 115; }
        
		// Clears the HidePopup timeout
        clearTimeout(theTimeout);

		// Do we have to redraw pop-up menu table?
        newMenu = 0
        if (whichMenu != lastMenu) {
                lastMenu = whichMenu
                newMenu = 1 
        }
        else if (whichHotItem != lastHotItem) {
                newMenu = 1	
        }
        
		// RENDERS THE POPUP TABLE IF IT'S NEVER BEEN RENDERED OR IS NOT THE LAST RENDERED TABLE
        if (newMenu) {
                lastHotItem = whichHotItem
				// popupWidth = "180"; insideWidth = "178";
                // popupWidth = "128"; insideWidth = "126";
				// Adjusts the size of each of the popup menus according to the size of text
				// Use only if need to alter width of popup menus individually
				// if ((whichMenu == 0) ||(whichMenu == 4)) { popupWidth = "56"; insideWidth = "54"; }
				if ((whichMenu == 0)){ popupWidth = "165"; insideWidth = "163"; }
				if ((whichMenu == 1)){ popupWidth = "160"; insideWidth = "178"; }
				if ((whichMenu == 2)){ popupWidth = "236"; insideWidth = "234"; }
				if ((whichMenu == 3)){ popupWidth = "250"; insideWidth = "248"; }
				if ((whichMenu == 4)){ popupWidth = "100"; insideWidth = "98"; }
				if ((whichMenu == 5)){ popupWidth = "110"; insideWidth = "108"; }
				if ((whichMenu == 6)){ popupWidth = "120"; insideWidth = "118"; }
				if ((whichMenu == 8)){ popupWidth = "180"; insideWidth = "178"; }
				//if ((whichMenu == 4)){ popupWidth = "179"; insideWidth = "177"; }
				// if ((whichMenu == 1) || (whichMenu == 2)) { popupWidth = "90"; insideWidth = "88"; }
				// the size of the height of each tr (leave alone)
                popupHeight = (itemsOnMenu[whichMenu] * 16)
				// theTable is a variable that holds the string of the entire table of the Popups
                theTable  = '<table width=' + popupWidth + ' height=' + (popupHeight + 3) + ' bgcolor=#A12A4E cellpadding=0 cellspacing=0 border=0><tr><td>\n'
                theTable += '<table align="center" valign="center" width=' + insideWidth + ' height=' + popupHeight + ' bgcolor=' + bgNormal + ' cellspacing=0 cellpadding=0 border=0>\n'
                theTable += '<tr><td width="100%" height=1></td></tr>\n' 
                for (x = 0; x < itemsOnMenu[whichMenu]; x++ ) {
                        bg2Use = bgNormal; class2Use = "notHot";
                        if (x == whichHotItem) { bg2Use = bgHot; class2Use = "notHot"; }
                        theTable += '<tr bgcolor=' + bg2Use + '><td height=15><a href="' + urlLinks[whichMenu][x] + '" class="' + class2Use + '" onMouseOver="doPopup(' + whichMenu + ',' + x + ');" onMouseOut="hideTime();">&nbsp;' + menuItems[whichMenu][x] + '</a></td></tr>\n'
                        if (x != itemsOnMenu[whichMenu]) { theTable += '<tr bgcolor=#A12A4E><td width="100%" height=1></td></tr>\n' }
                }
                theTable += '</table>\n</td></tr></table>\n'
				// Check for N4 and writes to the Layer tag
                if (n4) {
                        browserWidth = window.innerWidth;
                        browserOffset = 20;
                        //if (browserWidth < pageWidth ) {
                        // browserWidth = pageWidth;
                        //}
                        offset = (browserWidth - pageWidth)/2 + moveOver - 2;
        				// menuPosX = offset + browserOffset;
                        menuPosX = 49 + moveOver;
        
                        whichLayer = "nsPopup"
                        document.layers[whichLayer].visibility = 'hide'
                        document.layers[whichLayer].document.write(theTable)
                        document.layers[whichLayer].document.close()
                        if (whichHotItem == -1) {
                        document.layers["nsBuffer"].visibility = 'hide'
                        document.layers["nsBuffer"].document.write(theTable)
                        document.layers["nsBuffer"].document.close()
                        document.layers["nsBuffer"].moveTo(menuPosX, menuPosY[whichMenu])
                        document.layers["nsBuffer"].visibility = 'show'
                        }
                        document.layers[whichLayer].moveTo(menuPosX, menuPosY[whichMenu])
                        document.layers[whichLayer].visibility = 'show'
                }
				//Checks for IE4 and writes to the Div tag
                else if (ie4) {
                        browserWidth = parseInt(document.body.offsetWidth);
                        browserOffset = 20;
//                      if (browserWidth < pageWidth ) {
//                      browserWidth = pageWidth;
//                      }
                        offset = (browserWidth - pageWidth)/2 + moveOver;
//                      menuPosX = offset + browserOffset;
//                      menuPosX = offset - 70;
                        menuPosX = 49 + moveOver;

                        whichLayer = "iePopup"
                        document.all[whichLayer].innerHTML = theTable
                        document.all[whichLayer].style.posLeft = menuPosX
                        document.all[whichLayer].style.posTop = menuPosY[whichMenu]
                        document.all[whichLayer].style.visibility = 'visible'
                }
        }
}
// timeout funciton called to clear the layers and tables
// hideTme checks to see if not using a 4.0 browers it will make the roll over work or send it to the hidepopup.
function hideTime()
{
  	if (version != "ok")
	{
	cleanMe();
  	}
	else
	{
		theTimeout = setTimeout("hidePopups()", "400");
	}
}
		
//removes the layers or div and resets the rollover
function hidePopups()
{

  	lastMenu = -99
  	lastHotItem = -99
  	if (n4)
	{
        document.layers["nsPopup"].visibility = "hide";
        document.layers["nsBuffer"].visibility = "hide";
		cleanMe();
 	}
	else if (ie4)
	{ 
        document.all["iePopup"].style.visibility = 'hidden';
		cleanMe();
	}
}

//***********************************************************************
//                  End Dynamic HTML Popup Menu Code                   //
//***********************************************************************

// Preload images for rollovers
if(document.images)

{
var robitussin_home_on = new Image();
robitussin_home_on.src = "images/r_nav1_CH_on.gif";
var robitussin_home_off = new Image();
robitussin_home_off.src = "images/r_nav1_CH_off.gif";

var robitussin_cough1_on = new Image();
robitussin_cough1_on.src = "images/r_nav2_CH_on.gif";
var robitussin_cough1_off = new Image();
robitussin_cough1_off.src = "images/r_nav2_CH_off.gif";

var robitussin_cough2_on = new Image();
robitussin_cough2_on.src = "images/r_nav3_CH_on.gif";
var robitussin_cough2_off = new Image();
robitussin_cough2_off.src = "images/r_nav3_CH_off.gif";

var robitussin_children_on = new Image();
robitussin_children_on.src = "images/r_nav4_CH_on.gif";
var robitussin_children_off = new Image();
robitussin_children_off.src = "images/r_nav4_CH_off.gif";

var robitussin_cold_on = new Image();
robitussin_cold_on.src = "images/r_nav5_CH_on.gif";
var robitussin_cold_off = new Image();
robitussin_cold_off.src = "images/r_nav5_CH_off.gif";

var robitussin_formula_on = new Image();
robitussin_formula_on.src = "images/r_nav6_CH_on.gif";
var robitussin_formula_off = new Image();
robitussin_formula_off.src = "images/r_nav6_CH_off.gif";


var cough_dm_on = new Image();
cough_dm_on.src = "images/r_prodchild_1_on.jpg";
var cough_dm_off = new Image();
cough_dm_off.src = "images/r_prodchild_1_off.jpg";

var cough_cold_on = new Image();
cough_cold_on.src = "images/r_prodchild_2_on.jpg";
var cough_cold_off = new Image();
cough_cold_off.src = "images/r_prodchild_2_off.jpg";

}

// rollover active and inactive functions
function act(imgName) {
	if (document.images) {
	clearTimeout(theTimeout);
    hidePopups();
	document.robitussin_home_.src="images/r_nav1_CH_off.gif"; 
	document.robitussin_cough1_.src="images/r_nav2_CH_off.gif";
	document.robitussin_cough2_.src="images/r_nav3_CH_off.gif";
	document.robitussin_children_.src="images/r_nav4_CH_on.gif";
	document.robitussin_cold_.src="images/r_nav5_CH_off.gif";
	//document.robitussin_formula_.src="images/r_nav6_CH_off.gif";	
	document.cough_dm_.src="images/r_prodchild_1_off.jpg";	
	document.cough_cold_.src="images/r_prodchild_2_off.jpg";		
	document[imgName].src = eval(imgName + "on.src");
	}
}
function inact(imgName) {
	if (document.images) {
	document[imgName].src = eval(imgName + "off.src");
	document.robitussin_children_.src="images/r_nav4_CH_on.gif";
	}
}

// resets rollover images for browsers without DHTML
function cleanMe()
{
	document.robitussin_home_.src="images/r_nav1_CH_off.gif"; 
	document.robitussin_cough1_.src="images/r_nav2_CH_off.gif";
	document.robitussin_cough2_.src="images/r_nav3_CH_off.gif";
	document.robitussin_children_.src="images/r_nav4_CH_on.gif";
	document.robitussin_cold_.src="images/r_nav5_CH_off.gif";
	//document.robitussin_formula_.src="images/r_nav6_CH_off.gif";
	document.cough_dm_.src="images/r_prodchild_1_off.jpg";	
	document.cough_cold_.src="images/r_prodchild_2_off.jpg";	
	return;
}

// --&gt;


