//Onderstaande functies worden gebruikt door de applicatie, veranderingen aan deze code kan een correcte werking van de applicatie verhinderen
//verkrijg base href als deze aanwezig is voor het corrigeren van iexplorer javascript links
var baseAdres = "";
if( document.getElementsByTagName ) {
	var elems = document.getElementsByTagName('base');
	if( elems.length ) {
		baseAdres = elems[0].href;
	}
}

//menu openklappen
function openMenu(menuID,submenuID){

}
//extra menu openklappen
function openExtraMenu(menuID,submenuID){

}

//functies om popups van foto's te tonen
function unloadFrame(){

}
function openPicture(IDnr){
	currentPic = IDnr;
	if(arrayImages.length <= IDnr || homeLoaded == true){
		unloadFrame();
	} else {
		document.getElementById('fotoBalk').innerHTML = '<div id="imageLinksL"></div>' + '<div id="imageLinksC"></div>' + '<div id="imageLinksR"></div>';

		if(IDnr > 0){
		document.getElementById('imageLinksL').innerHTML = '<a href="javascript:;" onClick="javascript:openPicture(' + (IDnr - 1) + ');">&#139; vorige</a>';
		} else {
		 	document.getElementById('imageLinksL').innerHTML = '';	
		}
		document.getElementById('imageLinksC').innerHTML = '';
		if(arrayImages[IDnr].indexOf("3-") > -1 && arrayImages[IDnr].indexOf("[") > -1 && displayFotoText){
			document.getElementById('imageLinksC').innerHTML = '<div class="imageLinksTekst" style="display:inline;">' + arrayImages[IDnr].substring(arrayImages[IDnr].lastIndexOf("]")+1,arrayImages[IDnr].lastIndexOf(".")) + '</div>';
		}
	  // document.getElementById('imageLinksC').innerHTML += '<a href="javascript:;" onClick="javascript:unloadFrame();">venster sluiten</a>'

	   if(arrayImages.length-1 > IDnr){
	      document.getElementById('imageLinksR').innerHTML = '<a href="javascript:;" onclick="openPicture(' + (IDnr + 1) + ');">volgende &#155;</a>';
	   } else {
	 		document.getElementById('imageLinksR').innerHTML = '';
		}
		document.getElementById('popupImage').alt = '';
	   document.getElementById("popupImage").src = arrayImages[IDnr];
	   var preloadNext = new Image();
		preloadNext.src = arrayImages[IDnr + 1];
		if(IDnr > 0){
			var preloadPrev = new Image();
			preloadPrev.src = arrayImages[IDnr - 1];
		}
   }
}
function showImage(strImage){
	currentPic = 0;
	arrayImages = new Array();
	arrayImages[0] = "";
	document.getElementById('imageLinksR').innerHTML = '';
	document.getElementById('imageLinksL').innerHTML = '';
//	document.getElementById('imageLinksC').innerHTML = '<a href="javascript:;" onClick="javascript:unloadFrame();">venster sluiten</a>'
	document.getElementById('photoframe').onclick = '';
	document.getElementById("popupImage").src = strImage;

}
function setPhotoFrame(){
	unloadFrame();
}
function printPagina(){
	printVenster = open("","printWindow","width=800,height=400,left=10,top=10,resizable=yes");
	var printTekst = document.getElementById("mainContentDiv").innerHTML;
	printTekst = printTekst.replace(/<div class="etalageAfbeelding".*url\((.*)\).* .*<\/div>/ig,'<img src="$1" alt="" style="float:left;margin-right:10px;"/>');
	printTekst = printTekst.replace(/<div class="paginaAfbeeldingen".*url\((.*)\).* .*<\/div>/ig,'<img src="$1" alt="" style="float:left;"/>');
	printTekst = printTekst.replace(/<div class="etalageAfbeeldingen".*url\((.*)\).* .*<\/div>/ig,'<img src="$1" alt="" style="float:left;"/>');
	printTekst = printTekst.replace(/<div style="width.*url\((.*)\).* no-repeat.*<\/div>/ig,'<img src="$1" alt="" style="float:left;"/>');

	var printHTML = '<HTML><HEAD><TITLE>' + document.title + '</TITLE>';
	if(baseAdres != ""){printHTML += '<base href="' + baseAdres +  '/" />'} 
	printHTML += '<LINK HREF="basic.css" REL="stylesheet" TYPE="text/css"></HEAD><BODY onload="window.print()">'
	printHTML += printTekst;
	printHTML += '</BODY></HTML>'
	printVenster.document.open();
	printVenster.document.write(printHTML);
	printVenster.document.close();
}

//Einde applicatie functies

//handige functies
//voorkom lelijke omlijning van a elementen door indrukken van tab
var theahrefs = document.getElementsByTagName('a'); for(var x=0;x!=theahrefs.length;x++){theahrefs[x].onfocus = function stopLinkFocus(){this.hideFocus=true;};}

var albumActive = false;

//functie om externe links automatisch in nieuw venster te tonen
window.onload = externeLinks;
function externeLinks (){
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.","").toLowerCase();
	var a = document.getElementsByTagName("a");
	this.check = function(obj){
		var href = obj.href.toLowerCase();
		return (href.indexOf("http://")!=-1 && obj.target == "" && href.indexOf("javascript")==-1 && href.indexOf(hostname)==-1) ? true : false;
	};
	this.set = function(obj){
		obj.target = "_blank";
	};
	for (var i=0;i<a.length;i++){
		if(check(a[i])) set(a[i]);
	};
};
var homeLoaded = false;
function homeFunction(){
	homeLoaded = true;
	document.getElementById('fotoBalk').style.top = '320px';
	document.getElementById('nieuwsDiv').style.top = '340px';
	document.getElementById('photoframe').innerHTML = '<div id="flashMovie"></div>';
	var params = {};
	params.menu = "false";
	params.scale = "noscale";
	params.allowfullscreen = "true";
	swfobject.embedSWF("merens.swf", "flashMovie", 500, 320, "9.0.0", "expressInstall.swf", null, params);
}

var currentNr = 0;
//voeg event handlers toe aan divs
function registerEvents() {
	if(window.arrayImages != undefined){
     document.getElementById("popupImage").src = arrayImages[0];
	} else {
document.getElementById("popupImage").src = 'images/default.jpg';
}
	for(var i=0;i<totalMenu;i++){
		currentNr ++;
		if(document.getElementById('subMenu' + i)){
			document.getElementById('menu' + i).onmouseover = function(){
				document.getElementById('subMenu' + this.id.substring(4)).style.display = '';
			}
			document.getElementById('menu' + i).onmouseout = function(i){
				document.getElementById('subMenu' + this.id.substring(4)).style.display = 'none';
			}
			document.getElementById('subMenu' + i).style.display = 'none';
		}
	}
}

