// JavaScript Document
//var leiding = new Array("Francis Focquaert", "Jasper Dobbelaere", "Stijn Verstrynge", "Charlotte Longueville", "Stephanie Dobbelaere", "Lander D'hav&eacute;", "Flore Himschoot", "Elien De Loof", "Stephanie Serry", "Ariane De Smet", "Ilona Van Canneyt", "Dimitri De Ceuninck", "Joyce Dobbelaere", "Ellen Willemarck", "Dieter Dobbelaere", "Vic De Loof", "Bert Selter", "Christof Lippens", "Ruth De Loof");
var leiding = new Array("Arne", "Bosse", "Charon", "Dieter", "Elisa", "Emiel", "Femke", "Flore", "Francis", "Ilona", "Jasper", "Lander", "Leandra", "Milena", "Ruben", "Simon", "Stephanie", "Stuff", "Wout");

window.onload = function() {
		var rand = Math.ceil(Math.random() * leiding.length);
		leiding = shuffle(leiding);
		veranderAfbeelding(rand);
}

function veranderAfbeelding(id) {
	document.getElementById("naamLeiding").innerHTML = leiding[id-1];
	
	blendimage('blenddiv','fotoLeiding',"img/fotos_leiding/2009/tn_"+leiding[id-1]+".jpg",200);
	
	if(id == leiding.length)
		next = 1;
	else
		next = id + 1;
	
	setTimeout("veranderAfbeelding("+next+")", "5000");
}

shuffle = function(o){ //v1.0
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};

function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
} 

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 