$(document).ready(function() {
	
	$("#btn_show_share").click(function(e)
	{
		e.preventDefault();
		
		$("#div_share").css("display", "block");
		
	});
	
	$("#btn_share").click(function(e)
	{
		if ($("#txt_sender").val() == "")
		{
			$("#div_share #msg_box p").addClass("alert");
			$("#div_share #msg_box p").html("Please enter a your first name");
			$("#div_share #msg_box").css("display", "block");
			$("#txt_sender").focus();
			return false;
		}
		
		if ($("#txt_friend").val() == "")
		{
			$("#div_share #msg_box p").addClass("alert");
			$("#div_share #msg_box p").html("Please enter your friend`s name.");
			$("#div_share #msg_box").css("display", "block");
			$("#txt_friend").focus();
			return false;
		}
		
		if ($("#txt_friend_email").val() == "")
		{
			$("#div_share #msg_box p").addClass("alert");
			$("#div_share #msg_box p").html("Please enter an email address for the recipient");
			$("#div_share #msg_box").css("display", "block");
			$("#txt_friend_email").focus();
			return false;
		}
		
		//Show the ajax busy gif.
		$("#busy_send").css("display", "block");
		
		$.post("send.php"
			,{sender: $("#txt_sender").val(), txt_friend: $("#txt_friend").val(), txt_friend_email: $("#txt_friend_email").val()}
			,function(xml) 
			{
				$("#div_share #msg_box p").addClass("info");	
				$("#div_share #msg_box p").html(xml);
				$("#div_share #msg_box").css("display", "block");
		
				//Show the ajax busy gif.
				$("#busy_send").css("display", "none");
			}
		);
	});
	
	$("#btn_show_de").click(function(e)
	{
		e.preventDefault();
		
		$("#div_de").css("display", "block");
		
	});
	
	$("#btn_de").click(function(e)
	{
		//Show the ajax busy gif.
		$("#busy_de").css("display", "block");
		
		$.post("de.php"
			,{first_name: $("#first_name").val(), last_name: $("#last_name").val(), mobile: $("#mobile").val(), email: $("#email").val()}
			,function(res) 
			{	
				$("#div_de #msg_box p").addClass("info");	
				$("#div_de #msg_box p").html(res);
				$("#div_de #msg_box").css("display", "block");
		
				//Show the ajax busy gif.
				$("#busy_de").css("display", "none");
			}
		);
	});
	
	$(".btn_close").click(function(e)
	{
		$("#first_name").val("");
		$("#last_name").val("");
		$("#mobile").val("");
		$("#email").val("");
		
		$("#txt_sender").val("");
		$("#txt_friend").val("");
		$("#txt_friend_email").val("");
		
		$("#div_share").css("display", "none");
		$("#div_share #msg_box").css("display", "none");
		
		$("#div_de").css("display", "none");
		$("#div_de #msg_box").css("display", "none");
	});
	
   	
	
});