// activeer de bytr menu's  (via DHTML)

var activeMenuDiv = null;
var activeSubMenuDiv = null;
function setActiveMenu(theIndex, theA) {
	var theMainMenuId='';
	var theSubMenuId='';
	var displayMode='';
	if (theIndex==2) {

		displayMode='block';
		theSubMenuId = 'submenu2_1';
		theMainMenuId = 'menuoption2_1';
		
		// maak (evt.) submenu's zichtbaar
		if (document.getElementById(theSubMenuId)!=null)
			document.getElementById(theSubMenuId).style.display=displayMode;

		// de-activeer de oude hoofdmenu's 
		if (document.getElementById(theMainMenuId)!=null)
			document.getElementById(theMainMenuId).style.backgroundColor='#ffffff';

		theSubMenuId = 'submenu2_2';
		theMainMenuId = 'menuoption2_2';

		// maak (evt.) submenu's zichtbaar
		if (document.getElementById(theSubMenuId)!=null)
			document.getElementById(theSubMenuId).style.display=displayMode;

		// de-activeer de oude hoofdmenu's 
		if (document.getElementById(theMainMenuId)!=null)
			document.getElementById(theMainMenuId).style.backgroundColor='#ffffff';

/*		var theDiv;
		if (theA!=null)
			theDiv = theA.parentNode;
		else	
			theDiv = document.getElementById('menuoption2_1')
	
		theDiv.style.backgroundColor='#D9E9EF';
		if (activeMenuDiv!=null)
			activeMenuDiv.style.backgroundColor='#ffffff';
		activeMenuDiv = theDiv; */
	}

		for (t=4;t>0;t--) {
			displayMode=(t==theIndex)?'block':'none';
			theSubMenuId = 'submenu' + t;
			theMainMenuId = 'menuoption' + t;
			
			// maak (evt.) submenu's zichtbaar
			if (document.getElementById(theSubMenuId)!=null)
				document.getElementById(theSubMenuId).style.display=displayMode;
	
			// de-activeer de oude hoofdmenu's 
			if (document.getElementById(theMainMenuId)!=null)
				document.getElementById(theMainMenuId).style.backgroundColor='#ffffff';
		}
		var theDiv;
		if (theA!=null)
			theDiv = theA.parentNode;
		else	
			theDiv = document.getElementById('menuoption'+theIndex)
	
		theDiv.style.backgroundColor='#D9E9EF';
		if (activeMenuDiv!=null)
			activeMenuDiv.style.backgroundColor='#ffffff';
		activeMenuDiv = theDiv;

	
/*	if (theIndex==2) {
		var kader = document.getElementById('kader');
		if (kader!=null)
			kader.style.top = '504 px';
	} */
}

function changePhoto(imgNm, param) {
	if (param == null) {
		// er is op een foto geklikt -> stop slideshow
		clearTimeout(slideTimer);
	}

	if(imgNm != 'plain') {
		var showMedium = "img0";

		//document.images[showMedium].src = "img/plain.gif";

		if(document.all) {
		    document.images[showMedium].filters.blendTrans.apply();
		}

		var imgurl = imagePrefix + imgNm + "big.jpg";
		document.images[showMedium].src = imgurl;
		if(document.all) {
		    document.images[showMedium].filters.blendTrans.play();
		}

// Zet de juiste foto indexering aan:

	 	fotoindex = "slideshow";
	 	//alert(fotoindex);
	 	items = document.getElementById(fotoindex).getElementsByTagName("a");
 		for (var i = 0; i < items.length; i++) {
			items[i].className = "";
		}
 		document.getElementById('img'+imgNm).className = "active";
	}
}

var autoSlideImg = 1;
var slideTimer = null;

// wachttijd in milliseconds nadat de pagina geladen is
var waitTimeFirstSlide = 1800; 

// wachttijd in milliseconden tussen begin van transitie tot aan begin volgende transitie
//   de waitTimeFirstSlide mag korter zijn dan waitTimeNextSlides omdat de allereerste foto direct zonder transitie op 
//   de pagina getoond wordt. 
var waitTimeNextSlides = 2800; 
var waitTime = waitTimeFirstSlide;

function setWaitTimeFirstSlide(milliseconds) {
	waitTime = milliseconds;
}
function setWaitTimeNextSlides(milliseconds) {
	waitTimeNextSlides = milliseconds;
}
function autoStartSlide() {
	// alleen starten als er een slideshow op de pagina gevonden wordt
	if (document.getElementById('slideshow') != null)
		slideTimer = setTimeout('nextSlide()',waitTime);
		waitTime = waitTimeNextSlides;
}

function nextSlide() {
	autoSlideImg ++;
	if (document.getElementById('img'+autoSlideImg) == null)
		autoSlideImg = 1;
	changePhoto(autoSlideImg, 'auto');
	autoStartSlide();
}

/*onderstaand voorkomt dat spam-robots het email adres kunnen zien*/
function writeTjerk() {
	document.write('<a href="mai');
	document.write('lto:tjerk');
	document.write('@');
	document.write('bytr.nl">');
	document.write('tjerk');
	document.write('@');
	document.write('bytr.nl<\/a>');
}

/*onderstaand voorkomt dat spam-robots het email adres kunnen zien*/
function writeMailadres() {
	document.write('<a href="mai');
	document.write('lto:mail');
	document.write('@');
	document.write('bytr.nl">');
	document.write('mail');
	document.write('@');
	document.write('bytr.nl<\/a>');
}
function writeRichel() {
	document.write('<a href="mai');
	document.write('lto:richel');
	document.write('@');
	document.write('bytr.nl">');
	document.write('richel');
	document.write('@');
	document.write('bytr.nl<\/a>');
}

// kijk of er een slideshow aanwezig is op de pagina,
//   zo ja -> automatisch starten
//   eenmaal geklikt -> stoppen
window.onload = autoStartSlide;
