// Array holding all the dropdown menus
var ids = new Array("products_dd", "technology_dd", "customers_dd", "services_dd", "partners_dd", "resources_dd");

// Drop down properties
var timeout	= 50;
var closetimer	= 0;
var ddmenuitem	= 0;

// Current navigation item holder
var navItem = '';

// Set a timer to hide the dropdown menu
	function closeTime()
	{
		closetimer = window.setTimeout(hideDD, timeout);
	}

// Show the correct dropdown menu
	function showDD(id)
	{
		// Cancel the timer
		cancelTimer();
		// Hide all other drop
		hideDD();
		
		// Remove the string "_dd" from the passed id
		navItem = id.split("_dd");
		navItem = 'nav-' + navItem[0];
		
		// Activate the current navigation item
		activateTab(navItem);
		
		// Show the dropdown menu according to the id passed
		var elem = document.getElementById(id);
		elem.className = 'dropdown clearfix show';
	}
	
// Function to keep the hover state of the navigation item while on its dropdown menu
	function activateTab(id)
	{
		var elem = document.getElementById(id);
		elem.className = 'dd_open';
	}
	
// Hiding the dropdown menu
	function hideDD()
	{		
		// Remove the "dd_open" class off the current navigation item
		if (navItem != "")
		{
			var nav = document.getElementById(navItem);
			nav.className = '';
		}
		
		// Hide all dropdown menus
		for (i = 0; i < ids.length; i++)
		{
			var elem = document.getElementById(ids[i]);
			elem.className = 'dropdown clearfix hide';
		}
	}
	
// Cancel Timer
	function cancelTimer()
	{
		if(closetimer)
		{
			window.clearTimeout(closetimer);
			closetimer = null;
		}
	}

// Close layer when click-out
document.onclick = closeTime;