/** Stores active help window reference */
var helpWindow = null;

/** 
 * Opens help window for the current help form's tab index 
 * <p/>
 * If "url" param is not specified then this tries to obtain help navigation form's tab value and action 
 * to construct the help action url and then requests help for the currently active tab
 */
function openHelp(url, _width, _height) {
	// prepare help action url
	if (url == null) {
		helpActionForm = getHelpActionForm();
		tab = helpActionForm.tab.value;
		if (tab != null && "" != tab) {
			tab = "&tab=" + tab;
		} else {
			tab = "";
		}
		
		url = helpActionForm.action + "?adminUI=" + helpActionForm.adminUI.value + tab;
	}

	// check for help window content reloading
    if (helpWindow && !helpWindow.closed) {
    	if (helpWindow.location != url) {
        	helpWindow.location = url;
		}
    } else {
		helpWindow = window.open(url, "helpWindow", 
            'toolbar=0, location=0, directories=0, menubar=0, status=1, resizable=0, scrollbars=1, left=750, top=100, ' 
            + 'width=' + _width + ', height=' + _height);    
    }

	helpWindow.focus();
}

/** Switches current help topic */
function setHelpTab(tab) { 
	helpActionForm = getHelpActionForm();
    helpActionForm.tab.value = tab;
    helpActionForm.submit();
}

function getHelpActionForm() {
	return document.forms["helpRedirector"];
}

function helpDropDown() {
	var popup = document.getElementById('helpDropDown');
	//var selectors = document.getElementsByTagName("select");
	if (popup.style.display == 'block') {
		popup.style.display = 'none';
	} else {
		popup.style.display = 'block';
	}
}


