if(window.name!='bottomframe') {window.name='octobit'}

var winl = (screen.width - 480) / 2;
var wint = (screen.height - 340) / 2;

function foretrukne() {
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
		var url = window.location
		var title = document.title
		window.external.AddFavorite(url,title);
	}
	else {
		alert("Denne funktion er desvaerre ikke kompatibel med din browser.")
	}
}
function foretrukne1DK() {
	alert("Tryk ctrl/D for at føje denne side til dine bookmarks.")
}

function foretrukne1UK() {
	alert("Press ctrl/D to add this page to your bookmarks.")
}

function login() {
window.open('login.asp','login','height=220,width=460,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function popup(aid) {
  var winl = (screen.width - 480) / 2;
  var wint = (screen.height - 340) / 2;
  UniqueWindow = window.open('showPopup.asp?ArticleID='+aid,'','scrollbars=yes,toolbars=no,location=no,status=no,directories=no,resizable=no,top='+wint+',left='+winl+',height=340,width=480')
  UniqueWindow.focus();
}

function openPayWindow(pg){
  var winl = (screen.width - 520) / 2;
  var wint = (screen.height - 440) / 2;
  UniqueWindow = window.open('showPopup.asp?ArticleID='+pg,'','scrollbars=yes,toolbars=no,location=no,status=yes,directories=no,resizable=no,top='+wint+',left='+winl+',height=440,width=520')
  UniqueWindow.focus();
}

function logout() {
location.href='logout.asp';	
}

function setOnOverMenu(xx) {
  document.getElementById(xx).className='onOverMenu';
  document.getElementById(xx).style.cursor='hand';
  }
function setOnOutMenu(xx) {
  document.getElementById(xx).className='onOutMenu';
  document.getElementById(xx).style.cursor='auto';
}

function setOnOverMenusub(xx) {
  document.getElementById(xx).className='onOverMenusub';
  document.getElementById(xx).style.cursor='hand';
  }
function setOnOutMenusub(xx) {
  document.getElementById(xx).className='onOutMenusub';
  document.getElementById(xx).style.cursor='auto';
}

function slideShow(n) {
  window.open('SlideShow.asp?id='+n,'','height=482,width=600,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no')
}
function timeLine(n) {
  window.open('timeline.asp?id='+n,'','height=600,width=720,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no')
}


function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return '';
}
function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}
function setBoxStateCookie (v) {
    var rightNow = new Date()
    var expdate = new Date()
    expdate.setTime (expdate.getTime() + 60*(24 * 60 * 60 * 1000)) // dead in 2 months
    SetCookie ("boxState", v, expdate, "/")
}
function boxIsClosed(boxID) {
  boxState=GetCookie('boxState')
  if(boxState.indexOf('/'+boxID+'/')==-1) {
    return false
    } else {
    return true
    }
}
function setBoxStateOpened(boxID){
  if(boxIsClosed(boxID)){
    boxState=GetCookie('boxState')
    sID='/'+boxID+'/'
    pl=boxState.indexOf(sID)
    boxState=boxState.substr(0,pl)+boxState.substr(pl-1+sID.length,500)
    if (boxState=='/') {boxState=''}
    setBoxStateCookie(boxState)
    }
}
function setBoxStateClosed(boxID){
  if(!boxIsClosed(boxID)){  
    boxState=GetCookie('boxState')
    if(boxState==''){
      setBoxStateCookie('/'+boxID+'/')
      } else {
      setBoxStateCookie(boxState+boxID+'/')
      } 
    }
}
function toggleBoxState(boxID) {
  if(boxIsClosed(boxID)){
    setBoxStateOpened(boxID)
    } else {
    setBoxStateClosed(boxID)
    }
}
function initBoxes() {
  var boxState='';
  boxState=GetCookie('boxState')
  if(boxState!=''){
    boxState=boxState.substr(1,500);
    while(boxState!='') {
      pl=boxState.indexOf('/')
      boxID=boxState.substr(0,pl);
      if(document.getElementById('box'+boxID)!=null) {
      	toggleBox(boxID)
      	}
      boxState=boxState.substr(1,500);
      }
    }
}

function showArrow(x) {
  x.style.cursor='auto';
}

function showHand(x) {
  x.style.cursor='hand';
}


function setLinkCookie(lk) {
  var rightNow = new Date();
  var expdate = new Date();
  expdate.setTime (expdate.getTime() + 365*(24 * 60 * 60 * 1000)); // dead in 365 days
  SetCookie ("linklist", lk, expdate, "/");
}
function deleteLink(sl,rw){
  var c=GetCookie('linklist');
  var nc='';
  var pl1=0;
  var pl2=0;
  var pl3=0;
  var l='';
  var lt='';
  if(c!='') {
  while(c!='') {
    pl1=c.indexOf('[');
    pl2=c.indexOf('^');
    pl3=c.indexOf(']');
    lt=c.substr(pl1+1,pl2-1);
    l=c.substr(pl2+1,pl3-pl2-1);
    if(sl!=l) {
      nc=nc+'['+lt+'^'+l+']';
      } 
    c=c.substr(pl3+1,500);
    }
  setLinkCookie(nc);
  }
  writeRealLinks();    
}


function addLink() {
  var c=GetCookie('linklist');
  c=c+'['+document.title.substr(0,25)+'^'+location.href+']';
  setLinkCookie(c);  
  writeRealLinks();    
}

function writeLinks() {
  document.write('<span id="_kmp_linklist"> </span>');
  writeRealLinks();
}	

function editLink(sl) {
  var c=GetCookie('linklist');
  var nc='';
  var pl1=0;
  var pl2=0;
  var pl3=0;
  var l='';
  var lt='';
  if(c!='') {
  while((c!='') && (l=='')) {
    pl1=c.indexOf('[');
    pl2=c.indexOf('^');
    pl3=c.indexOf(']');
    lt=c.substr(pl1+1,pl2-1);
    l=c.substr(pl2+1,pl3-pl2-1);
    if(sl==l) {
      c='';
      } else {
      c=c.substr(pl3+1,500);
      l='';
      }
    }
    writeEditLink(lt,l);
  }
}

function writeEditLink(lt,l) {
  var res='<table border=0 cellpadding=0 cellspacing=0>';
  res=res+'<tr><td>Tekst:&nbsp;</td><td><input style="font-family:MS Dialog;font-size:8px;border:1px solid black; width:100px;"  name=linktext value="'+lt+'"/></td></tr>';
  res=res+'<tr><td>Link:&nbsp;</td><td><input style="font-family:MS Dialog;font-size:8px;border:1px solid black; width:100px;" name=linkvalue value="'+l+'"/><input name=oldlinkvalue type=hidden value="'+l+'"/></td></tr>';
  res=res+'<tr><td>&nbsp;</td><td style="padding-top:2px;padding-bottom:2px;"><span style="border:1px solid black;font-size:9px;" onmouseover="this.style.cursor=\'hand\'" onmouseout="this.style.cursor=\'auto\'" onclick="saveLink();">Gem link</span>&nbsp;<span style="border:1px solid black;font-size:9px;" onmouseover="this.style.cursor=\'hand\'" onmouseout="this.style.cursor=\'auto\'" onclick="writeRealLinks();">Fortryd</span></td></tr>';
  res=res+'</table>';
  document.all['_kmp_linklist'].innerHTML=res;
}

function saveLink() {
  var lt=document.all['linktext'].value;
  var l=document.all['linkvalue'].value;
  var ol=document.all['oldlinkvalue'].value;
  deleteLink(ol,0);
  var c=GetCookie('linklist');
  c=c+'['+lt.substr(0,25)+'^'+l+']';
  setLinkCookie(c);  
  writeRealLinks();
}

function writeRealLinks() {
  var c=GetCookie('linklist');
  var res='';
  var ant=0;
  var pl=0;
  var l='';
  var lt='';
  res='<table border=0 cellpadding=0 cellspacing=0>';
  res=res+'<tr><td colspan=3><span style="border:1px solid black;font-size:9px;" onmouseover="this.style.cursor=\'hand\'" onmouseout="this.style.cursor=\'auto\'" onclick="addLink();">Tilføj</span></td></tr>';
  res=res+'<tr><td colspan=3></td></tr>';
  if(c!='') {
  while(c!='') {
    pl=c.indexOf('[');
    c=c.substr(pl+1,500);
    pl=c.indexOf('^');
    lt=c.substr(0,pl);
    c=c.substr(pl+1,500);
    pl=c.indexOf(']');
    l=c.substr(0,pl);
    c=c.substr(pl+1,500)
    res=res+'<tr>';
    res=res+'<td><img onmouseover="this.style.cursor=\'hand\'" onmouseout="this.style.cursor=\'auto\'" onclick="editLink(\''+l+'\');" src="/icons/icon_edit.gif" alt="Rediger"></td>';
    res=res+'<td><img onmouseover="this.style.cursor=\'hand\'" onmouseout="this.style.cursor=\'auto\'" onclick="deleteLink(\''+l+'\',1);" src="/icons/icon_delete.gif" alt="Slet"></td>';
    res=res+'<td><a class="forsidelink" href="'+l+'">'+lt+'</a></td>';
    res=res+'</tr>';
    ant=ant+1;
    }  
  }
  res=res+'</table>';
  document.all['_kmp_linklist'].innerHTML=res;
  //alert(res)
}

function toggleBox(boxid) {
  if (eval('box'+boxid).style.display=='none'){
    eval('box'+boxid).style.display='';
    eval('toggleImg'+boxid).src='/icons/minimize.gif';
    setBoxStateOpened(boxid);
    } else {
    eval('box'+boxid).style.display='none';
    eval('toggleImg'+boxid).src='/icons/maximize.gif';
    setBoxStateClosed(boxid);
    }	
}



