var Images = new Array();
$(document).ready(function() {

	// SlidOut login form on top
	$('#loginToggle').toggle(function() {
		$("#login").animate({
			marginTop: "0"
		}, 500 );
		$("#loginToggle").text('Annuleren');
	}, function() {
		$("#login").animate({
			marginTop: "-50px"
		}, 500 );
		$("#loginToggle").text('Inloggen');
	});
	
	// Slideshow for banners
	$('#slideshow ul').after('<a href="#" class="prev">&laquo;</a><a href="#" class="next">&raquo;</a><div class="nav"></div>');
	$('#slideshow ul.slides').cycle({
		fx: 				'turnDown',
		speed:       200, 
		pager:      '#slideshow div.nav', 
		pagerEvent: 'mouseover',
		prev:   		'#slideshow .prev', 
		next:   		'#slideshow .next'
	});
	// preload banners //
	$('#slideshow ul.slides li img:first').each(function() { 
		var image = new Image();
		image.src = $(this).attr('src');
		Images.push(image);
	});

	// Smoothscroll to anchors
	$('a[href*=#]').click(function( e ) {
		// Settings
	   var duration=600;  // duration in ms
	   var scrolloffset = 110; // offset in pixels
	   var easing='swing'; // easing values: swing | linear
	   // get / set parameters
	   var newHash=this.hash;
	   if(this.hash == "")
	   	return;
	   var target=($(this.hash).offset().top)-scrolloffset;
	   var oldLocation=window.location.href.replace(window.location.hash, '');
	   var newLocation=this;
	   // make sure it's the same location      
	   if(oldLocation+newHash==newLocation) {
	      $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {});
	   }
	   e.preventDefault();
	});
	
	// Put labels inside input fields
	$("#search input, #newsletter input, #login input").labelify({
	  text: "label"
	});
	
	// Animate agenda-items on hover
	$('#agenda ul li a')
		.css( {opacity: 0.8, left: '-20'} )
		.mouseover(function(){
			$(this).stop().animate(
				{opacity: 1,
				left: '0'}, 
				{duration:200})
			})
		.mouseout(function(){
			$(this).stop().animate(
				{opacity: 0.8,
				left: '-20'}, 
				{duration:200})
			})
	
	// Create tooltips
	$("body").append('<div id="tooltip"></div>');
  $('#cal a[tooltip], #flickr a[tooltip]')
	  .live('mousemove', function(e) {
      $("#tooltip").css({
      	top: e.pageY + 10 + 'px',
      	left: e.pageX + 10 + 'px'
      });
	  })
	  .live('mouseenter', function(e) {
	   	$("#tooltip").show().html($(this).attr('tooltip'));
	   	
	  })
	  .live('mouseleave', function(e) {
	   	$("#tooltip").hide();
	   	
	  })
	 
	 // Other inits
	 $('form').forms();
	 Calendar.init();

});







