/* javascript-functies www.architectuurcentrumgrAp.nl */
/* ©2005-6 arthur van zuylen, www.2parts.nl */

/* leeg inputvenster */
function cleartext(thefield) {
 	if (thefield.defaultValue == thefield.value)
 	thefield.value = ""
}

/* vul inputvenster */
function fillemptytext(thefield) {
	if (thefield.value == "")
	thefield.value = thefield.defaultValue
}

/* selecteer inputvenster */
function selectall(form, element) {
	if (document.forms.length > 0) {
 		document.forms[form].elements[element].focus();
 		document.forms[form].elements[element].select();
	}
}

/* focus op inputvenster */
function setfocus(form, element) {
	if (document.forms.length > 0) {
		document.forms[form].elements[element].focus();
	}
}

/* activeer selectbox zonder button */
function go(sel) {
	var destination = sel.options[sel.selectedIndex].value;
	if(destination) {
		 location.href = destination;
	}
}

/* 'add event' functie om meerdere javascript-functies aan te roepen */
function addEvent(obj, evType, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
	
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	
	} else {
		return false;
	}
}

/* fade-in functies [ gebaseerd op http://www.splintered.co.uk/experiments/archives/javascript_fade ] */
var	fadeTarget;
var preInitTimer;

function preInit() {
	/* an inspired kludge that - in most cases - manages to initially hide the image
	   before even onload is triggered (at which point it's normally too late, and a nasty flash
	   occurs with non-cached images) */
	if ((document.getElementById)&&(fadeTarget=document.getElementById(fadeTargetId))) {
		fadeTarget.style.visibility = "hidden";
		if (typeof preInitTimer != 'undefined') clearTimeout(preInitTimer); /* thanks to Steve Clay http://mrclay.org/ for this small Opera fix */
	} else {
		preInitTimer = setTimeout("preInit()",2);
	}
}

function fadeInit() {
	if (document.getElementById) {
		/* get a handle on the fadeable object, to make code later more manageable */
		preInit(); /* shouldn't be necessary, but IE can sometimes get ahead of itself and trigger fadeInit first */
		/* set the initial opacity in a (hopefully) cross browser way
		   notice that because of the way the image is in front, and not obfuscated
		   by another object we need to "fade out", i don't need a fallback mechanism
		   to show/hide the covering object...the image is just there, full stop */
		if (fadeTarget.style.MozOpacity!=null) {  
			/* Mozilla's pre-CSS3 proprietary rule */
			fadeTarget.style.MozOpacity = 0;
		} else if (fadeTarget.style.opacity!=null) {
			/* CSS3 compatible */
			fadeTarget.style.opacity = 0;
		} else if (fadeTarget.style.filter!=null) {
			/* IE's proprietary filter */
			fadeTarget.style.filter = "alpha(opacity=0)";
		}
		/* make the object visible again */
		fadeTarget.style.visibility = 'visible';
		window.setTimeout("fadeIn(0)", 500);
	}
}

function fadeIn(opacity) {
	if(fadeTarget) {
		
		if (opacity <= 100) {
			if (fadeTarget.style.MozOpacity!=null) {
				/* Mozilla's pre-CSS3 proprietary rule */
				fadeTarget.style.MozOpacity = (opacity/100)-.001;
				/* the .001 fixes a glitch in the opacity calculation which normally results in a flash when reaching 1 */
			} else if (fadeTarget.style.opacity!=null) {
				/* CSS3 compatible */
				fadeTarget.style.opacity = (opacity/100)-.001;
			} else if (fadeTarget.style.filter!=null) {
				/* IE's proprietary filter */
				fadeTarget.style.filter = "alpha(opacity="+opacity+")";
				/* worth noting: IE's opacity needs values in a range of 0-100, not 0.0 - 1.0 */ 
			}
			opacity += 5;
			window.setTimeout("fadeIn("+opacity+")", 0);
		}
	}
}
