
/*QUICK Toggle menu
=====================================*/
$(function() {
	$("#quickMenuToggle").click(function() {
		$("#quickMenu").slideDown();
		return false;
	});
});


/*SHADOWBOX
=====================================*/
Shadowbox.init({
	language: "nl",
	overlayColor: "#000",
	handleOversize: "none",
	displayNav: "false",
	viewportPadding: "0"
});

/*DATEPICKER
=====================================*/
$(function(){
	$('.date-pick').datePicker();
});

/*CUFON
=====================================*/
Cufon.replace('div#usp, ul#menu, body#home div.tekst p, a.call-to-action, div.right a, div.themas a, div.artikelen h3', {hover: true});
Cufon.replace('ul.stars, body#pagina h1, body#popup h1, h2, h3, .bulletsubtitlestyle, .hoofdMenu li a, div#usp, div.tagcloud, ul#menu, body#home div.tekst p, div.themas, a.call-to-action, div.right a, div.maandNaam, div.triggerHead', { fontFamily: 'Boton BQ' });

/*SLIDESHOW
=====================================*/
$(function() {
	$('#slideshow').cycle({
		fx: 'fade',
		timeout: 8000
	});
});

$(function() {
	$('#banner1').cycle({
		fx: 'fade',
		timeout: 5000,
		speed: 500
	});
});

$(function() {
	$('#banner2').cycle({
		fx: 'fade',
		timeout: 5000,
		speed: 500
	});
});

/*HOOFDMENU
=====================================*/
$(function(){
  $("ul.hoofdMenu li:first").addClass('hMenu1');
  $("ul.hoofdMenu li:last").addClass('hMenu3');
});

/*FOOTERMENU
=====================================*/
$(function(){
  $("div#footermenu div ul li:first").addClass('first');
});

/*FOOTERMENU
=====================================*/
$(function(){
  $("div.themas a.specials:first").addClass('first');
});


/*ALBUM
=====================================*/
$(function() {
		$("div.scrollable").scrollable();
	});

	$(function() {
		$(".items img").click(function() {
			var url = $(this).attr("src").replace("_small", "");
			var wrap = $("#image_wrap");   //.fadeTo("medium", 0.5)
			var img = new Image();
			img.onload = function() {
				wrap.fadeTo("fast", 1);
				wrap.find("img").attr("src", url);
			};
			img.src = url;
		}).filter(":first").click();
	});

/*BROWSERSTYLE
=====================================*/
function dynamicStyle() {
	var screenW = (document.body) ? document.body.clientWidth : innerWidth
	var theStyle = (screenW > 1260) ? 'huge' : (screenW > 960) ? 'big' : 'small';
	var i, a;

	for (i = 0; a = document.getElementsByTagName('link')[i]; i++) {
		if (a.getAttribute('href').indexOf("huge") >= 0 || a.getAttribute('href').indexOf("big") >= 0 || a.getAttribute('href').indexOf("small") >= 0) {
			if (a.getAttribute('href').indexOf(theStyle) != -1) {
				a.disabled = false;
			} else {
				a.disabled = true;
			}
		}
	}
}

//window.onload = window.onresize = dynamicStyle;
if (window.addEventListener) {
	window.addEventListener("load", dynamicStyle, false);
	window.addEventListener("resize", dynamicStyle, false);
 }  else if (window.attachEvent)  {
	window.attachEvent("onload", dynamicStyle);
	window.attachEvent("onresize", dynamicStyle);
}

/* INPUT
=====================================*/
(function($) {
	$.fn.defaultValue = function() {
		return this.each(function() {

			$(this).data("originalText", $(this).val());

			$(this).blur(function() {
				if ($(this).val() == "") {
					$(this).val($(this).data("originalText"));
					$(this).removeClass("enabled");
				}
			});

			$(this).focus(function() {
				if ($(this).val() == $(this).data("originalText")) {
					$(this).val("");
					$(this).addClass("enabled");
				}
			});

		});
	}
})(jQuery);


$(document).ready(function() {
	$("#saddr, #saddr2").defaultValue();
});

/* UITKLAPPEN
=====================================*/
$(function(){
	$("div.collapse").each(function() {
		if (!$(this).next().next().hasClass("collapse")) {
			$(this).css({
				"margin-bottom": "0"
			}).find("div.block").css({
				"margin-bottom": "0"
			})
		}
	});

	$(".toggle_container").hide();
	
	$("div.trigger").click(function(){
		if ($(this).attr("active") == "true") {
			$(this).removeAttr("active");
			$(this).removeClass("active").next(".toggle_container").slideUp("slow");
		} else {
			$("div.trigger").removeClass("active").removeAttr("active");	
			$(this).attr("active", "true");
			$(".toggle_container").slideUp();
			$(this).addClass("active").next(".toggle_container").slideToggle("slow");
		}
	});
	//$("span.trigger").eq(0).click();
});

function initCarousel(carousel) {
	carousel.scroll(1);
}

/* AUTOMATISCH UITKLAPPEN
=====================================*/
$(document).ready(function() {
	$(document).find('*[active]').each(function(index){
		$(this).next(".toggle_container").slideToggle("slow");
	});
});


/* AUTOMATISCH UITKLAPPEN
=====================================*/
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("div.uitleg").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("div.uitleg").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});

$(window).load(function(){
	var hash = window.location.hash.replace('#', '');
	temparray = hash.split('?');
	if(temparray.length>1){
		if(temparray[0] == 'reserveernu') {
			Shadowbox.open({
				content : 'http://www.yankeedoodle.nl/pageid=206/structure=19/'+temparray[1].replace('&','/')+'/Reserveren.html',
				player : 'iframe',
				width : 540,
				height : 450
			});
			
		}
	}
	if(hash == 'reserveernu') {
		Shadowbox.open({
			content : 'http://www.yankeedoodle.nl/pageid=206/structure=19/Reserveren.html',
			player : 'iframe',
			width : 540,
			height : 450
			});
	}
	if(hash == 'reserveerhalloween') {
		Shadowbox.open({
			content : 'http://www.yankeedoodle.nl/pageid=108/structure=19/datum=2010-10-31/Reserveren.html',
			player : 'iframe',
			width : 540,
			height : 450
			});
	}

	if(hash == 'reserveernugroningen') {
		Shadowbox.open({
			content : 'http://www.yankeedoodle.nl/pageid=206/structure=19/vest=gr/Reserveren.html',
			player : 'iframe',
			width : 540,
			height : 450
			});
	}
	if(hash == 'kaartje') {
		Shadowbox.open({
			content : 'http://www.yankeedoodle.nl/pageid=204/structure=19/Nodig_anderen_uit.html',
			player : 'iframe',
			width : 720,
			height : 620
			});
	}

	if(hash == 'dinnergift') {
		Shadowbox.open({
			content : 'http://www.yankeedoodle.nl/pageid=205/structure=19/Dinnergift.html',
			player : 'iframe',
			width : 720,
			height : 620
			});
	}


});

$(function(){
	$("div[id='infoballoon']").balloon();
});

/* Formulier functies
=====================================*/

function changeformulier(value){
	if(value == "1")
	{
		$("input[id='hideshow']").parent().parent().css({"display": "none"});
		$("tr[class='rowadd']").css({"display": "none"});
		$("input[id='hideshow']").val(" ");
		$("tr[id='datekind']").css({"display": "none"});
		
		$("select[id='kindoptie']").each(function(){
			this[0].selected = "1";
		});
		
	}
	if(value == "2")
	{
		$("tr[class='kind1']").css({"display": "table-row"});
		$("tr[id='addchildrow1']").css({"display": "table-row"});
	}
}

function shownextchild(value){

	previousadd =  "addchildrow" + value;
	value = parseInt(value) + 1;

	rowclass = "kind" + value;
	addrowid = "addchildrow" + value;
	
	$("tr[class='"+rowclass+"']").css({"display": "table-row"});
	$("tr[id='"+addrowid+"']").css({"display": "table-row"});
	$("tr[id='"+previousadd+"']").css({"display": "none"});
	
}

