/*
Dropdown menu. FreeWare.
Nikolai Lebedev, Microinform&Webstreet101
Works in IE4x, IE4x, NN4x and do not give garbage in old browsers.
Both graphics and text can drop.
The menu drops just below the calling image, situated anywhere on the page.
No preliminary positioning is need.
Short and simple code.
*/

//Detecting the browser type
var isNetscape = (navigator.appName == "Netscape");
var isMacIE = ( (navigator.userAgent.indexOf("IE 4")  > -1) && (navigator.userAgent.indexOf("Mac")  > -1) );
var layerRef = (isNetscape) ? "document" : "document.all";
var styleRef = (isNetscape) ? "" : ".style";
var DHTML_Enabled = ( (document.layers || document.all) && !isMacIE );

// To hide from old browsers generate the menu
// dynamically, invisible at the beginning
function MenuCall(Content, Width, BackgrColor, MenuNumber) 
  {
      MenuID=MenuNumber;
      WidthMenu=Width;
      Color=BackgrColor;

      if (DHTML_Enabled) 
         {
            if (isNetscape) 
               { 
                 document.write("<LAYER  class=menu   bgcolor="+Color+"  width="+WidthMenu+"  visibility=hidden  id="+MenuID+"   onMouseover=\"MenuActivate('"+MenuID+"')\" onMouseOut=\"MenuKill('"+MenuID+"')\">"+Content+"</LAYER>");	
               } 
            else 
               {  
	           document.write("<DIV class=menu   id="+MenuID+"  STYLE=\"  position:absolute; visibility:hidden; background:"+Color+"\"  onMouseover=\"MenuActivate('"+MenuID+"')\" onMouseOut=\"MenuKill('"+MenuID+"')\">"+Content+"</DIV>");
		     eval(layerRef + '["'+MenuID+'"]'+ styleRef + '.width ='+WidthMenu);
	          }
        }
}
// To activate a menu just change the visibility parameter
function MenuActivate(MenuNumber) 
  {
         MenuID=MenuNumber;

         if (DHTML_Enabled) 
            { 
               if (isNetscape) 
                  { 
                      MenuIDPlace=MenuID+"Place"
                      MenuIDPicture=MenuID+"Picture"
                      // alert ( "MenuIDPicture="+MenuIDPicture)
                      CoordX=document.anchors[MenuIDPlace].x+document.images[MenuIDPicture].width;
                      CoordY=document.anchors[MenuIDPlace].y ;
                      eval(layerRef + '["'+MenuID+'"]' + styleRef + '.top = '+CoordY);
                      eval(layerRef + '["'+MenuID+'"]' + styleRef + '.left = '+CoordX);
                      eval(layerRef + '["'+MenuID+'"]' + styleRef + '.visibility = "visible"');                     
                   } 
               else 
                  {
                      eval(layerRef + '["'+MenuID+'"]' + styleRef + '.visibility = "visible"');
                  }
        }
   }
// To de-activate a menu just change the visibility parameter
function MenuKill(MenuNumber) 
   { 
      MenuID=MenuNumber;
      if (DHTML_Enabled) 
           {
//But first fixing a bug in IE4
	     if (  (!isNetscape)&&(window.event.toElement.tagName== 'A') )
	         {
	           return;
	         }  
	     if (  (!isNetscape)&&(window.event.toElement.tagName== 'DIV') )
	         {
	           return;
	         } 
// Now changing the visibility parameter
            eval(layerRef + '["'+MenuID+'"]' + styleRef + '.visibility = "hidden"');
		}
   }
// that's all
