Shadowbox.init();


//DATEPICKER
$(function() {
	$("#hmcform").submit(function() {
		var requiredFields = [
			"naam",
			"organisatie",
			"telefoon",
			"emailadres",
			"voorletters",
			"achternaam",
			"straat",
			"huisnummer",
			"postcode",
			"woonplaats",
			"telefoonclient",
			"inschrijfnummer",
			"geboortedatum",
			"uitvoerdatum"
		];
		var hasErrors = false;
		for (var i in requiredFields) {
			$field = $("input[name=" + requiredFields[i] + "]").removeClass("error");
			if ($field.val() == "") {
				hasErrors = true;
				$field.focus();
				$field.addClass("error");
			}
		}
		if (hasErrors) {
			jAlert('U heeft niet alle velden ingevuld', 'Aanvraagformulier')
			return false;
		} else {
			return checkForm();
		}
	});
	//TOOLTIP
	$(".tooltip").easyTooltip()
	
	$picker = $('#datepicker').datepicker({
		minDate: "+1D", 
		maxDate: "+131D", 
		dateFormat: "dd-mm-yy",
		firstDay: 1,
		beforeShowDay: function(day) {
			var day = day.getDay();
			if (day == 0 || day == 6) {
				return [false, ""]
			} else {
				return [true, ""]
			}
		}
	});
	$("#datepickerIcon").click(function() {
		$picker.datepicker("show");
		return false;
	});
	
	
	
	$picker2 = $('#datepicker2').datepicker({
		minDate: "-10D", 
		maxDate: "+231D", 
		dateFormat: "dd-mm-yy",
		firstDay: 1,
		beforeShowDay: function(day) {
			var day = day.getDay();
			
			return [true, ""]
			
		}
	});
	$("#datepickerIcon2").click(function() {
		$picker2.datepicker("show");
		return false;
	});
	
});

/*MAIN
=====================================*/
$(function(){
	$("ul#nav li:even").addClass('even');
	$("ul#nav li:odd").addClass('odd');
	$("div#breadcrumb a:first").addClass('first');
	$("div#breadcrumb a:last").addClass('last');
	$("div#toggleMenu ul:last").addClass('last');
	$("div#toggleMenu a.trigger:last").addClass('last');
	$("div.veld input.radio:first").addClass('first');
});

/*GERELATEERDE PROJECTEN
=====================================*/
$(function(){
	jQuery('.cases').jcarousel({
		scroll: 1
	});
});

/*SLIDESHOW
=====================================*/
$(function() {
	$('#headerImg').cycle({
		fx: 'fade',
		timeout: 5000
	});
});

/*LINK VERPLAATSEN
=====================================*/
$(function() {
	$("body#home div#content div.box").each(function(){
		if($(this).find("a").length > 0){
			var data = $(this).find("a").html();
			var href = $(this).find("a").attr("href");
			$(this).find("a").remove();
			$(this).prepend(data);
			$(this).wrapInner("<a href=\"" + href + "\"></a>");
		}
	});
});

/*MENU LEEG
=====================================*/
$(function() {
	if($("div#menu").length > 0){
		if($("div#menu ul li").length < 1){
			$("div#menu").css("display", "none");
			$("div#rolstoel").css("display", "none");
			$("div#content").css("width", 610);
		}
	}
});

/*TOGGLEBOX
=====================================*/
/*
$(document).ready(function(){
	$(".toggle_container").hide();
	
	$("a.trigger").click(function(){
		if ($(this).attr("active") == "true") {
			$(this).removeAttr("active");
			$(this).removeClass("active").next(".toggle_container").slideUp("slow");
		} else {
			//$("a.trigger").removeClass("active").removeAttr("active");	
			$(this).attr("active", "true");
			//$(".toggle_container").slideUp();
			$(this).addClass("active").next(".toggle_container").slideToggle("slow");
		}
		//return false;
	});

	$("a.trigger.active").click();
});
*/

/*STYLESHEET SWITCHER
=====================================*/
if($.cookie("css")) {
	if ($.browser.msie){
		$("link.switch").remove();
		document.createStyleSheet($.cookie("css"));
		$("link[href=" + $.cookie("css") + "]").addClass("switch").attr("screen", "media");
	}
	else
	{
		$("link.switch").attr("href", $.cookie("css"));
	}
}

$(document).ready(function() { 
	$("#size a").click(function() {
		if ($.browser.msie){
			$("link.switch").remove();
			document.createStyleSheet($(this).attr("rel"));
			$("link[href=" + $(this).attr("rel") + "]").addClass("switch").attr("screen", "media");
		}
		else
		{
			$("link.switch").attr("href", $(this).attr("rel"));
		}
		$.cookie("css", $(this).attr('rel'), {expires: 365, path: '/'});
		return false;
	});
});
