//Preload function for carrousel images
jQuery.preloadImages = function(images) {
  images.each(function(i) {
  	jQuery("<img>").attr("src", this.src);
  });
}

//When page ready, preload the images and start the carrousel
$(document).ready(function()
{
  //Preload the fotos
  $.preloadImages($("img.carrouselfoto"));

  //Cycle the fotos
  $('#carrousel').cycle({
    fx:       'fade',
    pause:    1,
    timeout:  5000,
    speed:    1000
  });
  
  //Insert the load gif
	$('#waterstanden').html('<img src="/images/ajax-loader.gif">');
  
  //Get the waterstanden
  $.get("http://www.ittereninbeeld.nl/home/waterstanden", function(data) {
  	
  	//Insert the waterstanden
  	$('#waterstanden').html(data);
  	
  	//Cycle the waterstanden
    $('#waterstanden').cycle({
      fx:       'scrollDown',
      pause:    0.5,
      timeout:  5000,
      speed:    1000
    });
  });
 });
