window.onload = BlurLinks
window.onresize = BlurLinks
//window.onerror = ErrorHandling

function verScroll(dir, spd, loop) {
loop = true;
direction = "up";
speed = 10;
scrolltimer = null;
if (document.layers) {
page = eval(document.content);
}
else {
if (document.getElementById) {
page= eval("document.getElementById('content').style");
}
else {
if (document.all) {
page = eval(document.all.content.style);
      }
   }
}
direction = dir;
speed = parseInt(spd);
var y_pos = parseInt(page.top);
if (loop == true) {
if (direction == "dn") {
page.top = (y_pos - (speed));
} else {
if (direction == "up" && y_pos < 10) {
page.top = (y_pos + (speed));
} else {
if (direction == "top") {
page.top = 10;
      }
   }
}
scrolltimer = setTimeout("verScroll(direction,speed)", 1);
   }
}

function stopScroll() {
loop = false;
clearTimeout(scrolltimer);
}


function SletUser(navn, url)
{
	var agree = confirm("Er du sikker på, du vil slette '" + navn + "'?");
	if (agree) {self.location.href=url}
}

function DeletePage(pagename, url)
{
	var agree = confirm("Er du sikker på, du vil slette '" + pagename + "'?");
	if (agree) {self.location.href=url}
}

function WindowSize(param)
{
var myWidth = 0, myHeight = 0;
  if( typeof( parent.window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = parent.window.innerWidth;
    myHeight = parent.window.innerHeight;
  } else if( document.documentElement &&
      ( parent.document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = parent.document.documentElement.clientWidth;
    myHeight = parent.document.documentElement.clientHeight;
  } else if( parent.document.body && ( parent.document.body.clientWidth || parent.document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = parent.document.body.clientWidth;
    myHeight = parent.document.body.clientHeight;
  }
  if (param == "width")
      {return myWidth}
      
  if (param == "height")
      {return myHeight}
}

function BlurLinks()
{
	if(document.getElementById)
	{
		lnks=document.getElementsByTagName('a');
    	for(i=0;i<lnks.length;i++)
    	{
    		lnks[i].onfocus=new Function("if(this.blur)this.blur()");
		}
	}
	var content = document.getElementById("indhold")
	content.style.top = (WindowSize("height")/2) - 310 + "px"
}

function ErrorHandling()
{
  return true;
}

function SearchBox(sprog)
{
  var searchstring = document.forms[0].searchstring.value;
  if (searchstring == "") 
  {
    var fejlbesked
    switch (sprog)
    {
      case "da": 
        fejlbesked = "For at søge skal feltet være udfyldt";
        break;
      case "en":
        fejlbesked = "In order to search, the search field must not be left emtpy";
        break;
      default:
        fejlbesked = "For at søge skal feltet være udfyldt";
        break;
    }
    alert(fejlbesked);
    return false
  }
  return true;
}

// Centreret popup
function newWindow(mypage,title,w,h) {
  if(screen.width){
  var winl = (screen.width-w)/2; var wint = (screen.height-h)/2;}
  else{winl = 0;wint =0;}
  if (winl < 0) winl = 0; if (wint < 0) wint = 0;
  var settings = 'scrollbars=0,resizable=0,height=' + h + ',' + 'width=' + w + ',' + 'top=' + wint + ',' + 'left=' + winl;
  win = window.open(mypage,title,settings);
  win.window.focus();
}

// BILLED POPUP
function ShowPicture(virtualroot, url)
{
 window.open(virtualroot + 'billedPopUp.aspx?url='+url,'','width=2,height=2');
}

//  MENU  //
function ShowMenu(menuID, parentID)
{
  if(document.getElementById)
	{
    div = menu_menu.getElementsByTagName('div');
    for(i=0;i<div.length;i++)
    {
      if (div[i].id != 'menu_TopDiv') {div[i].style.display='none'}
    }
    document.getElementById(menuID).style.display = 'block';
    document.getElementById(parentID).style.display = 'block';
    document.getElementById(menuID).style.left = event.clientX - 30 + "px";
  }
}
