//---------------------------------------------------------------------------------------------------------
//	DHTML JavaScript (ver 2.3)
//---------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------------
//	Show/ Hide menus
//-------------------------------------------------------------------------------------------------------
function show(group,item,imgId,imgBase)
{
	if(document.getElementById)
	{
		menuCount	= eval("m_" + group);
		
		mainMenu	= document.getElementById("m" + group + "0");
		subMenu		= document.getElementById("m" + group + item);

		//	Does object exist?
		if( !subMenu )
		{
			//	No, don't process
			return false;
		}
		
		if( imgId != 'NULL' )
		{
			imgObj	= document.getElementById( imgId );
			imgObj.setAttribute( 'base', imgBase );
			imgObj.setAttribute( 'src', imgBase );
		}
		
		mainMenu.style.visibility	= "visible";
		
		if ((mainMenu != subMenu) && (item != 0))
		{
			subMenu.style.visibility	= "visible";
			for (i = 1; i <= menuCount; i++)
			{
				if (i != item)
				{
					document.getElementById("m" + group + i).style.visibility	= "hidden";
				}
			}
		}
	}
}

//-------------------------------------------------------------------------------------------------------
//	Hide menu
//-------------------------------------------------------------------------------------------------------
function hide(group,item,imgId,imgBase)
{
	if(document.getElementById)
	{
		menuCount	= eval("m_" + group);

		//	Does object exist?
		if( !document.getElementById( "m" + group + menuCount ))
		{
			//	No, don't process
			return false;
		}
		
		if( imgId != 'NULL' )
		{
			imgObj	= document.getElementById( imgId );
			imgObj.setAttribute( 'base', imgBase );
			imgObj.setAttribute( 'src', imgBase );
		}
		
		if (item == 0)
		{
			startFrom	= 0;
		}
		else
		{
			startFrom	= 1;
		}
		for (i = startFrom; i <= menuCount; i++)
		{
			document.getElementById("m" + group + i).style.visibility	= "hidden";
		}
	}
}

//-------------------------------------------------------------------------------------------------------
//	Image swap
//-------------------------------------------------------------------------------------------------------
function swapImg(id,img)
{
	if( document.getElementById)
	{
		obj	= document.getElementById(id);
		obj.setAttribute( 'src', img );
	}
}

//-------------------------------------------------------------------------------------------------------
//	Client_text Selector
//-------------------------------------------------------------------------------------------------------
//	track what Client_text is highlighted in the sponsor a Client_text selector
currentClient_text	= 0;

function showClient_text(what)
{
	Client_textId			= "Client_text" + what;
	
	if(document.getElementById)
	{
		if ( !document.getElementById(Client_textId) )
		{
			return;
		}

		document.getElementById(Client_textId).style.visibility	= "visible";
		if (currentClient_text != what)
		{
			previousClient_textId		= "Client_text" + currentClient_text;
			document.getElementById(previousClient_textId).style.visibility	= "hidden";
		}
	}

	currentClient_text	= what;
}

//-------------------------------------------------------------------------------------------------------
//	Client_image Selector
//-------------------------------------------------------------------------------------------------------
//	track what Client_image is highlighted in the sponsor a Client_image selector
currentClient_image	= 0;

function showClient_image(what)
{
	Client_imageId			= "Client_image" + what;
	
	if(document.getElementById)
	{
		if ( !document.getElementById(Client_imageId) )
		{
			return;
		}

		document.getElementById(Client_imageId).style.visibility	= "visible";
		if (currentClient_image != what)
		{
			previousClient_imageId		= "Client_image" + currentClient_image;
			document.getElementById(previousClient_imageId).style.visibility	= "hidden";
		}
	}

	currentClient_image	= what;
}

//-------------------------------------------------------------------------------------------------------
//	Redirect
//-------------------------------------------------------------------------------------------------------
function redirectTo( nav )
{
	//	Selected a url?
	dropdown	= nav.options;
	value		= dropdown[dropdown.selectedIndex].value;

	if ( value )
	{
		window.location.href = value;	
	}
}

//-------------------------------------------------------------------------------------------------------
//	Gallery functionality
//-------------------------------------------------------------------------------------------------------
function gallerySwap(id)
{
	detailsImage	= document.getElementById('detailsgraphic');
	detailsImage.setAttribute( 'src', gallery[id] );
	
	textElement		= document.getElementById('detailstitle');
	textElement.innerHTML	= gallerytitle[id];
	
	textElement		= document.getElementById('detailstext');
	textElement.innerHTML	= gallerytext[id];
}

//*********************************************************************************************************
//	Positioning Tools
//*********************************************************************************************************
var positionShown  = false;

//-------------------------------------------------------------------------------------------------------
//	Turn position reporting On/Off
//-------------------------------------------------------------------------------------------------------
function togglePositionReporting()
{
	//	What ctrl key combination was hit
	if ( event.ctrlKey && (event.keyCode == 71) )
	{
		if (!document.getElementById('grid') || !document.getElementById('poslabel'))
		{
			return;
		}
		
		//	Get the tool objects
		gridObj  = document.getElementById('grid');
		labelObj = document.getElementById('poslabel');
		
		//	Turn the monitoring off
		if (positionShown)
		{
			//	Hide the grid
			gridObj.style.display = 'none';
			
			//	Show the position label
			labelObj.style.display = 'none';
			
			//	Stop monitoring
			document.onmousemove = '';
		}

		//	Turn the monitoring on
		else
		{
			//	Show the label
			labelObj.style.display = 'block';
			
			//	Show the grid
			gridObj.style.display	= 'block';
			gridObj.style.height	= document.body.clientHeight + 'px';

			//	Start monitoring
			document.onmousemove = showMousePosition;
		}

		//	Reset the state
		positionShown = positionShown ? false : true;
	}
}

//-------------------------------------------------------------------------------------------------------
//	Show the mouse position
//-------------------------------------------------------------------------------------------------------
function showMousePosition()
{
	//	Get the label
	labelObj = document.getElementById('poslabel');
	
	//	Get the scroll position
	if (document.compatMode && document.compatMode != "BackCompat")
	{
		scroll_left = document.documentElement.scrollLeft;
		scroll_top  = document.documentElement.scrollTop;
	}
	else
	{
		scroll_left = document.body.scrollLeft;
		scroll_top  = document.body.scrollTop;
	}

	//	Get the mouse position
	xMousePos	 = window.event.x + scroll_left - 2;
	yMousePos	 = window.event.y + scroll_top  - 3;
	xMousePosMax = document.body.clientWidth +  scroll_left;
	yMousePosMax = document.body.clientHeight + scroll_top;

	//	Reposition the label in the correct position
	labelObj.style.top  = yMousePos + 5;
	labelObj.style.left = xMousePos + 15;
	
	//	Update the label
	labelObj.innerText = xMousePos + ", " + yMousePos;
}

function showBio(id)
{
	url		  = '/our/bio.php/id/' + id;
	sizeX	  = 400;
	sizeY	  = 500;
	target	  = 'bio';

	//	Center the window
	leftpos	= (screen.width)  ? (screen.width-sizeX)/2 : 100;
	toppos	= (screen.height) ? (screen.height-sizeY)/2 : 100;
	
	//	Open the window
	winobject				= window.open(url,target,"menubar=0,statusbar=0,scrollbars=1,toolbar=0,location=0,width=" + sizeX + ",height=" + sizeY + ",left=" + leftpos + ",top=" + toppos + ",resizable=1" );
	winobject.focus();
}

//-------------------------------------------------------------------------------------------------------
//	Arrow highlight
//-------------------------------------------------------------------------------------------------------
function onArrow(id)
{
	if( document.getElementById)
	{
		obj	= document.getElementById('arrow' + id);
		obj.setAttribute( 'src', '/images/arrow-over.gif' );
	}
}

//-------------------------------------------------------------------------------------------------------
//	Arrow de-highlight
//-------------------------------------------------------------------------------------------------------
function offArrow(id)
{
	if( document.getElementById)
	{
		obj	= document.getElementById('arrow' + id);
		obj.setAttribute( 'src', '/images/arrow.gif' );
	}
}
