
	///////////////////////////////////////////////////////////////////
	/**
	* Begin modal window handling functions.
	*
	*/

	// Global for brower version branching.
	var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
	
	// One object tracks the current modal dialog opened from this window.
	var dialogWin = new Object();

	// Generate a modal dialog.
	// Parameters:
	//    url -- URL of the page/frameset to be loaded into dialog
	//    width -- pixel width of the dialog window
	//    height -- pixel height of the dialog window
	//    returnFunc -- reference to the function (on this page)
	//                  that is to act on the data returned from the dialog
	//    args -- [optional] any data you need to pass to the dialog
	function openDGDialog(url, width, height, params, returnFunc, args) 
	{
		if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed))
		{

			// The args value contains our source field id
			// we store this in a cookie to retrieve later
			// when we want to pass data back into the form
			//setCookie('ModalActive', 'true');
			setCookie('ModalSourceField', args);

			// Initialize properties of the modal dialog object.
			dialogWin.returnFunc = returnFunc
			dialogWin.returnedValue = ""
			dialogWin.args = args
			dialogWin.url = url
			dialogWin.width = width
			dialogWin.height = height

			// Keep name unique so Navigator doesn't overwrite an existing dialog.
			dialogWin.name = (new Date()).getSeconds().toString()

			// Assemble window attributes and try to center the dialog.
			if (Nav4)
			{
				// Center on the main window.
				dialogWin.left = window.screenX + 
				   ((window.outerWidth - dialogWin.width) / 2)
				dialogWin.top = window.screenY + 
				   ((window.outerHeight - dialogWin.height) / 2)
				var attr = "screenX=" + dialogWin.left + 
				   ",screenY=" + dialogWin.top + ",resizable=no,width=" + 
				   dialogWin.width + ",height=" + dialogWin.height
			}
			else
			{
				// The best we can do is center in screen.
				dialogWin.left = (screen.width - dialogWin.width) / 2
				dialogWin.top = (screen.height - dialogWin.height) / 2
				var attr = "left=" + dialogWin.left + ",top=" + 
				   dialogWin.top + ",resizable=no,width=" + dialogWin.width + 
				   ",height=" + dialogWin.height
			}
			
			// Generate the dialog and make sure it has focus.
			if (params)
			{
 				dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr + ',' + params);
 			}
			else
			{
				dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr);
			}
			dialogWin.win.focus()
		}
		else
		{
			dialogWin.win.focus()
		}

	} // end openDGDialog


	// Event handler to inhibit Navigator form element 
	// and IE link activity when dialog window is active.
	function deadend() {
		if (dialogWin.win && !dialogWin.win.closed) {
			dialogWin.win.focus()
			return false
		}
	}
	
	// Since links in IE4 cannot be disabled, preserve 
	// IE link onclick event handlers while they're "disabled."
	// Restore when re-enabling the main window.
	var IELinkClicks
	
	// Disable form elements and links in all frames for IE.
	function disableForms() {
		IELinkClicks = new Array()
		for (var h = 0; h < frames.length; h++) {
			for (var i = 0; i < frames[h].document.forms.length; i++) {
				for (var j = 0; j < frames[h].document.forms[i].elements.length; j++) {
					frames[h].document.forms[i].elements[j].disabled = true
				}
			}
			IELinkClicks[h] = new Array()
			for (i = 0; i < frames[h].document.links.length; i++) {
				IELinkClicks[h][i] = frames[h].document.links[i].onclick
				frames[h].document.links[i].onclick = deadend
			}
			frames[h].window.onfocus = checkModal
	    	frames[h].document.onclick = checkModal
		}
	}
	
	// Restore IE form elements and links to normal behavior.
	function enableForms() {
		for (var h = 0; h < frames.length; h++) {
			for (var i = 0; i < frames[h].document.forms.length; i++) {
				for (var j = 0; j < frames[h].document.forms[i].elements.length; j++) {
					frames[h].document.forms[i].elements[j].disabled = false
				}
			}
			for (i = 0; i < frames[h].document.links.length; i++) {
				frames[h].document.links[i].onclick = IELinkClicks[h][i]
			}
		}
	}
	
	// Grab all Navigator events that might get through to form
	// elements while dialog is open. For IE, disable form elements.
	function blockEvents() {
		if (Nav4) {
			window.captureEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS)
			window.onclick = deadend
		} else {
			disableForms()
		}
		window.onfocus = checkModal
	}
	// As dialog closes, restore the main window's original
	// event mechanisms.
	function unblockEvents() {
		if (Nav4) {
			window.releaseEvents(Event.CLICK | Event.MOUSEDOWN | Event.MOUSEUP | Event.FOCUS)
			window.onclick = null
			window.onfocus = null
		} else {
			enableForms()
		}
	}
	
	// Invoked by onFocus event handler of EVERY frame,
	// return focus to dialog window if it's open.
	function checkModal() {
		setTimeout("finishChecking()", 50)
		return true
	}
	
	function finishChecking()
	{

		// Check current window for open modal
		if (dialogWin.win && !dialogWin.win.closed)
		{
			//var haveModal = true;
			dialogWin.win.focus();
		}

		// Check parent window for open modal
		else if (parent.dialogWin.win && !parent.dialogWin.win.closed)
		{
			//var haveModal = true;
			parent.dialogWin.win.focus();
		}

		else
		{

			// Check child frames for open modal
			if (window.frames)
			{
				for (var i = 0; i < window.frames.length; i++)
				{
					if (window.frames[i].dialogWin && window.frames[i].dialogWin.win && !window.frames[i].dialogWin.win.closed)
					{
						//var haveModal = true;
						window.frames[i].dialogWin.win.focus() 
					}
				}
			}

			// Check parent child frames (peer frames) for open modal
			if (window.parent.frames)
			{
				for (var i = 0; i < window.parent.frames.length; i++)
				{
					if (window.parent.frames[i].dialogWin && window.parent.frames[i].dialogWin.win && !window.parent.frames[i].dialogWin.win.closed)
					{
						//var haveModal = true;
						window.parent.frames[i].dialogWin.win.focus() 
					}
				}
			}
		}

		/*
		if (!haveModal)
		{
			var modalCookieTest = readCookie('ModalActive');
			if (modalCookieTest)
			{
				unsetCookie('ModalActive', 'Parent window check');
			}
		}
		*/

	}

	///////////////////////////////////////////////////////////////////
	/**
	* Set the value of a form field.
	*
	* @return	null.
	*
	*/
	function setFieldValue()
	{

		// Load the source field Id from our cookie
		var sourceFieldId = readCookie('ModalSourceField');

		// Attempt to load the source field
		var sourceField = document.getElementById(sourceFieldId);

		// Remove all existing elements
		if (sourceField.options.length > 0)
		{
			for (var j = sourceField.options.length - 1; j >= 0; j--)
			{
				sourceField.options[j] = null;
			}
		}

		// Explode our value pairs
		var valuePairs = dialogWin.returnedValue.split(':@:');

		// Loop through each pair of key/values
		for (var i=0; i < valuePairs.length; i++)
		{

			// Split the source pair string into the key and value
			var current = valuePairs[i].split('::');

			// If we have data, add it to our list
			if (current[1])
			{

				// Add the new element
				sourceField.options[sourceField.length] = new Option(current[1], current[0]);

			}

		}
		
		return true;

	} // end setFieldValue


	///////////////////////////////////////////////////////////////////
	/**
	* Pass the selected entity data to the parent window.  This 
	* function is called from module::selectEntities
	*
	* @param	array	$field		The field to set.
	*
	* @param	array	$value		The value to set it to.
	*
	* @return	null.
	*
	*/
	function handleSelectEntities()
	{
		if (opener && !opener.closed)
		{
			opener.dialogWin.returnFunc()
		}
		//unsetCookie('ModalActive', 'Window close handling.');
		window.close();
		return false

	} // end handleSelectEntities


	///////////////////////////////////////////////////////////////////
	/**
	* Begin Navigation iFrame functions.
	*
	*/

	// auslesen der Breite des uebergeordneten Elementes
	function calcWidth()
	{
		if(!divTab.parentNode.width)
		{
			return divTab.style.width;
		}
		else
		{
			return parseInt(divTab.parentNode.width);
		}
	}
	
	// auslesend er Hoehe des uebergeordneten Elementes
	function calcHeight()
	{
		if (browserCheck() == "MSIE")
		{
			var returnHeight = parseInt(divTab.parentNode.offsetHeight)
		}
		else
		{
			var returnHeight = parseInt(divTab.parentNode.offsetHeight)
			returnHeight = returnHeight - 36;
		}
		return returnHeight;
	}


	// Initialeinstellung des ersten Elementes des Containers
	function initFirstElement()
	{

		var openTab = readCookie('TabMenuSelected');

		if (!openTab || arrValue.length == 1)
		{
			var openTab = 1;
		}
		
		if (!modalNavType)
		{
			var navType = '&nav_type=' + (openTab);
			var isModal = '&modal=0';
		}
		else
		{
			var navType = '&nav_type=' + (modalNavType);
			var isModal = '&modal=1';
		}

		var h = parseInt(divTab.style.height);

		for(a = 0; a < arrValue.length - 1; a++)
		{
			h -= parseInt(document.getElementById(a+1).style.height);
		}

		document.getElementById(openTab).innerHTML= strTab + "><b>" + arrValue[openTab-1] + "</b></div><iframe height=\'" + h + "' width=\'" + iFrameWidth + "%\' src=\'navigation.php?sid=" + sid + navType + isModal + "\' scrolling=\'auto\' frameborder=\'0\'></iframe>";

	}

	// ein neues Element wird ausgewaehlt
	function changeHeight(elem)
	{
		var intHeight = 0;
		var tabHeight = parseInt(divTab.style.height);
	
		if(parseInt(elem.style.height) > panelHeight)
		{
			return;
		}
		else
		{
			for(a = 0; a < arrValue.length; a++)
			{
				document.getElementById(a+1).style.height = panelHeight;
				document.getElementById(a+1).innerHTML = strTab + ">" + arrValue[a] + "</div>";
				if(document.getElementById(a+1) != elem)
				{
					intHeight += panelHeight;
				}
			}

			elem.style.height = parseInt(divTab.style.height) - intHeight;
			elem.innerHTML= strTab + "><b>" + arrValue[elem.id-1] + "</b></div><iframe height=\'" + elem.style.height + "' width=\'" + iFrameWidth + "%\' src=\'navigation.php?sid=" + sid + "&amp;nav_type=" + elem.id + "\' scrolling=\'auto\' frameborder=\'0\'></iframe>";
			setCookie('TabMenuSelected', elem.id);
		
		}
	}

	function visibleDiv()
	{
		if(divTab.style.visibility == "visible")
		{
			//debugger;
			//lastWidth = parseInt(divTab.parentNode.width);
			divTab.style.visibility = "hidden";
			//divTab.parentNode.width = 1;
		}
		else
		{
			//divTab.parentNode.width = lastWidth;
			divTab.style.visibility = "visible";
		}
	}

	function M_Move()
	{
		if(check)
		{
			divTab.style.width = parseInt(event.clientX);
		}
	}

	function M_Up()
	{
		check = 0;
	}

	function M_Down()
	{
		check = 1;
	}

	///////////////////////////////////////////////////////////////////
	/**
	* Basic determination of which browser we are using
	*
	* @return		string		The browser ID (MSIE|NS)
	*
	*/
	function browserCheck()
	{
	
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			return "MSIE";
		}
		else
		{
			return "NS";
		}
	
	} // end browserCheck

	///////////////////////////////////////////////////////////////////
	/**
	* Place focus on a content form field.
	*
	* @param		string		The item to set focus on.
	*
	* @return		null
	*
	*/
	function setFieldFocus(fieldId)
	{
		var theField = document.getElementById(fieldId);
		theField.focus();
		return true;
	
	} // end setFieldFocus

	///////////////////////////////////////////////////////////////////
	/**
	* Set a cookie.
	*
	* @param	string	$cookieName		The name of cookie.
	*
	* @param	string	$cookieData		The value to set it to.
	*
	* @param	string	$cookieExpire		When it should expire.
	*
	* @return	null.
	*
	*/
	function setCookie(cookieName, cookieData, cookieExpire)
	{
		//alert("Setting cookie " + cookieName + "=" + cookieData);

		if (cookieExpire)
		{
			var expires = ';' + cookieExpire;
		}
		else
		{
			var expire = '';
		}

		document.cookie = cookieName + '=' + cookieData + expire;
		return true;

	}


	///////////////////////////////////////////////////////////////////
	/**
	* Return the value of a cookie.
	*
	* @param	string	$cookieName		The name of cookie.
	*
	* @return	string					The cookie data
	*
	*/
	function readCookie(cookieName)
	{

		var cookie = document.cookie.split('; ');

		for (var i=0; i < cookie.length; i++)
		{
			var crumb = cookie[i].split('=');
			if (cookieName == crumb[0] && crumb[1])
			{
				var cookieData = crumb[1];
			}
		}
		
		if (!cookieData)
		{
			return false;
		}
		else
		{
			return cookieData;
		}

	} // end readCookie

	///////////////////////////////////////////////////////////////////
	/**
	* Unset a cookie.
	*
	* @param	string	$cookieName		The name of cookie.
	*
	* @param	string	$cookieData		The value to set it to.
	*
	* @param	string	$cookieExpire		When it should expire.
	*
	* @return	null.
	*
	*/
	function unsetCookie(cookieName, debugMessage)
	{
		//alert("Unsetting cookie " + cookieName + ' ' + debugMessage);
		document.cookie = cookieName + '=0;expires=Mon, 31 Dec 2001 18:18:33 GMT';
		return true;
	}

	///////////////////////////////////////////////////////////////////
	/**
	* Select all elements in a field.
	*
	* @param	object	$fieldRef			The field object to select.
	*
	* @return	boolean					true
	*
	*/
	function selectAllFromField(fieldRef)
	{
		for(a = 0; a < fieldRef.length; a++)
		{
			fieldRef.options[a].selected = true;
		}
		return true;
	}

	///////////////////////////////////////////////////////////////////
	/**
	* Activate a disabled field.
	*
	* @param	object	$fieldRef			The field object to 
	*								activate.
	*
	* @return	boolean					true
	*
	*/
	function activateField(fieldRef)
	{
		fieldRef.disabled = false;
		return true;
	}


	///////////////////////////////////////////////////////////////////
	/**
	* Display a confirmation message to the user.
	*
	* @param	object	$fieldRef			The field object to 
	*								activate.
	*
	* @return	boolean					true
	*
	*/
	function confirmSubmit(message)
	{
		return confirm(message);
	}


	function getDom(currElem)
	{
		if(isNS4)
		{
			return document[currElem];
		}
		else if(isIE4)
		{
			return document.all[currElem].style;
		}
		else if (isNS6)
		{
			return document.getElementById(currElem).style;
		}
		else
		{
			return null;
		}
	}

	function popUp(evt,currElem)
	{
		if ((isNS4 || isIE4 || isNS6) && currElem)
		{
			dom = getDom(currElem);
			state = dom.visibility;

			if (state == "visible" || state == "show")
			{
				dom.visibility = "hidden";
			}
			else
			{
				if (isNS4 || isNS6)
				{
					topVal = evt.pageY + 15;
					leftVal = evt.pageX + 0;
				}
				else if (isIE4)
				{
					leftVal = evt.x + document.body.scrollLeft + 5;
					topVal = evt.y + document.body.scrollTop + 10;
				}

				if(leftVal < 2)
				{
					leftVal = 2;
				}
				if(topVal < 2)
				{
					topVal = 2;
				}

				if((isNS4 || isNS6) && leftVal > (window.innerWidth - 250))
				{
					leftVal = window.innerWidth - 280;
				}
				else if(isIE4 && leftVal > (document.body.offsetWidth - 250))
				{
					leftVal = document.body.offsetWidth - 280;
				}

				dom.top = topVal;
				dom.left = leftVal;
				dom.visibility = "visible";
			}
		}
	}


	////////////////////////////////////////////////////////////////////
	/*
	*	From this point to the end of the file we initialize values,
	*	and setup the JS system.
	*
	*/ 

	if(browserCheck() == "MSIE")
	{
		var panelHeight = 32;
	}
	else
	{
		var panelHeight = 23;
	}

	var isNS6 = false;
	var isNS4 = false;
	var isIE4 = false;
	if(document.all)
	{
		isIE4 = true;
	}
	else if(document.layers)
	{
		isNS4 = true;
	}
	else if(document.getElementById)
	{
		isNS6 = true;
	}

	if(browserCheck() == "MSIE")
	{
		var panelHeight = 32;
	}
	else
	{
		var panelHeight = 23;
	}

