/** 
 * DIV fader functionality.
 */
 
/** 
 * Instantiate global variables.
 */
 var GLJS_Fader_strActiveDIV = '';

/** 
 * Fade a DIV in.
 */
 function GLJS_Fader_fadeInDIV(strDIV,strTD,intWidth,intHeight)
 {
	// Check if any DIVs are already open - yes, close it
	if (GLJS_Fader_strActiveDIV != '')
	{
		GLJS_Fader_fadeOutDIV();
	}
	
	// Set active DIV
	GLJS_Fader_strActiveDIV = strDIV;
	
	// Calculate location of DIV on screen
	if (GLJS_Fader_strActiveDIV != '')
	{
		var intElemOffsetLeft = document.getElementById(strTD).offsetLeft;
		var intElemOffsetTop = document.getElementById(strTD).offsetTop;
		var intElemWidth = document.getElementById(strDIV).offsetWidth;
		var intElemHeight = document.getElementById(strDIV).offsetHeight;
	}
	
	// Style and position the DIV
	(intElemWidth > 500) ? document.getElementById(strDIV).style.width = 500 : document.getElementById(strDIV).style.width = intElemWidth;
	if (intElemOffsetTop + intElemHeight > document.body.clientHeight)
	{
		intElemOffsetTop = intElemOffsetTop + 100;
	}
	else
	{
		intElemOffsetTop = intElemOffsetTop + 200;
	}
	document.getElementById(strDIV).style.left = (screen.width/2) - (intWidth/2);
	document.getElementById(strDIV).style.top = intElemOffsetTop;
	document.getElementById(strDIV).style.visibility = 'visible';
 }

/** 
 * Fade a DIV out.
 */
 function GLJS_Fader_fadeOutDIV()
 {
	// Style and position the DIV
	document.getElementById(GLJS_Fader_strActiveDIV).style.visibility = 'hidden';
	document.getElementById(GLJS_Fader_strActiveDIV).style.left = 0;
	document.getElementById(GLJS_Fader_strActiveDIV).style.top = 0;
	
	// Reset active DIV identifier
	GLJS_Fader_strActiveDIV = '';
 }