$(document).ready(function(){
  $("#Image1").click(function(){
      var mail = $("#mail").val();
      var subject = $("#subject").val();

	  errors = false;
	  str = "";

	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   if(reg.test(mail) == false) {
		  $('span.email').html("Invalid Email Address.");
		  $('span.email').fadeIn("slow");
		  setTimeout('$("span.email").fadeOut("slow")', 5000);
		  errors = true;
	   }

	   if (subject == "") {
		  $('span.subject').html("Please Enter The Message.");
		  $('span.subject').fadeIn("slow");
		  setTimeout('$("span.subject").fadeOut("slow")', 5000);
		   errors = true;
	   }

	   if (errors) {
		   return false;
	   }
	 
	  
	  var datastr ="mail=" + mail + "&subject=" + subject;
      send(datastr);
	  return false;
  })
})

function send(datastr){
  $.ajax({
    type: "POST",
    url: basepath+"mail",
    data: datastr,
    cache: false,
    success: function(html){
	  $("#mail").val("");
	  $("#subject").val("");
      $('span.success').html(html);
	  $('span.success').fadeIn("slow");
	  setTimeout('$("span.success").fadeOut("slow")', 5000);
	  hide_mail_body();
    }
  });
}

function hide_mail_body()
{
	$("#mail_form1").hide();
	$("#mail_form2").hide();
	$("#mail_form3").hide();
}