window.onload = init;
var timer;
function init(){
	if(document.getElementById("bedrijfsleden1")){
		fotoRotate.createObj(
			document.getElementById("bedrijfsleden1"),					//Element <a>
			"http://www.vboi.nl/images/160_114_2/",							//Foto url
			"bedrijfslid",								//Ledentype
			false										//Random
		);
	}
	if(document.getElementById("instellingsleden1")){
		fotoRotate.createObj(
			document.getElementById("instellingsleden1"),					//Element <a>
			"http://www.vboi.nl/images/160_114_2/",	//Foto url
			"instellingslid",								//Ledentype
			false										//Random
		);
	}
	
	sims.g('q').onfocus=function(){
		if(this.value == "zoekterm"){
			this.className = "normal";
			this.value = "";
		}
	}
	sims.g('q').onblur=function(){
		if(this.value == ""){
			this.className = "grey";
			this.value = "zoekterm";
		}
	}
	
	sims.g('q_leden').onfocus=function(){
		if(this.value == "zoekterm"){
			this.className = "normal";
			this.value = "";
		}
	}
	sims.g('q_leden').onblur=function(){
		if(this.value == ""){
			this.className = "grey";
			this.value = "zoekterm";
		}
	}
}

var fotoRotate = {
	createObj: function(el,dir,ledenType,random){
		el.fotoDir = dir;
		el.random = random;
		el.curLogoNum = 0;
		el.nextLogo = fotoRotate.nextLogo;
		el.startFotoRotate = fotoRotate.start;
		el.logoArray = sims.ajax.getObj("http://www.vboi.nl/vboi/php/getBannerReclame.php?ledentype=" + ledenType);
		el.startFotoRotate();
		el.onmouseover = function(){clearTimeout(this.timer);}
		el.onmouseout = function(){this.timer=setTimeout("document.getElementById('" + this.id + "').nextLogo()",4500);}
	},
	nextLogo: function(){
		if(this.random){
		
		} else {
			if(this.curLogoNum == this.logoArray.length-1){ this.curLogoNum = 0; } else { this.curLogoNum++; }
		}
		if(this.logoArray[this.curLogoNum]['website'] != ""){
			this.href=this.logoArray[this.curLogoNum]['website'];
		} else {
			this.href="#";
		}
		this.firstChild.src=this.fotoDir + this.logoArray[this.curLogoNum]['logo'];
		this.title="Klik om de website van " + this.dir + this.logoArray[this.curLogoNum]['bedrijfsnaam']; + " te bezoeken.";
		this.timer=setTimeout("document.getElementById('" + this.id + "').nextLogo()",4500);
	},
	start: function(){
		this.curLogoNum = sims.math.random(0,this.logoArray.length-1);
		this.nextLogo();
	}
}
