gallery = new Array();
currentPic = 0;
buffer = '';
var c=0;
var t;
var timer_is_on=0;


window.onload = function () {

	if (document.getElementById('emailSpan')) {
	  document.getElementById('emailSpan').innerHTML = "miekerobben.nl";
	}

	if (document.getElementById('submitSpan')) {
	  document.getElementById('submitSpan').innerHTML = "<input type='submit' value='Versturen' style='border:1px solid'>";
  	}


	if (document.getElementById('vierbuttons')) {
		var arrBtn = document.getElementById('vierbuttons').getElementsByTagName('IMG');
		for (var i = 0; i < arrBtn.length; i++) {

				arrBtn[i].onmouseover=function() {
				  opacity(this.id, 100, 75, 1);
				}

				arrBtn[i].onmouseout =function() {
				  opacity(this.id, 75, 100, 1);
				}
		}
	}


	if (document.getElementById('icoontjes')) {
		var arrBtn = document.getElementById('icoontjes').getElementsByTagName('IMG');
		for (var i = 0; i < arrBtn.length; i++) {

				arrBtn[i].onmouseover=function() {
				  opacity(this.id, 100, 25, 1);
				}

				arrBtn[i].onmouseout =function() {
				  opacity(this.id, 25, 100, 1);
				}
		}
	}







	if (document.getElementById('aanmeld_form')) {
		document.getElementById('aanmeldformsubmit').onclick = function() {
			return checkPPForm('aanmeld_form');
		}
	}



}


/* EINDE ONLOAD		*/





function showPic(fotoNr, fotoSrc) {

		var extraMarginTop = 40+f_scrollTop();

		document.getElementById('fotolijst').style.marginTop = extraMarginTop+'px'

		document.getElementById('fotogroot').src = fotoSrc.replace("/th_", '/');
		document.getElementById('visualText').innerHTML = document.getElementById('textDiv'+fotoNr).innerHTML;

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





function timedCount(richting) {
	//document.getElementById('txt').value=c;

	if(richting == 'pos') {
		move(12);
		c=c+12;
	} else {
		move(-12);
		c=c-12;
	}


	t=setTimeout("timedCount('"+richting+"')",30);
}

function doTimer(richting)	{
	if (!timer_is_on) {
	  timer_is_on=1;
	  timedCount(richting);
	}
}

function stopCount() {
	clearTimeout(t);
	timer_is_on=0;
}



function move(direction) {

if(timer_is_on==1) {
		var currentValue = parseInt(document.getElementById('thumbDisplay').style.marginLeft);
		var MaxValue = (parseInt(document.getElementById('maxValue').innerHTML));
		var newValue = (parseInt(direction)+currentValue);


		if(newValue <= 0) {
			document.getElementById('arrLeft').src =thisHost+'pix/links.gif';
		} else {
			document.getElementById('arrLeft').src =thisHost+'pix/links_inactive.gif';
		}



		if(newValue < MaxValue) {
			document.getElementById('arrRight').src =thisHost+'pix/rechts_inactive.gif';
		} else {
			document.getElementById('arrRight').src =thisHost+'pix/rechts.gif';
		}


		if( (currentValue == 0) && (newValue < 0) ) {
			document.getElementById('thumbDisplay').style.marginLeft = newValue+'px';
		}


		if(  (currentValue <= 0) && (newValue > (MaxValue-240))   &&   ((currentValue != 0) && (newValue != 120))   ) {
			document.getElementById('thumbDisplay').style.marginLeft = newValue+'px';
		}
}

}










function checkPPForm(strId) {

	var verzend = 'JA';
	var errorLijst = '';
	if(document.getElementById('aanmeldform_teamnaam').value 		== '') { verzend = 'NEE'; errorLijst = errorLijst+"\n- Vul een team- of bedrijfsnaam in."; }
	if(document.getElementById('aanmeldform_naam').value 		== '') { verzend = 'NEE'; errorLijst = errorLijst+"\n- Vul uw naam in."; }
	if(document.getElementById('aanmeldform_plaats').value 		== '') { verzend = 'NEE'; errorLijst = errorLijst+"\n- Vul uw woonplaats in."; }
	if(document.getElementById('aanmeldform_tel').value 			== '') { verzend = 'NEE'; errorLijst = errorLijst+"\n- Vul uw telefoonnummer in."; }
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('aanmeldform_email').value)){} else { verzend = 'NEE';  errorLijst = errorLijst+"\n- Vul een geldig e-mailadres in."; }


	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 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>';



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


	if(popUpContent == "agenda")  {
		popUpContent = document.getElementById('agenda_inhoud').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';
	changeOpac(85, 'blur');

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

}














function initGalButtons() {


  if (document.getElementById('vorige')) {
	var btnVorige = document.getElementById('vorige');

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

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

	btnVorige.onclick=function(){
		navigateGal(-1);
	}
  }




  if (document.getElementById('volgende')) {
	var btnVolgende = document.getElementById('volgende');

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

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

	btnVolgende.onclick=function(){
		navigateGal(1);
	}
  }

}



function navigateGal(pos) {

	var aantalPics = gallery.length-1;
	currentPic = currentPic+pos;

	if(currentPic < 0) {
		currentPic = aantalPics;
	}
	if(currentPic > aantalPics) {
		currentPic = 0;
	}


	document.getElementById('fotogroot').src = gallery[currentPic].replace("/th_", '/');
	document.getElementById('visualText').innerHTML = document.getElementById('textDiv'+parseInt(currentPic+1)).innerHTML;


}



function initGal(type) {

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


	  var btn=document.getElementById('gallery').getElementsByTagName("IMG");
	  for(var i=0;i<btn.length;i++) {

	    if(btn[i].alt != 'na') {

			gallery[gallery.length] = btn[i].src;

			btn[i].onmouseover=function() {
			  this.style.cursor = 'pointer';
			  opacity(this.id, 100, 50, 128);
			}
			btn[i].onmouseout=function() {
			  opacity(this.id, 50, 100, 768);
			}
			btn[i].onclick=function() {
			  currentPic = parseInt(this.id.substring(4))-1;
			  showPic(this.id.substr(4), this.src);
			}
		}
	  }



}






function hoverOn(el) {
	el.className='on';
}

function hoverOff(el) {
	el.className='off';
}



function goTo(strUrl) {
	window.location= strUrl;
}




function showSheet(strEl) {
	sheet = document.getElementById(strEl);
	sheet.style.display='block';
}



function hideSheet(strEl) {
	sheet = document.getElementById(strEl);
	sheet.style.display='none';
}





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 + ")";
}






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 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 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 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);
	}
}

