fotolocation = 'img/Headshots/Grayscale/';
var timeout;
fotos2 = new Array; //this is filled with the photos in random order by loadfotoband, to copy when screen is too wide
function loadfotoband(){ //upon resize the fotoband is emptied (because of the width), so fill it again
	fotos = new String('Angelique,Beppo,Cees,Els,Floor,Hein,Jan-Piet,Jeroen,Karin,Marlies,Matthijs,Motormuis,Noelle,Dinand,Stefaan').split(',');
	fotodiv = MM_findObj('fotoband');
	fotodiv.style.width = w - 1 + 'px';
	nobr = document.createElement('NOBR');
	ipick = parseInt(Math.random() * fotos.length);
	for (i=0;i<fotos.length;i++){
		if (MM_findObj('img'+i)){ //use existing photo
			nobr.appendChild(MM_findObj('img'+i));
		}else{ //create new photo
			while (!fotos[ipick]){
				ipick = parseInt(Math.random() * fotos.length);
			}
			img = document.createElement('IMG');
			img.src = fotolocation + fotos[ipick] + '.jpg';
			img.id = 'img'+i;
			nobr.appendChild(img);
			fotos2[i] = fotos[ipick];
			fotos[ipick] = false;
		}
	}
	//load the photos twice, beyond that, black will appear in the fotoband
	for (i=fotos.length;i<2*fotos.length;i++){
		if (MM_findObj('img'+i)){ //use existing photo
			nobr.appendChild(MM_findObj('img'+i));
		}else{ //create new photo
			img = document.createElement('IMG');
			img.src = fotolocation + fotos2[i - fotos.length] + '.jpg';
			img.id = 'img'+i;
			nobr.appendChild(img);
		}
	}
	fotodiv.appendChild(nobr);
	// nobr.offsetWidth = 1786 = breedte van alle plaatjes, Firefox detecteert dit niet goed wanneer de pagina geladen wordt
	timeout = setTimeout('movefotoband();',1000);
}

var timeoutpreparetodie;
preparingtodie = false;
function stopfotoband(){
	coorX = w/2;
}
function movefotoband(){
	clearTimeout(timeout);
	if (coorXo == coorX){
		if (!preparingtodie){ // let only one timer run please
			preparingtodie = true;
			timeoutpreparetodie = setTimeout('stopfotoband();',5000); //stop after 5 seconds of no movement
		}
	}else{
		clearTimeout(timeoutpreparetodie);
		preparingtodie = false;
	}
	folks = MM_findObj('img0').parentNode; //mozilla doesn't put the children under nobr
	if (coorY < parseInt(findPosY(MM_findObj('fotoband')))+128){
		if (coorX > 2*w/3){ // moveleft
			temp = folks.childNodes[0];
			folks.removeChild[0];
			folks.appendChild(temp);
		}else if (coorX < w/3){ // moveright
			temp = folks.childNodes[folks.childNodes.length - 1];
			folks.removeChild[folks.childNodes.length - 1];
			folks.insertBefore(temp,folks.childNodes[0]);
		}
	}
	timeouttime = (parseInt(w - (Math.abs(coorX-w/2))));
	if (timeouttime < 100){ timeouttime = 100; }
	//alert(timeouttime);
	timeout = setTimeout('movefotoband();',timeouttime);
	coorXo = coorX;
}

function doenercode(which){
	which.innerHTML = which.id;
}
