/**
* @author      Mario Ruis
*/



window.onload = function () {

	if ((navigator.appName == "Microsoft Internet Explorer" &&
	    navigator.appVersion.indexOf("Mac") == -1 &&   navigator.appVersion.indexOf("3.1") == -1) ||

	    (navigator.plugins && navigator.plugins["Shockwave Flash"])
	                       || navigator.plugins["Shockwave Flash 2.0"]){
		flash=1;
	}

	if (document.getElementById('blur')) {
		document.getElementById('blur').style.height = getDocHeight()+'px';
	}

	if (document.getElementById('submitSpan')) {
	  document.getElementById('submitSpan').innerHTML = '<input type="submit" value=" &nbsp;  &nbsp; Versturen  &nbsp;  &nbsp; " />';
	}


	if(document.getElementById('tabholder')) { activeerTabs('tabholder'); }
	if(document.getElementById('rekenBlad')) { activeerCalc(); }


	if (document.getElementById('fieldsToCheck')) {
		runFormCheck();
	}

	if (document.getElementById('passiespelen_form')) {
		initPPForm('passiespelen_form');

		document.getElementById('ppformsubmit').onclick = function() {
			return checkPPForm('passiespelen_form');
		}
	}



	if (document.getElementById('fadeonload')) {
		opacity('fadeonload', 100, 0, 2400);
	}

	if (document.getElementById('fadeonload10')) {
		opacity('fadeonload10', 100, 0, 15000);
	}

	if (document.getElementById('tab_prod')) {
	activeerWebTabs('tabholdersub');
	}

	if (document.getElementById('actiebanner')) {
	activeerActieBanner('actiebanner');
	}


	if (document.location.href.indexOf("#") !=-1) {
		arrUrl = document.location.href.split("#");
		if(arrUrl[0] == thisHost+"assortiment/catalogussen") {
		showPopup(arrUrl[1]);
		}
	}



	if (document.getElementById('sluiten')) {
	var btnSluit = document.getElementById('sluiten');

	btnSluit.onmouseover=function(){
		this.style.cursor = 'pointer';
		btnSluit.src = thisHost+'pix/sluiten_on.gif';
	}

	btnSluit.onmouseout=function(){
		btnSluit.src = thisHost+'pix/sluiten.gif';
	}

	btnSluit.onclick=function(){
		document.getElementById('popupcontent').innerHTML = '';
		document.getElementById('popupcontent').style.visibility = 'hidden';
		document.getElementById('fotolijst').style.visibility = 'hidden';
		document.getElementById('fotolijst').style.width = '1200px';
		//document.getElementById('fotolijst').style.width = '-605px';
		opacity('blur', 75, 0, 0);
		document.getElementById('blur').style.visibility = 'hidden';
	}
	opacity('blur', 100, 0, 0);
	}



  if (document.getElementById('submitOfferteSpan')) {
	  document.getElementById('submitOfferteSpan').innerHTML = ' <input type="button" value="Verzenden" style="border:1px solid #888888; padding:2px; width:146px" id="button_offerte" />';

		var button = document.getElementById('button_offerte');
		button.onclick = function() {
			return verzendForm('offerteForm');
		}
  }



  if (document.getElementById('nvep')) {
	var btnNvep = document.getElementById('nvep');

	btnNvep.onmouseover=function(){
		this.style.cursor = 'pointer';
		opacity('nvep', 100, 55, 200);
	}
	btnNvep.onclick=function(){
		window.scroll(0,0);
		showPopup('nvep');
	}
	btnNvep.onmouseout=function(){
		opacity('nvep', 55, 100, 200);
	}


  }



  if (document.getElementById('osvvv')) {
	var btnNvep = document.getElementById('osvvv');

	btnNvep.onmouseover=function(){
		this.style.cursor = 'pointer';
		opacity('osvvv', 100, 55, 200);
	}
	btnNvep.onclick=function(){
		window.scroll(0,0);
		showPopup('osvvv');
	}
	btnNvep.onmouseout=function(){
		opacity('osvvv', 55, 100, 200);
	}
  }



  if (document.getElementById('midrechts')) {
		zwartWitEffect();
  }





}





function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}


function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}





function verzendForm(strId) {

	var verzend = 'JA';
	if(document.getElementById('offerteAanvraag_actiecode')) {
		if(document.getElementById('offerteAanvraag_actiecode').value 	== '') { verzend = 'NEE'; }
	}

	if(document.getElementById('offerteAanvraag_naam').value 			== '') { verzend = 'NEE'; }
	if(document.getElementById('offerteAanvraag_tel').value 			== '') { verzend = 'NEE'; }
	var email = document.getElementById('offerteAanvraag_email').value;
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){} else { verzend = 'NEE'; }



	if(verzend == 'JA') {
	 document.getElementById(strId).submit();
 	} else {
	 alert('Vul a.u.b. alle verplichte velden van het formulier op correcte wijze in.');
	}
}




function initPPForm(strId) {

  var input_aantal_vouchers = document.getElementById('input_aantal_vouchers');
  input_aantal_vouchers.onkeyup = function() {
	  checkIntAndCorrectInput('input_aantal_vouchers');
  }


  ////////////////////////////////////////////////////////

  var input_aantal_arrangementen = document.getElementById('input_aantal_arrangementen');
  input_aantal_arrangementen.onkeyup = function() {
	  checkIntAndCorrectInput('input_aantal_arrangementen');
  }

  ////////////////////////////////////////////////////////

  var input_aantal_volwassenen = document.getElementById('input_aantal_volwassenen');
  input_aantal_volwassenen.onkeyup = function() {
	  checkIntAndCorrectInput('input_aantal_volwassenen');
  }

  ////////////////////////////////////////////////////////

  var input_aantal_kind = document.getElementById('input_aantal_kind');
  input_aantal_kind.onkeyup = function() {
	  checkIntAndCorrectInput('input_aantal_kind');
  }

  ////////////////////////////////////////////////////////

  var input_aantal_senioren = document.getElementById('input_aantal_senioren');
  input_aantal_senioren.onkeyup = function() {
	  checkIntAndCorrectInput('input_aantal_senioren');
  }

  ////////////////////////////////////////////////////////

	document.getElementById('pp_datum').onchange = function() {
		checkPPDate();
	}
}


function checkPPDate() {

	var ppdatum = document.getElementById('pp_datum').options[document.getElementById('pp_datum').selectedIndex].value;
	if( (ppdatum == 'zondag 30 mei 14:30 (toegangskaarten uitverkocht)') || (ppdatum == 'zondag 13 jun 14:30 (toegangskaarten uitverkocht)') ) {
		alert("LET OP: De toegangskaarten voor zondag 30 mei en zondag 13 juni zijn uitverkocht.");
		 document.getElementById('input_aantal_volwassenen').value =0;
		 document.getElementById('input_aantal_kind').value =0;
		 document.getElementById('input_aantal_senioren').value =0;
	}

}


function checkAantalPPForm(strId) {
  var field = document.getElementById(strId);
	if(field.value == '') {
		field.value = 0;
	}
}


function checkIntAndCorrectInput(strId) {
  var field = document.getElementById(strId);
	  if(!IsInteger(field.value)) {
		alert('voer a.u.b. een cijfer in');
		field.value = 0;
	  }

  if(field.value != 0) {
  	checkPPDate();
  }


  checkPakketHolder();
}




function checkPakketHolder() {
  var pakket_holder = document.getElementById('pakket_holder');

  var pakket_content_a = document.getElementById('pakket_content_a').innerHTML;
  var pakket_content_b = document.getElementById('pakket_content_b').innerHTML;

  input_aantal_vouchers = document.getElementById('input_aantal_vouchers');
  if( (input_aantal_vouchers.value == 0) || (input_aantal_vouchers.value == '') ) {
		pakket_holder.innerHTML = pakket_content_a;
  } else {
		pakket_holder.innerHTML = pakket_content_b;
  }

}


function checkPPForm(strId) {

	var verzend = 'JA';
	var errorLijst = '';
	if(document.getElementById('ppform_naam').value 		== '') { verzend = 'NEE'; errorLijst = errorLijst+"\n- Vul uw naam in."; }
	if(document.getElementById('ppform_adres').value 		== '') { verzend = 'NEE'; errorLijst = errorLijst+"\n- Vul uw adres in."; }
	if(document.getElementById('ppform_postcode').value 	== '') { verzend = 'NEE'; errorLijst = errorLijst+"\n- Vul uw postcode in."; }
	if(document.getElementById('ppform_plaats').value 		== '') { verzend = 'NEE'; errorLijst = errorLijst+"\n- Vul uw plaats in."; }
	if(document.getElementById('ppform_tel').value 			== '') { verzend = 'NEE'; errorLijst = errorLijst+"\n- Vul uw telefoonnummer in."; }
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('ppform_email').value)){} else { verzend = 'NEE';  errorLijst = errorLijst+"\n- Vul een geldig e-mailadres in."; }





	checkAantalPPForm('input_aantal_vouchers');
	checkAantalPPForm('input_aantal_arrangementen');
	var aantal_food = (  parseInt(document.getElementById('input_aantal_vouchers').value) + parseInt(document.getElementById('input_aantal_arrangementen').value)  );

	checkAantalPPForm('input_aantal_volwassenen');
	checkAantalPPForm('input_aantal_kind');
	checkAantalPPForm('input_aantal_senioren');
	var aantal_gasten = (  parseInt(document.getElementById('input_aantal_volwassenen').value) + parseInt(document.getElementById('input_aantal_kind').value) + parseInt(document.getElementById('input_aantal_senioren').value) );

	if(aantal_food == 0) { verzend = 'NEE'; errorLijst = errorLijst+"\n\nOm een reservering te kunnen plaatsen dient u minimaal 1 voucher of 1 van onze arrangementen te kiezen."; }
	if(aantal_gasten > aantal_food) { verzend = 'NEE'; errorLijst = errorLijst+"\n\nU heeft wel kaarten maar niet voor iedere gast een vouchers of arrangement gereserveerd\nReserveer a.u.b. voor iedere gast een voucher of een van onze arrangementen."; }



	if(verzend == 'JA') {
	 document.getElementById(strId).submit();
 	} else {
	 alert('Vul a.u.b. alle verplichte velden van het formulier op correcte wijze in.'+errorLijst);
	}


}




function activeerTabs(tabholderId) {

  var tab = document.getElementById(tabholderId).getElementsByTagName("div");
  for(var i=0;i<tab.length;i++) {

	if(tab[i].id == currentP) {
		tab[i].style.backgroundPosition= ' 0px -31px';
		tab[i].firstChild.style.color='#ffffff';
	}

  	tab[i].onmouseover=function() {
		this.style.cursor='pointer';
		this.style.backgroundPosition= ' 0px -31px';
 		this.firstChild.style.color='#ffffff';
   }

    tab[i].onmouseout=function() {
		if(this.id.substr(0, 10) != '__active__') {
		this.style.cursor='default';
		this.style.backgroundPosition= ' 0px 0px';
		this.firstChild.style.color='#ffffff';
		}
    }

    tab[i].onclick=function() {
		if(this.id.substr(0, 10) != '__active__') {
		window.location=thisHost+this.id;
		} else {
		window.location=thisHost+this.id.substr(10);
		}
    }

  }
}






function zwartWitEffect() {

  var img = document.getElementById('midrechts').getElementsByTagName("img");
  for(var i=0;i<img.length;i++) {


	var newImg = new Image();
	newImg.src = img[i];
	var height = img[i].height;
	var width = img[i].width;



	if( (height == 150) && (width == 150) ){


		img[i].onmouseover=function() {

			var partjes = this.src.split("/");
			var bestandsnaam = partjes[(partjes.length)-1];
			if(partjes[(partjes.length)-2] == 'pix_custom_dekoel') {
				var url = thisHost+'admin/pages/pix_custom_dekoel/';
			} else {
				var url = thisHost+'pix/';
			}

			this.src = url+bestandsnaam.substring(3);

		}

		img[i].onmouseout=function() {

			var partjes = this.src.split("/");
			var bestandsnaam = partjes[(partjes.length)-1];
			if(partjes[(partjes.length)-2] == 'pix_custom_dekoel') {
				var url = thisHost+'admin/pages/pix_custom_dekoel/';
			} else {
				var url = thisHost+'pix/';
			}

			this.src = url+'zw_'+bestandsnaam;

		}
	}


  }

}





function activeerWebTabs(tabholderId) {


  var tab = document.getElementById(tabholderId).getElementsByTagName("div");
  for(var i=0;i<tab.length;i++) {

	if(tab[i].id == activeWebTab) {
		tab[i].style.backgroundPosition= ' 0px -38px';
		tab[i].firstChild.style.color='#333333';
	}

  	tab[i].onmouseover=function() {
		this.style.cursor='pointer';
		this.style.backgroundPosition= ' 0px -38px';
 		this.firstChild.style.color='#333333';
   }

    tab[i].onmouseout=function() {
		if(this.id != activeWebTab) {
		this.style.cursor='default';
		this.style.backgroundPosition= ' 0px 0px';
		this.firstChild.style.color='#333333';
		}
    }

    tab[i].onclick=function() {

		if(this.id != activeWebTab) {

			activeWebTab = this.id;
			var tabNaam = this.firstChild.id;

			if(document.getElementById('vak_tab_prod')) { document.getElementById('vak_tab_prod').style.display = 'none'; 	document.getElementById('div_tab_prod').style.backgroundPosition= ' 0px 0px'; }
			if(document.getElementById('vak_tab_specs')) {  document.getElementById('vak_tab_specs').style.display = 'none'; document.getElementById('div_tab_specs').style.backgroundPosition= ' 0px 0px'; }
			if(document.getElementById('vak_tab_prijs')) {  document.getElementById('vak_tab_prijs').style.display = 'none'; document.getElementById('div_tab_prijs').style.backgroundPosition= ' 0px 0px'; }

 			document.getElementById(activeWebTab).style.backgroundPosition= ' 0px -38px';
 			document.getElementById('vak_'+tabNaam).style.display = 'inline';
		}
    }

  }


}









function activeerActieBanner(strId) {
 var banner = document.getElementById(strId);
  banner.onmouseover=function() {
   this.style.cursor='pointer';
   opacity(strId, 100, 60,256);
  }

  banner.onmouseout=function() {
   this.style.cursor='default';
   opacity(strId, 60, 100, 512);
  }

  banner.onclick=function() {
   popitup(thisHost+'inc/pages/actie.php');
  }

}








function topMenuEffect(id, klasse) {
if (document.getElementById(id)) {
 var kn = document.getElementById(id);
  kn.onmouseover=function() {
   this.className=klasse+'on';
  }

  kn.onmouseout=function() {
   this.className=klasse+'off';
  }
 }
}





function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}





function showPic(fotoNr, fotoSrc) {
		document.getElementById('fotogroot').src = fotoSrc;

		//effecten
		document.getElementById('blur').style.visibility = 'visible';
		opacity('blur', 0, 75, 100);
		setTimeout("document.getElementById('fotolijst').style.visibility = 'visible'", 100);
		setTimeout("document.getElementById('fotogroot').style.visibility = 'visible'", 100);
}






function popitup(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=480,height=640');");
return false;
}




function showPopup(popUpContent)
{



	var installflash = ''
	+'<p>'
	+'<img src="'+thisHost+'pix/de-koel-catering.gif" alt="De Koel Catering" /><br />&nbsp;<br />&nbsp;<br />Om onze digitale folder te bekijken dient u Adobe Flash player te installeren.<br />Download de Flash Player via: <a href="http://get.adobe.com/flashplayer/" target="_blank">http://get.adobe.com/flashplayer/</a>'
	+'</p>';


	var bookdekoel = ''
	+'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="1200" height="550">'
	+'<param name="movie" value="'+thisHost+'brochure/dekoel.swf">'
	+'<param name="quality" value="high">'
	+'<param name="bgcolor" value="#ffffff">'
	+'<param name="scale" value="noscale">'
	+'<embed src="'+thisHost+'brochure/dekoel.swf" width="1200" height="550" quality="high"  bgcolor="#ffffff" scale="noscale" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>'
	+'</object>';


	var bookculinair = ''
	+'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="1200" height="640">'
	+'<param name="movie" value="'+thisHost+'brochure/culinair.swf">'
	+'<param name="quality" value="high">'
	+'<param name="bgcolor" value="#ffffff">'
	+'<param name="scale" value="noscale">'
	+'<embed src="'+thisHost+'brochure/culinair.swf" width="1200" height="640" quality="high"  bgcolor="#ffffff" scale="noscale" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>'
	+'</object>';


	if( (popUpContent == "bookdekoel") || (popUpContent == "groepsarrangementen") ){
		if(flash == 1) {
			popUpContent = bookdekoel;
		} else {
			popUpContent = installflash;
		}
	}

	if( (popUpContent == "bookculinair") ){
		if(flash == 1) {
			popUpContent = bookculinair;
		} else {
			popUpContent = installflash;
		}
	}

	if(popUpContent == "buffet_menu") { popUpContent = document.getElementById('buffet_omschrijving').innerHTML; }
	if(popUpContent == "pakket_menu") { popUpContent = document.getElementById('pakket_omschrijving').innerHTML; }
	if(popUpContent == "nvep")  {
		popUpContent = document.getElementById('nvep_omschrijving').innerHTML;
		document.getElementById('fotolijst').style.width = '700px';
		document.getElementById('fotolijst').style.marginLeft = '-355px';
	}
	if(popUpContent == "osvvv") {
		popUpContent = document.getElementById('osvvv_omschrijving').innerHTML;
		document.getElementById('fotolijst').style.width = '700px';
		document.getElementById('fotolijst').style.marginLeft = '-355px';
	}



	// settings
	var popUpContentSpan = document.getElementById('popupcontent');
	var fotolijst = document.getElementById('fotolijst');
	var blur = document.getElementById('blur');
	popUpContentSpan.innerHTML = popUpContent;
	//effecten
	blur.style.visibility = 'visible';
	opacity('blur', 0, 75, 75);

	setTimeout("document.getElementById('fotolijst').style.visibility = 'visible'", 75);
	setTimeout("document.getElementById('popupcontent').style.visibility = 'visible'", 75);

}






function detectFlash()
{
		if ((navigator.userAgent.indexOf('MSIE') != -1)
		&& (navigator.userAgent.indexOf('Win') != -1))
		{
		document.writeln('<script language="VBscript">');
		document.writeln('Private i, x, ControlVersion');
		document.writeln('ON ERROR RESUME NEXT');
		document.writeln('x = null');
		document.writeln('ControlVersion = 0');
		document.writeln('var Flashmode');
		document.writeln('FlashMode = False');
		document.writeln('For i = 9 To 1 Step -1');
		document.writeln(' Set x = CreateObject("ShockwaveFlash.ShockwaveFlash." & i)');
		document.writeln(' ControlInstalled = IsObject(x)');
		document.writeln(' If ControlInstalled Then');
		document.writeln(' flash = CStr(i)');
		document.writeln(' Exit For');
		document.writeln(' End If');
		document.writeln('Next');
		document.writeln('</scr' + 'ipt>');

		// VB check failed
		// TODO: use alternative check
		if (flash == 0)
		{
		flash = 7;
		}
		} else {
		if (navigator.plugins && navigator.plugins.length > 0)
		{
		if (navigator.plugins["Shockwave Flash"])
		{
		flash = navigator.plugins["Shockwave Flash"].description;
		flash = flash.substring(flash.indexOf(".")-1);
		}
		}
		}
		return parseInt(flash);
}




function doRefresh() {
  window.location.reload();
}



function changePic(strId, strNewSrc) {
	document.getElementById(strId).src = strNewSrc;
}


function clearField(fieldId) {
  	var field = document.getElementById(fieldId);
  	field.value='';
}


function runFormCheck() {

	var fieldsToCheck = document.getElementById("fieldsToCheck").value;
	var submitId = document.getElementById("submitButtonId").value;
	var aantalCorrecteVelden	  = 0;
	var aantalCorrecteVeldenNodig = document.getElementById("fieldsToBeCorrect").value;
	var veld = fieldsToCheck.split("__");

	for ( var i in veld ) {
			var params = veld[i].split("|");

			/**************************************************************
			* @param text  Voor text velden
			*/
			if (params[1] == "text") {
				waardeIn = document.getElementById(params[0]).value.length;

				// IS DE LIMIT EEN MINIMUM OF MAXIMUM
				if(params[2].substring(0,3) == 'min') {
					if (params[2].substring(4) <= parseInt(waardeIn)) {
						aantalCorrecteVelden++;
					}
				} else {
					if (parseInt(waardeIn) >= params[2].substring(4)) {
						aantalCorrecteVelden++;
					}
				  }
			}
			/**************************************************************/



			/**************************************************************
			* @param text  Voor email adressen
			*/
			if (params[1] == "email") {
				if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById(params[0]).value)){
					aantalCorrecteVelden++;
				}
			}
			/**************************************************************/



			/**************************************************************
			* @param text  Voor checkboxen
			*/
			if (params[1] == "checkbox") {
				if (document.getElementById(params[0]).checked == true){
					aantalCorrecteVelden++;
				}
			}
			/**************************************************************/



	 } // einde for


	/**************************************************************
	* @param text  Submit button instellen
	*/
	if (aantalCorrecteVelden == aantalCorrecteVeldenNodig){
		document.getElementById(submitId).disabled = false;
	}
	else {
		document.getElementById(submitId).disabled = true;
	}
	/**************************************************************/


}






function valideerEmail(fieldId, submitId) {

field = document.getElementById(fieldId);

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(field.value)){
		document.getElementById(submitId).disabled = false;
	}
	else {
		document.getElementById(submitId).disabled = true;
	}
}


function checkMinStrLength(fieldId, submitId, waardeMin) {

waardeIn = document.getElementById(fieldId).value.length;

if  ( parseInt(waardeIn) > waardeMin) {
		document.getElementById(submitId).disabled = false;
	} else {
   		document.getElementById(submitId).disabled = true;
	}
}



function setIntLength(waarde, maxwaarde, obj) {

	if ( parseInt(waarde) > maxwaarde) {
   		obj.value = maxwaarde;
   		alert("Het maximum aantal is "+maxwaarde);
	}
}



function setFloatInput(obj) {

	if((obj.value == '') || (!IsNumeric(obj.value)) ) {
		obj.value = 0
	}

}





function numbersOnly(evt){

  evt = (evt) ? evt : event;

  var c = (evt.charCode) ? evt.charCode :

 ((evt.keyCode) ?
 	evt.keyCode : ((evt.wich) ? evt.wich : 0));

   if (c > 31 && (c < 48 || c > 57)) {
    alert("Vul a.u.b. een cijfer in.");
    return false;
   }

   return true;
}


function IsNumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}



function IsInteger(sText) {
   var ValidChars = "0123456789";
   var IsInteger=true;
   var Char;


   for (i = 0; i < sText.length && IsInteger == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsInteger = false;
         }
      }
   return IsInteger;

}






function wisMceField(fieldId){
	var inst = tinyMCE.getInstanceById(fieldId);
	inst.execCommand("mceSetContent", false, '');
}


function plaatsInMceField(fieldId, selectId){
	var templateId = document.getElementById(selectId).options[document.getElementById(selectId).selectedIndex].value;
	var tekst = asyncReq('GET', thisHost+'inc/system.php', 'act=gettemplate&var='+templateId, 'mce', fieldId, '', '');
}














function setElLaden(elId) {
	document.getElementById(elId).innerHTML = '<img src="'+thisHost+'pix_portal/laden.gif">';
}


function asyncReq(type, actie, params, doel, doelnaam, onReady, onReadyVar) {

	if (typeof xmlHttp == 'undefined') {
		if (window.ActiveXObject) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} else if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest();
		  }
			requestHandle(xmlHttp, type, actie, params, doel, doelnaam, onReady, onReadyVar);

	} else {
			if (window.ActiveXObject) {
				xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
			} else if (window.XMLHttpRequest) {
				xmlHttp2 = new XMLHttpRequest();
			  }
			requestHandle(xmlHttp2, type, actie, params, doel, doelnaam, onReady, onReadyVar);
	  }
}



function requestHandle(xmlHttpObj, type, actie, params, doel, doelnaam, onReady, onReadyVar) {

	if(type == "GET") {
		actie = actie+'?'+params;
	}

  xmlHttpObj.open(type, actie, true);
    xmlHttpObj.onreadystatechange = function () {

		if((xmlHttpObj.readyState == 4) && (xmlHttpObj.status == 200)) {
				if((doel == 'dom') && document.getElementById(doelnaam)) {
     			  document.getElementById(doelnaam).innerHTML = xmlHttpObj.responseText;
     			  if(onReady != '') {
					 window[onReady](onReadyVar);
				  }
				}

				else if(doel == 'buffer') {
     			  buffer = xmlHttpObj.responseText;
     			  if(onReady != '') {
					 window[onReady](onReadyVar);
				  }
				}

				else if(doel == 'mce') {
				  	var inst = tinyMCE.getInstanceById(doelnaam);
					inst.execCommand("mceInsertContent", false, ''+xmlHttpObj.responseText);
				}
		}
	}

	if(type == "GET") {
    	xmlHttpObj.send(null);
	} else {
    	xmlHttpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    	xmlHttpObj.send(params);
	}
}





function opacity(id, opacStart, opacEnd, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;

	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}



