$(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;
		
		/* Note: To enable this AJAX form, make sure this is on the same path as the included mail.php, then
		         simply uncomment this area here, and remove the area indicated below. If you have questions
		         don't hessitate to e-mail me: hello -at- cricketlachica.com.
		         
		$.ajax({
		    type: "POST",
		    url: "mail.php",
		    data: dataString,
		    success: function() {
		      $('#contactform form').html("<div id='message'></div>");
		      $('#message').html("<h2>Message Sent.</h2>")
		      .append("<p>Thank you for your message. I'll make sure to get back to you in a couple of days.</p>")
		      .hide()
		      .fadeIn(1500);
		    }
		}); */
		
		
		/* ------------------------ SNIP ------------------------ */
		$('#contactform form').html("<div id='message'></div>");
		      $('#message').html("<h2>Message Sent.</h2>")
		      .append("<p>Thank you for your message. I'll make sure to get back to you in a couple of days.</p>")
		      .hide()
		      .fadeIn(1500);
		/* ------------------------ SNIP ------------------------ */
		
		return false;
	});
	
	$("#themes a").click( function() {
		$("body").removeClass();
		$("body").addClass( $(this).attr("rel") );
		return false;
	});
});
