jQuery.fn.extend({
    emptyonclick: function(options) {
        return this.each(function() {
            new jQuery.EmptyOnClick(this, options);
        });
    }
});

jQuery.EmptyOnClick = function(element, options) {
    var defaultValue = $(element).val();
    if($(element).attr('readonly') == true) { 
    	return;
    }
    // Bind event handlers to the element
    $(element)
    // On Focus: Store the default value if it's not set, empty the field
    .bind("focus", function(e) {
        if(defaultValue == $(this).val())
            $(this).val('');

    })
    // On Blur: if the field is empty, reset the default value
    .bind("blur", function(e) {
        if(!$(this).val()) {
            $(this).val(defaultValue);
        }
    });

    // Search for the form which has the element
    $("form:has(#"+element.id+")")
    // If the form gets resetted, set the default value back
    .bind('reset', function(e) {
        $(element).val(defaultValue);
        $(element).removeClass(options.changeClass);
    }) 
    // If the form gets submitted empty, remove the default values
    .bind('submit', function(e) {
        if($(element).val() == defaultValue)
            $(element).val('');
    });
};

$(document).ready(function($) {
   $("#edit-submitted-startdatum").datepicker({
	   changeMonth: true,
	   changeYear: true,
	   dayNamesMin: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'],
	   nextText: '',
	   prevText: '',
	   dateFormat: 'dd/mm/yy'
   });
//   $("#edit-submitted-startdatum").setDefaults($.datepicker.regional['nl']);
   
   $("#kalenderoff").click(function() { 
	   	$("#edit-submitted-startdatum").datepicker("show");
   });
   $('input, textarea').emptyonclick();  
   if(document.URL.indexOf("klantenservice") >= 0){ 
	   $(".menu").parent().css('background-color','#ADDBFC');
	   $(".menu-335 > a").addClass('active');
	   /*
	   $(".menu > .leaf > a ").each(function() {
		   	var href = $(this).attr('href');
		   	$(this).addClass('active');
		   	if(document.URL.indexOf(href) >= 0){
		   		
		   		$(this).addClass('active');
		   	}
	   }); 
	   */
	   
	   // On page 'Klantenservice', all is normal
   } else { 
	   $(".menu").parent().css('background-color','white');
	   $(".menu").hide();
   
	   $(".menu-335,.menu").bind('mouseenter', function() {
		   $(".menu").fadeIn("fast");
		   $(".menu").parent().css('background-color','#ADDBFC');
	   });
   	
	   $(".menu-333,.menu-999, .menu-337, .menu-338").bind('mouseenter', function() {
	    	$(".menu").fadeOut("fast");
	    	$(".menu").parent().css('background-color','white');
		});
   }
   
});


