function stormynd(img_url,img_width,img_height,title)
	 {
	 var window_width = (img_width + 50);
	 var window_height = (img_height + 50);
	 var sw = screen.width;
	 var sh = screen.height;
	 var window_left = ((sw/2) - (window_width/2) - 66);
	 var window_top = ((sh/2) - (window_height/2) - 70);
	 newwin = open("","newwindow","width="+ window_width +",height="+ window_height +",scrollbars=no,toolbar=no,directories=no,menubar=no,resizable=no,status=no,left="+ window_left +",top="+ window_top +",screenx="+ window_left +",screeny="+ window_top);

	 newwin.document.open();

	 var newpage = '<HTML><HEAD><link rel="stylesheet" type="text/css" href="../styles.css"><TITLE>'+title+'</TITLE></HEAD><BODY BGCOLOR="#000000" MARGINWIDTH="0" MARGINHEIGHT="8" LEFTMARGIN="0" TOPMARGIN="20">';

	 newpage += '<CENTER><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR><TD><IMG class="randmyndir" SRC="'+img_url+'" ALT="'+title+'" BORDER="1" VSPACE="4" onClick="self.close()"></TD></TR>';

	 newwin.document.write(newpage);
	 newwin.document.close();
	 newwin.focus();
	 }
	 
function OpenComments (c) 
		{
    			window.open(c,'comments','width=480,height=480,scrollbars=yes,status=yes');
		}
function OpenRandom(URL) 
 		{
			day = new Date();
			id = day.getTime();
			eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,location=0,directories=0,status=0,menubar=0, scrollbars=0,resizable=no,width=610,height=560,left = 250,top = 222');");
		}
function OpenMyndaglosur(URL) 
 		{
			day = new Date();
			id = day.getTime();
			eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=950,height=750,left = 250,top = 222');");
		}

function OpenTrackback (c) 
		{
    			window.open(c,'trackback','width=480,height=480,scrollbars=yes,status=yes');
		}

function GeraGlugga(sida, nafn) 
        {
                msgWindow=window.open( sida, nafn, "toolbar=no,width=700,height=600,directories=no,status=no,scrollbars=auto,resize=no,menubar=no") 
        }
		
		 
function NyrGluggi(url,window_name,width,height) 
		{
  				newWindow=window.open(url,window_name,'toolbar=0,scrollbars=1,location=0,status=0,menubar=0,width=' + width + ',height=' + height)
  				setTimeout("newWindow.focus();", 100);
		}

/* CSS skiptir! */


function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

