var maxZ = 0;
var dragging = false;
var startEvtX = -1;
var startEvtY = -1;
var tracking = false;
var trackedElement = "";
var trackStart = 0;
var NS = (navigator.appName.indexOf("Netscape") >=0) ? true : false;

if (NS) {
  document.captureEvents(Event.MOUSEMOVE);
  window.onMouseMove=move;
}
else if (document.all) {
   document.onmousemove=move;
}

function move(e) {
  if (!tracking) return;
  if (NS) {
    trackedElement.style.top = "" + (e.pageY + 4) + "px";
    trackedElement.style.left = "" + (e.pageX+ 8 - trackStart) + "px";
    trackedElement.style.height = "auto";
  } else {
    trackedElement.style.top = "" + (event.y + 4 + xScrollTop()) + "px";
    trackedElement.style.left = "" + (event.x + 8 - trackStart) + "px";
  }
}


function UpMe(src) {
  elem = document.getElementById(src);
  if (!(elem == null)) {
    elem.style.zIndex = maxZ+1
    maxZ = maxZ + 1
  }
}

function StartMoving(evt,src) {
  elem = document.getElementById(src);
  if (!(elem == null)) {
    if (!dragging) {
      elem.style.zIndex = maxZ+1;
      dragging = true;
      startEvtX = evt.clientX;
      startEvtY = evt.clientY;
    }
  }
}

function StopMoving() {
  dragging = false;
}

function MoveMe(evt,src) {
  if (dragging) {
    elem = document.getElementById(src);
    if (!(elem == null)) {
      temp = elem.offsetLeft + evt.clientX - startEvtX;
      elem.style.left = "" + temp + "px";
      temp = elem.offsetTop + evt.clientY - startEvtY;
      elem.style.top = "" + temp + "px"
      startEvtX = evt.clientX;
      startEvtY = evt.clientY;
    }
  }
}


function Show(what,show,container) {
  elem  = document.getElementById(what);
  if (container != null) {
    trackStart=xLeft(container);
  }
  if (!(elem == null)) {
    if (show) {
      elem.style.visibility = "visible";
      elem.style.display = "block";
      if (NS) {
        window.captureEvents(Event.MOUSEMOVE);
        window.onmousemove = move;
        //elem.style.top = "" + (event.pageY + 4) + "px";
       // elem.style.left = "" + (event.pageX+ 8) + "px";
      } else {
        elem.style.top = "" + (event.y + 4 + xScrollTop()) + "px";
        elem.style.left = "" + (event.x + 8 - trackStart) + "px";
      }
      trackedElement = elem;
      tracking = true;
    } else {
      if (NS) {
        window.releaseEvents(Event.MOUSEMOVE);
      }
      elem.style.visibility = "hidden";
      elem.style.display = "none";
      tracking = false;
      trackedElement = "";
	  trackStart = 0;
    }
  }
}



function openURL(where,impl) {

  if (!impl) {
    alert("Sidan " + where + " redigeras.");
    return false;
  } else {
    window.open(where,"","");
    return true;
  }
}

function openfriend(url) {
  window.open(url,"friend","toolbar=yes, location=yes, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes, width=400, height=400");
}

function openwindow(url)
{
window.open(url,"fanzine","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, width=400, height=400")
}

function openbookreview(url)
{
  window.open(url,"bokrecension","toolbar=no, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, width=600, height=300");
}

function openpicture(url,width,height)
{
  str = "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=" + width + ", height=" + height;
  window.open(url,"picture",str);
}

function openpicturefritext1(url,width,height)
{
  str = "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=" + width + ", height=" + height;
  window.open(url,"picture",str);
}


function ShowHideSubMenuAuxBlogg(id,hideshow) {
  var i = 1;
  var elem = document.getElementById("" + id + i);
  while (elem != null) {
    elem.style.display=hideshow;
	i++;
	elem = document.getElementById("" + id + i);
  }
}

function HideSubMenusBlogg() {
  var i = 1;
  ShowHideSubMenuAuxBlogg("y2005y","none")
  ShowHideSubMenuAuxBlogg("y2004y","none");
  ShowHideSubMenuAuxBlogg("y2003y","none");
}  

function ShowSubMenuBlogg(whatdiv,count) {
  ShowHideSubMenuAuxBlogg(whatdiv,"block");
}
