/**
* @fileoverview This file contains the static object  EditHelp.
* @author Sara Lin
* @version 0.1
*/

/**
* Edit help handles XML help file import and export functionalities in the admin tab.
* @namespace
*/
AdminTab.editHelp = {
	/**
	* loads the edit help view and attaches event to the submit button
	* @constructor
	*/
	load: function() {
		if ($('helpEditPage')==undefined) {
			thisObj = this;
			new Ajax.Request(base_url+'admin/getPage/help', {
				onSuccess: function(response) {
					$('adminContent').innerHTML = response.responseText;
					
					var submitBtn = $$('#helpEditPage .submit')[0];
					Event.observe(submitBtn, 'click', AdminTab.editHelp.submit);
				}
			});
		}
	},
	
	/**
	* uploads the XML help file, faq.xml, from admin's desktop to the server.  The file must be named as "faq.xml"
	*/
	submit: function() {
		if ($('uploadFAQ').value.lastIndexOf("faq.xml")==-1) {
			alert("Error: the file must be faq.php!");
			return;
		}

		$('helpEditPage').submit();
	}
}