/*
	Met dank aan Peter Paul Koch voor de inspiratie!
	http://www.quirksmode.org	
*/

window.onload = init;											// de juiste functie aan het onload-event koppelen

function init () {
	
	// eerst het menu initialiseren
	var x = document.getElementsByTagName ('a');	// alle <a> tags in een array stoppen
	var n = x.length;
	
	if (document.location == 'http://www.lupineuitvaartzorg.nl/') {
		document.getElementById('overlupine').style.backgroundColor = '#FFCC00';
		document.getElementById('overlupine').style.color = '#000000';
	}
	else {
		for (i = 0; i < n; i++) {
			if (document.location == x[i].href) {				// checken welk menu-item naar de huidige pagina verwijst
				x[i].style.backgroundColor = '#FFCC00';		// indien gevonden, kleuren aanpassen
				x[i].style.color = '#000000';
				break;													// onzin om verder te zoeken
			}
		}
	}
	
	// nu kijken of er nog clickable thumbs in de pagina voorkomen
	x = document.getElementsByTagName ('img');
	n = x.length;
	
	for (i = 0; i < n; i++) {
		if (x[i].className.indexOf ('Thumb') != -1) {
				x[i].onclick = function () {
				return openPictureWin (this, 5);
			}
		}
	}
	
	// webdesign div
	document.getElementById('webdesign').onclick = function () {
		var str = 
			"\t------------------------------------------                                \n" +
			"\t       Deze website is ontworpen\n" +
			"\t     en gebouwd door Koehoorn IT\n" +
			"\t------------------------------------------\n" +
			"\t            www.koehoornit.nl\n" +
			"\t------------------------------------------";
			
		return alert (str);
	}
}

var pictureWindow;

function openPictureWin (obj, scale) {
	var re1 = new RegExp ('small', 'gi') ;
	var re2 = new RegExp ('\/beheer\/uploadedPics\/', 'gi') ;
	var thePic = obj.src.replace (re1, 'big');	
	thePic = thePic.replace (re2, '\/images\/pics\/big\/');	

	var theTitle = "Lupine Uitvaartzorg"
	var theWidth = obj.width * scale;
	var theHeight = obj.height * scale;
	var htmlString;
	var strSettings;
	var posLeft;
	var posTop;
	
	
	htmlString = "<html><head><title>";
	htmlString += theTitle;
	htmlString += "<\/title><style>* {border: 0; margin: 0; padding: 0;} body {background-color: black}<\/style><\/head><body style=\"cursor: pointer\" leftmargin=\"0\" topmargin=\"0\" bgcolor=\"#555555\">";
	htmlString += "<img title=\"Klik om te sluiten\" onclick=\"window.close()\" src=\"";
	htmlString += thePic;
	htmlString += "\"><\/body><\/html>";
	
	/*
	htmlString = "<html><head><title>";
	htmlString += theTitle;
	htmlString += "<\/title><\/head><body style=\"cursor: pointer\" leftmargin=\"0\" topmargin=\"0\" bgcolor=\"#555555\">";
	htmlString += "<table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\"";
	htmlString += "cellpadding=\"0\"><tr><td align=\"center\" valign=\"middle\"><img title=\"Klik om te sluiten\" onclick=\"window.close()\" src=\"";
	htmlString += thePic;
	htmlString += "\"><\/td><\/tr><\/table><\/body><\/html>";
	*/
	
	posLeft = (screen.availWidth - theWidth) / 2;
	posTop = (screen.availHeight - theHeight) / 2;
	strSettings = '"toolbar=no, scrollbars=no, left=' + posLeft + ',top=' + posTop + ',width=' + theWidth + ', height=' + theHeight + '"';

	if (pictureWindow && !pictureWindow.closed) {
		pictureWindow.close();
	}

	pictureWindow = window.open ("picwin.html", "pictures", strSettings);
	pictureWindow.document.write (htmlString);
	pictureWindow.focus();
	pictureWindow.document.close ();
	
	return false;
}
