//------------------------------------------------------
// init

window.onload = init;
function init(){
  celtRollover()
}
// End init
//------------------------------------------------------

//------------------------------------------------------
// global rollover
function celtRollover(){
	var rollimg = document.getElementsByTagName('img');
	if (rollimg.length == 0 ) { return }
	var preloads = new Object();
	for (var i=0;i<rollimg.length;i++) {
		if (rollimg[i].src.charAt(this.length-7) != 'normal.gif') {continue}
		if (!rollimg[i].id || rollimg[i].id == undefined) { rollimg[i].id = 'img'+i }
		preloads['normal'+rollimg[i].id] = new Image;
		preloads['normal'+rollimg[i].id].src = rollimg[i].src.split("_")[0] + '_normal.gif';
		preloads['high'+rollimg[i].id] = new Image;
		preloads['high'+rollimg[i].id].src = imgElm[i].src.split("_")[0] + '_high.gif';
		rollimg[i].onmouseover = function() {this.src=preloads['high'+this.id].src;}
		rollimg[i].onmouseout = function() {this.src=preloads['normal'+this.id].src;}
	}
}
// End global rollover
//------------------------------------------------------


//------------------------------------------------------
// Toggle scripts

// Zappwerk menu
var o="open";
var c="closed";
function zappMenu(el,t){
  var t = ( typeof(t)=='undefined' || t==null || t=="" ) ? 'LI' : t
  var e = fpd(el,t);
  var u = fpd(e,'UL');
  var l = u.getElementsByTagName('LI');
  for(n=0;n<l.length;n++){
    l[n].id=(u.id)+n;
    if (l[n].className.indexOf(c)>-1) {
      switchClassName(e,c,c);
    }
  }
  var eul = e.getElementsByTagName('UL')[0];
  if (eul){
    e.onmouseover = function(){
      switchClassName(e,c,o);
      eul.style.zIndex="300"
    }
    e.onmouseout = function(){
      setTimeout("switchClassName(document.getElementById('"+e.id+"'),o,c)", 400)
      eul.style.zIndex="0"
    }
  }
}

// Zappwerk toggle
function zappToggle(el,t){
  var t = ( t=="" || t==undefined || t==null ) ? 'LI' : t
  var e = fpd(el,t);
  var u = fpd(e,'UL');
  var l = u.getElementsByTagName('LI');
  for(n=0;n<l.length;n++){
    l[n].id=(u.id)+n;
    if (l[n].className.indexOf(o)>-1) {
      switchClassName(e,o,c);
    }else{
      if (l[n].className.indexOf(c)>-1) {
        switchClassName(e,c,o);
      }
    }
  }
}

// End Toggle scripts
//------------------------------------------------------


//------------------------------------------------------
// Classname handlers

function addCSSClass(elem,cn){elem.className=(elem.className+" "+cn).trim();}
function removeCSSClass(elem,cn){elem.className=elem.className.replace(cn,"").trim();}
String.prototype.trim=function(){return this.replace( /^\s+|\s+$/, "" );}
function switchClassName(e,a,b){e.className=e.className.replace(a,"").trim();e.className=(e.className+" "+b).trim();}
function fpd(elem,e){var o=elem;while(o.parentNode.nodeName!=e.toUpperCase()){o=o.parentNode;}return o.parentNode;}

// End Classname handlers
//------------------------------------------------------


// test whether an input text, textarea or select field is empty
// also trim the input string from leading and trailing whitespace
// expect parameter f to be a field element of a form (object)
// v1.0 - 4.10.2003 -  Kemal Djakman - VVBS Web Services
function isEmpty( f ) {
	if (f.type == 'text' || f.type == 'textarea' || f.type == 'password') {
		re = /^\s+|\s+$/g;
		return (!f.value.replace(re,''));
	} else if (f.type == 'select-one' || f.type == 'select-multiple') {
		return (!f.value);
	}
	return true;
}


// test whether none of the specified fields in form are empty
// (test is limited to text, textarea, password and select fields)
// 1st parameter is a form object
// 2nd parameter is an array of strings which corresponds to form field names
// v1.0 - 4.10.2003 -  Kemal Djakman - VVBS Web Services
function ValidateRequired( form, fields ) {
	var emsg = '';

	for (i=0; i<fields.length; i++) {
		F = form[fields[i]];
		if (F && F.type && isEmpty(F)) {
			emsg += ('- ' + (F.title ? F.title : F.name) + "\n");
		}
	}

	if (emsg) {
//		alert('Error: The folowing fields are missing:\n' + emsg);
		alert('Error: foute of niet-ingevuld velden.\nDeze velden zijn verplicht:\n' + emsg);
		return false;
	}
	return true;
}






//
// Macromedia rollovers
//

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}



function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


// Kemal's simple css hide-unhide block
function togblk( s ) {
	if (!s || !document.getElementById ) return;
	var b = document.getElementById(s);
	if (!b) return;
	if (b.style.display == 'none')
		b.style.display = 'block';
	else if (b.style.display == 'block')
		b.style.display = 'none';
}


// Kenny's slightly simpler switch block
function more(  )
{
	document.getElementById('intro_text').style.display = 'none';
	document.getElementById('full_text').style.display = 'block';
}

function less()
{
	document.getElementById('full_text').style.display = 'none';
	document.getElementById('intro_text').style.display = 'block';
}

function toglink( o ) {
	if (o.innerHTML) {
		if (o.innerHTML == '·&nbsp;lees meer')
			o.innerHTML = '·&nbsp;sluit mij';
		else if (o.innerHTML == '·&nbsp;sluit mij')
			o.innerHTML = '·&nbsp;lees meer';
	}
}
navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);

function setOpacity(el, value) {
	el.style.opacity = value/10;
	el.style.filter = 'alpha(opacity=' + value*10 + ')';
}
