// JavaScript Document
	


function showForm()	{
	$("#thanks").hide();
	$("#error").hide();
	$("#form").show();
}

function showThanks(message)	{
	$("#form").hide();
	$("#error").hide();
	$("#thanks").show();
	//$("#message").val
}

function showError()	{
	$("#form").hide();
	$("#thanks").hide();
	$("#error").show();
}

$(document).ready(function(){
													 
	$(".tooltip").tipsy({html:true, gravity:'w'});		
	
	/*
	$("#submit-button").click(function() {
		$("#subscribe_form").validate({
			submitHandler: function(form) {
			form.submit();
			}
		}); 
	});
	*/
	
	$("#subscribe_form").validate();
	
	/* tell a friend with AJAX */
	$("#ajax_send").click(
		function() {
			$.ajax({ 
				/*type: "POST", */
				cache: false,
				url: "/emif/ajax.php" , 
				data: "name="+$('#name').val()+"&firstname="+$('#firstname').val()+"&email="+$('#email').val(), /*+"&dummy="+Math.random()*100000,*/
				/*data: {name:$('#name').val(), firstname:$('#firstname').val(), email:$('#email').val(), dummy:Math.random()*100000},*/
				success: function(message){ 
					if(message == "false")
						showError();
					else {
						$('#name').val("");
						$('#firstname').val("");
						$('#email').val("");
						showThanks(message);
					}
				} 
			}); 
		}
	); 
	
});
