// Jquery custom
// Load jquery functions by call or on load

$(document).ready(function() {
	
	$('#slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:600,
		pauseTime:3000,
		directionNav:false, //Next and Prev
		directionNavHide:false,
		controlNav:true //1,2,3...
	});
	
	// find the div.fade elements and hook the hover event
	$('#attr a').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .hover', this);
 
		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(300, 1);
		} else {
			fade.fadeIn(300);
		}
	}, function () {
		var fade = $('> .hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(300);
		}
	});
 
	// get rid of the text
	$('#attr a > .hover').empty();
	
	/**************************************************
		FORM VALIDATION | QUICK CONTACT
	**************************************************/
	
	var formContact = $("#form-contact").size();
	if (formContact) {
		$("#form-contact").validate({
			rules: {
				naam: "required",
				emailadres: { 
					required: true,
					email: true
				},
				telefoonnummer: "required",
				branche: "required",
				onderwerp: "required",
				bericht: "required"
			},
			messages: {
				naam: "Vul alstublieft uw naam in",
				emailadres: {
					required: "Vul alstublief een e-mailadres in",
					email: "Vul alstublieft een geldig e-mailadres in"
				},
				telefoonnummer: "Vul alstublieft een telefoonnummer in",
				branche: "Selecteer alstublieft uw branche",
				onderwerp: "Vul alstublieft het onderwerp van uw vraag in",
				bericht: "Vul alstublieft uw vraag/bericht in"
			}
		});
	}
	
})

jQuery(function($) {
	var slide = false;
	var height = $('#footer_content').height();
	$('#footer_button').click(function() {
		var docHeight = $(document).height();
		var windowHeight = $(window).height();
		var scrollPos = docHeight - windowHeight + height;
		$('#footer_content').animate({ height: "toggle"}, 1000);
		if(slide == false) {
			if($.browser.opera) {
				$('html').animate({scrollTop: scrollPos+'px'}, 1000);
			} else {
				$('html, body').animate({scrollTop: scrollPos+'px'}, 1000);
			}
			slide = true;
		} else {
			slide = false;
		}
	});
});
$(function() {
	$('#attr a').tipsy(
	{
		gravity: 's', // nw | n | ne | w | e | sw | s | se
		fade: true
	}); 
});
