// bannerrotation III - Thomas Salvador, 2010, brauchbar.de
// free to use, if this notice is kept intact

var banner_data = new Array();

function banner_define(picture,link,width,height,alt) { 
  l_picture = picture;
  l_link = link;
  if (banner_define.arguments.length > 2) {
    l_width = width;
  } else {
    l_width = 0;
  }
  if (banner_define.arguments.length > 3) {
    l_height = height;
  } else {
    l_height = 0;
  }
  if (banner_define.arguments.length > 4) {
    l_alt = alt;
  } else {
    l_alt = '';
  }
  banner_data[banner_data.length] = new Array(l_picture,l_link,l_width,l_height,l_alt);
}

function banner_output(id,delay,defined) {
  if (banner_output.arguments.length == 3) {
    if (defined == -1) {
      defined = (new Date()).getTime()%banner_data.length;
    }
    no = defined;
    
  } else {
    no = (new Date()).getTime()%banner_data.length;
  }
  container = document.getElementById(id);
  
  img  = banner_data[no][0];
  href = banner_data[no][1];
  if (banner_data[no][2] != 0) {
    width=' width="'+banner_data[no][2]+'"';
  } else {
    width='';
  }
  if (banner_data[no][3] != 0) {
    height=' height="'+banner_data[no][3]+'"';
  } else {
    height='';
  }  
  if (img.substr(img.length-4,4) == '.swf') {
    container.innerHTML = '<object type="application/x-shockwave-flash"'
    + 'data="'+img+'"'
		+ width+height+'>'
		+ '<param name="movie"'
		+ ' value="'+img+'" />'
		+ '</object>';
  } else {
  alt=' alt="'+banner_data[no][4]+'"';
  container.innerHTML = '<a href="'+href+'" target="_top">'
  +'<img border="0" src="'+img+'"'+width+height+alt+'></a>';
  }
  if (banner_output.arguments.length == 3) {
    setTimeout('banner_output("'+id+'",'+delay+','+((defined+1)%banner_data.length)+');',delay);
  } else {
    if (banner_output.arguments.length == 2) {
      setTimeout('banner_output("'+id+'",'+delay+');',delay);
    }
  }
}
