/*****************************
 * FORM HELP
 * Description: Enables the retrieval and display of help for fields
 * Author: Homme Zwaagstra
 *****************************/

/* Set the help on an element */
function fh_help_on(element, t) {
	element.innerHTML = t.responseText;
	element.className = 'info';
}

/* Remove the help from an element */
function fh_help_off(element) {
    element.innerHTML = '';
    element.className = 'noinfo';
}

/* Toggle help for a form field on or off */
function fh_help_toggle(id, theclass) {
    var div = $(id + '.info');
	if (div.className == 'info') {
	    fh_help_off(div);
	} else {
        url = '/catalogue/form_help.php?id=' + theclass;
        new Ajax.Request(url, {
            onSuccess: function(t) { fh_help_on(div, t) },
            onFailure: function(t) { alert('Sorry - no help is available') }
        });
    }
}
