function loadBanners(settings) { 
  //settings = getSettings(blockvar);

  // parameters
  this.block = document.getElementById(settings.block);
  this.mapping = settings.mapping;
  this.numbanners = this.mapping.length;
  this.numlayers = settings.numlayers;
  this.marginbottom = settings.marginbottom;
  this.interval = settings.interval;
  this.direction = settings.direction;

  // maak banner container
  bannermask = document.createElement('div');
  bannermask.style.width = "1000000px";
  bannermask.id = this.id + "mask";
  this.block.appendChild(bannermask);
    
  // plaats de eerste banners
  for (x=0; x<this.numlayers; x++) {
    banner = document.createElement('div');
    if (this.direction == "bottom") {
      banner.style.marginBottom = this.marginbottom + "px";
    } else {
      banner.style.marginRight = this.marginbottom + "px";
      banner.style.float = 'left';
      banner.style.width = "auto";
      banner.style.display = 'inline';
    }
    ahref = document.createElement('a');
    ahref.href = '/php/banner.php?action=click&id=' + this.mapping[x+1][0];
    image = document.createElement('img');
    image.style.verticalAlign = 'top';
    image.src = this.mapping[x+1][1];
    if (this.mapping[x+1][2] != '') {
      var mouseimg = new Image();
      mouseimg.src = this.mapping[x+1][2];
      var mouseout = new Image();
      mouseout.src = this.mapping[x+1][1];
      image.onmouseover = function() { this.src=mouseimg.src};
      image.onmouseout = function() { this.src=mouseout.src};
    }
    image.border = 0;
    ahref.appendChild(image);
    banner.appendChild(ahref);
    bannermask.appendChild(banner);
  }

  // meet de hoogte van de eerste banners
  maskheight = 0;
  for (x=0; x<this.numlayers; x++) {
    var edim = Element.getDimensions(bannermask.childNodes[x]);	
    maskheight = (maskheight+edim.height) + this.marginbottom;
  }

  // dynamisch banners bijplaatsen
  bannermask.current = 0;
  bannermask.marginbottom = this.marginbottom;
  bannermask.numbanners = this.numbanners;
  this.block.style.overflow = "hidden";
  if (this.direction == "bottom") {
    this.block.style.height = Math.max(maskheight,600) + "px";
  } else {
    this.block.style.width = "100%";
    this.block.style.height = "100%";
  }
  current = x;
  timer = setInterval(function() {
      x = 1 + x % (this.numbanners-1);
      banner = document.createElement('div');
      if (this.direction == "bottom") {
        banner.style.marginBottom = this.marginbottom + "px";
      } else {
        banner.style.marginRight = this.marginbottom + "px";
        banner.style.float = 'left';
        banner.style.width = "auto";
        banner.style.display = 'inline';
        //banner.style.top = "0px";
      }
      ahref = document.createElement('a');
      ahref.href = '/php/banner.php?action=click&id=' + this.mapping[x][0];
      image = document.createElement('img');
      image.style.verticalAlign = 'top';
      image.src = this.mapping[x][1];
      if (this.mapping[x][2] != '') {
        var mouseimg = new Image();
        mouseimg.src = this.mapping[x][2];
        var mouseout = new Image();
        mouseout.src = this.mapping[x][1];
        image.onmouseover = function() { this.src=mouseimg.src};
        image.onmouseout = function() { this.src=mouseout.src};
      }
      image.border = 0;
      if (this.direction == "bottom") {
        bannermask.scrollBannerUp();
      } else {
        bannermask.scrollBannerLeft();
      }
      ahref.appendChild(image);
      banner.appendChild(ahref);
      bannermask.appendChild(banner);
  }, this.interval);

  bannermask.scrollBannerUp = function() {
    var cdim = Element.getDimensions(this.childNodes[0]);	
    new Effect.Move(this, { x: 0, y: -(cdim.height+this.marginbottom), duration: 1.5, afterFinish: bannermask.cleanUp} );
  }

  bannermask.scrollBannerLeft = function() {
    var cdim = Element.getDimensions(this.childNodes[0]);	
    new Effect.Move(this, { x: -(cdim.width+this.marginbottom), y: 0, duration: 1.5, afterFinish: bannermask.cleanUp} );
  }

  bannermask.cleanUp = function(position) {
    if (parent.direction == "bottom") { bannermask.setStyle({'top': '0px'}); } else { bannermask.setStyle({'left': '0px'}); }
    bannermask.childNodes[0].remove();
    bannermask.current++;
  }
}

function getSettings(blockvar) {
  if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
      tmp = xmlhttp.responseText;
      eval(tmp);
      alert(tmp);
    }
  }
  xmlhttp.open("GET","/php/banner_ajax.php?block="+blockvar,true);
  xmlhttp.send("");
}
