/*
 * Derived from:
 * http://designshack.co.uk/tutorials/creating-a-slide-in-jquery-contact-form
 */

function hideContactForm() {
	$("#messageSent").hide();
	$("#contactForm").slideUp("slow");
	$("#contactLink").hide("slow");
}

function openContactForm() {
	if ($("#contactForm").is(":hidden")) {
                	$("#contactLink").show("slow");
		$("#contactForm").slideDown("slow");
	}
}
	
$(document).ready(function(){
	$("#contactForm #location").val( location.href );
    $("#contactLink").hide();

    $("#contactLink").click(function(){
		$("#contactForm").slideUp("slow");
    	$("#contactLink").hide("slow");
	});
});
            
function sendForm(){
	var name    = $("#contactForm #Name").val();
	var email   = $("#contactForm #Email").val();
	var message = $("#contactForm #Message").val();
 
	$.get(
		"/sendmail.rb",
		{ 
			'name'    : name,
			'email'   : email,
			'message' : message,
			'location': location.href
		},
		function (data) {
			// Nothing to do here for the time being.
		}
	);

	$("#messageSent").show("slow");
	setTimeout('hideContactForm()', 4000);
};
