function show_form()
{
	if ($('form').css("display")=='none')
	{
		$('#show-form').addClass("opened");
		$('form').fadeTo(1000, 1);
	}
	else
	{
		$('#show-form').removeClass("opened");
		$('form').fadeTo(1000, 0, function()
		{
			$('form').css("display","none");
		});
	}
}

function send_mail()
{
	$name		=	$("#name").val();
	$email		=	$("#email").val();
	$message	=	$("#message").val();
	
	if($name!=""&&$email!=""&&$message!="")
	{
		$('#mail-snd').attr("disabled","disabled");
		$.post("/send.php", {name:$name, email:$email, message:$message}, function(data)
		{
			if (data=="ok")
			{
				$("#status").html("Message successfully sent!");
				$("#status").addClass("success");
				$("#status").show();
				$('form')[0].reset();
				$('#mail-snd').removeAttr("disabled");
			}
			else
			{
				$("#status").html("Message not sent!");
				$("#status").addClass("unsuccess");
				$("#status").show();
				$('#mail-snd').removeAttr("disabled");
			}
		});
	}
}
function footer_opacity()
{
	$("#footer").fadeTo(0, 0.5);
}
$(document).ready(function()
{
	// old personal counter but still the best one...
	$.post("http://www.tredivisopunto.com/countme.asp");

	footer_opacity();

	$('#show-form').click(function()
	{
		show_form();
	});
	
	$('#mail-snd').click(function()
	{
		send_mail();
	});
	$("form").submit(function(e) 
	{
		e.preventDefault();
	})
});
