﻿var TopPosCorrection = 40;
var LeftPosCorrection = 0;

scrollID = 1;

function showMaxView() {
  if (document.getElementById("maxview")) {
    if (document.getElementById("maxview").style.display == "block") {
      document.getElementById("maxview").style.display = "none";
    } else {
      document.getElementById("maxview").style.display = "block";
    }
  }
}
function docwriter(str) {
  document.write(str);
}
function getFlashObjId(movieName) {
  movieFileNameParts = movieName.split('/');
  movieFileName = movieFileNameParts[movieFileNameParts.length - 1];
  return (movieFileName.substr(0, movieFileName.length - 4));
}
function writeFlashObj(movie, width, height, strFlashVars) {
  var flashObjId = getFlashObjId(movie);
  var flashObj = '';
  flashObj += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" id="' + flashObjId + '" align="middle">';
  flashObj += '<param name="allowScriptAccess" value="sameDomain" />';
  flashObj += '<param name="movie" value="' + movie + '" />';
  flashObj += '<param name="quality" value="high" />';
  flashObj += '<param name="bgcolor" value="#ffffff" />';
  flashObj += '<param name="menu" value="false" />';
  if (strFlashVars.length > 0) {
    flashObj += '<param name="FlashVars" value="' + strFlashVars + '" />';
  }
  flashObj += '<embed FlashVars="' + strFlashVars + '" src="' + movie + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="' + flashObjId + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
  flashObj += '</object>';
  docwriter(flashObj);
}

function writeFlashObjToContainer(movie, width, height, strFlashVars, containerid) {
  var flashObjId = getFlashObjId(movie);
  var flashObj = '';
  flashObj += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" id="' + flashObjId + '" align="middle">';
  flashObj += '<param name="allowScriptAccess" value="sameDomain" />';
  flashObj += '<param name="movie" value="' + movie + '" />';
  flashObj += '<param name="quality" value="high" />';
  flashObj += '<param name="bgcolor" value="#ffffff" />';
  flashObj += '<param name="menu" value="false" />';
  if (strFlashVars.length > 0) {
    flashObj += '<param name="FlashVars" value="' + strFlashVars + '" />';
  }
  flashObj += '<embed FlashVars="' + strFlashVars + '" src="' + movie + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="' + flashObjId + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
  flashObj += '</object>';



  document.getElementById(containerid).innerHTML = flashObj;

  // docwriter(flashObj);
}

var arrParams = window.location.search.substr(1).split("&");
var arrQueryString = {}; // Key/Value pairs
for (tempString = [], q = 0; q < arrParams.length; q++) {
  tempString = arrParams[q].split("=");
  arrQueryString[tempString[0]] = tempString[1];
}




/* MENU */

var jump = 4;
var time = 1;
var arrSubMenus = []; //{};//id:[element,height,count,timeout,status]
var b = new browser();
var ix = new Array();
var OpC = new Array();
function getPos(elm) {
  for (var zx = zy = 0; elm != null; zx += elm.offsetLeft, zy += elm.offsetTop, elm = elm.offsetParent);
  return { x: zx, y: zy };
}
function browser() {
  this.agent = navigator.userAgent.toLowerCase();
  this.op = window.opera;
  this.saf = this.agent.indexOf("safari") > -1;
  this.moz = this.agent.indexOf("gecko") > -1 && !this.saf;
  this.ie = this.agent.indexOf("msie") > -1 && !this.op;
  this.ie7 = this.ie && this.agent.indexOf("msie 7") > -1;
  this.mac = this.agent.indexOf("mac") > -1;
  //this.khtml=this.agent.indexOf("khtml")>-1;
  return this;
}
function startOpChange(elm, end, tim) {
  if (!b.ie && !b.moz && !b.saf) return;
  var idx = OpC.length;
  for (var i = 0; idx > i; i++) {
    if (OpC[i][0] == elm) {
      clearInterval(OpC[i][4]);
      idx = i;
      break;
    }
    OpC[idx] = new Array();
  }
  if (idx == 0) OpC[idx] = new Array();
  if (b.ie) actOp = elm.filters.alpha.opacity;
  else if (b.moz) actOp = Math.round((elm.style.MozOpacity * 100));
  else if (b.saf) actOp = Math.round((elm.style.opacity * 100));
  if (actOp != end) {
    OpC[idx][0] = elm;
    OpC[idx][1] = actOp;
    OpC[idx][2] = end;
    OpC[idx][3] = (end > actOp) ? 1 : -1;
    var delayTime = time; //Math.floor((tim*10)/Math.abs((actOp-end)));
    OpC[idx][4] = setInterval("opChange(" + idx + ")", delayTime);
  }
}
function opChange(idx) {
  OpC[idx][1] += OpC[idx][3];
  if (b.ie) OpC[idx][0].filters.alpha.opacity = OpC[idx][1];
  else if (b.moz) OpC[idx][0].style.MozOpacity = Math.min(0.9999, OpC[idx][1] / 100);
  else if (b.saf) OpC[idx][0].style.opacity = OpC[idx][1] / 100;
  if (OpC[idx][1] == OpC[idx][2]) {
    clearInterval(OpC[idx][4]);
    return;
  }
}
function toggleOpacity(el, dir) {
  arrLI = el[0].getElementsByTagName("li");
  for (l = 0; l < arrLI.length; l++) {
    if (l + 1 == arrLI.length) { opVAl2 = (dir == "down" ? 80 : 100); startOpChange(arrLI[l], opVAl2, 1); }
    if (l + 2 == arrLI.length) { opVAl1 = (dir == "down" ? 90 : 100); startOpChange(arrLI[l], opVAl1, 1); }
  }
}
function closeSub(s) {
  if (!arrSubMenus[s][4]) return;
  flex = Math.max(1, Math.round((arrSubMenus[s][2]) / 7));
  if (arrSubMenus[s][0].offsetHeight > 0) arrSubMenus[s][0].style.height = (arrSubMenus[s][1] - arrSubMenus[s][1] % (jump * flex)) + "px";
  clearInterval(arrSubMenus[s][3]); arrSubMenus[s][3] = null; arrSubMenus[s][4] = false;
  arrSubMenus[s][3] = setInterval("if(parseInt(document.getElementById('" + arrSubMenus[s][0].id + "').style.height)<1&&window.arrSubMenus[" + s + "][3]){toggleOpacity(arrSubMenus[" + s + "],'down');clearInterval(arrSubMenus[" + s + "][3]);arrSubMenus[" + s + "][3]=null;}else{document.getElementById('" + arrSubMenus[s][0].id + "').style.height=parseInt(document.getElementById('" + arrSubMenus[s][0].id + "').style.height)-" + (jump * flex) + "+'px';}", time);
}
function openSub(s) {
  if (arrSubMenus[s][4]) return;
  flex = Math.max(1, Math.round((arrSubMenus[s][2]) / 7));
  arrSubMenus[s][0].style.height = arrSubMenus[s][1] % (jump * flex) + "px";
  clearInterval(arrSubMenus[s][3]); arrSubMenus[s][3] = null; arrSubMenus[s][4] = true;
  arrSubMenus[s][3] = setInterval("if(parseInt(document.getElementById('" + arrSubMenus[s][0].id + "').style.height)>=arrSubMenus[" + s + "][1]&&window.arrSubMenus[" + s + "][3]){toggleOpacity(arrSubMenus[" + s + "],'up');clearInterval(arrSubMenus[" + s + "][3]);arrSubMenus[" + s + "][3]=null;}else{document.getElementById('" + arrSubMenus[s][0].id + "').style.height=parseInt(document.getElementById('" + arrSubMenus[s][0].id + "').style.height)+" + (jump * flex) + "+'px';}", time);
}
function toggleSubMenu(topUL) {
  subID = "sub" + topUL.parentNode.id.replace(/^top([0-9]{1,2})$/, "$1");
  for (s = 0; s < arrSubMenus.length; s++) {
    if (arrSubMenus[s][0].id == subID) openSub(s);
    else closeSub(s);
  }
  return false;
}
function initMenus() {
  if (b.ie && !b.ie7) jump = Math.round(jump * 1.7);
  else if (b.mac && b.moz) { jump++; time = time / 2; }
  else if ((b.mac && b.saf) || (!b.mac && b.moz)) jump--;
  var arrMenus = document.getElementById("prodesign_topmenu").getElementsByTagName("li");
  for (m = 0; m < arrMenus.length; m++) {
    if (!arrMenus[m].id.match(/^top[0-9]{1,2}$/)) continue;
    arrMenus[m].getElementsByTagName("a")[0].onclick = function() { return toggleSubMenu(this); };
    subUL = document.getElementById("sub" + arrMenus[m].id.replace(/^top([0-9]{1,2})$/, "$1"));
    if (subUL) {
      arrLI = subUL.getElementsByTagName("li");
      arrSubMenus[arrSubMenus.length] = [subUL, subUL.offsetHeight, arrLI.length, null, false];
      procentHeight = parseInt(100 / arrSubMenus[arrSubMenus.length - 1][2]);
      for (l = 0; l < arrSubMenus[arrSubMenus.length - 1][2]; l++) {
        arrLI[l].style.height = procentHeight + (l + 1 == arrSubMenus[arrSubMenus.length - 1][2] ? 100 % arrSubMenus[arrSubMenus.length - 1][2] : 0) + "%"; //if(b.ie) 
        if (l + 1 == arrSubMenus[arrSubMenus.length - 1][2] || l + 2 == arrSubMenus[arrSubMenus.length - 1][2]) {
          if (b.ie) arrLI[l].filters.alpha.opacity = l + 2 == arrSubMenus[arrSubMenus.length - 1][2] ? "90" : "80";
          else if (b.moz) arrLI[l].style.MozOpacity = l + 2 == arrSubMenus[arrSubMenus.length - 1][2] ? "0.9" : "0.8";
          else if (b.saf) { arrLI[l].style.opacity = l + 2 == arrSubMenus[arrSubMenus.length - 1][2] ? "0.9" : "0.8"; }
        }
      }
      pos = getPos(arrMenus[m]);
      subUL.style.top = pos.y + arrMenus[m].offsetHeight + 2 + "px";
      subUL.style.left = pos.x + 8 + "px";
      if (b.ie) subUL.style.left = pos.x + 14 + "px";
      subUL.style.height = "0";
      subUL.style.visibility = "visible";
    }
  }
  return;
}

function preloadImages() {
  if (document.images) {
    img1 = new Image();
    img1.src = "/Files/Billeder/Products/ProduktLister/all.jpg";
  }
}

function onloadStuff() {
  initMenus();
  preloadImages();
}

window.onload = onloadStuff;


function fillLBModelNo() {
  if (document.getElementById("jobs_modelno")) {
    if (document.getElementById("lb_modelno")) { document.getElementById("lb_modelno").innerHTML = document.getElementById("jobs_modelno").innerHTML; }
  }
}

function checkLegend() {
  if (location.href.indexOf("aspx?ID=") > -1) {
    if (location.href.split("aspx?ID=")[1].indexOf("&") > -1) {
      if (location.href.split("aspx?ID=")[1].split("&")[0] == 1 && document.getElementById("legend_home")) { document.getElementById("legend_home").style.display = "none"; }
    } else {
      if (location.href.split("aspx?ID=")[1].split("&")[0] == 1 && document.getElementById("legend_home")) { document.getElementById("legend_home").style.display = "none"; }
    }
  } else {
    if (document.getElementById("legend_home")) { document.getElementById("legend_home").style.display = "none"; }
  }
}

function showEcomFiltering() {
  if (document.getElementById("prodList")) {
    //    document.getElementById("aViewAll").style.textDecoration = "underline";

    if (arrQueryString["GroupID"] != undefined) {
      document.getElementById("EcomFiltering").style.display = "block";
    }
  }
}













/*  Scrollbar START  */
// JavaScript Document
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);
    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) {
  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);
  
// Dette er koden der sørger for den automatiske product liste scroll
	if (this.Co3["slideToX"] != null){
    this.glideTo(this.Co3["slideToX"], this.Co3["slideToY"], this.Co3["slideSpeed"]);
	}
  
};
function initScrollLayer() {
  i = 1;
  for (scroller in arrScroll) {
//   if (getURLParam("test") != "")
//      alert("doNotUseGlideTo: " + doNotUseGlideTo);
    pageScroll[pageScroll.length] = new scrollObjCo3(scroller.replace(/^scroll_/, ""));
    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) {
  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) {
  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) {
  writeScrollStart(sID);
  document.write(contentHTML);
  writeScrollEnd(sID);
}
/*  Write the Scrollbar END  */

/*  Scrollbar END  */
function createFlash(link, name, align, width, height) {
  var flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
    + ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '"'
    + ' id="' + name + '" align="' + align + '">'
    + '<param name="allowScriptAccess" value="always" />'
    + '<param name="movie" value="' + link + '" /><param name="wmode" value="transparent" />'
    + '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
    + '<embed src="' + link + '" quality="high" bgcolor="#fff" width="' + width + '"'
    + ' height="' + height + '" name="' + name + '" align="' + align + '" wmode="transparent"'
    + ' allowScriptAccess="always" type="application/x-shockwave-flash"'
    + ' pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
  return flash;
}

function writeFlash(link, name, align, width, height) {
  if (link != "")
    document.write(createFlash(link, name, align, width, height));
}