//Status

function setmenustatus(evt)
{
  if(evt == null)
  { //IE
    evt = event; 
  }
  
  var tgt = getTarget(evt);

  window.status=tgt.innerText;

  try
  { //firefox
    tgt.addEventListener('mouseout',clearstatus,true);
  }
  catch(e)
  { //IE
    tgt.onmouseout=clearstatus;
  }

  evt.returnValue=true;
}

function clearstatus(evt)
{
  if(evt == null)
  { //IE
    evt = event; 
  }
  
  window.status='';  
  evt.returnValue=true;
}

//Description

function setdescription(evt, descriptionfield, text)
{
  if(evt == null)
  { //IE
    evt = event; 
  }
  
  var tgt = getTarget(evt);
  var descriptionfielddiv = document.getElementById(descriptionfield);
  
  descriptionfielddiv.innerHTML = text;
  window.status = cleanHTMLtags(text);
  
  tgt.descriptionfield = descriptionfield;
  tgt.onmouseout=cleardescription;
  evt.returnValue=true;
}

function cleardescription(evt)
{
  if(evt == null)
  { //IE
    evt = event; 
  }
  
  var tgt = getTarget(evt);
  
  window.status='';
  if(tgt.descriptionfield)
  {
    var descriptionfielddiv = document.getElementById(tgt.descriptionfield);
    descriptionfielddiv.innerHTML='';
  }  
  evt.returnValue=true;
}

function cleanHTMLtags(str)
{
  if(str.indexOf("<") < 0)
  {
    return str
  }
  else
  {
    startix = str.indexOf("<");
    stopix = str.indexOf(">");
    
    newstr = str.substring(0, startix) + str.substring(stopix +1, str.length);
    return cleanHTMLtags(newstr);
  }
  
}
//Popups

function pop(bred,hog,src)
{
  window.open( src, "_blank", "scrollbars=yes,width=" + bred + ",height=" + hog);
}

function bild(bred,hog,src,namn) 
{ 
var lastix = Math.max(window.location.href.lastIndexOf("\\"), window.location.href.lastIndexOf("/")); 
var basepath = window.location.href.substring(0, lastix); 

//titta om src innehåller .gif, .png eller .jpg om inte så lägg till .jpg för att få filnamnet 
if(src.indexOf(".gif") >= 0 || src.indexOf(".png") >= 0 || src.indexOf(".jpg") >= 0) 
{ 
var picname = src; 
} 
else 
{ 
var picname = src + ".jpg"; 
} 

bWindow=window.open("", "_blank", "width=" + bred + ",height=" + hog + ""); 
bWindow.document.open(); 
bWindow.document.write("<html><head><title>" + namn + "</title></head><body background=" + basepath + "/bilder/" + picname + "><br><br></body></html>"); 
bWindow.document.close(); 
} 


function showchildren(evt)
{
   if(evt == null)
   {
     //IE
     evt = event; 
   }
   
    var tgt = getTarget(evt);
    var parent = tgt.parentNode;

    for(var i=0;i<parent.childNodes.length;i++)
    {
      if(parent.childNodes[i].nodeType == 1 && (parent.childNodes[i] != tgt))
      {
        if(!parent.expanded)
          parent.childNodes[i].style.display = "block";
        else
          parent.childNodes[i].style.display = "none";
      }
    }
    
    parent.expanded = !parent.expanded;
    evt.cancelBubble = true;
 }
  
function setlinkhover(event)
{  
  var tgt = getTarget(event);
  
  var ix = tgt.className.substr(tgt.className.length -1);
  tgt.className = "HEADERHOVER" + ix;

  try
  { //firefox
    tgt.addEventListener('mouseout',removelinkhover,true);
  }
  catch(e)
  { //IE
    tgt.onmouseout=removelinkhover;
  }
  
  window.status=tgt.innerText;
  
  event.returnValue=true;      
}

function removelinkhover(evt)
{
  if(evt == null)
  {
    //IE
    evt = event; 
  }
  
  var tgt = getTarget(evt);
  var ix = tgt.className.substr(tgt.className.length -1);
  tgt.className = "HEADER" + ix;
  tgt.onmouseout = null;

  window.status="";

   evt.returnValue=true;      
}

