/** @file site_modal.js
* @author Michael Snow
* @version 1.0
* @date 11/2008
* @brief This file contains site wide javascript functions for opening and closing modal windows.
* @bug
* @warning
*/
//*****************************************************************************************************//

// Declare all variable names to create handlers to the modal windows
var configModWin; ///< Defines modal window handler for Modifying Configuration Settings modal window

/** makeInvisible
*  \brief Makes HTML select form fields invisible, and hides fields with a greater z-index than the modal window
*  however, no routine exists to find them, just have those that are known
*/
function makeInvisible() {
	// The following makes HTML select boxes invisible and hides the main_nav navigation bar
	if(typeof ie_6_or_less !='undefined') {
		for (var i_tem = 0; i_tem < document.getElementsByTagName('select').length; i_tem++)
			document.getElementsByTagName('select')[i_tem].style.visibility='hidden';
	}
	if(document.getElementById('main_nav'))	document.getElementById('main_nav').style.display='none';
	if(document.getElementById('app_nav')) document.getElementById('app_nav').style.display='none';
}

/** makeVisible
*  \brief Makes HTML select form fields visible, and shows fields with a greater z-index than the modal window
*  however, no routine exists to find them, just have those that are known
*/
function makeVisible() {
	// The following makes HTML select boxes visible and shows the main_nav navigation bar
	if(typeof ie_6_or_less !='undefined') {
		for (var i_tem = 0; i_tem < document.getElementsByTagName('select').length; i_tem++)
			document.getElementsByTagName('select')[i_tem].style.visibility='';
	}
	if(document.getElementById('main_nav'))	document.getElementById('main_nav').style.display='block';
	if(document.getElementById('app_nav'))document.getElementById('app_nav').style.display='block';
}

/** openAddUser_Modal
*  \brief Opens and Closes a modal window used for adding users to the system, by use of a handler object
*  \return The onclose function returns a boolean, true if ok to close, otherwise false
*/
function openConfig_Modal() {
	makeInvisible(); // Hides HTML form elements like selects and those with a greater z-index than modal window

	// Opens the window using the following
	configModWin=dhtmlmodal.open('ConfigBox', 'iframe', 'configs.php', 'Modify System Configurations', 'width=450px,height=350px,center=0,resize=0,scrolling=0');

	// Determine which script's form called this function, then clear and disable that form, resetting message containers
	/*
	if(document.AdminsMgmtForm) {
		modifyForm('AdminsMgmtForm', 'clear', skipUG);
		modifyForm('AdminsMgmtForm', 'disable', skipUG);
		document.getElementById('SajaxMsg').innerHTML = '';
		document.getElementById('SajaxMsg').style.display='none';
	}
*/
	// Closes the window using the following
	configModWin.onclose=function() {
		makeVisible(); // Shows HTML form elements like selects and those with a greater z-index than modal window
		// Determine which script's form called this function
		// Get the selected UserGroup and populate the users HTML Select box
		//var sel_ug = document.getElementById('UserGroup').value;
		//populate_select_admin_users(sel_ug);
		return true;
	}
}