$(document).ready(function(){		
	// NAVIGATION INIT	
	$(".menu").lavaLamp({
		easing: "easeInOutBack",
		duration: 600
	});	
	$(".menu a, .animatedLink").slideAnimate();	

	$(".hoverImage, div.projectWrapper img, div.spotlightImage img").hover(function() {
		$(this).css({'z-index' : '10'});
		$(this).addClass("hover").stop()
			.animate({
				marginTop: '-3px',
				marginLeft: '-5px',
				marginBottom: '-4px',
				width: '295px',
				height: '140px'
			}, 300); 
	
		} , function() {
		$(this).css({'z-index' : '0'}); 
		$(this).removeClass("hover").stop() 
			.animate({
				marginTop: '0',
				marginLeft: '0',
				marginBottom: '0',
				width: '279px',
				height: '133px'
			}, 300);
	});
	
	$(".leesMeer").click(function() {
		if( $(this).prev().is(":hidden") ){
			$(this).prev().slideToggle("fast");
			$(this).html('Minder');
		} else {
			$(this).prev().slideToggle("fast");
			$(this).html('Meer');
		}
		return false;
	});
	
        $(".tweets").tweet({
            username: "netdesignnl",
            count: 4,
            loading_text: "tweets laden..."
        });
        
        $(function() {
        	$('.showCase').show();
        	$('#showCaseRun').cycle({
			fx: 'fade',
			timeout: 5000,
			after: function() {
				$('.showCaseCaption').html(this.alt);
			}
		});
	});
	
	$("#contactForm").validate({
		
		rules: {
			naam: "required",
			email: {
				required: true,
				email: true
			},
			onderwerp: "required",
			bericht: "required",
			captcha:{
				required: true,
				remote: "/wp-content/themes/netdesign/includes/captcha/process.php"
			}
		},
		messages: {
			naam: "Vul alstublieft uw naam in.",	
			email: "Vul alstublieft een geldig e-mailadres in.",
			onderwerp: "Vul alstublieft een onderwerp in.",
			bericht: "Voer alstublieft een bericht in.",
			captcha: "De karakters zijn niet juist overgenomen. Probeer het alstublieft nog eens."	
		},
		onkeyup: false,
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				target: "#result"
			});
			jQuery(form).resetForm();
			$.post('/wp-content/themes/netdesign/includes/captcha/newsession.php');
			$("#captchaimage").load('/wp-content/themes/netdesign/includes/captcha/image_req.php');
		}, invalidHandler: function() {
			//alert('dit is fout');
			$.post('/wp-content/themes/netdesign/includes/captcha/newsession.php');
			$("#captchaimage").load('/wp-content/themes/netdesign/includes/captcha/image_req.php');
		}
	
	});
	
	$("#refreshimg").click(function(){
		
		$.post('/wp-content/themes/netdesign/includes/captcha/newsession.php');
		$("#captchaimage").load('/wp-content/themes/netdesign/includes/captcha/image_req.php');
		return false;
	});
});

jQuery.fn.slideAnimate = function (settings) {
    return this.each(function () {
        var init = this
        
        $(init).click(function (event) {
            event.preventDefault()
            var destID = $(init).attr("href")
            var destLocation = $(destID).offset().top
           
            $("html:not(:animated),body:not(:animated)").animate({
                scrollTop: destLocation
            }, 1500, 'easeInOutCirc', function () {
                window.location.hash = destID
            });
            return false;
        })
    })
}

Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3');

