//<![CDATA[

/****************************************************************
* File:		panels.js
*
* Author:	Chris Rodbourne
*
* Date:		2006-01-30
*
* Purpose:	Handles flappy panels for relevant page
*
* Mods:
*
****************************************************************/

/******* CONSTANTS *******/

// There's an external constant defined in the parent page of the cookie name to use in 'panelType'

var tabTimer;

/****************************************************************
*
* Function:		memoriseTab
*
* Purpose:		Called on mouseover of tabbed areas or click on link offpage
*				Either junmps to URL
8				or sets a timer to switch tabs
*
* Params:		panel is the DIV name e.g. panel1
*				linkinfo is the URL to go to if present
*
* Returns:		Nothing
*
*****************************************************************/

function memoriseTab(panel, linkinfo)
{
	if (linkinfo)
	{
		window.location = linkinfo;
	}

	setTimer(panel);
}


/****************************************************************
*
* Function:		setTimer
*
* Purpose:		Sets off timer to switch tabs
*
* Params:		panel is the DIV name e.g. panel1
*				linkinfo is the URL to go to if present
*
* Returns:		false
*
*****************************************************************/

function setTimer(panel)
{
	tabTimer = window.setTimeout("restorePanel('"+panel+"')", 220);
	return false;
}


/****************************************************************
*
* Function:		mainPanel
*
* Purpose:		This guy interrupts any timers in operation to stop an
*				unecessary panel switch
*
* Params:		panelID, 1 through 4 - not used at this time
*
* Returns:		Nothing
*
*****************************************************************/

function mainPanel(panelD)
{
	window.clearTimeout(tabTimer);
}


/****************************************************************
*
* Function:		restorePanel
*
* Purpose:		Called by timer and also on page load to switch or restore panel
*				When done sets the cookie
*
* Params:		panel is the panel to switch to
8				Uses external variable panelType for cookie name
*
* Returns:		Nothing
*
*****************************************************************/

function restorePanel(panel)
{
	if (panel == 'undefined' || panel == undefined || panel == null || panel == '')
	{
		panel = GetCookie(panelType);
		if (panel == 'undefined' || panel == undefined || panel == null || panel == '')
		{
			panel = "panel1";
		}
	} else {
		if (panelType) { SetCookie(panelType, panel); }
	}

	var graphicString = "graphic";
	if (panelType == "industriesPanel")
	{
		graphicString = "industriesgraphic";
	}
		
	for (i = 1; i < 5; i++)
	{
		if (panel == "panel"+i)
		{
			document.getElementById('panel'+i).style.visibility='visible';
			document.getElementById(graphicString+i).style.visibility='visible';
			document.getElementById('featureboxes'+i).style.visibility='visible';
		} else {
			document.getElementById('panel'+i).style.visibility='hidden';
			document.getElementById(graphicString+i).style.visibility='hidden';
			document.getElementById('featureboxes'+i).style.visibility='hidden';
		}
	}
}

//]]>
