jQuery(document).ready(function($) {
	/* ------------------------------------------------- */
	/* SUPERSIZED
	/* ------------------------------------------------- */
	$(function(){
		$.fn.supersized.options = {  
			startwidth: 1200,  
			startheight: 800,
			vertical_center: 0,
			slideshow: 0,
			navigation: 0,
			transition: 0, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
			pause_hover: 0,
			slide_counter: 1,
			slide_captions: 1,
			slide_interval: 3000  
		};
        $('#supersize').supersized(); 
    });
	
	/* ------------------------------------------------- */
	/* MAKE TOOLBOX
	/* ------------------------------------------------- */
	if($('#toolbox').size() > 0) {
		$('#toolbox').draggable({'handle':'#toolbox #drag','containment':'window','z-index':1000});
		$('#toolbox #btn-plan a').addClass('current');
		$('#detail-wrapper #plan').addClass('current').show();
		// BUILD TOOLBOX INTERACTIVITY
		$('#toolbox #btn-plan a').click(function(e) {
			e.preventDefault();
			if(!$(this).hasClass('current')) {
				var visible = $('#detail-wrapper div.current');
				visible.fadeOut('fast', function() { visible.hide().removeClass('current'); });
				$('#detail-wrapper #plan').fadeIn().addClass('current');
				$('#toolbox a').removeClass('current');
				$(this).addClass('current');
			}
		});
		
		$('#toolbox #btn-photos a').click(function(e) {
			e.preventDefault();
			if(!$(this).hasClass('current')) {
				var visible = $('#detail-wrapper div.current');
				visible.fadeOut('fast', function() { visible.hide().removeClass('current'); });
				$('#detail-wrapper #photos').fadeIn().addClass('current');
				$('#toolbox a').removeClass('current');
				$(this).addClass('current');
			}
		});
		
		$('#description a.close').click(function() { $('#detail-wrapper #description').slideToggle(); })
		
		$('#toolbox #btn-description a').click(function(e) {
			e.preventDefault();
			$('#detail-wrapper #description').slideToggle();
		});
	}
	
	/* ------------------------------------------------- */
	/* SET FIXED DIV WIDTHS
	/* ------------------------------------------------- */
	$('div.fixed').each(function() {
		var width = $('#wrapper').width();
		$(this).width(width);
	});
	
	
	/* ------------------------------------------------- */
	/* ADD UX AND SET MENU-BTN
	/* ------------------------------------------------- */
	$('#menu-wrapper').hide().mouseleave(function() {  $(this).fadeOut('fast'); });
	if($('#wrapper').width() >= 960)
	{
		$('#menu-btn').css({'right': $('#wrapper').width() + 'px'});
	} else {
		$('#menu-btn').css({'right': $('#wrapper').width() + 'px'});
	}
	$('#menu-btn').click(function() { $('#menu-wrapper').fadeIn('fast'); })
	
	
	/* ------------------------------------------------- */
	/* SET NEWS-FLASHES POS
	/* ------------------------------------------------- */
	if($('#news-flash').size() > 0) $('#news-flash').css({'right': ($('#wrapper').width() + 30) + 'px'});
	if($('#banner').size() > 0) $('#banner').css({'right': ($('#wrapper').width() + 25) + 'px'});
	
	
	/* ------------------------------------------------- */
	/* PRETTY CHECKBOXES
	/* ------------------------------------------------- */
	$('input[type=checkbox]').prettyCheckboxes();
	
	
	/* ------------------------------------------------- */
	/* ACTIVATE SCROLLABLE
	/* ------------------------------------------------- */
	if($('div.scrollable').size() > 0) $('div.scrollable').scrollable({next:'a.prev', prev:'a.next', speed:500, items:'div.items', size:1}).mousewheel().circular();

	
	
	/* ------------------------------------------------- */
	/* DRAGGABLE MAP
	/* ------------------------------------------------- */
	if($('#draggable').size() > 0) {
		
		$("#draggable").css({top:0, left:0});
		$('#small-inplantingsplan').click(function() { $('#small-inplantingsplan').fadeOut(); });
		$('#close-zoom').click(function() { $('#small-inplantingsplan').fadeIn(); });
		
		var maskWidth  = $("#draggable").parent().width();
		var maskHeight = $("#draggable").parent().height();
		var imgPos     = $("#draggable").offset();
		var imgWidth   = $("#draggable").width();
		var imgHeight  = $("#draggable").height();

		var x1 = (imgPos.left + maskWidth) - imgWidth;
		var y1 = (imgPos.top + maskHeight) - imgHeight;
		var x2 = imgPos.left;
		var y2 = imgPos.top;

		$("#draggable").draggable({containment:[x1,y1,x2,y2]});
		$("#draggable").css({cursor:'move'});
	}

	/* ------------------------------------------------- */
	/* FORM VALIDATION
	/* ------------------------------------------------- */
	$.metadata.setType("attr", "validate");
	$("#SubscriptionAddForm").validate();
	function clearForm(form) {
		// iterate over all of the inputs for the form
		// element that was passed in
		$(':input', form).each(function() {
			var type = this.type;
			var id = this.id;
			var tag = this.tagName.toLowerCase(); // normalize case
			// it's ok to reset the value attr of text inputs,
			// password inputs, and textareas
			if (type == 'text' || type == 'password' || tag == 'textarea')
				this.value = "";
			// checkboxes and radios need to have their checked state cleared
			// but should *not* have their 'value' changed
			else if ((type == 'checkbox' || type == 'radio') && id != 'nieuwsbrief')
				this.checked = false;
			// select elements need to have their 'selectedIndex' property set to -1
			// (this works for both single and multiple select elements)
			else if (tag == 'select')
				this.selectedIndex = -1;
		});
	};

	clearForm("#SubscriptionAddForm");
	
	
	$("#InformationAddForm").validate();
	function clearForm(form) {
		// iterate over all of the inputs for the form
		// element that was passed in
		$(':input', form).each(function() {
			var type = this.type;
			var id = this.id;
			var tag = this.tagName.toLowerCase(); // normalize case
			// it's ok to reset the value attr of text inputs,
			// password inputs, and textareas
			if (type == 'text' || type == 'password' || tag == 'textarea')
				this.value = "";
			// checkboxes and radios need to have their checked state cleared
			// but should *not* have their 'value' changed
			else if ((type == 'checkbox' || type == 'radio') && id != 'nieuwsbrief')
				this.checked = false;
			// select elements need to have their 'selectedIndex' property set to -1
			// (this works for both single and multiple select elements)
			else if (tag == 'select')
				this.selectedIndex = -1;
		});
	};

	//clearForm("#InformationAddForm");
});

