﻿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 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 x = 0;
var y = 0;

function getPosition(evt) {
var evt = (evt) ? evt : event; 
var coords = { x: 0, y: 0};
var offsetX = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
var offsetY = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
coords.x = offsetX + evt.clientX;
coords.y = offsetY + evt.clientY;
return coords;
}

function appendSubmenu(ident, leftpos, toppos) {
  var submenu = '<table cellpadding="0" cellspacing="0">';
  var subarray = eval('sm' + ident);
  for(var n in subarray) {
  submenu += '<tr><td><a href="default.aspx?id=m' + ident + 's' + n + '" onmouseover="Stop();window.status=\'\';return true" onmouseout="Start(' + ident + ')">&nbsp;' + subarray[n] + '&nbsp;</a></td></tr>';
  }
  submenu += '</table>';
  document.getElementById("dropdown").innerHTML = submenu;
  document.getElementById("dropdown").style.left = leftpos + 'px';
  document.getElementById("dropdown").style.top = (toppos+5) + 'px';
  Stop();
  x = ident;
}

function removeSubmenu() {
document.getElementById("dropdown").style.left = '0px';
document.getElementById("dropdown").style.top = '-500px';
Stop();
x = 0;
}

function Show(event, ident) {
  if(ident==x) {
  removeSubmenu();
  }
  else {
  var coords = getPosition(event);
  appendSubmenu(ident, coords.x, coords.y);
  }
}

function Hide(ident) {
  if(ident==x) {
  removeSubmenu();
  }
}

function Start(ident) {
  if(document.getElementById("dropdown").style.left!='0px') {
  timeout = 'Hide(' + ident + ')';
  trigger = window.setTimeout(timeout, 1000);
  y = 1;
  }
}

function Stop() {
  if(y>0) {
  window.clearTimeout(trigger);
  y = 0;
  }
}

function visFlash(movieID) {
location.href = 'flash.aspx?id=' + escape(movieID);
}

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 lnkHover, intMargin, intReduc;

if(lnkDeco=='underline') {
lnkHover = 'none';
}
else {
lnkHover = 'underline';
}

if(imgWidth=='950') {
intMargin = 0;
intReduc = 185;
}
else {
intMargin = 15;
intReduc = 170;
}

var strCSS = '<style type="text/css">';

strCSS += 'table#container td.channel{height:100%;background-color:'+bgColor+';}';

strCSS += 'div.topbar{margin-top:'+intMargin+'px;margin-left:'+intMargin+'px;height:'+imgHeight+'px;}';
strCSS += 'div.menubar{margin-left:'+intMargin+'px;width:'+imgWidth+'px;font-size:10px;}';

strCSS += 'div.menubar table td{text-align:center;border:'+barBorder+';background-color:'+offColor+';}';

strCSS += 'div.menubar table td a:link{background-color:transparent;color:'+barColor+';text-decoration:none;width:100%;height:100%;display:block;}';
strCSS += 'div.menubar table td a:visited{background-color:transparent;color:'+barColor+';text-decoration:none;width:100%;height:100%;display:block;}';
strCSS += 'div.menubar table td a:active{background-color:transparent;color:'+barColor+';text-decoration:none;width:100%;height:100%;display:block;}';
strCSS += 'div.menubar table td a:hover{background-color:transparent;color:'+barColor+';text-decoration:none;width:100%;height:100%;display:block;}';

strCSS += 'div#dropdown a:link{background-color:'+offColor+';color:'+barColor+';text-decoration:none;width:100%;height:100%;display:block;}';
strCSS += 'div#dropdown a:visited{background-color:'+offColor+';color:'+barColor+';text-decoration:none;width:100%;height:100%;display:block;}';
strCSS += 'div#dropdown a:active{background-color:'+offColor+';color:'+barColor+';text-decoration:none;width:100%;height:100%;display:block;}';
strCSS += 'div#dropdown a:hover{background-color:'+onColor+';color:'+barColor+';text-decoration:none;width:100%;height:100%;display:block;}';

strCSS += 'div.reduc{margin-left:'+intReduc+'px;}';

strCSS += 'div#content{width:920px;font-size:13px;font-family:'+fType+';}';
strCSS += 'div#content td.z_calhead_z{text-align:center;width:14%;background-color:'+bgColor+';color:'+fgColor+';font-weight:bold;font-size:10px;}';
strCSS += 'a.z_link_z:link{color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkDeco+';}a.z_link_z:visited{color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkDeco+';}a.z_link_z:active{color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkDeco+';}a.z_link_z:hover{color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkHover+';}';
strCSS += 'input.btn{cursor:pointer;cursor:hand;background-color:'+bgColor+';color:'+fgColor+';width:60px;font-size:9px;}';

strCSS += 'div#content table td.forumlabel{background-color:'+bgColor+';color:'+fgColor+';font-size:10px;font-family:verdana,arial,sans-serif;}';
strCSS += '.unilabel{background-color:'+bgColor+';color:'+fgColor+';border:1px solid '+fgColor+';}';

if(!is_ie6) {
  strCSS += 'div#panel div{width:61px;cursor:default;float:left;margin-right:2px;margin-bottom:2px;text-align:right;display:block;padding-left:1px;padding-right:1px;color:black;border:1px solid black;}';
  if(is_ie) {
  strCSS += 'div#content{overflow:hidden;}';
  }
  else {
  strCSS += 'html{overflow:-moz-scrollbars-vertical;}';
  }
  if(!is_opera) {
  strCSS += 'div#content textarea{height:18px;}';
  }
  else {
  strCSS += 'div#content textarea{height:60px;}';
  }
}
else {
  strCSS += 'div#panel div{width:65px;cursor:default;float:left;margin-right:2px;margin-bottom:2px;text-align:right;display:block;padding-left:1px;padding-right:1px;color:black;border:1px solid black;}';
}
strCSS += '</style>';

document.write(strCSS);
