////frame-break/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//if(parent.frames[0]){parent.location.href = self.location.href;}


if(document.getElementById&&!document.all)
{
	ns6=1;
}
else
{
	ns6=0;
}
var agtbrw=navigator.userAgent.toLowerCase();
var operaaa=(agtbrw.indexOf('opera')!=-1);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



function GetE(curobj){
	var folder='';
	//zelf gemodificeerd: eerst "document.getElementById(curobj)"
	//maar als er dan getest wordt of een element bestaat, geeft dat false, en wordt de else doorlopen => error
	if(document.getElementById){
		folder=document.getElementById(curobj);
	}
	else{
		if(ns6==1||operaaa==true){
			folder=curobj.nextSibling.nextSibling;
		}
		else{
			folder=document.all[curobj.sourceIndex+1];
		}
	}
	return folder
}


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=50,height=50');");
}


// Eventueel gebruiken:
// Dynamic loading	:http://www.webreference.com/programming/javascript/mk/
// Fade in FF		:http://www.brainerror.net/scripts_js_blendtrans.php
// Eenvoudige slide :http://www.codelifter.com/main/javascript/slideshow2.html
//cancel timer :clearTimeout(the_timeout);
/***********************************************
* Ultimate Fade-In Slideshow (v1.5): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

//Vr dynamic loading enzo
function PrepareSlideShow(){return;}



//Wordt aangeroepen door de afbeelding
function RunSlideShow(Basis, imageFiles,width, height, displaySecs,Fade,Bediening){
	GetE(Basis).style.border='';
	GetE(Basis).style.display='none';
	
	
	//In deze div wordt de diareeks geplaatst, is std aanwezig
	GetE(Basis+"DIV").setAttribute('align', 'center');
	
	//Aanmaken van de DIV	=>Doen we niet meer; IE kan geen nodes toevoegen indien de parent een <p> is
	//						Dit is een gevaar
	//newDiv = document.createElement('DIV');
	//newDiv.setAttribute('id', Basis+'DIV');
	//GetE(Basis).parentNode.insertBefore(newDiv,GetE(Basis));
	
	
	
	var Test= new Array();
	if(imageFiles=='')	//De nieuwe FCK
		Images 	= GetE(Basis).getAttribute('afbeeldingen').split(';');
	else				//De oude FCK
		Images 	= imageFiles.split(';');
	Links	= GetE(Basis).getAttribute('links').split(';');
	for(var i=0; i<Images.length; i++){
		Test[i] = new Array();
		Test[i][0] = Images[i];
		Test[i][1] = Links[i];
		Test[i][2] = '_blank';
	}
	//Hier geven we de basis van de div door
	new fadeshow(Basis+"DIV", Test, width, height, displaySecs*1000, Fade, 0, 0, '')
}



//TODO: 
//De old-browser versie ook centreren en mooi uitlijnen

if(typeof(BgTekst)!='undefined'){
	var fadebgcolor=BgTekst
}
else{
	var fadebgcolor="white"
}
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(Basis, theimages, fadewidth, fadeheight, delay, Fade, borderwidth, pause, displayorder){
	this.pausecheck				=pause
	this.mouseovercheck			=0
	this.delay					=delay
	this.degree					=10 //initial opacity degree (10%)
	this.curimageindex			=0
	this.nextimageindex			=1
	fadearray[fadearray.length]	=this
	this.slideshowid			=fadearray.length-1
	this.canvasbase				=Basis+"canvas"+this.slideshowid
	this.curcanvas				=this.canvasbase+"_0"
	this.ImageWidth				=fadewidth
	this.ImageHeight			=fadeheight
	this.Fade					=Fade
		
	if (displayorder=="R")
		theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
	
	this.theimages=theimages
	this.imageborder=parseInt(borderwidth)
	this.postimages=new Array() //preload images
	for (p=0;p<theimages.length;p++){
		this.postimages[p]=new Image()
		this.postimages[p].src=theimages[p][0]
	}
 
	var fadewidth=fadewidth+this.imageborder*2
	var fadeheight=fadeheight+this.imageborder*2

	if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
		GetE(Basis).innerHTML='<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+';"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-color:'+fadebgcolor+';"></div></div>'
	else
		GetE(Basis).innerHTML='<div style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>'

	
	
	if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
		this.startit(fadearray[this.slideshowid]);
	else{
		this.curimageindex++
		setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
	}
}

//std: per 50msec 10up		-> duurt dus 500msec
//nu:  per 25msec 5up		-> duurt dus 500mse
function fadepic(obj, Snel){
	if (obj.degree<100){
		if(obj.Fade==true && Snel!=true)
			obj.degree+=5
		else
			obj.degree=100
		
		
		if (obj.tempobj.filters&&obj.tempobj.filters[0]){
			if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
				obj.tempobj.filters[0].opacity=obj.degree
			else //else if IE5.5-
				obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
		}
		else 
			if (obj.tempobj.style.MozOpacity)
				obj.tempobj.style.MozOpacity=obj.degree/101
			else if (obj.tempobj.style.KhtmlOpacity)
				obj.tempobj.style.KhtmlOpacity=obj.degree/100
	}
	else{
		clearInterval(fadeclear[obj.slideshowid])
		obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
		obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
		obj.populateslide(obj.tempobj, obj.nextimageindex)
		obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
		setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
	}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
	//Kijken of de afb kleiner is dan de slideshow, dan moet de grootte niet aangepast worden
	if( !((this.postimages[picindex].width>this.ImageWidth)&&(this.postimages[picindex].height>this.ImageHeight)) ){
		var ImageWidth  = this.postimages[picindex].width ;
		var ImageHeight	= this.postimages[picindex].height;
	}
	else{
		if ( (this.postimages[picindex].width/this.ImageWidth)>(this.postimages[picindex].height/this.ImageHeight) ){
			var ImageWidth = this.ImageWidth;
			var ImageHeight= Math.round( this.postimages[picindex].height * ( this.ImageWidth  / this.postimages[picindex].width ) ) ;
		}
		else{
			var ImageHeight = this.ImageHeight;
			var ImageWidth  = Math.round( this.postimages[picindex].width  * ( this.ImageHeight / this.postimages[picindex].height ) ) ;
		}
	}
	
	var top = (this.ImageHeight - ImageHeight)/2;
	var left= (this.ImageWidth  - ImageWidth )/2;
	
	//Alles hierboven + de width/height definities in img een beetje beneden mogen weg als A.php gif en png ondersteunt
	//var top = (this.ImageHeight - this.postimages[picindex].height)/2;
	//var left= (this.ImageWidth  - this.postimages[picindex].width )/2;

	var cheat_begin='<div align="left" style="position:relative;width: '+this.ImageWidth+'px; height: '+this.ImageHeight+'px; padding-top:'+top+'px; padding-right:'+left+'px; padding-bottom:'+top+'px; padding-left:'+left+'px;">';
	var cheat_einde='</div>';
	
	var slideHTML=""
	
	slideHTML+=cheat_begin
	
	if (this.theimages[picindex][1]!="") //if associated link exists for image
		slideHTML+='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'

	
	slideHTML+='<img width='+ImageWidth+' height='+ImageHeight+' src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
	
	if (this.theimages[picindex][1]!="") //if associated link exists for image
		slideHTML+='</a>'
		
	slideHTML+=cheat_einde
	
	picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(eerst){
	if (this.pausecheck==1) //if pause onMouseover enabled, cache object
		var cacheobj=this
	if (this.mouseovercheck==1)
		setTimeout(function(){cacheobj.rotateimage()}, 100)
	else if (iebrowser&&dom||dom){
		this.resetit()
		var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
		crossobj.style.zIndex++
		if(eerst==true)
			fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"], true)",1)
		else
			fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",25)
			
		this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
	}
	else{
		
		if ( this.postimages[this.curimageindex].width > this.postimages[this.curimageindex].height ){
			var ImageWidth = this.ImageWidth;
			var ImageHeight= Math.round( this.postimages[this.curimageindex].height * ( this.ImageWidth  / this.postimages[this.curimageindex].width ) ) ;
		}
		else{
			var ImageHeight = this.ImageHeight;
			var ImageWidth  = Math.round( this.postimages[this.curimageindex].width  * ( this.ImageHeight / this.postimages[this.curimageindex].height ) ) ;
		}
		var ns4imgobj=document.images['defaultslide'+this.slideshowid]
		ns4imgobj.width=ImageWidth;
		ns4imgobj.height=ImageHeight;
		ns4imgobj.src=this.postimages[this.curimageindex].src
	}
	this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
	this.degree=10
	var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	if (crossobj.filters&&crossobj.filters[0]){
		if (typeof crossobj.filters[0].opacity=="number") //if IE6+
			crossobj.filters(0).opacity=this.degree
		else //else if IE5.5-
		crossobj.style.filter="alpha(opacity="+this.degree+")"
	}
	else if (crossobj.style.MozOpacity)
		crossobj.style.MozOpacity=this.degree/101
	else if (crossobj.style.KhtmlOpacity)
		crossobj.style.KhtmlOpacity=obj.degree/100
}
 
 
fadeshow.prototype.startit=function(obj){
	//Controleren of de afbeeldingen al geladen zijn
	var width = obj.postimages[0].width;
	if( width==0||typeof(width)=='undefined'||width==''){
		setTimeout('fadearray['+obj.slideshowid+'].startit(fadearray['+obj.slideshowid+'])', 10);
		return false;
	}
	
	//TEST: controle van de tweede afb
	var width = obj.postimages[1].width;
	if( width==0||typeof(width)=='undefined'||width==''){
		setTimeout('fadearray['+obj.slideshowid+'].startit(fadearray['+obj.slideshowid+'])', 10);
		return false;
	}

	var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(obj.curcanvas)
	obj.populateslide(crossobj, obj.curimageindex)
	if (obj.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
		var cacheobj=this
		var crossobjcontainer=iebrowser? iebrowser["master"+obj.slideshowid] : document.getElementById("master"+obj.slideshowid)
		crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
		crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
	}
	obj.rotateimage(true)
}

