/**
 * Post the "Was this information helpful?" form using AJAX and display a 
 * success message. This script does not read the server's response after the 
 * form has been posted - so errors are just ignored.
 *
 * Requires: jquery-1.2.6.min.js
 */
var PageRatings = {
	FORM_ACTION: "/_assets/php/page-ratings-wrapper.php",
	SUCCESS_MESSAGE: "<p>Thank you</p>",
	DEBUG: false,
	
	vote: function(number) {
		var data = {
			Vote: number,
			url: document.location.toString(),
			return_url: document.location.toString()
		};
		$.post(this.FORM_ACTION, data, this._callback, "html");
		
		// Show the success message
		$(".info-useful ul").hide();
		$(".info-useful").append(this.SUCCESS_MESSAGE);
	},
	
	_callback: function(response, status) {
		if (PageRatings.DEBUG) {
			alert("Response: " + response + "\n\n" + "Status: " + status);
		}
	}
};

