$(function() {
  $('.error').hide();
  

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var comment = $("textarea#comment").val();
		if (comment == "") {
      $("label#comment_error").show();
      $("textarea#comment").focus();
      return false;
    }
		var itemtype = $("input#itemtype").val();
		
		var itemid = $("input#itemid").val();
		
		
		var dataString = 'comment='+ comment + '&itemtype=' + itemtype + '&itemid=' + itemid;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "/Mynme/Reviews/add",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Thanks for your comment!!</h2>")
        .append("<p>It will be reviewed shortly and will appear here if appropriate.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message');
        });
      }
     });
    return false;
	});
});
