
var accordionAnimationInProgress = false;

$(document).ready(function(){
	
	/**
	 * Uitklap menu met alleen jquery
	 */
	$('ul#nav ul').hide();
	$('ul#nav li:has(ul) > a').addClass('closed');

	$('ul#nav li:has(ul) > a').click(function () {
		if ($(this).hasClass('opened')) {
			$(this).parent().children('ul').slideUp('fast');
			$(this).addClass('closed');
			$(this).removeClass('opened');
		} else {
			$(this).parent().children('ul').slideDown('fast');
			$(this).addClass('opened');
			$(this).removeClass('closed');
		}
		return false;
	});
	/**
	 * Accodion modus
	$('ul#nav li:has(ul)').hover(function () {
		if (accordionAnimationInProgress) {
			return;
		}
		accordionAnimationInProgress = true;
		$('ul#nav li:has(ul)').removeClass('expanded');
		$(this).addClass('expanded');
		$('ul#nav li:has(ul) > a').addClass('closed');
		$('ul#nav li:has(ul) > a').removeClass('opened');		
		$('ul#nav li:not(.expanded) ul').slideUp('fast');
		$('ul#nav li.expanded ul').slideDown('fast', function () {
			$('ul#nav li.expanded > a').removeClass('closed');
			$('ul#nav li.expanded > a').addClass('opened');
			accordionAnimationInProgress = false;			
		});		
	});
	*/
	
	$("#slider").easySlider({
		auto: true,
		continuous: true,
		controlsShow: false
	});
	
	$("div.image-block a").click(function () {
		var source = $(this).attr("href");
		var title = $(this).attr("title");
		$("body").append('<div class="dialog"><img src="'+ source +'" alt=""></div>');
		$(".dialog img").load(function () {
		  var dWidth = ($(this).width());
		  //var dHeight = ($(this).height());
		  $('.dialog').dialog({
				width: dWidth+20,
				//height: dHeight+40,
				modal: true,
				title: title,
				position: 'center',
				close: function(event, ui) { 
					$(this).remove();
				}
			});
		});
	});
	
	$("a.map").click(function () {
		var title = $(this).attr("title");
		$("body").append('<div class="dialog"><iframe width="600" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.nl/maps/ms?ie=UTF8&amp;hl=nl&amp;msa=0&amp;msid=115933247913747971128.00047c6a572a4f07e4452&amp;ll=52.4541,4.812269&amp;spn=0.010461,0.025706&amp;z=15&amp;output=embed"></iframe></div>');
		$(".dialog").dialog({
			modal: true,
			title: title,
			width:	620,
			height: 440,
			resizable: false,
			close: function(event, ui) { 
				$(this).remove();
			}
		});
	});
	
	$("#submit").hover(function() { 
			$(this).addClass("hover"); 
		}, function() { 
			$(this).removeClass("hover"); 
	});
});

