$(document).ready(function() {
  $("#sendEmail").validate();
  $(".button").click(function() {  
    // validate and process form here
    var processURL = $("input#processURL").val();
    var URL2Send = $("input#URL2Send").val();
    var comment = $("textarea#comment").val();
    var senderName = $("input#senderName").val();
    var senderEmail = $("input#senderEmail").val();
    var recipientEmail = $("input#recipientEmail").val();  
     
    if ($("#sendEmail").validate().form() == false) {  
        return false; 
    }
    var dataString = 'senderName='   + senderName 
                + '&senderEmail='    + senderEmail 
                + '&recipientEmail=' + recipientEmail
                + '&comment='        + comment
                + '&URL2Send='       + URL2Send;

    //alert(URL2Send); return false;
    $.ajax({
      type: "POST",
      url: processURL,
      data: dataString,
      success: function() {
        $('#tellafriend').hide("fast");
        $('#message').show("fast");
      }
    }); 
    return false;    
    });  
});

function TogglePanel(id){
  var panelStatus = $(id).css("display");
  if(panelStatus == "none"){
     $(id).show("slow");
  }else{
     $(id).hide("slow");
  }
}

$.fn.clearForm = function() {
  return this.each(function() {
 var type = this.type, tag = this.tagName.toLowerCase();
 if (tag == 'form')
   return $(':input',this).clearForm();
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = '';
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 else if (tag == 'select')
   this.selectedIndex = -1;
  });
};

function sendMore(){
    $("#message").hide("fast");
    $("#sendEmail").clearForm();
    $("#tellafriend").show("slow");
}
 

