/*** 
 * Shop@ JavaScript Menu System
 *
 * COPYRIGHT 2000 AMERICA ONLINE, INC.
 * Version: 1.4.0 -- generic to service
 * History:
 * [2000/06/14] creation by EK 
 * [2000/07/14] added hook for support for 2.x and 3.x browsers
 * [2000/08/03] added more constants, support for submenu colors,
 * 	and drop down menus (KJB)
 * [2000/08/07] changed implementation to support Netscape (EK)
 *              - Wrapped Label
 * [2000/08/10] added Unsupported function, Mac detection (KJB)
 * [2000/09/21] fixed nav issue on NS Mac/Linux/Unix (KJB)
 */

/** CONSTANTS */
COLOR_MENU_ITEM_SELECTED = "#E6E6C2";
COLOR_MENU_ITEM    = "#F4F4D9";
COLOR_SUBMENU_ITEM = "#E6E6C2";
COLOR_SUBMENU_ITEM_SELECTED	= "#F8FE78";
WIDTH_MAINMENU = 170;
WIDTH_SUBMENU = 150;
TIMER_MOUSE_OUT_DELAY = 400;
TYPE = 1;
TYPE_DROPDOWN = 0;
TYPE_FLYOUT = 1;
TOP_FONT_SPECS = "<FONT FACE='Verdana, sans-serif' SIZE='1.5' COLOR='#5668BE'>"
SUB_FONT_SPECS = "<FONT FACE='Verdana, sans-serif' SIZE='1' COLOR='#5668BE'>";
BULLET_CODE = "&nbsp;<img src='" + __js_homeURL + "/images/left/dot.gif'>&nbsp;"
EXPAND_CODE = "" //"<img src='/images/left/right_arrow.gif' border=0 align='bottom' width='8' height='10'>"
HTML_OLD_BROWSER = "<b>Please enable JavaScript or upgrade your web browser. This menu requires JavaScript 1.2.</b>";

/** GLOBAL VARIABLES */
gCurrentResource = null;
gMouseOutTimer   = null;
gMenuBarName	  = "TheMenuBar";


    var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
                && (agt.indexOf('webtv')==-1)); 
    var is_nav4up = (is_nav && (is_major >= 4)); 
    var is_ie   = (agt.indexOf("msie") != -1);
    var is_ie3  = (is_ie && (is_major < 4));
    var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) );
    var is_ie4up  = (is_ie  && (is_major >= 4));
    var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_mac    = (agt.indexOf("mac")!=-1);
    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
    				(agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
    				(agt.indexOf("powerpc")!=-1)));
    var is_gecko = (agt.indexOf("gecko")!=-1);


	if (is_mac && !(is_nav)) {
		DisplayMenu = MAC_DisplayMenu;
	} else 	if (is_ie4up || is_gecko) {
		DisplayMenu = Flyout;
	} else if (is_nav4up){
		DisplayMenu = NS_DisplayMenu;
	} else {
		DisplayMenu = Unsupported_DisplayMenu;
	}

/** GLOBAL HELPER FUNCTIONS */


function MAC_DisplayMenu() {
	var mod_collapse_code = COLLAPSE_CODE.split("=\'");
	var mod_collapse_code2 = mod_collapse_code[1].split("\' ");
	COLLAPSE_CODE = mod_collapse_code2[0];

	var mod_expand_code = EXPAND_CODE.split("=\'");
	var mod_expand_code2 = mod_expand_code[1].split("\' ");
	EXPAND_CODE = mod_expand_code2[0];
	// End

	if ( __menuModel ) {
		explodeCode = "";
		counter = 1;
		for ( var label in __menuModel ) {
			var res = __menuModel[label];

			//Single Categories with no subcat
			if ( res.length ) {
				var id = "I_" + counter;
				explodeCode += MAC_newMenuItem( id, label, res );
				

			//Categories with sub elements.
			} else {
				if (res) {
					var id = "C_" + counter;
					explodeCode += MAC_newSubMenu( id, label, res );
				}
			}
			counter++;
		}
	}
	document.write(explodeCode);
}

function MAC_SubNav( id ) {
	handle=eval ("document.all." + id);
	subnav =  eval ("document.all." + id + "nav");
	var newImage= eval ("document.img" + id);

	if (subnav.style.display == "block") {
	    handle.style.backgroundColor = COLOR_MENU_ITEM;
	    subnav.style.display = "none";
	    newImage.src = EXPAND_CODE;
	    
	} else {
	    handle.style.backgroundColor = HIGHLIGHT_COLOR;
	    subnav.style.display = "block";
	    newImage.src = COLLAPSE_CODE;
	}

}

	
function MAC_SetBackgroundColor( id, color, state ){
	var view = eval("document.all." + id);
	var isContainer = id.charAt(0);
	if( isContainer == "C" ) {
		subnav = eval ("document.all." + id + "nav");
		if( subnav.style.display == "block" ) {
			return;			
		}
	}
	
	
	if( view != null ){
		view.style.backgroundColor = color; 
	}
	
}	

function MAC_newMenuItem( id, label, res ) {
	var newMenuItemCode = "<DIV style=\"width:" + WIDTH_MAINMENU + "; BACKGROUND-COLOR:" + COLOR_MENU_ITEM + ";\" id=\"" + id + "\" onmouseout=\"MAC_SetBackgroundColor(' " + id + "','" + COLOR_MENU_ITEM + "\','OUT');\" onmouseover=\"MAC_SetBackgroundColor(' " + id + "','" + HIGHLIGHT_COLOR + "\','OVER');\"><B>";
	newMenuItemCode += TOP_FONT_SPECS + BULLET_CODE + "</FONT><A HREF=\"";
	newMenuItemCode += res;
	newMenuItemCode += "\"STYLE=\"text-decoration:none\">";
	newMenuItemCode += TOP_FONT_SPECS;
	newMenuItemCode += label;
	newMenuItemCode += "</FONT></A></B></DIV>";
	return newMenuItemCode;
}

function MAC_newSubMenu( id, label, res ) {
	var newSubMenuCode = "<DIV  style=\"width:" + WIDTH_MAINMENU +"; BACKGROUND-COLOR:" + COLOR_MENU_ITEM + ";\" onclick=\"MAC_SubNav('" + id + "')\" onmouseout=\"MAC_SetBackgroundColor('" + id + "','" + COLOR_MENU_ITEM + "\','OUT');\" onmouseover=\"MAC_SetBackgroundColor('" + id + "','" + HIGHLIGHT_COLOR + "\','OVER');\" id=\"" + id;
	newSubMenuCode += "\" CLASS=\"MenuItem\" STYLE=\"cursor:hand\">";
	newSubMenuCode += TOP_FONT_SPECS + BULLET_CODE;
	newSubMenuCode += label;
	newSubMenuCode += "<img name=\"img";
	newSubMenuCode += id;
	newSubMenuCode += "\" src=\"";
	newSubMenuCode += EXPAND_CODE;
	newSubMenuCode += "\" border=0 align='bottom' width='10' height='10'>";
	newSubMenuCode += "</FONT></DIV>\n";
	newSubMenuCode += "<DIV id=\"" + id + "nav\"";
	newSubMenuCode += "style=\"display:none; background:" + COLOR_SUBMENU_ITEM + "\";>";
	var counter2 = 1;
	for (var sublabel in res) {
		var subid = "I_" + counter + "_" + counter2;
		var subres = res[sublabel];
		newSubMenuCode += MAC_newSubMenuItem( subid, sublabel, subres );
		counter2++;
	}
	newSubMenuCode += "</DIV>\n";
	return newSubMenuCode;
}

function MAC_newSubMenuItem( id, label, res ) {
	var newSubMenuItemCode = "<DIV style=\"width:" + WIDTH_MAINMENU + "px;\" id=\"" + id + "\" onmouseout=\"MAC_SetBackgroundColor(' " + id + "','" + COLOR_SUBMENU_ITEM + "\','OUT');\" onmouseover=\"MAC_SetBackgroundColor(' " + id + "','" + COLOR_SUBMENU_ITEM_SELECTED + "\','OVER');\">";
	newSubMenuItemCode += "<table border='0' cellpadding='0' cellspacing='0'><tr valign='top'><td width='15' ALIGN='RIGHT'>" + TOP_FONT_SPECS + BULLET_CODE + "</font></td><td><A HREF=\"";
	newSubMenuItemCode += res;
	newSubMenuItemCode += "\"STYLE=\"text-decoration:none\">";
	newSubMenuItemCode += TOP_FONT_SPECS;
	newSubMenuItemCode += label;
	newSubMenuItemCode += "</FONT></A></td></tr></table></DIV>";	
	return newSubMenuItemCode;
}

function Flyout(){

	document.write( "<div id='TheFloatingMenu' style='width:"+WIDTH_SUBMENU+"' class='FloatingMenu' onmouseover='OnHandleFMMouseOver()' onmouseout='OnHandleFMMouseOut()' onselectstart='return false;'></div>" );

	SetBackgroundColor( "TheFloatingMenu", COLOR_MENU_ITEM );

	var tagName = "div";
	if( TYPE == TYPE_DROPDOWN ){
		tagName = "span";
	}
	
	for( var rid in __oMenuModel ){
		var res  = __oMenuModel[rid];
		var html = "";
		if( res.isContainer() ){
			for(var mainCatID in res.map)
			{
				break;
			}
			html= "<" + tagName + " id='"+rid+"' style='width:" + WIDTH_MAINMENU + "' class='MenuItem' onselectstart='return false;' onmouseout='OnHandleMouseOut(\""+rid+"\")' onmouseover='OnHandleMouseOver(\""+rid+"\")' onClick='onMainCatClick(\"" + res.map[mainCatID] + "\")'>" + TOP_FONT_SPECS 
				+ BULLET_CODE
				+		__oMenuModel[rid].asHTML() 
				+ EXPAND_CODE
				+ "</font></" + tagName + ">";
		} else {
			alert(__oMenuModel[rid].rid);
			html= "<" + tagName + " id='"+rid+"' style='width:" + WIDTH_MAINMENU + "' class='MenuItem' onselectstart='return false;' onmouseout='OnHandleMouseOut(\""+rid+"\")' onmouseover='OnHandleMouseOver(\""+rid+"\")' onclick='OnHandleClick(\""+rid+"\")'>" + TOP_FONT_SPECS  
				+ BULLET_CODE
				+		__oMenuModel[rid].asHTML() 
				+ "</font></" + tagName + ">";		
		}

		document.write( html );

		SetBackgroundColor( rid, COLOR_MENU_ITEM );
	}
}

function onMainCatClick(url)
{
	location.href = url;
}

function OnHandleMouseOver( resID ){
	ClearMouseOutTimer();
	HideSubmenu();
	ShowSubmenu( __oMenuModel[resID] );
}

function OnHandleMouseOut( resID ){
	InitMouseOutTimer();
}

function OnHandleClick( resID ){
	ClearMouseOutTimer();
	HideSubmenu();
	var res = __oMenuModel[resID];
	OpenItem( res.getURL() );
}

function OnHandleFMMouseOver(){
	ClearMouseOutTimer();
}

function OnHandleFMMouseOut(){
	InitMouseOutTimer();
}

function InitMouseOutTimer(){
	ClearMouseOutTimer();
	gMouseOutTimer = setTimeout("HideSubmenu();", TIMER_MOUSE_OUT_DELAY)
}

function ClearMouseOutTimer(){
	clearTimeout(gMouseOutTimer);
}

function OpenFlyout( x0, y0, htmlContent ){
	SetLeft( "TheFloatingMenu", x0 );
	SetTop( "TheFloatingMenu", y0 );
	SetContent( "TheFloatingMenu", htmlContent );
	SetVisibility( "TheFloatingMenu", "visible" );
}

function CloseFlyout(){
	SetVisibility( "TheFloatingMenu", "hidden" );
	SetContent( "TheFloatingMenu", "" );
}

function SetLeft( id, x0 ){
	var view = grabObject(id);
	if( view != null ){
	view.style.left = x0 + "px"; 
	
	}		
}

function SetTop( id, y0 ){
	var view = grabObject(id);
	if( view != null ){
		view.style.top = y0 + "px"; 
	}			
}

function GetLeft( id ){
	var view = grabObject(id);
	if( view != null ){
		var xPos = view.offsetLeft;
		return xPos;
		
	} else {
		return 0;
	}	
}

function GetTop( id ){
	var view = grabObject(id);
	if( view != null ){
		return view.offsetTop; 
	} else {
		return 0;
	}	
}

function GetHeight( id ){
	var view = grabObject(id);
	if( view != null ){
		return view.offsetHeight; 
	} else {
		return 0;
	}	
}

function GetWidth( id ){
	return WIDTH_MAINMENU;
}

function SetContent( id, htmlContent ){
	var view = grabObject(id);
	if( view != null ){
		view.innerHTML = htmlContent; 
	}		
}

function SetVisibility( id, str ){
	var view = grabObject(id);
	if( view != null ){
		view.style.visibility = str; 
	}	
}

function SetBackgroundColor( rid, color ){
	var view = grabObject(rid);
	if( view != null ){
		view.style.backgroundColor = color; 
	}
}

function OnHandleFMIMouseOver( id ){
	SetBackgroundColor( id, COLOR_SUBMENU_ITEM_SELECTED );
}

function OnHandleFMIMouseOut( id ){
	SetBackgroundColor( id, COLOR_SUBMENU_ITEM );
}

function grabObject( id ) {
if(is_ie4) {
	view = eval( id );
	}
if(is_ie5up || is_gecko) {
	view = document.getElementById(id);
	}
	return view;
	}


function ShowSubmenu( res ){
   if( gCurrentResource == res ){
		return;
	}

	var id = res.id;
	if( id == null ){
		alert( "Resource does not have an id" );
		return;
	}

	SetBackgroundColor( id, COLOR_MENU_ITEM_SELECTED );

	if(  res.isContainer() ){	
		var html = "";
		var counter = 0;

		if (TYPE == TYPE_DROPDOWN ) {
			var x0 = GetLeft( id );
			var y0 = GetTop( id ) + GetHeight( id );
		} else {
			var x0 = GetLeft( id ) + GetWidth( id );
			var y0 = GetTop( id );
		}


		for( var label in res.map ){
			if(counter>0) html += ItemAsHTML( counter, label, res.map[label] );
			counter ++;
		}

		OpenFlyout( x0, y0, html );
	}

	gCurrentResource = res;
}

function ItemAsHTML( id, label, url ){
	var html = "<div id='FMI" + id + "' width='100%' STYLE='background:" + COLOR_SUBMENU_ITEM + "' class='MenuItem' onselectstart='return false;' onmouseout='OnHandleFMIMouseOut( this.id )' onmouseover='OnHandleFMIMouseOver( this.id )' onclick='OpenItem(\""+ url +"\")'>" + SUB_FONT_SPECS 
			 +  BULLET_CODE
			 +  label			  
			 +  "</font></div>";
	return html;		
}

function HideSubmenu(){
	if( gCurrentResource == null ){
		return;
	}
	CloseFlyout();
	SetBackgroundColor( gCurrentResource.id, COLOR_MENU_ITEM );
	gCurrentResource = null;
}

function OpenItem( url ){
	document.location = url;
}


/** GLOBAL HELPER FUNCTIONS */

function NS_DisplayMenu(){

	document.write( "<layer id='TheFloatingMenu' width='" + WIDTH_SUBMENU + "' onmouseover='NS_OnHandleFMMouseOver()' onmouseout='NS_OnHandleFMMouseOut()'></layer>" );

	NS_SetBackgroundColor( "TheFloatingMenu", COLOR_MENU_ITEM );

	var totItems = 0;
	for( var rid in __oMenuModel ){
		totItems ++;
	}
	
	var width = WIDTH_MAINMENU;
	if( TYPE == TYPE_DROPDOWN ){
		width = totItems * WIDTH_MAINMENU
	}

	var counter = 0;
		
   document.write( "<table cellpadding=0 cellspacing=0 border=0 width="+width+"><tr><td>" );	
   document.write( "<ilayer id='" + gMenuBarName + "'>" );	
	for( var rid in __oMenuModel ){
		var res  = __oMenuModel[rid];
		var html = "";

		if( res.isContainer() ){
			html= "<layer id='" + rid + "' class='NSMenuItem' width='" + WIDTH_MAINMENU + "' onmouseout='NS_OnHandleMouseOut(\""   + rid + "\")' onmouseover='NS_OnHandleMouseOver(\"" + rid + "\")'>" + TOP_FONT_SPECS 
			+  BULLET_CODE
			+ "<A HREF='#' class='NSMenuItem' onclick='return false'>" + TOP_FONT_SPECS
			+	__oMenuModel[rid].asHTML() 
 			+ "</font></A>"
  			+ EXPAND_CODE
			+ "</font></layer>"
			+ "<ilayer id='" + rid + "Shadow' class='NSMenuItem' visibility = 'hidden'>" + TOP_FONT_SPECS 
			+  BULLET_CODE
			+ "<A HREF='#' class='NSMenuItem' onclick='return false'>" + TOP_FONT_SPECS
			+	__oMenuModel[rid].asHTML() 
 			+ "</font></a>"
  			+ EXPAND_CODE
			+ "</font></ilayer>"

		} else {
			var url =  res.getURL();
			html= "<layer id='" + rid + "' class='NSMenuItem' width='" + WIDTH_MAINMENU + "' onmouseout='NS_OnHandleMouseOut(\"" + rid + "\")' onmouseover='NS_OnHandleMouseOver(\"" + rid + "\")'>" + TOP_FONT_SPECS
			+ BULLET_CODE
			+ "<A HREF='" + url + "' class='NSMenuItem' onmouseout='NS_OnHandleMouseOut(\"" + rid + "\")' onmouseover='NS_OnHandleMouseOver(\"" + rid + "\")' onclick='NS_OnHandleClick(\"" + rid + "\")'>" 
 			+ TOP_FONT_SPECS
			+   __oMenuModel[rid].asHTML() 
			+ "</font></a>"
			+ "</font></layer>"
			+ "<ilayer id='" + rid + "Shadow' class='NSMenuItem' visibility = 'hidden'>" + TOP_FONT_SPECS
			+ BULLET_CODE
			+ "<A HREF='" + url + "' class='NSMenuItem' onmouseout	='NS_OnHandleMouseOut(\"" + rid + "\")' onmouseover='NS_OnHandleMouseOver(\"" + rid + "\")' onclick    ='NS_OnHandleClick(\"" + rid + "\")'>" 
 			+ TOP_FONT_SPECS
			+   __oMenuModel[rid].asHTML()     
			+ "</font></a>"
			+ "</font></ilayer>"
		}
		
		if( TYPE == TYPE_FLYOUT ){
			html = html + "<br>";
		}
		counter ++;
		document.write( html );
	}
	document.write( "</ilayer></td></tr></table>" );
	var previousItem = null;
	for( var rid in __oMenuModel ){
		if( previousItem != null ){
			// document.getElementByID(elementname)  
			var dx = document.layers[gMenuBarName].document.layers[ previousItem ].clip.width;
			var dy = document.layers[gMenuBarName].document.layers[ previousItem ].clip.height;

			if( TYPE == TYPE_FLYOUT ){
				dx = 0;
			} else {
				dy = 0;
			}
 			document.layers[gMenuBarName].document.layers[ rid ].top  = 
			document.layers[gMenuBarName].document.layers[ previousItem ].top  + dy ;
 			document.layers[gMenuBarName].document.layers[ rid ].left = 
			document.layers[gMenuBarName].document.layers[ previousItem ].left + dx ;
		}	

		NS_SetBackgroundColor( rid, COLOR_MENU_ITEM );
		NS_SetVisibility( rid, "visible" );
		previousItem = rid;
	}
}

function NS_OnHandleMouseOver( resID ){
	NS_ClearMouseOutTimer();
	NS_HideSubmenu();
	NS_ShowSubmenu( __oMenuModel[resID] );
}

function NS_OnHandleMouseOut( resID ){
	NS_InitMouseOutTimer();
}

function NS_OnHandleClick( resID ){
	NS_ClearMouseOutTimer();
	NS_HideSubmenu();
	var res = __oMenuModel[resID];
	NS_OpenItem( res.getURL() );
}

function NS_OnHandleFMMouseOver(){
	NS_ClearMouseOutTimer();
}

function NS_OnHandleFMMouseOut(){
	NS_InitMouseOutTimer();
}

function NS_InitMouseOutTimer(){
	NS_ClearMouseOutTimer();
	gMouseOutTimer = setTimeout("NS_HideSubmenu();", TIMER_MOUSE_OUT_DELAY)
}

function NS_ClearMouseOutTimer(){
	clearTimeout(gMouseOutTimer);
}

function NS_OpenFlyout( x0, y0, htmlContent ){
	NS_SetLeft( "TheFloatingMenu", x0 );
	NS_SetTop( "TheFloatingMenu", y0 );
	NS_SetContent( "TheFloatingMenu", htmlContent );
	NS_SetVisibility( "TheFloatingMenu", "visible" );
}

function NS_CloseFlyout(){
	NS_SetVisibility( "TheFloatingMenu", "hidden" );
	NS_SetContent( "TheFloatingMenu", "" );
}

function NS_SetLeft( id, x0 ){
	var view = document.layers[ id ];
	if( view == null ){
		view = document.layers[gMenuBarName].document.layers[id];
	}
	if( view != null ){
		view.left = x0; 
	}		
}

function NS_SetTop( id, y0 ){
	var view = document.layers[ id ];
	if( view == null ){
		view = document.layers[gMenuBarName].document.layers[id];
	}
	if( view != null ){
		view.top = y0; 
	}			
}

function NS_GetLeft( id ){
	var view = document.layers[ id ];
	if( view == null ){
		view = document.layers[gMenuBarName].document.layers[id];
	}
	if( view != null ){
		return view.pageX; 
	} else {
		return 0;
	}	
}

function NS_GetTop( id){
	var view = document.layers[ id ];
	if( view == null ){
		view = document.layers[gMenuBarName].document.layers[id];
	}
	if( view != null ){
		return view.pageY; 
	}			
}

function NS_GetHeight( id ){
	var view = document.layers[ id ];
	if( view == null ){
		view = document.layers[gMenuBarName].document.layers[id];
	}
	if( view != null ){
		return view.clip.height; 
	} else {
      return 0;
   }	
}

function NS_GetWidth( id ){
	return WIDTH_MAINMENU;
}

function NS_SetContent( id, htmlContent ){
	var view = document.layers[id];
	if( view == null ){
		view = document.layers[gMenuBarName].document.layers[id];
	}
	if( view != null ){
		view.document.open();
		view.document.write( htmlContent );
		view.document.close(); 
	}		
}

function NS_SetVisibility( id, str ){
	var view = document.layers[id];
	if( view == null ){
		view = document.layers[gMenuBarName].document.layers[id];
	}
	if( view != null ){
		if( str == "hidden" ){
			view.visibility = "hidden" ;
		} else {
			view.visibility = "show" ;
		}	 
	}	
}

function NS_SetBackgroundColor( rid, color ){
	var view = document.layers[rid];
	if( view == null ){
		view = document.layers['TheFloatingMenu'].document.layers[rid]
	}
	if( view == null ){
		view = document.layers[gMenuBarName].document.layers[rid]   
	}
	if( view != null ){
		view.bgColor = color; 
	}
}

function NS_OnHandleFMIMouseOver( id ){
	NS_SetBackgroundColor( id, COLOR_SUBMENU_ITEM_SELECTED );
}

function NS_OnHandleFMIMouseOut( id ){
	NS_SetBackgroundColor( id, COLOR_SUBMENU_ITEM );
}


function NS_ShowSubmenu( res ){
   if( gCurrentResource == res ){
		return;
	}

	var id = res.id;
	if( id == null ){
		alert( "Resource does not have an id" );
		return;
	}

	NS_SetBackgroundColor( id, COLOR_MENU_ITEM_SELECTED );

	if(  res.isContainer() ){	
		var html = "";
		var counter = 0;
		for( var label in res.map ){
			html += NS_ItemAsHTML( counter, label, res.map[label] );
			counter ++;
		}

		if (TYPE == TYPE_DROPDOWN ) {
			var x0 = NS_GetLeft( id );
			var y0 = NS_GetTop( id ) + NS_GetHeight( id );
		} else {
			var x0 = NS_GetLeft( id ) + NS_GetWidth( id );
			var y0 = NS_GetTop( id );
		}

		NS_OpenFlyout( x0, y0, html );
	}

	gCurrentResource = res;
}

function NS_ItemAsHTML( id, label, url ){
	var html = "<ilayer id='FMI" + id + "' top=0 width='" + WIDTH_SUBMENU + "' bgcolor='" + COLOR_SUBMENU_ITEM + "'>" +  SUB_FONT_SPECS
			+ BULLET_CODE
			+ "<a href='" + url + "' class='NSMenuItem' onmouseout='NS_OnHandleFMIMouseOut ( \"FMI" + id + "\" )' onmouseover='NS_OnHandleFMIMouseOver( \"FMI" + id + "\" )' onclick='NS_OpenItem(\"" + url + "\")'>" +  SUB_FONT_SPECS
			+ label
			+ "</font></a>"
			+ "</font></ilayer><BR>"
	return html;		
}

function NS_HideSubmenu(){
	if( gCurrentResource == null ){
		return;
	}
	NS_CloseFlyout();
	NS_SetBackgroundColor( gCurrentResource.id, COLOR_MENU_ITEM );
	gCurrentResource = null;
}

function NS_OpenItem( url ){
	document.location = url;
}


function Unsupported_DisplayMenu() {
INDEX = "index.adp";
	if ( __menuModel ) {
		explodeCode = "";
		var counter = 1;

		for ( var label in __menuModel ) {
			var res = __menuModel[label];

			// Category with URL
			if ( res.length ) {
				htmlCode = BULLET_CODE + "<A HREF=\"";
				htmlCode += res;
				htmlCode += "\" STYLE=\"text-decoration: none\">";
				htmlCode += TOP_FONT_SPECS;
				htmlCode += label;
				htmlCode += "</FONT></A><BR>";
				explodeCode += htmlCode;

			// Category with sub-elements
			} else {
				if (res) {
					var id = label.split(" ")[0];
					var id = id.split(",")[0];			

					for (var sublabel in res) {
						var subres = res[sublabel];
						var mod_url = subres.lastIndexOf("/");
						var mod_url2 = subres.slice(0,mod_url+1);
						subres = mod_url2 + INDEX;
						break;
					}

					htmlCode = BULLET_CODE + "<A HREF=\"";
					htmlCode += subres;
					htmlCode += "\" STYLE=\"text-decoration: none\">";
					htmlCode += TOP_FONT_SPECS;
					htmlCode += label;
					htmlCode += "</FONT></A><BR>";
					explodeCode += htmlCode;
				}
			}
		}
	}
	document.write(explodeCode);
}





/* + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + 
 *	R  E  D  R  A  W     C  O  D  E
 * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * */
//reloads the window if Nav4 resized
function MM_reloadPage(init) {  
	if (init==true) with (navigator) {
		if ((appName=="Netscape") && (parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth;
			document.MM_pgH=innerHeight;
			onresize=MM_reloadPage; 
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
		location.reload();
}
MM_reloadPage(true);





/* + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + 
 *			O B J E C T        M O D E L
 * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * */
function __I( id, label, itemURL ){
	this.id			= id;
	this.label	 	= label;
	this.targetURL  = itemURL;

	this.getURL	= function(){
		return this.targetURL;	
	}

	this.asHTML	= function(){
		return label;
	}
	
	this.label = function(){
		return label;
	}

	this.isItem = function(){
		return true;
	}

	this.isContainer = function(){
		return false;
	}
}

function __C( id, label, map ){
	this.label 	= label;
	this.map 	= map;
	this.id		= id;
	//this.url		= url;

	this.asHTML	= function(){
		return label;
	}

	this.label = function(){
		return this.label;
	}

	this.isItem = function(){
		return false;
	}

	this.isContainer = function(){
		return true;
	}
}

/** INITIALIZATION */
__oMenuModel = new Object();
if( __menuModel ){

	var counter = 1;
	for( var label in __menuModel )
	{
		var id = "resource" + counter;
		counter ++;
			
		var res = __menuModel[label];
		if( res.length )
		{
			__oMenuModel[id] = new __I( id, label, res );	
			alert(res);
		}
		else 
			__oMenuModel[id] = new __C( id, label, res);				
	}
}