﻿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';
}

function setHeight() {
  if((is_ie7)||(is_opera)) {
  var viewportHeight = document.documentElement.offsetHeight || window.innerHeight;
  var reservedHeight = parseInt(imageHeight) + 42 + menubarHeight;
  var remainedHeight = viewportHeight - reservedHeight;
  document.getElementById("content").style.height = remainedHeight + 'px';
  }
}

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, intReduc;

if(lnkDeco=='underline') {
lnkHover = 'none';
}
else {
lnkHover = 'underline';
}

if(ctWidth=='750') {
intReduc = 100;
}
else {
intReduc = 200;
}

var textWidth = parseInt(ctWidth) - 30;

var strCSS = '<style type="text/css">';

strCSS += 'body{background-color:'+background+';}';

if(tpBorder=='yes') {
strCSS += 'table#container td table#box td#top{border-top:1px solid '+borderColor+';border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';border-left:1px solid '+borderColor+';width:950px;height:'+imageHeight+'px;}';
}
else {
strCSS += 'table#container td table#box td#top{border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;width:'+ctWidth+'px;height:'+imageHeight+'px;}';
}

if(ctBorder=='yes') {
  if(ctWidth=='750') {
    if((menubarHeight==0)&&(tpBorder=='yes')) {
    strCSS += 'table#container td table#box td#content{border-top:0px;border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';border-left:0px;height:100%;width:750px;background-color:'+ctBackColor+';color:'+ctForeColor+';font-size:13px;font-family:'+fontFamily+';}';
    }
    else {
    strCSS += 'table#container td table#box td#content{border-top:1px solid '+borderColor+';border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';border-left:0px;height:100%;width:750px;background-color:'+ctBackColor+';color:'+ctForeColor+';font-size:13px;font-family:'+fontFamily+';}';
    }
  }
  else {
    if((menubarHeight==0)&&(tpBorder=='yes')) {
    strCSS += 'table#container td table#box td#content{border-top:0px;border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';border-left:1px solid '+borderColor+';height:100%;width:950px;background-color:'+ctBackColor+';color:'+ctForeColor+';font-size:13px;font-family:'+fontFamily+';}';
    }
    else {
    strCSS += 'table#container td table#box td#content{border-top:1px solid '+borderColor+';border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';border-left:1px solid '+borderColor+';height:100%;width:950px;background-color:'+ctBackColor+';color:'+ctForeColor+';font-size:13px;font-family:'+fontFamily+';}';
    }
  }
  if((menubarHeight==0)&&(tpBorder=='yes')) {
  strCSS += 'table#container td table#box td#channel{border-top:0px;border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';border-left:1px solid '+borderColor+';height:100%;width:199px;background-color:'+cnBackColor+';color:'+cnForeColor+';}';
  }
  else {
  strCSS += 'table#container td table#box td#channel{border-top:1px solid '+borderColor+';border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';border-left:1px solid '+borderColor+';height:100%;width:199px;background-color:'+cnBackColor+';color:'+cnForeColor+';}';
  }
}
else {
  strCSS += 'table#container td table#box td#content{border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;height:100%;width:'+ctWidth+'px;background-color:'+ctBackColor+';color:'+ctForeColor+';font-size:13px;font-family:'+fontFamily+';}';
  if(tpBorder=='yes') {
  strCSS += 'table#container td table#box td#channel{border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;height:100%;width:202px;background-color:'+cnBackColor+';color:'+cnForeColor+';}';
  }
  else {
  strCSS += 'table#container td table#box td#channel{border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;height:100%;width:200px;background-color:'+cnBackColor+';color:'+cnForeColor+';}';
  }
}

if(mnBorder=='yes') {
  if((tpBorder=='yes')&&(ctBorder=='yes')) {		//Hvis allerede ramme om top og indhold
  strCSS += 'table#container td table#box td.bar{border-top:0px;border-right:1px solid '+borderColor+';border-bottom:0px;border-left:1px solid '+borderColor+';height:18px;background-color:'+mnBackColor+';color:'+mnForeColor+';line-height:18px;text-align:center;}';
  }
  else if((tpBorder=='no')&&(ctBorder=='yes')) {	//Hvis allerede ramme om indhold, men ikke top
  strCSS += 'table#container td table#box td.bar{border-top:1px solid '+borderColor+';border-right:1px solid '+borderColor+';border-bottom:0px;border-left:1px solid '+borderColor+';height:18px;background-color:'+mnBackColor+';color:'+mnForeColor+';line-height:18px;text-align:center;}';
  }
  else if((tpBorder=='yes')&&(ctBorder=='no')) {	//Hvis allerede ramme om top, men ikke indhold
  strCSS += 'table#container td table#box td.bar{border-top:0px;border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';border-left:1px solid '+borderColor+';height:18px;background-color:'+mnBackColor+';color:'+mnForeColor+';line-height:18px;text-align:center;}';
  }
  else {						//Hvis hverken ramme om top eller indhold
  strCSS += 'table#container td table#box td.bar{border-top:1px solid '+borderColor+';border-right:1px solid '+borderColor+';border-bottom:1px solid '+borderColor+';border-left:1px solid '+borderColor+';height:18px;background-color:'+mnBackColor+';color:'+mnForeColor+';line-height:18px;text-align:center;}';
  }
}
else {
strCSS += 'table#container td table#box td.bar{border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;height:18px;background-color:'+mnBackColor+';color:'+mnForeColor+';line-height:18px;text-align:center;}';
}

strCSS += 'table#container td#content table td{border:1px solid '+ctForeColor+';color:'+ctForeColor+';background-color:transparent;font-size:13px;font-family:'+fontFamily+';}';

strCSS += 'div#submenu{padding-top:12px;padding-left:15px;background-color:'+mnBackColor+';color:'+mnForeColor+';}';

strCSS += 'div.sublink{border-top:1px solid '+cnBackColor+';padding-top:5px;padding-bottom:5px;}';

strCSS += 'a:link{color:'+ctForeColor+';background-color:transparent;text-decoration:underline;}';
strCSS += 'a:visited{color:'+ctForeColor+';background-color:transparent;text-decoration:underline;}';
strCSS += 'a:active{color:'+ctForeColor+';background-color:transparent;text-decoration:underline;}';
strCSS += 'a:hover{color:'+ctForeColor+';background-color:transparent;text-decoration:none;}';

strCSS += 'a.menu:link {color:'+mnForeColor+';background-color:transparent;text-decoration:none;}';
strCSS += 'a.menu:visited {color:'+mnForeColor+';background-color:transparent;text-decoration:none;}';
strCSS += 'a.menu:active {color:'+mnForeColor+';background-color:transparent;text-decoration:none;}';
strCSS += 'a.menu:hover {color:'+mnForeColor+';background-color:transparent;text-decoration:none;}';

strCSS += 'div#channeltext a:link {color:'+cnForeColor+';background-color:transparent;text-decoration:underline;}';
strCSS += 'div#channeltext a:visited {color:'+cnForeColor+';background-color:transparent;text-decoration:underline;}';
strCSS += 'div#channeltext a:active {color:'+cnForeColor+';background-color:transparent;text-decoration:underline;}';
strCSS += 'div#channeltext a:hover {color:'+cnForeColor+';background-color:transparent;text-decoration:none;}';

strCSS += 'div#channeltext a.z_link_z:link {color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkDeco+';}';
strCSS += 'div#channeltext a.z_link_z:visited {color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkDeco+';}';
strCSS += 'div#channeltext a.z_link_z:active {color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkDeco+';}';
strCSS += 'div#channeltext a.z_link_z:hover {color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkHover+';}';

strCSS += 'a.extmenu:link{color:'+cnForeColor+';background-color:transparent;text-decoration:none;}';
strCSS += 'a.extmenu:visited{color:'+cnForeColor+';background-color:transparent;text-decoration:none;}';
strCSS += 'a.extmenu:active{color:'+cnForeColor+';background-color:transparent;text-decoration:none;}';
strCSS += 'a.extmenu:hover{color:'+cnForeColor+';background-color:transparent;text-decoration:none;}';

strCSS += 'a.z_link_z:link{color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkDeco+';}';
strCSS += 'a.z_link_z:visited{color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkDeco+';}';
strCSS += 'a.z_link_z:active{color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkDeco+';}';
strCSS += 'a.z_link_z:hover{color:'+lnkColor+';background-color:transparent;text-decoration:'+lnkHover+';}';

strCSS += 'hr{color:'+ctForeColor+';background-color:'+ctForeColor+';height:1px;}';
strCSS += 'td#channel hr{color:'+cnForeColor+';background-color:'+cnForeColor+';}';

strCSS += 'td.info div{color:'+foreground+';background-color:transparent;}';

strCSS += 'td.info div a:link{color:'+foreground+';background-color:transparent;text-decoration:none;}';
strCSS += 'td.info div a:visited{color:'+foreground+';background-color:transparent;text-decoration:none;}';
strCSS += 'td.info div a:active{color:'+foreground+';background-color:transparent;text-decoration:none;}';
strCSS += 'td.info div a:hover{color:'+foreground+';background-color:transparent;text-decoration:none;}';

strCSS += 'div#bodytext{margin:15px;width:'+textWidth+'px;}';

strCSS += 'div#dropdown a:link{background-color:'+mnBackColor+';color:'+mnForeColor+';text-decoration:none;}';
strCSS += 'div#dropdown a:visited{background-color:'+mnBackColor+';color:'+mnForeColor+';text-decoration:none;}';
strCSS += 'div#dropdown a:active{background-color:'+mnBackColor+';color:'+mnForeColor+';text-decoration:none;}';
strCSS += 'div#dropdown a:hover{background-color:'+mnHoverColor+';color:'+mnForeColor+';text-decoration:none;}';

strCSS += 'div.reduc{width:550px;margin-left:'+intReduc+'px;}';

if(ctWidth=='750') {
strCSS += 'input.btn{cursor:pointer;cursor:hand;font-size:9px;width:60px;background-color:'+cnBackColor+';color:'+cnForeColor+';}';
strCSS += 'table#container td#content table td.forumlabel{background-color:'+cnBackColor+';color:'+cnForeColor+';}';
strCSS += '.unilabel{background-color:'+cnBackColor+';color:'+cnForeColor+';border:1px solid '+cnForeColor+';}';
strCSS += 'table#container td#content table .unilabel table td{background-color:'+cnBackColor+';color:'+cnForeColor+';}';
}
else {
strCSS += 'input.btn{cursor:pointer;cursor:hand;font-size:9px;width:60px;background-color:'+mnBackColor+';color:'+mnForeColor+';}';
strCSS += 'table#container td#content table td.forumlabel{background-color:'+mnBackColor+';color:'+mnForeColor+';}';
strCSS += '.unilabel{background-color:'+mnBackColor+';color:'+mnForeColor+';border:1px solid '+mnForeColor+';}';
strCSS += 'table#container td#content table .unilabel table td{background-color:'+mnBackColor+';color:'+mnForeColor+';}';
}

strCSS += 'img.imgbtn{cursor:pointer;cursor:hand;}';

if(!is_ie6) {
  strCSS += 'div#panel div{background-color:'+ctBackColor+';color:'+ctForeColor+';border:1px solid '+ctForeColor+';width:61px;cursor:default;float:left;margin-right:2px;margin-bottom:2px;text-align:right;display:block;padding-left:1px;padding-right:1px;}';
  if(is_ie) {
  strCSS += 'div#bodytext{overflow:hidden;}';
  }
  else {
  strCSS += 'html{overflow:-moz-scrollbars-vertical;}';
  }
  if(!is_opera) {
  strCSS += 'div#bodytext textarea{height:18px;}';
  }
  else {
  strCSS += 'div#bodytext textarea{height:60px;}';
  }
}
else {
  strCSS += 'div#panel div{background-color:'+ctBackColor+';color:'+ctForeColor+';border:1px solid '+ctForeColor+';width:65px;cursor:default;float:left;margin-right:2px;margin-bottom:2px;text-align:right;display:block;padding-left:1px;padding-right:1px;}';
}

strCSS += '</style>';

document.write(strCSS);
