// JavaScript Document
$(document).ready(function(){
$("#sendmail").click(function(){
var valid = "";
var isr = ' is required.';
var name = $("#name").val();
var mail = $("#mail").val();
var subject = $("#subject").val();
var fromdate = $("#fromdate").val();
var todate = $("#todate").val();
var text = $("#text").val();

if (name.length<1) {
valid += '<br />Name'+isr;
}
if (!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
valid += '<br />A valid Email'+isr;
}
if (subject.length<1) {
valid += '<br />Subject'+isr;
}
if (text.length<1) {
valid += '<br />Text'+isr;
}
if (valid!="") {
$("#response").fadeIn("slow");
$("#response").html("Error:"+valid);
}
else {
var datastr ='name=' + name + '&mail=' + mail + '&fromdate=' + fromdate + '&todate=' + todate + '&subject=' + subject + '&text=' + text;
$("#response").css("display", "block");
$("#response").html("Sending message ... ");
$("#response").fadeIn("slow");
setTimeout("send('"+datastr+"')",4000);
}
return false;
});
});
function send(datastr){
$.ajax({
type: "POST",
url: "mail.php",
data: datastr,
cache: false,
success: function(html){
$("#response").fadeIn("slow");
$("#content").html(html);
//setTimeout('$("#response").fadeOut("slow")',4000);

}
});
}


