/************************************************************************************************************
 	Title:      ctmHomeSlidingPanels.js
 
	Author:     Marieke Roels
	Email:      mro@eim.nl
	 
	company:    EIM BV
	Website:    www.eim.nl
	 
	Purpose:    File containing the custom Javascript functions for the homepage
	 
	Usage:     
	 
	Modification Log:
	 
	Name   Date   Description
	================================================================================
	MRO   23/04/2008  Created
	MRO	  05/05/2008  Add and remove active class for active menuitem
 ************************************************************************************************************/
var lockContentPanel = false; //Boolean indicating if the panels is locked (true) or if it should close on mouseout (false)
var oActiveMenuItem = ""; //The current active link object


/***
 * Function used to open a content panel
 * 
 * @iContentPanel - Integer indicating which content panel should be opened; left = 0, right = 2
 * @sClass - String containing the className that should be given to the panel container
 * @oEvent - the event that triggered this functions
 * @iRow (optional) - The row of the spry dataset that has to be selected
 **/
function openContent(iContentPanel, sClass, oEvent, iRow)
{

		//If an active link was set, set classname of current active link back to normal
		if(oActiveMenuItem)
		{
			oActiveMenuItem.className = "";
		}
		
		//Set new active link
		if(oEvent.target)
		{
			oActiveMenuItem = oEvent.target;
		}
		else if(oEvent.srcElement)
		{
			oActiveMenuItem = oEvent.srcElement;
		}
		
		//To prevent errors from recalcitrant browsers check for active menu again and set className of link to active 
		if(oActiveMenuItem)
		{
			oActiveMenuItem.className = "accountMenuLinkActive";
		}	
		
		//Lock the panel
		lockContentPanel = true;
	
	//If opend by rollover set active row in the dataset
	if(oEvent.type == "mouseover" && typeof iRow != "undefined")
	{
		dsMenuData.setCurrentRow(iRow);
	}
	
	//Hide the centerImage
	document.getElementById('centerImage').style.display = 'none';
	
	//Set panel class to given class and slide panel
	document.getElementById('homePanelContainer').className = sClass;
	test.showPanel(iContentPanel);
}

/***
 * Function used to close a content panel
 * 
 * @oEvent - the event that triggered this functions
 **/
function closeContent(oEvent)
{
	//Only close the panel if panel isn't locked or the panel is closed by a click event
	if(lockContentPanel == false || oEvent.type == 'click')
	{
		//Remove the panel lock
		lockContentPanel = false;
		
		//Set panel class to closed and slide panel back
		document.getElementById('homePanelContainer').className = 'closedContent';
		test.showPanel(1);
		
		//Remove the active class from the active menuitem and remove active menulink object
		if(oActiveMenuItem)
		{
			oActiveMenuItem.className = "";
			oActiveMenuItem = "";
		}
		
		//Show the centerImage
		document.getElementById('centerImage').style.display = 'inline';
	}
}
