/*
*	Author: Sten Van den Bergh 
*/



$(function() {
	// External links
	$("a[href^='http:']:not([href*='" + window.location.host + "'])").each(function() {
		if( !$(this).hasClass('fancybox') )
		{
			$(this).click(function()
			{
			    window.open(this.href); // pop a new window
			    return false; // return false to keep the actual link click from actuating
			});
		}
	});

	$('input:text, textarea').focus(function() {
		if (this.value == this.defaultValue) {
			this.value = '';
		}
	});
	$('input:text, textarea').focusout(function(){
		if(this.value == '') {
			this.value = this.defaultValue;
		}
	});

	// Uniform
	$(function(){ $("select, input:checkbox").uniform(); });

	// Get active element in sub nav, and add span for the focus arrow (not possible in HTML because of Structure addon)
	if($("#nav-sub .active").length) {
		$("#nav-sub .active").append("<span>&nbsp;</span>");
	}

	// fancybox
	$("a[rel=fancy-gallery]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
		}
	});
	


	// Dit zou werken maar moeilijk met meertalig: http://stackoverflow.com/questions/2733922/jquery-validation-how-to-ignore-default-values-when-validating-mandatory-fields
	/*jQuery.validator.addMethod("defaultInvalid", function(value, element) 
    {
     switch (element.value) 
     {
      case "Your Name": -- this will be the default value in the Name text box
       if (element.name == "Your Name")
          return false;
     }
	

	// Form Validation
	$("form").validate({
		errorPlacement: function(error, element) {
			
		}
	});*/
});
