/*

Script voor mouseovers LVA

(C) 2003-2004 vizi. Alle rechten voorbehouden.

DOM, ECMA-262 en Javascript compatible manier om mouseovers te 
genereren of popupvenster te openen zonder enige scripting in XHTML.

DOM mouseoverscript gebaseerd op het voorbeeldscript op:
http://www.readinged.com/articles/javascriptdom/

Plaats:
root/scripts/nodomnofun.js

Laatst gewijzigd:
19 augustus 2004

Leer, steel niet!

*/
// Bepaal gehighlighte item (indien aanwezig).
var themeBaseId = false;

window.onload = function() {
	if (document.getElementById) {
		// Verzendknop op formulier contactpagina
		var verzendKnop = (document.getElementById('verzend')) ? document.getElementById('verzend') : null;
		
		if (verzendKnop) {
			verzendKnop.onmouseover = function() { this.src = this.src.replace('.gif', '_aan.gif'); }
			verzendKnop.onmouseout  = function() { this.src = this.src.replace('_aan.gif', '.gif'); }
		}

		// Bibliotheek link op projectoverzichten.
		var bibliotheekKnop = (document.getElementById('projecten-bibliotheek')) ? document.getElementById('projecten-bibliotheek').getElementsByTagName("img")[0] : null;
		
		if (bibliotheekKnop) {
			bibliotheekKnop.onmouseover = function() { this.src = this.src.replace('.gif', '_aan.gif'); }
			bibliotheekKnop.onmouseout  = function() { this.src = this.src.replace('_aan.gif', '.gif'); }
		}
	}
	
	if (document.getElementsByTagName) {
		
		var allLinks = document.getElementsByTagName('a');
		
		for (var i = 0; i < allLinks.length; i++) {
		
		switch (allLinks[i].className) {
			
			// Mogelijkheid #1: categorie-mouseover op de homepage.
			case 'catover':
				allLinks[i].onmouseover = function() {
					var thisImg = this.getElementsByTagName('img');
					thisImg[0].src = thisImg[0].src.replace('_uit', '_aan');
				}
				
				allLinks[i].onmouseout = function() {
					var thisImg = this.getElementsByTagName('img');
					thisImg[0].src = thisImg[0].src.replace('_aan', '_uit');
				}
				
				break;


			// Mogelijkheid #2: themanav-mouseover op themapagina.
			case 'themaover':
				allLinks[i].onmouseover = function() {
					var thisImg = this.getElementsByTagName('img');
					thisImg[0].src = thisImg[0].src.replace('-blauw.jpg', '.jpg');

					// Haal thema item op, indien aanwezig.
					var themaDiv = document.getElementById("thema");
					var imgDivs = themaDiv.getElementsByTagName("div");
					for (i = 0; i < imgDivs.length; i++) {
						if (imgDivs[i].className == "base") themeBaseId = imgDivs[i].id.substring(5);
					}

					// Zet basis themaitem uit.
					if (themeBaseId) {
						var themeLink = document.getElementById("toggle-" + themeBaseId);
						var themeLinkImg = themeLink.getElementsByTagName("img")[0];
						if (themeLinkImg.src.indexOf("-blauw") < 0)
						{
							themeLinkImg.src = themeLinkImg.src.replace('.jpg', '-blauw.jpg');
						}
						document.getElementById("info-" + themeBaseId).className = "";
					}
					
					var thisItem = this.id.substring(7);
					var thisInfo = document.getElementById("info-" + thisItem);
					thisInfo.style.visibility = "visible";
				}
				
				allLinks[i].onmouseout = function() {
					var thisImg = this.getElementsByTagName('img');
					thisImg[0].src = thisImg[0].src.replace('.jpg', '-blauw.jpg');

					var thisItem = this.id.substring(7);
					var thisInfo = document.getElementById("info-" + thisItem);
					thisInfo.style.visibility = "hidden";

					// Zet basis themaitem uit.
					if (themeBaseId) {
						var themeLink = document.getElementById("toggle-" + themeBaseId);
						var themeLinkImg = themeLink.getElementsByTagName("img")[0];
						if (themeLinkImg.src.indexOf("-blauw") > -1)
						{
							themeLinkImg.src = themeLinkImg.src.replace('-blauw.jpg', '.jpg');
						}
						themeLinkImg.src = themeLinkImg.src.replace('-blauw.jpg', '.jpg');
						document.getElementById("info-" + themeBaseId).className = "base";
					}
				}
				
				break;


			// Mogelijkheid #3: beeldnav-mouseover op projectpagina.
			// Niet meer in gebruik per 16/02/2007: thumbs altijd in kleur voor navigatie beelden project.
			case 'beeldover':
				allLinks[i].onmouseover = function() {
					var thisImg = this.getElementsByTagName('img');
					thisImg[0].src = thisImg[0].src.replace('-blauw.jpg', '.jpg');
				}
				
				allLinks[i].onmouseout = function() {
					var thisImg = this.getElementsByTagName('img');
					thisImg[0].src = thisImg[0].src.replace('.jpg', '-blauw.jpg');
				}
				
				break;
			
			
			// Mogelijkheid #4: project-mouseover op archiefpagina.
			case 'archiefover':
				allLinks[i].onmouseover = function() {
					var thisArchief = this.parentNode.parentNode.parentNode.id.substring(7);
					var thisImg = document.getElementById('img' + thisArchief);
					
					var thisPath = (this.pathname.substring(0,1) == '/') ? this.pathname : ('/' + this.pathname);
					
					thisImg.src = 'http://' + this.hostname + '/media' + thisPath + '/middel.jpg';
				}
				
				allLinks[i].onmouseout = function() {
					var thisArchief = this.parentNode.parentNode.parentNode.id.substring(7);
					var thisImg = document.getElementById('img' + thisArchief);
					
					thisImg.src = '/beeld/archief_' + thisArchief + '.gif';
				}
				
				break;
			
			
			// Mogelijkheid #5: medewerker-mouseover.
			case 'mdwover':
				allLinks[i].onmouseover = function() {
					var thisImg = document.getElementById('foto' + this.id);
					var newImgSrc = thisImg.src.replace('-blauw.jpg','.jpg');
					thisImg.src = newImgSrc;
				}
				
				allLinks[i].onmouseout = function() {
					var thisImg = document.getElementById('foto' + this.id);
					var newImgSrc = thisImg.src.replace('.jpg','-blauw.jpg');
					thisImg.src = newImgSrc;
				}
				
				break;
			
			
			// Mogelijkheid #6: de link moet een popup openen.
			case 'popwin':
				allLinks[i].onclick = function () {
					var thisPopupVars = this.id.toString();
					var thisPopupWidth = thisPopupVars.substring(1,4);
					var thisPopupHeight = thisPopupVars.substring(4,7);
					var thisPopupScroll = thisPopupVars.substring(7,8);
					var thisPopupURL = '/pop/'
					  + thisPopupVars.substring(8,(thisPopupVars.length))
					  + '.html';
					
					var thisPopupParams = 'width='
					  + thisPopupWidth + ',height='
					  + thisPopupHeight + ',location=0,menubar=0,scrollbars='
					  + thisPopupScroll + ',status=1,toolbar=0,resizable=1';
					
					var popupWin = window.open(thisPopupURL,'',thisPopupParams);
					
					return false;
				}
				
				break;
			
			}
		}
	}
}