sfHover = function() {
	try
	{
	var sfEls = document.getElementById('nav').getElementsByTagName('LI');
	for (var i = 0; i < sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	} catch (ex)
	{
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

var activeImage;

function ActiveRef(img) {
	// Set active image
	activeImage = img;
	// Make all images inactive
	var container = document.getElementById('thumbs');
	var images = container.getElementsByTagName('img');
	for (var i = 0; i < images.length; i++) {
		images[i].className = '';
	}

	// Make selected image active
	activeImage.className = 'active';

	// Hide all divs with text
	var textcontainer = document.getElementById('reftext');
	var divs = textcontainer.getElementsByTagName('div');
	for (var i = 0; i < divs.length; i++) {
		divs[i].style.display = 'none';
	}

	// Show loading message
	document.getElementById('PageText').innerHTML = '<div style="text-align: center; padding-top: 40px;"><img src="site/images/loading.gif"><br />Loading...</div>';
	document.getElementById('PageText').style.display = 'block';

	// Preload the big image
	var pic = new Image(1,1);
	pic.src = img.attributes['bigVersion'].value;
	if (pic.complete) {
		var id = activeImage.id;
		id = id.replace('img_', 'item_');
		document.getElementById('header').style.backgroundImage = 'url(' + document.getElementById('bigPicture').src + ')';
		document.getElementById('PageText').style.display = 'none';
		setOpacity(0);
		document.getElementById(id).style.display = 'block';
		document.getElementById('bigPicture').src = activeImage.attributes['bigVersion'].value;
		FadeIn();
	} else {
		pic.onload = function() {
			var id = activeImage.id;
			id = id.replace('img_', 'item_');
			document.getElementById('header').style.backgroundImage = 'url(' + document.getElementById('bigPicture').src + ')';
			document.getElementById('PageText').style.display = 'none';
			setOpacity(0);
			document.getElementById(id).style.display = 'block';
			document.getElementById('bigPicture').src = activeImage.attributes['bigVersion'].value;
			FadeIn();
		}
	}
}

var curOpacity;

function setOpacity(level) {
	var is_ie6 = (window.external && typeof window.XMLHttpRequest == "undefined");
	curOpacity = level;
	var id = activeImage.id;
	id = id.replace('img_', 'item_');
	document.getElementById('bigPicture').style.opacity = level;
	document.getElementById('bigPicture').style.MozOpacity = level;
	document.getElementById('bigPicture').style.KhtmlOpacity = level;
	document.getElementById('bigPicture').style.filter = "alpha(opacity=" + (level * 100) + ");";
	document.getElementById(id).style.opacity = level;
	document.getElementById(id).style.MozOpacity = level;
	document.getElementById(id).style.KhtmlOpacity = level;
	document.getElementById(id).style.filter = "alpha(opacity=" + (level * 100) + ");";
}

var t;

function FadeIn() {
	var cur = curOpacity;
	cur = parseFloat(cur) + 0.05;
	cur = Math.round(cur*100) / 100;
	setOpacity(cur);
	if (cur < 1) {
		if (t == null) {
			t = setTimeout("FadeIn()",1);
		} else {
			clearTimeout(t);
			t = setTimeout("FadeIn()",1);
		}
	}	
}

function gLoad() {
	if (document.getElementById("map")) {
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("map"));
			var locatie = new GLatLng(51.030908, 4.472659);
			//var icon = new GIcon();
			//icon.image = "site/images/googleMaps.png";
			//icon.iconSize = new GSize(96, 48);
			//icon.iconAnchor = new GPoint(29, 46);
			map.addControl(new GSmallMapControl());
			//map.addControl(new GMapTypeControl());
			map.setCenter(locatie, 15);
			var marker = new GMarker(locatie, {clickable: true, draggable: false});
			map.addOverlay(marker);
		}
	}
}

function googleUnload() {
	if (document.getElementById("map")) {
		GUnload();
	}
}


function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function addUnLoadEvent(func1) {
	var oldonunload = window.onunload;
	if (typeof window.onunload != 'function') {
		window.onunload = func1;
	} else {
		window.onunload = function() {
			if (oldonunload) {
				oldonunload();
			}
			func1();
		}
	}
}

addLoadEvent(gLoad);
addUnLoadEvent(googleUnload);