
YAHOO.namespace("feedback.container");

function init() {
	
	// Define various event handlers for Dialog
	var handleSubmit = function() {
		this.submit();
	};
	var handleCancel = function() {
		this.cancel();
	};
	var handleSuccess = function(o) {
		//var response = o.responseText;
		//response = response.split("<!")[0];
		//document.getElementById("resp").innerHTML = response;
    var response_message = "<p class=\"messagebox\"><span class=\"messageheader\">Thank you for your feedback!</span><br />    We appreciate you taking the time to share your thoughts with us,     and for helping us to improve the Manuals Plus experience for all customers! </p>";
		document.getElementById("fb_message_box").innerHTML = response_message;
	};
	var handleFailure = function(o) {
		alert("Submission failed: " + o.status);
	};

	// Instantiate the Dialog
	YAHOO.feedback.container.fb_dialog = new YAHOO.widget.Dialog("fb_dialog", 
							{ width : "32em",
							  fixedcenter : true,
							  visible : false, 
							  constraintoviewport : true,
							  buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
								      { text:"Cancel", handler:handleCancel } ]
							});

	// Validate the entries in the form to require that both first and last name are entered
/*	YAHOO.feedback.container.fb_dialog.validate = function() {
		var data = this.getData();
		if (data.firstname == "" || data.lastname == "") {
			alert("Please enter your first and last names.");
			return false;
		} else {
			return true;
		}
	};
*/
	// Wire up the success and failure handlers
	YAHOO.feedback.container.fb_dialog.callback = { success: handleSuccess,
						     failure: handleFailure };
	
	// Render the Dialog
	YAHOO.feedback.container.fb_dialog.render();

	YAHOO.util.Event.addListener("show", "click", YAHOO.feedback.container.fb_dialog.show, YAHOO.feedback.container.fb_dialog, true);
	YAHOO.util.Event.addListener("hide", "click", YAHOO.feedback.container.fb_dialog.hide, YAHOO.feedback.container.fb_dialog, true);
}

YAHOO.util.Event.onDOMReady(init);
