function addEvent(elm, evType, fn, useCapture)
{
	// addEvent 
	// cross-browser event handling for IE5+,  NS6 and Mozilla
	// By Scott Andrew
	if (elm.addEventListener)
	{
		elm.addEventListener(evType, fn, useCapture);
 		return true;
	} 
	else if (elm.attachEvent)
	{
		var r = elm.attachEvent("on"+evType, fn);
		return r;
	} 
	else 
	{
   		// alert("Handler could not be added");
  	}
} 

function removeEvent(elm, evType, fn, useCapture)
{
	// removeEvent 
	// cross-browser event handling for IE5+,  NS6 and Mozilla
	// By Scott Andrew
	if (elm.removeEventListener)
	{
    		elm.removeEventListener(evType, fn, useCapture);
    		return true;
  	} 
	else if (elm.detatchEvent)
	{
    		var r = elm.detachEvent("on"+evType, fn);
    		return r;
  	} 
	else 
	{
 		//  alert("Handler could not be removed");
  	}
} 



function menu_init()
{
	// Find all divTag with class menubar and assign functions to A and IMG tags
	if (!document.getElementsByTagName) 
	{
	return;
	}
	var divTag = document.getElementsByTagName("div");
	for (di=0;di<divTag.length;di++) 
	{
		var thisDiv = divTag[di];
		if (((' '+thisDiv.className+' ').indexOf("menuleiste") != -1) && (thisDiv.id)) 
		{
			menu_makemenu(thisDiv);
		}
		else 
		{
		 	 if (((' '+thisDiv.className+' ').indexOf("menu") != -1) && (thisDiv.id)) 
			 {
			 menu_makesubmenu(thisDiv);
			 }
		}
	}
}

function menu_makemenu(menu)
{
	var anchors = menu.getElementsByTagName("a");
	for (i = 0; i < anchors.length; i++) 
	{
		var thisAnchor = anchors[i];
		if (((' '+thisAnchor.className+' ').indexOf("menuButton") != -1) && (thisAnchor.id)) 
		{
			var images = thisAnchor.getElementsByTagName("img");
			for (ti = 0; ti < images.length; ti++) 
			{
				var thisImage = images[ti];
				if ((thisImage.src) && (thisAnchor.id)) 
				{
					thisImage.style.width = (thisImage.width);
					thisImage.style.height = (thisImage.height + 0.1);
				}
			}	
			if (thisAnchor.id)
			{
				thisAnchor.onmouseover=function(event){
				buttonMouseover(event, this.id+"menu");
				}
				thisAnchor.onmouseout=function(event){
				buttonOrMenuMouseout(event);
				}
			}
		}
	}
}


function menu_makesubmenu(menu)
{
	if ((!((' '+menu.id+' ').indexOf("submenu") != -1))) 
	{	
		   	 menu.onmouseover=function(event){
			 menuMouseover(event);
			 }
	}
	var anchors = menu.getElementsByTagName("a");
	tagged = 0;
	for (si = 0; si < anchors.length; si++) 
	{
		var thisAnchor = anchors[si];
		if (((' '+thisAnchor.className+' ').indexOf("menuItem") != -1) && (menu.id)) 
		{
			if(thisAnchor.id )
			{ 
				var spans = thisAnchor.getElementsByTagName("span");
				for (sti = 0; sti < spans.length; sti++) 
				{
					var thisSpan = spans[sti];
					if (((' '+thisSpan.className+' ').indexOf("menuItemText") != -1) && (thisAnchor.id)) 
					{
					
   						thisAnchor.onmouseover=function(event){
						menuItemMouseover(event, this.id+"menu");
						}
						sti = spans.length;
					}
				}
			}	

		}
	}
}
