$(document).ready(function()
{
	$("#submenu > ul > li > a.hasSubMenu").click(function() {
        if($(this).hasClass("expanded")) {
            $(this).siblings('ul').slideUp();
        } else {
            $(this).siblings('ul').slideToggle();
        };
        $(this).parent('li').toggleClass("collapsed").toggleClass("expanded");
        return false;        
	});
    
    $('#belmij').click(function() {
        $(this).parent().parent().css('height', '65px');
        $(this).parent().parent().parent().css('height', '127px');
        $(this).css('background', 'url("images/arrowDown.png") right no-repeat');
        $('#blokBelMij').show();
        return false;
    });
    
    $('.blogItemMore').click(function() {
        $(this).parent('.blogItemContentSmall').hide();
        $(this).parent().siblings('.blogItemContent').show();
        $(this).parent().parent().children('.blogItemLeft').children('.blogItemFb').show();
        return false;
    });
    
    $('.blogItemLess').click(function() {
        $(this).parent('.blogItemContent').hide();
        $(this).parent().siblings('.blogItemContentSmall').show();
        $(this).parent().parent().children('.blogItemLeft').children('.blogItemFb').hide();
        return false;
    });
    
	$("a[rel='lightbox']").colorbox();
    
    $('.innerfade').innerfade({
		speed: 750,
		timeout: 5000,
		type: 'random'
	});
    
    $("#footerForm").validate({
        errorPlacement: function(error, element) {
			error.prependTo( element.parent().next() );
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
    });
    
    $("#searchForm").validate({
        errorPlacement: function(error, element) {
			error.prependTo();
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
    });
    
    $("#sideForm").validate({
        errorPlacement: function(error, element) {
			error.prependTo( element.parent().next() );
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		},
        rules: 
        {
            telefoon: {
                NotEqual : '' 
            }
        }
    });
    
    $.validator.methods.NotEqual = function(value, element) {
        return value != element.defaultValue;
    };        
    
    $("#vraagForm").validate({
        errorPlacement: function(error, element) {
			error.prependTo( element.parent().next() );
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
    });
    
    $(".clearInput").focus(function(srcc)
    {
        if ($(this).val() == this.defaultValue)
        {
            $(this).val("");
            $(this).css('color', '#00aeef');
        }
    });
    
    $(".clearInput").blur(function()
    {
        if ($(this).val() == "")
        {
            $(this).val(this.defaultValue);
        }
    });
    
    $(".clearInput").blur();
    
    $(".clearInputFooter").focus(function(srcc)
    {
        if ($(this).val() == this.defaultValue)
        {
            $(this).val("");
            $(this).css('color', '#635f58');
        }
    });
    
    $(".clearInputFooter").blur(function()
    {
        if ($(this).val() == "")
        {
            $(this).val(this.defaultValue);
        }
    });
    
    $(".clearInputFooter").blur();
});

function reloadCaptcha()
{
	document.getElementById('captcha').src = document.getElementById('captcha').src+ '?' +new Date();
}
