var isShuffled = false;
var current = 0;
var start = 0;
var end = 11;

var meer_adv_cl = false;
var start_adv = 0;
var end_adv = 11;

var isShuffled_hd = false;
var current_hd = 0;
var start_hd = 0;
//var fade_gif = "images/afb_header/fade_gif.gif";

function fisherYates ( myArray ) {
  var i = myArray.length;
  if ( i == 0 ) return false;
  while ( --i ) {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = myArray[i];
     var tempj = myArray[j];
     myArray[i] = tempj;
     myArray[j] = tempi;
   }
}

function banner() {
	if (!isShuffled) {
		fisherYates(ids);
		isShuffled = true;
	}
	
	id = ids[current];
	current++;
	current %= ids.length;

	if (ids.length > 0) document.getElementById("afbeelding_bnr").innerHTML = "<a href=\""+newplace[id]+"\" target=\"_blank\"><img border=\"0\" src=\""+ads[id]+"\" width=\"342\" height=\"129\" alt=\"\"></a>";

	timer=setTimeout("banner()", advUpdateInterval);
}

function fade() {
	if (!isShuffled_hd) {
		fisherYates(ids_hd);
		isShuffled_hd = true;
	}

	id = ids_hd[current_hd];
	current_hd++;
	current_hd %= ids_hd.length;

	if (document.all) {
		//document.images.SlideShow.style.filter="blendTrans(duration=3)";
		eval("document.images.SlideShow.style.filter=\"blendTrans(duration="+fadeLength_hd+")\";");
		document.images.SlideShow.filters.blendTrans.Apply();
	}
	document.images.SlideShow.src = ads_hd[id];
	document.getElementById("SlideShowLink").href=newplace_hd[id];
	
	if (document.all) {
		document.images.SlideShow.filters.blendTrans.Play();
	}

	timer = setTimeout("fade_to_banner()", advLength_hd);
}

function fade_to_banner() {
	if (document.all) {
		//document.images.SlideShow.style.filter="blendTrans(duration=3)";
		eval("document.images.SlideShow.style.filter=\"blendTrans(duration="+fadeLength_hd+")\";");
		document.images.SlideShow.filters.blendTrans.Apply();
	}
	document.images.SlideShow.src = fade_gif;
	document.getElementById("SlideShowLink").href="#";
	
	if (document.all) {
		document.images.SlideShow.filters.blendTrans.Play();
	}

	timer = setTimeout("fade()", bnrLength_hd);
}

