

function submitForm(formId) {
	document.getElementById(formId).submit();
}

function submitFormAndContinue(formId, nextSection) {
	// set next section
	var nextFormSection = document.getElementById('nextFormSection');
	nextFormSection.value = nextSection;
	
	document.getElementById(formId).submit();
}

/*----------------------------------------------------------------------------*/
/* Dynamic form elements */

function toggleChecked(target) {
	target.disabled = !target.disabled;
}

function enable(target, execute) {
	if (execute == undefined ||
	    execute) {
		target.disabled = false;
	}	
}
function disable(target, execute) {
	alert(execute);
	if (execute == undefined ||
	    execute) {
		target.disabled = true;
	}	
}

/*----------------------------------------------------------------------------*/
/* Browse search */

function initBrowseSearchBar(elId) {
    var oACDS = new YAHOO.widget.DS_XHR("./ajaxSearchPig.php", ["\n", "\t"] );
	oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
   
	var oAutoComp = new YAHOO.widget.AutoComplete(elId,elId+'_matches', oACDS);
    oAutoComp.queryDelay = 0;
    oAutoComp.minQueryLength = 0;
    oAutoComp.maxResultsDisplayed = 10;
    oAutoComp.autoHighlight = false;
    oAutoComp.highlightClassName = "yui-ac-highlight";
    oAutoComp.prehighlightClassName = "yui-ac-prehighlight";
    
	oAutoComp.formatResult = handleFormatResult;
}

/*----------------------------------------------------------------------------*/
/* Show/Hide Explanation */

function showExplanation(name) {
	var elName = name + 'Desc';
	YAHOO.util.Dom.setStyle(elName, 'display', 'block');
}

function hideExplanation(name) {
	var elName = name + 'Desc';
	YAHOO.util.Dom.setStyle(elName, 'display', 'none');
}
