/*****************************************************************************************
Name:			global.js
Copyright:		2007 Breakthrough Design Group.
Description:	Javascript dynamic "Services" navigation functionality.
*****************************************************************************************/

/** Here we attach the onmouseover, and onmouseout listeners to our "Services" link **/
window.addEvent('domready',function()
{
	// Positioning the services sub menu
	positionServicesSubNav();
	// Automatically re-positioning the services sub menu when the window is resized.
	window.addEvent('resize',positionServicesSubNav);
	// Displaying the services sub menu when the Services link is moused over.
	$('services').addEvent('mouseover',showServices);
	// Closing the sub menu if they simply mouseout of the services link.
	$('services').addEvent('mouseout', prepHide);
	// Cancelling that close if they move to the sub menu
	$('services_sub').addEvent('mouseover',function(){clearTimeout(hideTimeout)});
	// Closing the sub menu if they mouseout of it
	$('services_sub').addEvent('mouseout',prepHide);	
});

/******************************************************************************
Name: 	showServices
Desc:	Displays the Services sub-menu whenever the Services link is moused over.
******************************************************************************/
var demo1effect;
function showServices()
{
	$('services_sub').fade('in');
}
var hideTimeout;
function prepHide()
{
	hideTimeout = setTimeout('hideServices()',500);
}
function hideServices()
{
	$('services_sub').fade('out');
}

/******************************************************************************
Name: 	positionServicesSubNav
Desc:	This function positions our services sub nav directly underneath our
		services link.	
******************************************************************************/
function positionServicesSubNav()
{	
	var servPos = findPosition($('services'));
	// We offset it by a few so it lines up with the text in the sub menu rather than the left border.
	var servLeft = servPos[0] + 5;
	$('services_sub').style.left = (servLeft - 10) + 'px'; 
	
	// For some reason even ppk's findPos function doesn't work properly, so we have to offset it some, i hate this
	var servTop = servPos[1]+15;	
	$('services_sub').style.top = servTop + 'px'; 
	
	hideServices(); 	// necessary to prevent an odd flashing
	setTimeout('$("services_sub").style.display = ""',1000);	//necessary to see the menu
}

/******************************************************************************
Name: 	dynamicallyPosition
Desc:	This function is necessary to place or lock absolutely positioned elements
		with centered content elements.  Basically it changes the 'left' parameter 
		as needed to move the absolutely positioned element when the content is
		resized.
params:	el - The id of the element you wish to position dynamically.		
******************************************************************************/
function dynamicallyPosition(el)
{
	
}