// JavaScript Document

// Listens for the document to be loaded
$(document).ready(function() {
	
	// Highlights a gallery thumb
	$(".thumb").hover(function () {
		$(this).find("img").fadeTo(200, 0.3);
		$(this).find("div.tag").animate({opacity: "show", bottom: "65"}, "slow");
      }, 
	  
      function () {
        $(this).find("img").fadeTo(200, 1);
		$(this).find("div.tag").animate({opacity: "hide", bottom: "85"}, "fast");
      }
    );
	
	
	
	// rotatesd the home carousel of images
	$('#home-carousel').cycle({
		fx: 		'fade',
		speed: 		1000,
		timeout: 	4000,
		next: 		'#home-carousel'
	});
	
	
	
	// Switch a gallery image
	$(".thumb a").click(function(event) {
		event.preventDefault();
		thumb = $(this).attr("id");
		
		$("#gallery").fadeOut(400, function() {
			$("#gallery").load("/index.php?action=swap-gallery-image&image="+thumb, false, function() {
				$("#gallery").fadeIn(400);
			});
		});
	});
	
	
	
	// Send the contact form
	$("#contact-form .button").click(function(event) {
		event.preventDefault();
		
		name 		= $("input#name").val();
		method 		= $("input#method").val();
		information = $("input#information").val();
		interest 	= $("input#interest").val();
		
		$("#contact-alert").load("/contact/action/send-contact/quick.html", {name: name, method: method, information: information, interest: interest}, function() {
			$("#contact-alert")
			.fadeIn("slow")
			.animate({opacity: 1}, 5000)
			.fadeOut("slow");
		});
	});
	
});
