$(document).ready(function() {
	/* Tabs */
	var aboutHeight = $("div#about").height();
	var portfolioHeight = $("div#portfolio").height();
	var socialHeight = $("div#social").height();
	var contactHeight = $("div#contact").height();
	$("div.content").height(0);
	
	var current = "about";
	$("div#" + current).height( eval(current+"Height") );
	
	$("a.tablink").click( function() {
		$("a.tablink").removeClass("selected");
		$(this).addClass("selected");
		$("div#" + current).animate({ height: 0 }, 500, function() { $(this).hide(); });
		var toShow = $(this).attr("rel");
		if( toShow == "contact" ) toAdd = 30;
		else toAdd = 0;
		$("div#" + toShow).show().animate({ height: eval(toShow+"Height") + toAdd }, 500);
		current = toShow;
		return false;
	});
	
	/* Portfolio */
	$("a.break").click( function() { return false; });
	$("a[rel='lightbox']").colorbox();
	$("#slider").scrollable({ size: 1, clickable: false, keyboard: false });
	
	/* Social Networks */
	$('#socialnetworks ul li').hover(
		function() {
			$(this).animate({
			    left: '-=10'
			  }, 200, function() {
			    // Animation complete.
			  });
		},
		function() {
			$(this).animate({
			    left: '+=10'
			  }, 200, function() {
			    // Animation complete.
			  });
		}
	);
	
	/* Contact Form */
	$('.required').hide();
	$("#sendform").click( function() {
		$('.required').hide();  
	    var name = $("input#contact_name").val();  
	    if (name == "") {  
	      $("label#name_error").show();  
	      $("input#contact_name").focus();  
	      return false;  
	    }  
	    var email = $("input#contact_email").val();  
	    if (email == "") {  
	      $("label#email_error").show();  
	      $("input#contact_email").focus();  
	      return false;  
	    }  
	    var message = $("textarea#contact_message").val();  
	    if (message == "") {  
	      $("label#message_error").show();  
	      $("textarea#contact_message").focus();  
	      return false;  
	    }
	    
	    var dataString = 'name='+ name + '&email=' + email + '&message=' + message;
		
		         
		$.ajax({
		    type: "POST",
		    url: "mail.php",
		    data: dataString,
		    success: function() {
		      $('#contactform form').html("<div id='message'></div>");
		      $('#message').html("<h2>Bericht verzonden.</h2>")
		      .append("<p>Dank voor uw bericht. Ik zal spoedig contact met u opnemen.</p>")
		      .hide()
		      .fadeIn(1500);
		    }
		}); 
		
		return false;
	});
	
	$("#themes a").click( function() {
		$("body").removeClass();
		$("body").addClass( $(this).attr("rel") );
		return false;
	});
});
