/* Top-Menu Java Scripts */
onload = function() {
    initializePage();
}

function topMenuaddEventListener(target, type, callback, captures)
{
  
	if (target.addEventListener)
	{
      // FF, Safari, etc.
	   target.addEventListener(type,callback,captures);
	}
	else
	if (target.attachEvent)
	{
	   // IE
	   target.attachEvent('on'+type,callback,captures);
	}
	else
	{
	   // IE 5 Mac ++
	   target['on'+type] = callback;
	}
}
function getAncestorWithId(elm)
{
   while (elm != null && elm.id == "")
      elm = elm.parentNode;
   return elm;
}
function getPosition(elm)
{
   var pos = new Object();
   pos.x = 0;
   pos.y = 0;
   if (elm.offsetParent)
   {
      while (elm.offsetParent)
      {
         pos.x += elm.offsetLeft;
         pos.y += elm.offsetTop;
         elm = elm.offsetParent;
         
      }
   }
   else
   {
      if (elm.x)
      {
         pos.x = elm.x;
         pos.y = elm.y;
      }
   }
   return pos;
}
var activeMenuHeaderId = null;
var activeMenuItemsId = null;
var timerId = -1;
function out(s)
{
   var div = document.createElement("div");
   div.innerText = s;
   document.body.appendChild(div);
}
function hideMenu(evt)
{
   if (activeMenuItemsId != null)
   {
      if (evt == null)
         evt = event;
      var target = evt.target;
      if (target == null)
         target = evt.srcElement;
      target = getAncestorWithId(target);
      if (target.id != activeMenuHeaderId && target.id != activeMenuItemsId)
      {
         document.getElementById(activeMenuItemsId).style.display = "none";
         activeMenuHeaderId = null;
         activeMenuItemsId = null;
      }
   }
}
function cancelEvent(evt)
{
   if (evt == null)
      event.cancelBubble = true;
   else
   if (evt.stopPropagation)
      evt.stopPropagation();
}
function showMenu(evt)
{

   if (activeMenuHeaderId == null && activeMenuItemsId == null)
   {
    
      hide = false;
      if (evt == null)
         evt = event;
      var target = evt.target;
      if (evt.target == null)
         target = evt.srcElement;
      if (target.nodeType == 3)  // Safari bug
         target = target.parentNode;
      target = getAncestorWithId(target);
      var items = document.getElementById(target.id + "Items");
      if(items != null) //If submenu is empty
      {
        var pos = getPosition(target);
        
        
//        items.style.left = target.offsetLeft + "px";
        
  //      items.style.top = pos.y + 8 + 'px';// + target.offsetHeight + "px";
        items.style.display = "block";
        activeMenuHeaderId = target.id;
        activeMenuItemsId = items.id;
        if (evt.stopPropagation)
             evt.stopPropagation();
        else
             evt.cancelBubble = true;
       }
   }
}
function initializePage()
{
  var array = menuitems.split(';');

  topMenuaddEventListener(document.body, "mouseover", hideMenu);
      
  for(var i = 0; i < (array.length -1) ; i++)
  {
    topMenuaddEventListener(document.getElementById(array[i]), "mousemove", showMenu);
  }
}

/* layout_ie.js */



/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/



/*
Jan Erik
http://fabric.no
*/

var app = navigator.appName; //document.write(navigator.userAgent)
if(app == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") == -1) {
    /* Fiks for hoppende grafikk. IE glemmer ting.. */
   // document.write("<style>.tabLanguage, .tabFontSize { border:0px solid red; }</style>")
    //var nuts = getElementsByClassName(document, "a", "tabFontSize")
    //window.status = "left="  + nuts[0]
}

/* Cache Mon Feb 20 23:32:43 CET 2006 */

var menuActive = "false";

function ShowMenuForCategory(divId) 
{
	document.getElementById(divId).style.visibility = "visible";
}

function HideMenuForCategory(divId)
{
	setTimeout("HideMenuForCategoryImpl('" + divId + "')", 1000);
	
}
function HideMenuForCategoryImpl(divId)
{
	
	if(menuActive == "false")
	{
		document.getElementById(divId).style.visibility = "hidden";
	}
	else
	{
		setTimeout("HideMenuForCategoryImpl('" + divId + "')", 1000);
	}
}

function setMenuActive(bool)
{
	menuActive = bool;
	
}

