galleryPS = new Array();
currentPic = 0;
buffer = '';
flash=0;



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('galleryPS')) {
	  initGalButtons();
	  initGal('galleryPS');
	}

	if (document.getElementById('sml')) {
		var arrBtn = document.getElementById('sml').getElementsByTagName('IMG');
		for (var i = 0; i < arrBtn.length; i++) {
			arrBtn[i].onmouseout=hoverOff(arrBtn[i].src);
			arrBtn[i].onmouseover=hoverOn(arrBtn[i]);
		}
	}


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

	if (document.getElementById('emailSpan')) {
	document.getElementById('emailSpan').innerHTML = '<a href="mailto:info@limianz.nl" style="color:#ffffff">info@limianz.nl</a>';
	}

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





  if (document.getElementById('leeftijdkind')) {

		var selBox= document.getElementById('leeftijdkind');

		selBox.onchange = function() {
			setKindRegels(parseInt(selBox.options[selBox.selectedIndex].value));
		}



  }


  if (document.getElementById('sluitenTwee')) {
	var btnSluitTwee = document.getElementById('sluitenTwee');

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

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

	btnSluitTwee.onclick=function(){
		if(document.getElementById('popupcontent')) {
		document.getElementById('popupcontent').style.visibility = 'hidden';
		}
		document.getElementById('site').style.visibility = 'visible';
		document.getElementById('popupcontent').style.visibility = 'hidden';
	}

  }




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


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


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



  if (document.getElementById('callmebackform_submit'))  {

		document.getElementById('callmebackform_submit').onclick = function() {
			checkCallMeBackForm();
		}

		document.getElementById('callmebackform_submit').onmouseover = function() {
			this.style.cursor = 'pointer';
		}

  }





  if (document.getElementById('nieuwsbriefform_submit'))  {

		document.getElementById('nieuwsbriefform_submit').onclick = function() {
			checkNieuwsbriefForm();
		}

		document.getElementById('nieuwsbriefform_submit').onmouseover = function() {
			this.style.cursor = 'pointer';
		}

  }



}


/* EINDE ONLOAD		*/





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





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 initGalButtons() {


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

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

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

	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.png';
	}

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

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




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

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

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

	btnSluit.onclick=function(){
		if(document.getElementById('fotogroot')) {
		document.getElementById('fotogroot').style.visibility = 'hidden';
		document.getElementById('fotogroot').src = './pix/blanco.gif';
		}
		document.getElementById('site').style.display = 'block';
		document.getElementById('fotolijst').style.display = 'none';
	}

  }




}







function checkCallMeBackForm() {


	var telefoonnummer = document.getElementById('cmbfTel').value;

	if(telefoonnummer.length < 8) {
		alert("U dient een geldig telefoonnummer in te voeren.");
	} else {
		document.getElementById('callmebackform').submit();
	}

}











function checkNieuwsbriefForm() {


	var naam = document.getElementById('nbfNaam').value;
	var email = document.getElementById('nbfEmail').value;
	var emailCheck = 'NOTOK';

	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){ emailCheck = 'OK'; } else { emailCheck = 'NOTOK'; }

	if(naam.length <= 1) {
		alert("U dient een geldige naam in te voeren.");
	} else if(emailCheck == 'NOTOK') {
		alert("U dient een geldig emailadres in te voeren.");
	} else {
		document.getElementById('nieuwsbriefform').submit();
	}

}





function setKindRegels(aantalKinderen) {

	var inhoud = '';

	for(var i=1;i<(aantalKinderen+1);i++) {
		inhoud = inhoud+'<small>Leeftijd kind '+i+' </small><input type="text" name="leeftijd_kind_'+i+'" style="width:55px; display:inline; font-size:11px" /><br />';
	}

	document.getElementById('leeftijdkindHolder').innerHTML = inhoud;

}





function zwartWitEffect(elID) {

  var img = document.getElementById(elID).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( (width == 275) ||  (width == 200) || (width == 150)  ){


		img[i].onmouseover=function() {

			var partjes = this.src.split("/");
			var bestandsnaam = partjes[(partjes.length)-1];
			if(partjes[(partjes.length)-2] == 'pix_custom_limianz') {
				var url = 'http://www.dekoel.nl/admin/pages/pix_custom_limianz/';
			} else {
				var url = 'http://www.dekoel.nl/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_limianz') {
				var url = 'http://www.dekoel.nl/admin/pages/pix_custom_limianz/';
			} else {
				var url = 'http://www.dekoel.nl/pix/';
			}

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

		}
	}


  }

}












function navigateGal(pos) {


    aantalPics = galleryPS.length-1;
	currentPic = currentPic+pos;


	if(currentPic < 0) {
		currentPic = aantalPics;
	}
	if(currentPic > aantalPics) {
		currentPic = 0;
	}
	document.getElementById('fotogroot').src = galleryPS[currentPic];

	layout = document.getElementById('foto'+(currentPic+1)).className;
	document.getElementById('lijstZilver').className =  'lijstZilver_'+layout;
	document.getElementById('tableLijstZilver').className =  'tableLijstZilver_'+layout;


}





function initGal(type) {



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

		galleryPS[i] = btn[i].title;

		btn[i].onmouseover=function() {
		  if(this.alt != 'na') {
		  this.style.cursor = 'pointer';
		  opacity(this.id, 100, 50, 128);

		  }
		}
		btn[i].onmouseout=function() {
		  if(this.alt != 'na') {
		  opacity(this.id, 50, 100, 768);
		  }
		}
		btn[i].onclick=function() {
		  currentPic = parseInt(this.id.substring(4))-1;
		  if(this.alt != 'na') {

		  showPic(this.title, this.src, this.className);

		  }
		}
	  }



}








function showPic(fotoSrcOriginal, fotoSrc, layout) {

		document.getElementById('site').style.display = 'none';

		var extraMarginTop = 40+f_scrollTop();

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

		if(document.getElementById('fotogroot')) {
		document.getElementById('fotogroot').src = fotoSrcOriginal;
		}

		document.getElementById('lijstZilver').className =  'lijstZilver_'+layout;
		document.getElementById('tableLijstZilver').className =  'tableLijstZilver_'+layout;


		//effecten
		setTimeout("document.getElementById('fotolijst').style.display = 'block'", 10);

		if(document.getElementById('fotogroot')) {
		setTimeout("document.getElementById('fotogroot').style.visibility = 'visible'", 10);
		}
}








function showPopup(popUpContent)
{


	var extraMarginTop = 40+f_scrollTop();
	var popUpContentText = document.getElementById('popupcontentText');


	if(popUpContent == "buffet_menu") { popUpContent = document.getElementById('buffet_omschrijving').innerHTML; }


	var booklimianz = ''
	+'<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/limianz.swf">'
	+'<param name="quality" value="high">'
	+'<param name="bgcolor" value="#ffffff">'
	+'<param name="scale" value="noscale">'
	+'<embed src="'+thisHost+'brochure/limianz.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 == "booklimianz") ){
		if(flash == 1) {
			popUpContent = booklimianz;

		} else {
			popUpContent = installflash;
		}

		popUpContentText.style.background = 'transparent';
	} else {
		popUpContentText.style.background = '#ffffff';
	}


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


	document.getElementById('site').style.visibility = 'hidden';
	document.getElementById('popupcontent').style.marginTop = extraMarginTop+'px'


	popUpContentText.innerHTML = popUpContent;

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

}







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

if(typeof Browser != "undefined") {
  
  window.addEvent('load', function() {
    /*docCoords = document.getCoordinates();
    siteCoords = $('site').getCoordinates();
    if(siteCoords.height < docCoords.height) {
      leftContent = $('site').getElement('div.contentleft');
      leftContent.setStyle('height',(docCoords.height-326)+'px');
      $('site').setStyle('overflow','hidden');
      $('site').setStyle('height', docCoords.height);
    }
    window.addEvent('resize', function() {
      docCoords = document.getCoordinates();
      siteCoords = $('site').getCoordinates();
      if(siteCoords.height < docCoords.height) {
        leftContent = $('site').getElement('div.contentleft');
        leftContent.setStyle('height',(docCoords.height-326)+'px');
        $('site').setStyle('overflow','hidden');
        $('site').setStyle('height', docCoords.height);
      }
    });*/
   
    siteCoords = $('site').getCoordinates();
    $('site').setStyle('overflow','hidden');
    $('site').setStyle('height', (siteCoords.height-60));
    
    $$('#maincontentright h2').each(function(hElm){
      cornerElm = new Element('span', {
        'class': 'leftcorners'
      });
      cornerElm.inject(hElm,'top');
    });
  });
  
  window.addEvent('domready', function() {
    $$('#menu li').each(function(menuElm) {
      menuElm.addEvent('mouseenter', function(e) {
        if(e != null) {
          e.preventDefault();
        }
        this.addClass('over');
      });
      menuElm.addEvent('mouseleave', function(e) {
        if(e != null) {
          e.preventDefault();
        }
        this.removeClass('over');
      });
    });
    
    //IE LAST MENU ITEM FIX 
    if(Browser.ie) {
      var lastLi = $('menu').getLast('li');
      var lastLink = lastLi.getElement('a');
      lastLink.setStyle('padding-right','13px');
      lastLi.setStyle('background-position','left top');
      lastLi.setStyle('margin','0 -8px 0 2px')
    }
    
    $$('.homepagebanner').each(function(bannerElm) {
      bannerElm.addEvent('mouseenter', function(e) {
        if(e != null) {
          e.preventDefault();
        }
        this.addClass('over');
      });
      bannerElm.addEvent('mouseleave', function(e) {
        if(e != null) {
          e.preventDefault();
        }
        this.removeClass('over');
      });
      
      bannerElm.addEvent('click', function(e) {
        if(e != null) {
          e.preventDefault();
        }
        var link = bannerElm.getElement('a');
        if(link != null) {
          window.location = link.get('href');
        }
      })
    });
  });
} else {
  window.onload = function () {
    document.getElementById('site').style.height = getDocHeight()+'px';

    window.onresize = function() {
      document.getElementById('site').style.height = getDocHeight()+'px';
    }
  }
}

