/*  Scrollbar START  */

// JavaScript Document
noScrollBar = false;

function hookOnloadEvent(f) {
  if (window.onload) {
    f2 = window.onload;
    window.onload = function() {
      f2();
      f();
    };
  }
  else window.onload = f;
}
hookOnloadEvent(initScrollLayer);
scrollObjCo3.loadLayer = function(wnId, id) {
  if (scrollObjCo3s[wnId]) scrollObjCo3s[wnId].load(id);
};
scrollObjCo3.prototype.load = function(lyrId) {
  if (!document.getElementById) return;
  var win, lyr;
  if (this.lyrId) {
    lyr = document.getElementById(this.lyrId);
    lyr.style.visibility = "hidden";
  }
  lyr = document.getElementById(lyrId);
  win = document.getElementById(this.id);
  lyr.style.top = this.y = 0;
  lyr.style.left = this.x = 0;
  this.maxY = (lyr.offsetHeight - win.offsetHeight > 0) ? lyr.offsetHeight - win.offsetHeight : 0;
  this.wd = lyr.offsetWidth;
  this.maxX = (this.wd - win.offsetWidth > 0) ? this.wd - win.offsetWidth : 0;
  this.lyrId = lyrId;
  lyr.style.visibility = "visible";
  this.on_load();
  this.ready = true;
};
scrollObjCo3.prototype.on_load = function() { };
scrollObjCo3.prototype.shiftTo = function(lyr, x, y) {
  if (!lyr) return;
  lyr.style.left = (this.x = x) + "px";
  lyr.style.top = (this.y = y) + "px";
};
function getPageOffsets(el) {
  var left = el.offsetLeft;
  var top = el.offsetTop;
  if (el.offsetParent && el.offsetParent.clientLeft || el.offsetParent.clientTop) {
    left += el.offsetParent.clientLeft;
    top += el.offsetParent.clientTop;
  }
  while (el = el.offsetParent) {
    left += el.offsetLeft;
    top += el.offsetTop;
  }
  return { x: left, y: top };
};


scrollObjCo3.stopScroll = function(wnId) { if (scrollObjCo3s[wnId]) scrollObjCo3s[wnId].endScroll(); };
scrollObjCo3.doubleSpeed = function(wnId) { if (scrollObjCo3s[wnId]) scrollObjCo3s[wnId].speed *= 2; };
scrollObjCo3.resetSpeed = function(wnId) { if (scrollObjCo3s[wnId]) scrollObjCo3s[wnId].speed /= 2; };
scrollObjCo3.initScroll = function(wnId, deg, sp) {
  if (scrollObjCo3s[wnId]) {
    var cosine, sine;
    if (typeof deg == "string") {
      switch (deg) {
        case "up":
          deg = 90;
          break;
        case "down":
          deg = 270;
          break;
        case "left":
          deg = 180;
          break;
        case "right":
          deg = 0;
          break;
        default:
          deg = 90; //up
      }
    }
    deg = deg % 360;
    if (deg % 90 == 0) {
      cosine = (deg == 0) ? -1 : (deg == 180) ? 1 : 0;
      sine = (deg == 90) ? 1 : (deg == 270) ? -1 : 0;
    }
    else {
      var angle = deg * Math.PI / 180;
      cosine = -Math.cos(angle);
      sine = Math.sin(angle);
    }
    scrollObjCo3s[wnId].fx = cosine / (Math.abs(cosine) + Math.abs(sine));
    scrollObjCo3s[wnId].fy = sine / (Math.abs(cosine) + Math.abs(sine));
    scrollObjCo3s[wnId].endX = (deg == 90 || deg == 270) ? scrollObjCo3s[wnId].x : (deg < 90 || deg > 270) ? -scrollObjCo3s[wnId].maxX : 0;
    scrollObjCo3s[wnId].endY = (deg == 0 || deg == 180) ? scrollObjCo3s[wnId].y : (deg < 180) ? 0 : -scrollObjCo3s[wnId].maxY;
    scrollObjCo3s[wnId].startScroll(sp, wnId);
  }
};
scrollObjCo3.prototype.startScroll = function(speed, wnId) {
  if (!this.ready) return;
  if (this.timerId) clearInterval(this.timerId);
  this.speed = speed || scrollObjCo3.speed;
  this.speed = this.Co3["speed"];
  this.lyr = document.getElementById(this.lyrId);
  this.lastTime = (new Date()).getTime();
  this.on_scroll_start();
  this.timerId = setInterval(this.animString + ".scroll()", 10);

  // Mousewheel eventen:
  // Her kaldes en metode der skal stoppen scrollen
  // Metoden kaldes med forsinkelse, s? scrollen kan n? et stykke vej
  if (mouseWheelEventInProgress)
    setTimeout(this.animString + ".mousewheelStop()", 300);
};

scrollObjCo3.prototype.scroll = function() {
  var now = (new Date()).getTime();
  var d = (now - this.lastTime) / 1000 * this.speed;
  if (d > 0) {
    var x = this.x + this.fx * d; var y = this.y + this.fy * d;
    if (this.fx == 0 || this.fy == 0) {
      if ((this.fx == -1 && x > -this.maxX) || (this.fx == 1 && x < 0) || (this.fy == -1 && y > -this.maxY) || (this.fy == 1 && y < 0)) {
        this.lastTime = now;
        this.shiftTo(this.lyr, x, y);
        this.on_scroll(x, y);
      }
      else {
        clearInterval(this.timerId);
        this.timerId = 0;
        this.shiftTo(this.lyr, this.endX, this.endY);
        this.on_scroll_end(this.endX, this.endY);
      }
    }
    else {
      if ((this.fx < 0 && x >= -this.maxX && this.fy < 0 && y >= -this.maxY) || (this.fx > 0 && x <= 0 && this.fy > 0 && y <= 0) || (this.fx < 0 && x >= -this.maxX && this.fy > 0 && y <= 0) || (this.fx > 0 && x <= 0 && this.fy < 0 && y >= -this.maxY)) {
        this.lastTime = now;
        this.shiftTo(this.lyr, x, y);
        this.on_scroll(x, y);
      }
      else {
        clearInterval(this.timerId);
        this.timerId = 0;
        this.on_scroll_end(this.x, this.y);
      }
    }
  }
};
scrollObjCo3.prototype.endScroll = function() {
  if (!this.ready) return;
  if (this.timerId) clearInterval(this.timerId);
  this.timerId = 0;
  this.lyr = null;

};
// Mousewheel eventen:
// Denne metode stopper scrollen og derefter s?tter den en variabel s? en ny mousescroll event kan finde sted.
scrollObjCo3.prototype.mousewheelStop = function() {
  this.endScroll();
  mouseWheelEventInProgress = false;

};
scrollObjCo3.prototype.on_scroll = function() { };
scrollObjCo3.prototype.on_scroll_start = function() { };
scrollObjCo3.prototype.on_scroll_end = function() { };
scrollObjCo3.slideDur = 500;
scrollObjCo3.scrollBy = function(wnId, x, y, dur) { if (scrollObjCo3s[wnId]) scrollObjCo3s[wnId].glideBy(x, y, dur); };
scrollObjCo3.scrollTo = function(wnId, x, y, dur) { if (scrollObjCo3s[wnId]) scrollObjCo3s[wnId].glideTo(x, y, dur); };
scrollObjCo3.prototype.glideBy = function(dx, dy, dur) {
  if (!document.getElementById || this.sliding) return;
  this.slideDur = dur || scrollObjCo3.slideDur;
  this.destX = this.destY = this.distX = this.distY = 0;
  this.lyr = document.getElementById(this.lyrId);
  this.startX = this.x;
  this.startY = this.y;
  if (dy < 0) this.distY = (this.startY + dy >= -this.maxY) ? dy : -(this.startY + this.maxY);
  else if (dy > 0) this.distY = (this.startY + dy <= 0) ? dy : -this.startY;
  if (dx < 0) this.distX = (this.startX + dx >= -this.maxX) ? dx : -(this.startX + this.maxX);
  else if (dx > 0) this.distX = (this.startX + dx <= 0) ? dx : -this.startX;
  this.destX = this.startX + this.distX;
  this.destY = this.startY + this.distY;
  this.slideTo(this.destX, this.destY);
};
scrollObjCo3.prototype.glideTo = function(destX, destY, dur) {
  if (!document.getElementById || this.sliding) return;
  this.slideDur = dur || scrollObjCo3.slideDur;
  this.lyr = document.getElementById(this.lyrId);
  this.startX = this.x;
  this.startY = this.y;
  this.destX = -Math.max(Math.min(destX, this.maxX), 0);
  this.destY = -Math.max(Math.min(destY, this.maxY), 0);
  this.distY = this.destY - this.startY;
  this.distX = this.destX - this.startX;
  this.slideTo(this.destX, this.destY);
};
scrollObjCo3.prototype.slideTo = function(destX, destY) {
  this.per = Math.PI / (2 * this.slideDur);
  this.sliding = true;
  this.slideStart = (new Date()).getTime();
  this.aniTimer = setInterval(this.animString + ".doSlide()", 10);
  this.on_slide_start(this.startX, this.startY);
};
scrollObjCo3.prototype.doSlide = function() {
  var elapsed = (new Date()).getTime() - this.slideStart;
  if (elapsed < this.slideDur) {
    var x = this.startX + this.distX * Math.sin(this.per * elapsed);
    var y = this.startY + this.distY * Math.sin(this.per * elapsed);
    this.shiftTo(this.lyr, x, y);
    this.on_slide(x, y);
  }
  else {
    clearInterval(this.aniTimer);
    this.sliding = false;
    this.shiftTo(this.lyr, this.destX, this.destY);
    this.lyr = null;
    this.on_slide_end(this.destX, this.destY);
  }
};
scrollObjCo3.prototype.on_slide_start = function() { };
scrollObjCo3.prototype.on_slide = function() { };
scrollObjCo3.prototype.on_slide_end = function() { };
var co3_slidebar = {
  obj: null,
  slideDur: 500,
  init: function(bar, track, axis, x, y) {
    x = x || 0;
    y = y || 0;
    bar.style.left = x + "px";
    bar.style.top = y + "px";
    bar.axis = axis;
    track.bar = bar;
    if (axis == "h") {
      bar.trkWd = track.offsetWidth;
      bar.maxX = bar.trkWd - bar.offsetWidth - x;
      bar.minX = x;
      bar.maxY = y;
      bar.minY = y;
    }
    else {
      bar.trkHt = track.offsetHeight;
      bar.maxY = bar.trkHt - bar.offsetHeight - y;
      bar.maxX = x;
      bar.minX = x;
      bar.minY = y;
    }
    bar.on_drag_start = bar.on_drag = bar.on_drag_end = bar.on_slide_start = bar.on_slide = bar.on_slide_end = function() { };
    bar.onmousedown = this.startDrag; track.onmousedown = this.startSlide;
  },
  startSlide: function(e) {
    if (co3_slidebar.aniTimer) clearInterval(co3_slidebar.aniTimer);
    e = e ? e : window.event;
    var bar = co3_slidebar.obj = this.bar;
    e.offX = (typeof e.layerX != "undefined") ? e.layerX : e.offsetX;
    e.offY = (typeof e.layerY != "undefined") ? e.layerY : e.offsetY;
    bar.startX = parseInt(bar.style.left); bar.startY = parseInt(bar.style.top);
    if (bar.axis == "v") {
      bar.destX = bar.startX;
      bar.destY = (e.offY < bar.startY) ? e.offY : e.offY - bar.offsetHeight;
      bar.destY = Math.min(Math.max(bar.destY, bar.minY), bar.maxY);
    }
    else {
      bar.destX = (e.offX < bar.startX) ? e.offX : e.offX - bar.offsetWidth;
      bar.destX = Math.min(Math.max(bar.destX, bar.minX), bar.maxX);
      bar.destY = bar.startY;
    }
    bar.distX = bar.destX - bar.startX;
    bar.distY = bar.destY - bar.startY;
    co3_slidebar.per = Math.PI / (2 * co3_slidebar.slideDur);
    co3_slidebar.slideStart = (new Date()).getTime();
    bar.on_slide_start(bar.startX, bar.startY);
    co3_slidebar.aniTimer = setInterval("co3_slidebar.doSlide()", 10);
  },
  doSlide: function() {
    if (!co3_slidebar.obj) { clearInterval(co3_slidebar.aniTimer); return; }
    var bar = co3_slidebar.obj;
    var elapsed = (new Date()).getTime() - this.slideStart;
    if (elapsed < this.slideDur) {
      var x = bar.startX + bar.distX * Math.sin(this.per * elapsed);
      var y = bar.startY + bar.distY * Math.sin(this.per * elapsed);
      bar.style.left = x + "px";
      bar.style.top = y + "px";
      bar.on_slide(x, y);
    }
    else {
      clearInterval(this.aniTimer);
      bar.style.left = bar.destX + "px";
      bar.style.top = bar.destY + "px";
      bar.on_slide_end(bar.destX, bar.destY);
      this.obj = null;
    }
  },
  startDrag: function(e) {
    e = co3_event.DOMit(e);
    if (co3_slidebar.aniTimer) clearInterval(co3_slidebar.aniTimer);
    var bar = co3_slidebar.obj = this;
    bar.downX = e.clientX;
    bar.downY = e.clientY;
    bar.startX = parseInt(bar.style.left);
    bar.startY = parseInt(bar.style.top);
    bar.on_drag_start(bar.startX, bar.startY);
    co3_event.add(document, "mousemove", co3_slidebar.doDrag, true);
    co3_event.add(document, "mouseup", co3_slidebar.endDrag, true);
    e.stopPropagation();
  },
  doDrag: function(e) {
    e = e ? e : window.event;
    if (!co3_slidebar.obj) return;
    var bar = co3_slidebar.obj;
    var nx = bar.startX + e.clientX - bar.downX;
    var ny = bar.startY + e.clientY - bar.downY;
    nx = Math.min(Math.max(bar.minX, nx), bar.maxX);
    ny = Math.min(Math.max(bar.minY, ny), bar.maxY);
    bar.style.left = nx + "px";
    bar.style.top = ny + "px";
    bar.on_drag(nx, ny);
    return false;
  },
  endDrag: function() {
    co3_event.remove(document, "mousemove", co3_slidebar.doDrag, true);
    co3_event.remove(document, "mouseup", co3_slidebar.endDrag, true);
    if (!co3_slidebar.obj) return;
    co3_slidebar.obj.on_drag_end(parseInt(co3_slidebar.obj.style.left), parseInt(co3_slidebar.obj.style.top));
    co3_slidebar.obj = null;
  }
};

//scrollObjCo3.prototype.bSizeDragBar=true;
scrollObjCo3.prototype.setUpScrollbar = function(id, trkId, axis, offx, offy) {
  if (!document.getElementById || !document.getElementById(id)) return;
  var bar = document.getElementById(id);
  var trk = document.getElementById(trkId);
  co3_slidebar.init(bar, trk, axis, offx, offy);
  bar.wn = scrollObjCo3s[this.id];
  if (axis == "v") this.vBarId = id;
  else this.hBarId = id;
  if (this.bSizeDragBar) this.setBarSize();
  bar.on_drag_start = bar.on_slide_start = scrollObjCo3.getWndoLyrRef;
  bar.on_drag_end = bar.on_slide_end = scrollObjCo3.tossWndoLyrRef;
  bar.on_drag = bar.on_slide = scrollObjCo3.UpdateWndoLyrPos;
};
scrollObjCo3.getWndoLyrRef = function() { this.wnLyr = document.getElementById(this.wn.lyrId); };
scrollObjCo3.tossWndoLyrRef = function() { this.wnLyr = null; };
scrollObjCo3.UpdateWndoLyrPos = function(x, y) {
  var nx, ny;
  if (this.axis == "v") {
    nx = this.wn.x;
    ny = -(y - this.minY) * (this.wn.maxY / (this.maxY - this.minY)) || 0;
  }
  else {
    ny = this.wn.y;
    nx = -(x - this.minX) * (this.wn.maxX / (this.maxX - this.minX)) || 0;
  }
  this.wn.shiftTo(this.wnLyr, nx, ny);
};
scrollObjCo3.prototype.updateScrollbar = function(x, y) {
  var nx, ny;
  if (this.vBarId) {
    if (!this.maxY) return;
    ny = -(y * ((this.vbar.maxY - this.vbar.minY) / this.maxY) - this.vbar.minY);
    ny = Math.min(Math.max(ny, this.vbar.minY), this.vbar.maxY);
    nx = parseInt(this.vbar.style.left);
    this.vbar.style.left = nx + "px";
    this.vbar.style.top = ny + "px";
  }
  if (this.hBarId) {
    if (!this.maxX) return;
    nx = -(x * ((this.hbar.maxX - this.hbar.minX) / this.maxX) - this.hbar.minX);
    nx = Math.min(Math.max(nx, this.hbar.minX), this.hbar.maxX);
    ny = parseInt(this.hbar.style.top);
    this.hbar.style.left = nx + "px";
    this.hbar.style.top = ny + "px";
  }
};
scrollObjCo3.prototype.restoreScrollbars = function() {
  var bar;
  if (this.vBarId) {
    bar = document.getElementById(this.vBarId);
    bar.style.left = bar.minX + "px";
    bar.style.top = bar.minY + "px";
  }
  if (this.hBarId) {
    bar = document.getElementById(this.hBarId);
    bar.style.left = bar.minX + "px";
    bar.style.top = bar.minY + "px";
  }
};
scrollObjCo3.prototype.setBarSize = function() {
  var bar;
  var lyr = document.getElementById(this.lyrId);
  var wn = document.getElementById(this.id);
  if (this.vBarId) {
    bar = document.getElementById(this.vBarId);
    //lyr = ScrollContent
    //wn = ScrollWindow
    //bar = scrollDragV
    //alert(bar.id + " : " + lyr.offsetHeight + " : " + wn.offsetHeight + " : " + bar.trkHt);
    bar.style.height = (lyr.offsetHeight > wn.offsetHeight) ? parseInt(bar.trkHt / (lyr.offsetHeight / wn.offsetHeight)) + "px" : parseInt(bar.trkHt - 2 * bar.minY) + "px";
    bar.maxY = bar.trkHt - bar.offsetHeight - bar.minY;
  }
  if (this.hBarId) {
    bar = document.getElementById(this.hBarId);
    bar.style.width = (this.wd > wn.offsetWidth) ? parseInt(bar.trkWd / (this.wd / wn.offsetWidth)) + "px" : parseInt(bar.trkWd - 2 * bar.minX) + "px";
    bar.maxX = bar.trkWd - bar.offsetWidth - bar.minX;
  }
};
scrollObjCo3.prototype.on_load = function() {
  this.restoreScrollbars();
  if (this.bSizeDragBar) this.setBarSize();
};
scrollObjCo3.prototype.on_scroll = scrollObjCo3.prototype.on_slide = function(x, y) { this.updateScrollbar(x, y); };
scrollObjCo3.prototype.on_scroll_start = scrollObjCo3.prototype.on_slide_start = function() {
  if (this.vBarId) this.vbar = document.getElementById(this.vBarId);
  if (this.hBarId) this.hbar = document.getElementById(this.hBarId);
};
scrollObjCo3.prototype.on_scroll_end = scrollObjCo3.prototype.on_slide_end = function(x, y) {
  this.updateScrollbar(x, y);
  this.lyr = null; this.bar = null;
};
var co3_event = {
  add: function(obj, etype, fp, cap) {
    cap = cap || false;
    if (obj.addEventListener) obj.addEventListener(etype, fp, cap);
    else if (obj.attachEvent) obj.attachEvent("on" + etype, fp);
  },
  remove: function(obj, etype, fp, cap) {
    cap = cap || false;
    if (obj.removeEventListener) obj.removeEventListener(etype, fp, cap);
    else if (obj.detachEvent) obj.detachEvent("on" + etype, fp);
  },
  DOMit: function(e) {
    e = e ? e : window.event;
    e.tgt = e.srcElement ? e.srcElement : e.target;
    if (!e.preventDefault) e.preventDefault = function() { return false; };
    if (!e.stopPropagation) e.stopPropagation = function() { if (window.event) window.event.cancelBubble = true; };
    return e;
  }
};
scrollObjCo3.prototype.setStyles = function(scrollerCount) {
  this.bSizeDragBar = true;
  var scrollHolder = document.getElementById("scrollHolder_" + scrollerCount);
  var scrollWindow = document.getElementById("scrollWindow_" + scrollerCount);
  var scrollContent = document.getElementById("scrollContent_" + scrollerCount);
  var scrollBarV = document.getElementById("scrollBarV_" + scrollerCount);
  if (this.Co3["dirV"] && scrollBarV) {
    //if(scrollContent.offsetHeight<=this.Co3["height"]){this.Co3["drag_imageV"]="";scrollBarV.style.display="none";}
    var arrowUp = new Image();
    arrowUp.src = this.Co3["arrow_up"];
    var scrollArrowUp = document.getElementById("scrollArrowUp_" + scrollerCount);
    var scrollArrowDown = document.getElementById("scrollArrowDown_" + scrollerCount);
    scrollArrowUp.style.left = scrollArrowUp.style.top = scrollArrowDown.style.left = scrollArrowDown.style.bottom = "0";
    scrollArrowUp.style.height = scrollArrowDown.style.height = scrollArrowUp.style.width = scrollArrowDown.style.width = this.Co3["track_weight"] + "px";
    scrollArrowUp.style.backgroundImage = "url(" + this.Co3["arrow_up"] + ")";
    scrollArrowDown.style.backgroundImage = "url(" + this.Co3["arrow_down"] + ")";
    scrollArrowUp.style.backgroundColor = scrollArrowDown.style.backgroundColor = this.Co3["arrow_color"];
    scrollBarV.style.top = "0";
    scrollBarV.style.left = this.Co3["width"] + this.Co3["scrollbar_space"] + "px";
    scrollBarV.style.height = this.Co3["height"] + "px";
    scrollBarV.style.width = this.Co3["track_weight"] + "px";
    var scrollTrackV = document.getElementById("scrollTrackV_" + scrollerCount);
    scrollTrackV.style.backgroundColor = this.Co3["track_color"];
    scrollTrackV.style.top = this.Co3["track_weight"] + this.Co3["arrow_space"] + "px";
    scrollTrackV.style.height = this.Co3["height"] - 2 * this.Co3["track_weight"] - 2 * this.Co3["arrow_space"] + "px";
    if (this.Co3["drag_imageV"] != "") {
      this.bSizeDragBar = false;
      var dragImageV = new Image();
      dragImageV.src = this.Co3["drag_imageV"];
      scrollTrackV.firstChild.style.backgroundImage = "url(" + dragImageV.src + ")";
      scrollTrackV.firstChild.style.height = this.Co3["drag_height"] + "px";
      if (this.Co3["drag_width"] > this.Co3["track_weight"]) {
        scrollArrowUp.style.left = scrollArrowDown.style.left = Math.round((this.Co3["drag_width"] - this.Co3["track_weight"]) / 2) + "px";
        scrollBarV.style.width = scrollTrackV.style.width = scrollTrackV.firstChild.style.width = this.Co3["drag_width"] + "px";
      }
      else {
        scrollBarV.style.width = scrollTrackV.style.width = scrollTrackV.firstChild.style.width = this.Co3["track_weight"] + "px";
        scrollTrackV.firstChild.style.left = Math.round((this.Co3["track_weight"] - this.Co3["drag_width"]) / 2) + "px";
      }
    }
    else {
      scrollTrackV.style.width = this.Co3["track_weight"] + "px";
      scrollTrackV.style.background = this.Co3["track_color"];
      scrollTrackV.firstChild.style.background = this.Co3["drag_color"];
      scrollTrackV.firstChild.style.height = Math.min(this.Co3["drag_height"], Math.round(scrollTrackV.offsetHeight / 2)) + "px";
      scrollTrackV.firstChild.style.width = this.Co3["track_weight"] + "px";
    }
  }
  var scrollBarH = document.getElementById("scrollBarH_" + scrollerCount);
  if (this.Co3["dirH"] && scrollBarH) {
    //if(scrollContent.offsetWidth<=this.Co3["width"]){this.Co3["drag_imageH"]="";scrollBarH.style.display="none";}
    var arrowLeft = new Image();
    arrowLeft.src = this.Co3["arrow_left"];
    var scrollArrowLeft = document.getElementById("scrollArrowLeft_" + scrollerCount);
    var scrollArrowRight = document.getElementById("scrollArrowRight_" + scrollerCount);
    scrollArrowLeft.style.left = scrollArrowLeft.style.top = scrollArrowRight.style.right = scrollArrowRight.style.top = "0";
    if (this.Co3["arrow_ajust"]) {
      scrollArrowLeft.style.marginLeft = scrollArrowRight.style.marginRight = this.Co3["arrow_space"] + "px";
      scrollArrowLeft.style.backgroundRepeat = scrollArrowRight.style.backgroundRepeat = "no-repeat";
    }
    scrollArrowLeft.style.height = scrollArrowRight.style.height = scrollArrowLeft.style.width = scrollArrowRight.style.width = this.Co3["track_weight"] + "px";
    scrollArrowLeft.style.backgroundImage = "url(" + this.Co3["arrow_left"] + ")";
    scrollArrowRight.style.backgroundImage = "url(" + this.Co3["arrow_right"] + ")";
    scrollArrowLeft.style.backgroundColor = scrollArrowRight.style.backgroundColor = this.Co3["arrow_color"];
    scrollBarH.style.top = this.Co3["height"] + this.Co3["scrollbar_space"] + "px";
    scrollBarH.style.left = "0";
    scrollBarH.style.width = this.Co3["width"] + "px";
    scrollBarH.style.height = this.Co3["track_weight"] + "px";
    var scrollTrackH = document.getElementById("scrollTrackH_" + scrollerCount);
    scrollTrackH.style.backgroundColor = this.Co3["track_color"];
    scrollTrackH.style.left = this.Co3["track_weight"] + this.Co3["arrow_space"] + "px";
    scrollTrackH.style.width = this.Co3["width"] - 2 * this.Co3["track_weight"] - 2 * this.Co3["arrow_space"] + "px";
    if (this.Co3["drag_imageH"] != "") {
      this.bSizeDragBar = false;
      var dragImageH = new Image();
      dragImageH.src = this.Co3["drag_imageH"];
      scrollTrackH.firstChild.style.backgroundImage = "url(" + dragImageH.src + ")";
      scrollTrackH.firstChild.style.width = this.Co3["drag_height"] + "px";
      if (this.Co3["drag_width"] > this.Co3["track_weight"]) {
        scrollArrowLeft.style.top = scrollArrowRight.style.top = Math.round((this.Co3["drag_width"] - this.Co3["track_weight"]) / 2) + "px";
        scrollBarH.style.height = scrollTrackH.style.height = scrollTrackH.firstChild.style.height = this.Co3["drag_width"] + "px";
      }
      else {
        scrollBarH.style.height = scrollTrackH.style.height = scrollTrackH.firstChild.style.height = this.Co3["track_weight"] + "px";
        scrollTrackH.firstChild.style.top = Math.round((this.Co3["track_weight"] - this.Co3["drag_width"]) / 2) + "px";
      }
    }
    else {
      scrollTrackH.style.height = this.Co3["track_weight"] + "px";
      scrollTrackH.style.background = this.Co3["track_color"];
      scrollTrackH.firstChild.style.background = this.Co3["drag_color"];
      scrollTrackH.firstChild.style.height = this.Co3["track_weight"] + "px";
      scrollTrackH.firstChild.style.width = Math.min(this.Co3["drag_height"], Math.round(scrollTrackH.offsetWidth / 2)) + "px";
    }
  }
  try {
    scrollHolder.style.width = this.Co3["width"] + (scrollBarV ? (scrollBarV.offsetWidth + this.Co3["scrollbar_space"]) : "") + "px";
    scrollHolder.style.height = this.Co3["height"] + (scrollBarH ? (scrollBarH.offsetHeight + this.Co3["scrollbar_space"]) : "") + "px";
    scrollWindow.style.width = this.Co3["width"] + "px";
    scrollWindow.style.height = this.Co3["height"] + "px";
    scrollWindow.style.clip = "rect(0," + this.Co3["width"] + "px," + this.Co3["height"] + "px,0)";

    // Skal s?rge for at skjule den vertikale scrollbar, hvis der ikke er brug for den.
    if (scrollContent.clientHeight <= this.Co3["height"])
      scrollBarV.style.visibility = "hidden";

    // Skal s?rge for at skjule den horisontale scrollbar, hvis der ikke er brug for den.
    if (scrollContent.clientWidth <= this.Co3["width"])
      scrollBarH.style.visibility = "hidden";
  } catch (ex) { }
};
arrScroll = {}
pageScroll = [];
scrollObjCo3s = {};
scrollObjCo3.speed = 200;
function scrollObjCo3(wnId, doNotUseGlideTo) {
  
  this.id = "scrollWindow_" + wnId;
  scrollObjCo3s[this.id] = this;
  this.animString = "scrollObjCo3s." + this.id;
  this.customizeScroll(wnId);
  this.setStyles(wnId);
  this.load("scrollContent_" + wnId);
  if (this.Co3["dirV"]) this.setUpScrollbar("scrollDragV_" + wnId, "scrollTrackV_" + wnId, "v", 1, 1);
  if (this.Co3["dirH"]) this.setUpScrollbar("scrollDragH_" + wnId, "scrollTrackH_" + wnId, "h", 1, 1);
  if(!doNotUseGlideTo)
    this.glideTo(this.Co3["slideToX"], this.Co3["slideToY"], this.Co3["slideSpeed"]);
};
function initScrollLayer(doNotUseGlideTo) {
  if (!noScrollBar) {
    i = 1;
    for (scroller in arrScroll) {
      pageScroll[pageScroll.length] = new scrollObjCo3(scroller.replace(/^scroll_/, ""), doNotUseGlideTo);

      document.getElementById("scrollHolder_" + i).onmousewheel = wheel;
      if (window.addEventListener)
      /** DOMMouseScroll is for mozilla. */
        document.getElementById("scrollHolder_" + i).addEventListener('DOMMouseScroll', wheel, false);

      window
      i++;
    } 
  }
}
scrollObjCo3.prototype.customizeScroll = function(wnId) {
  this.Co3 = {};
  this.Co3 = arrScroll["scroll_" + wnId];
  scrollObjCo3.speed = this.Co3["speed"];
};


/*MOUSEWHEEL START*/
mouseWheelEventInProgress = false;

function handle(delta, target) {
  targetID = getScrollId(target);
  co3 = scrollObjCo3s['scrollWindow_' + targetID].Co3;
  forward = "left";
  backwards = "right";
  if (co3.dirV) {
    forward = "up";
    backwards = "down";
  }

  if (!mouseWheelEventInProgress) {
    if (delta < 0) {
      mouseWheelEventInProgress = true;
      scrollObjCo3.initScroll('scrollWindow_' + targetID, backwards);
    } else {
      mouseWheelEventInProgress = true;
      scrollObjCo3.initScroll('scrollWindow_' + targetID, forward);
    }
  }
}
function getScrollId(target) {

  if (target.parentNode.id.indexOf("scrollHolder_") >= 0)
    return target.parentNode.id.replace("scrollHolder_", "")
  return getScrollId(target.parentNode);
}

function writeToLog(text) {
  document.getElementById("textarea").value = "\n" + text + document.getElementById("textarea").value;
}

/** Event handler for mouse wheel event.
** Denne metode skal tilmeldes det ?nskede objekts onmousewheel event.
** 
*/
function wheel(event) {
  var delta = 0;
  if (!event) /* For IE. */
    event = window.event;
  if (event.wheelDelta) { /* IE/Opera. */
    delta = event.wheelDelta / 120;
    /** In Opera 9, delta differs in sign as compared to IE.
    */
    if (window.opera)
      delta = -delta;
  } else if (event.detail) { /** Mozilla case. */
    /** In Mozilla, sign of delta is different than in IE.
    * Also, delta is multiple of 3.
    */
    delta = -event.detail / 3;
  }
  /** If delta is nonzero, handle it.
  * Basically, delta is now positive if wheel was scrolled up,
  * and negative, if wheel was scrolled down.
  */
  if (delta) {
    var targ;
    if (event.target)
      targ = event.target;
    else if (event.srcElement)
      targ = event.srcElement;
    //Handle er den metode man vil have til at k?re n?r eventen fyres
    handle(delta, targ);
  }
  /** Prevent default actions caused by mouse wheel.
  * That might be ugly, but we handle scrolls somehow
  * anyway, so don't bother here..
  */
  if (event.preventDefault)
    event.preventDefault();
  event.returnValue = false;
}

//if (window.addEventListener)
//        /** DOMMouseScroll is for mozilla. */
//        window.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
//window.onmousewheel = document.onmousewheel = wheel;
/*MOUSEWHEEL END*/


/*  Write the Scrollbar START  */
//Writes the first part of the scrollbar
// sID is the Id of the scrollbar
function writeScrollStart(sID) {
  if (!noScrollBar) {
    document.write('<div id="scrollHolder_' + sID + '" class="scrollHolder">');
    document.write('<div id="scrollWindow_' + sID + '" class="scrollWindow">');
    document.write('<div id="scrollContent_' + sID + '" class="scrollContent">');
  } 
}

//Writes the last part of the scrollbar
// sID is the Id of the scrollbar
function writeScrollEnd(sID) {
  if (!noScrollBar) {
    document.write('</div>');
    document.write('</div>');
    document.write('<div id="scrollBarV_'
     + sID + '" class="scrollBar"><div id="scrollArrowUp_'
     + sID + '" class="scrollArrow" onMouseOver="scrollObjCo3.initScroll(\'scrollWindow_'
     + sID + '\',\'up\')" onMouseOut="scrollObjCo3.stopScroll(\'scrollWindow_'
     + sID + '\')" onMouseDown="scrollObjCo3.doubleSpeed(\'scrollWindow_'
     + sID + '\')" onMouseUp="scrollObjCo3.resetSpeed(\'scrollWindow_'
     + sID + '\')"></div><div id="scrollTrackV_'
     + sID + '" class="scrollTrack"><div id="scrollDragV_'
     + sID + '" class="scrollDrag"></div></div><div id="scrollArrowDown_'
     + sID + '" class="scrollArrow" onMouseOver="scrollObjCo3.initScroll(\'scrollWindow_'
     + sID + '\',\'down\')" onMouseOut="scrollObjCo3.stopScroll(\'scrollWindow_'
     + sID + '\')" onMouseDown="scrollObjCo3.doubleSpeed(\'scrollWindow_'
     + sID + '\')" onMouseUp="scrollObjCo3.resetSpeed(\'scrollWindow_'
     + sID + '\')"></div></div>');
    document.write('<div id="scrollBarH_'
    + sID + '" class="scrollBar"><div id="scrollArrowLeft_'
    + sID + '" class="scrollArrow" onMouseOver="scrollObjCo3.initScroll(\'scrollWindow_'
    + sID + '\',\'left\')" onMouseOut="scrollObjCo3.stopScroll(\'scrollWindow_'
    + sID + '\')" onMouseDown="scrollObjCo3.doubleSpeed(\'scrollWindow_'
    + sID + '\')" onMouseUp="scrollObjCo3.resetSpeed(\'scrollWindow_'
    + sID + '\')"></div><div id="scrollTrackH_'
    + sID + '" class="scrollTrack"><div id="scrollDragH_'
    + sID + '" class="scrollDrag"></div></div><div id="scrollArrowRight_'
    + sID + '" class="scrollArrow" onMouseOver="scrollObjCo3.initScroll(\'scrollWindow_'
    + sID + '\',\'right\')" onMouseOut="scrollObjCo3.stopScroll(\'scrollWindow_'
    + sID + '\')" onMouseDown="scrollObjCo3.doubleSpeed(\'scrollWindow_'
    + sID + '\')" onMouseUp="scrollObjCo3.resetSpeed(\'scrollWindow_'
    + sID + '\')"></div></div>');
    document.write('</div>');
  } 
}

// Writes a full scrollbar including content
// sID is the Id of the scrollbar
function writeScrollBar(sID, contentHTML) {
  if (!noScrollBar) {
    writeScrollStart(sID);
    document.write(contentHTML);
    writeScrollEnd(sID);
  }
}
/*  Write the Scrollbar END  */

/*  Scrollbar END  */
