var useBSNns;

if (useBSNns) {
	if (typeof(bsn) == "undefined")
		bsn = {}
	var _bsn = bsn;
} else {
	var _bsn = this;
}


_bsn.afbeeldingenVervangen = function (divs, fadetijd, vertraging ) {	
	this.nAct = -1;
	this.aDivs = divs;
	
	for (var i=0;i<divs.length;i++)
	{
		document.getElementById(divs[i]).style.opacity = 0;
		document.getElementById(divs[i]).style.position = "absolute";
		document.getElementById(divs[i]).style.filter = "alpha(opacity=0)";
		document.getElementById(divs[i]).style.visibility = "hidden";
	}
	
	this.nDur = fadetijd;
	this.nVertraging = vertraging;
		
	this._nieuw();
}


_bsn.afbeeldingenVervangen.prototype._nieuw = function() {
	if (this.nID1)
		clearInterval(this.nID1);
	
	this.nOldAct = this.nAct;
	this.nAct++;
	if (!this.aDivs[this.nAct])	this.nAct = 0;
	document.getElementById( this.aDivs[this.nAct] ).style.visibility = "visible";
	
	this.nInt = 50;
	this.nTijd = 0;
	
	var p=this;
	this.nID2 = setInterval(function() { p._vervaag() }, this.nInt);
}


_bsn.afbeeldingenVervangen.prototype._vervaag = function() {
	this.nTijd += this.nInt;
	
	var op = this._maakSoepel(this.nTijd, 0, 1, this.nDur);
	var ieop = op*100;
	document.getElementById( this.aDivs[this.nAct] ).style.opacity = op;
	document.getElementById( this.aDivs[this.nAct] ).style.filter = "alpha(opacity="+ieop+")";
	
	if (this.nOldAct > -1) {
		document.getElementById( this.aDivs[this.nOldAct] ).style.opacity = 1 - op;
		document.getElementById( this.aDivs[this.nOldAct] ).style.filter = "alpha(opacity="+(100 - ieop)+")";
	}
	
	if (this.nTijd == this.nDur) {
		clearInterval( this.nID2 );
		
		if (this.nOldAct > -1)
			document.getElementById( this.aDivs[this.nOldAct] ).style.visibility = "hidden";	
		
		var p=this;
		this.nID1 = setInterval(function() { p._nieuw() }, this.nVertraging);
	}
}



_bsn.afbeeldingenVervangen.prototype._maakSoepel = function(t,b,c,d) {
	return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
}


function wijzigReferentieFoto(type, afbeelding) {
	if (type == "openen") {
		document.getElementById('referentieFoto').style.backgroundImage = "url('" + afbeelding + "')";	
		document.getElementById('containerReferentieFoto').style.display = "block";	
	} else if (type == "sluiten") {
		document.getElementById('containerReferentieFoto').style.display = "none";	
	}
}

