﻿var agt    = navigator.userAgent.toLowerCase();
var is_mac = (agt.indexOf("mac") != -1);
var is_opera = (agt.indexOf("opera") != -1);
var is_ie = ((agt.indexOf("msie") != -1) && (!is_opera));
var is_ie6 = (((is_ie) && (agt.indexOf("msie 5") != -1) || (agt.indexOf("msie 6") != -1)));
var is_ie7 = ((is_ie) && (!is_ie6));

var instruction;

if(!is_mac) {
instruction = 'Blokering af pop-op-vinduer er slået til\n\nHold Ctrl tast nede, mens du klikker';
}
else {
instruction = 'Blokering af pop-op-vinduer er slået til\n\nHold Æble tast nede, mens du klikker';
}

var activated = false;

function Init() {
  activated = true;
  if(is_ie7) {
  var thisHeight = document.documentElement.offsetHeight - (imgHeight + 40);
  document.getElementById("container").style.height = thisHeight + 'px';
  }
}

function Set() {
  if(is_ie7) {
  var thisHeight = document.documentElement.offsetHeight - (imgHeight + 40);
  document.getElementById("container").style.height = thisHeight + 'px';
  }
  setTimeout("Activate()", 1000);
}

function Activate() {
activated = true;
}

var x = 0;
var y = 0;

var intVal;

if(is_ie) {
intVal = 13;
}
else {
intVal = 15;
}

var topPos = new Array();	//Dynamisk placering af undermenu boks

for(var i=1; i<13; i++) {
intVal += 22;
topPos[i] = imgHeight + intVal;
}

function Show(a, m) {
  if(activated) {
    b = ('submenu' + a);
    c = document.getElementById(b).style;
    if(c.visibility.toLowerCase() == 'visible') {
    Stop();
    c.visibility = 'hidden';
    }
    else {
    c.top = topPos[m] + 'px';
    c.visibility = 'visible';
    if(x != a) Hide(x);
    }
    x = a;
  }
}

function Hide(d) {
  if(d>0) {
    e = ('submenu' + d);
    f = document.getElementById(e).style;
    if(f.visibility.toLowerCase() == 'visible') {
    Stop();
    f.visibility = 'hidden';
    }
  }
}

function Start(g) {
  if(activated) {
    h = ('submenu' + g);
    i = document.getElementById(h).style;
    k = 'Show(' + g + ')';
    if(i.visibility.toLowerCase() == 'visible') {
    z = window.setTimeout(k, 1000);
    y = 1;
    }
  }
}

function Stop() {
  if(y>0) {
  window.clearTimeout(z);
  y = 0;
  }
}

function Reset() {
Hide(x);
}

function visBilledserie(folderID) {
location.href = 'dias.aspx?id=' + folderID;
}

var siteWindow = null;

function visHjemmeside(x) {
  var winleft = (screen.width - 790) / 2;
  siteWindow = window.open(x,'siteWindow','width=790,height=550,left='+winleft+',top=0,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes');
  if(!siteWindow) {
  alert(instruction);
  }
  else {
  if(siteWindow.open) siteWindow.focus();
  }
}

function getTitle(img) {
var separator = img.lastIndexOf("\/")+1;
var fullname = img.slice(separator);
return fullname;
}

var imageWindow = null;

function visBillede(iName, iWidth, iHeight) {
  var winleft = (screen.width - iWidth) / 2;
  var wintop = (screen.height - iHeight) / 2;
  imageWindow = window.open('','imageWindow','width='+iWidth+',height='+iHeight+',left='+winleft+',top='+wintop);
  if(imageWindow) {
  imageWindow.document.writeln('<html>');
  imageWindow.document.writeln('<head>');
  imageWindow.document.writeln('<meta http-equiv="imagetoolbar" content="no" />');
  imageWindow.document.writeln('<title>' + getTitle(iName) + '</title>');
  imageWindow.document.writeln('</head>');
  imageWindow.document.writeln('<body onblur="self.close()" style="margin:0px;border-style:none">');
  imageWindow.document.writeln('<img src="' + iName + '" width="' + iWidth + '" height="' + iHeight + '">');
  imageWindow.document.writeln('</body>');
  imageWindow.document.writeln('</html>');
  imageWindow.document.close();
  }
  else {
  alert(instruction);
  }
}

var strCSS = '<style type="text/css">';
if(!is_ie6) {
  strCSS += 'div#panel div{width:61px;}';
  if(is_ie) {
  strCSS += 'div#contenttext{overflow:hidden;}';
  }
  else {
  strCSS += 'html{overflow:-moz-scrollbars-vertical;}';
  }
  if(!is_opera) {
  strCSS += 'div#contenttext textarea{height:18px;}';
  }
  else {
  strCSS += 'div#contenttext textarea{height:60px;}';
  }
}
else {
  strCSS += 'div#panel div{width:65px;}';
}
strCSS += '</style>';

document.write(strCSS);