// CUFON
Cufon.replace('div#slogan, h1, nav a.main, ul.contact, div#tagcloud, div#content section h2, h3', {hover: true});

//SHADOWBOX
Shadowbox.init({
	troubleElements: ["select", "object", "embed", "canvas", "iframe"]
});
window.onload = function() {
	Shadowbox.setup("ul.detail a", {
		gallery:		"Detail",
		autoplayMovies:	true
	});
};

//EXAMPLETEXT
	function switchText(){
		if ($(this).val() == $(this).attr('title'))
			$(this).val('').removeClass('exampleText');
		else if ($.trim($(this).val()) == '')
			$(this).addClass('exampleText').val($(this).attr('title'));
	}

// ELEMENTEN GELIJKE HOOGTE
	function equalHeight(obj){
		topHeight = 0;
		obj.each(function(){
			topHeight = ($(this).height() > topHeight ? $(this).height() : topHeight)
		});
		obj.height(topHeight);
	}

$(window).load(function(){
	equalHeight($("div.case"));
	equalHeight($(".jcarousel-item a div"));
	equalHeight($("body.home div#content section"));

	$("figure").each(function(){
		$(this).find("figcaption").css("max-width", $(this).find("img").width()).show();
		});
	$("div.input_block").each(function(){
		$(this).find("div.label").height($(this).height());
		});
});

$(function(){

	//AUTORESIZE CONTACT TEXTAREA
	$('aside textarea').autoResize({
		animateDuration : 300,
		limit: 600
	});

//RANDOM
	for (var i = 0; i < 1; i++) {
		$(".clients").find("a:hidden:random").each(function() {
			$(this).appendTo($(this).parent()).show();
		});
	}

//JCAROUSEL
	if($("article div.carousel ul li").length > 0){
		$('.carousel .jcarousel').jcarousel({
			 scroll: 1
			,auto: 6
			,wrap: "circular"
		});
	}
	else{
		$("article div.carousel").css("display", "none");
	}

	$('.carousel2 .jcarousel').jcarousel({
		scroll: 1
	});

//CONTACTFORM

	$("aside div.value.text input").each(function(){
		$(this).addClass('exampleText').attr("data-value", $(this).val());
	});

	$('form').submit(function() {
		$(this).find('input[type=text][title!=""]').each(function() {
			if ($(this).val() == $(this).attr('title')) $(this).val('');
		});
	});

	$('aside#right textarea#formfield3').addClass('exampleText').attr('data-value', 'Your message').val('Your message');
	$('aside#right textarea#formfield7').addClass('exampleText').attr('data-value', 'Uw bericht').val('Uw bericht');

	$('aside#right div.value.text input, aside#right textarea').focus(function(){
		if($(this).hasClass('exampleText')){
			$(this).removeClass('exampleText').val('');
		}
	}).blur(function(){
		if($(this).val() === ''){$(this).val($(this).attr('data-value')).addClass('exampleText');}
	});

//CALLTOACTIONS
	$("a.cta").each(function(){
		$(this).before("<div class=\"clear\"></div>");
		$(this).after("<div class=\"clear\"></div>");
	});

// DATEPICKER	
	$(".datepicker").datepicker({
		dateFormat: 'dd-mm-yy',
		firstDay: 1,
		nextText: 'volgende',
		prevText: 'vorige',
		dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
		dayNamesShort: ['Zon', 'Maa', 'Din', 'Woe', 'Don', 'Vrij', 'Zat'],
		dayNamesMin: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'],
		monthNames: ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'],
		monthNamesShort: ['Jan','Feb','Maa','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec']
	});

});

jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
{
	random: function(a, i, m, r) {
		if (i == 0) {
			jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
		};
		return i == jQuery.jQueryRandom;
	}
});

