/**
* Called when the document has finished loading
*/
$(document).ready(function()
{

	$("#main").slideUp(0);
	$("#main").slideDown("slow");
	$(".poweredBy").fadeTo(0, 0.25);

	$(".poweredBy").hover(function(){

		$(".poweredBy").fadeTo("slow", 1);

	}, function(){

		$(".poweredBy").fadeTo("slow", 0.25);

	});
	
	// Work section --------------------------------------------------------------------------

	var numSlides = 5;
	var currentSlide = 1;

	$("#workList").slideUp(0);
	$("#workListHandle").click(function(){

		$("#workList").slideToggle("slow");
		if ($("#workList").hasClass("unhidden"))
		{
			$("#workListHandle").html("<span>Hide list of projects &uarr;</span>");
			$("#workList").removeClass("unhidden");
			$("#workList").addClass("hidden");
		}
		else
		{
			$("#workListHandle").html("<span>Show list of projects &darr;</span>");
			$("#workList").removeClass("hidden");
			$("#workList").addClass("unhidden");
		}

	});
	
	$(".rightArrow").click(function(){

		if (currentSlide < numSlides)
		{
			currentSlide++;
			$("#browseProjectsCurrent").html(currentSlide + " of " + numSlides + " projects");
			$(".slide").animate({"top": "-=300px"}, "slow");
		}

	});

	$(".leftArrow").click(function(){

		if (currentSlide > 1)
		{
			currentSlide--;
			$("#browseProjectsCurrent").html(currentSlide + " of " + numSlides + " projects");
			$(".slide").animate({"top": "+=300px"}, "slow");
		}
	});

	// About section ----------------------------------------------------------------------

	/**
	* Called when the user clicks the 'submit' button
	*/
	$("#contactForm").submit(function(){
		
    		//hide the form
    		$("#contactForm").hide();
		$("#contactFormContainer").append($(".loadingContainer"));
		$("#contactFormContainer").css({background:"none"});

    		//show the loading bar
    		$(".loadingContainer").append($(".loadingGraphic"));
    		$(".loadingGraphic").css({display:"block"});

    		//send the ajax request
    		$.get(	"include/sendmail.php", {name:$("#name").val(),
                      	email:$("#email").val(),
		      	subject:$("#subject").val(),
                      	comment:$("#message").val()},

    			//return the data
    			function(data){
      				//hide the graphic
      				$(".loadingGraphic").css({display:"none"});
      				$(".loadingContainer").append(data);
    			});

  		//stay on the page
  		return false;
  	});


});