// Multitier Menu Structure
// v1.5 - 3-12-2008
// Stylesheets - multiteirmenu.css

function open_menu(menu_id, title)
{
	var menu = jQuery('#' + menu_id);
	if (menu.length == 0 || jQuery('#' + menu_id).css('display') == 'block')
	{
		if (jQuery('#' + menu_id).css('display') == 'block')
		{
			// Menu Open Speed (Slow, Normal, Fast)
			jQuery('#' + menu_id).slideToggle('fast');
			title.className = 'category_name';
		}
		return ;
	}

//	Set all li positions to static so IE behaves correctly hack
//	if (jQuery.browser.msie)
//	menu.parents('#nav').find('li').each(function () { jQuery(this).attr('prevPosition', jQuery(this).css('position')).css('position', 'static')} );

// Hide all Level two menus until animation is complete
	// menu.parents('#nav').find('.categ > ul ul').css('visibility', 'hidden');

	// alert(menu_id);
// Close currently open category menu
	jQuery('#nav .categ > ul').each(function () {
		if (jQuery(this).css('display') == 'block')
		{
// Save the previous background color to an attribute of the element and set current background color to white
			if (jQuery(this).css('background-color') == 'transparent')
//				Required by Safari
				jQuery(this).attr('prevBgColor', jQuery(this).css('background-color')).css('background-color', 'white');

// toggle
// Menu Open Speed (Slow, Normal, Fast)
			jQuery(this).slideToggle('fast', function () {
//				var bgColor;
//				When done revert the background color
//				Safari Requirement?
				jQuery(this).css('background-color', (bgColor = jQuery(this).attr('prevBgColor')) ? bgColor : 'transparent');
			});

			return false;
		}
	});

//Reset Category Title Color
	jQuery('#nav a').each(function () {
		if (jQuery(this).attr('name') == 'category_name')
			this.className = 'category_name';
	});
	
// Open category menu
// Menu Open Speed (Slow, Normal, Fast)
	menu.slideToggle('fast', function () {
		// Revert the IE Hack that was previous instituted so that Internet Explorer worked properly
		//if (jQuery.browser.msie)
		//	jQuery(this).parents('#nav').find('li').each(function () {
		//		jQuery(this).css('position', (position = jQuery(this).attr('prevPosition')) ? position : 'relative' );
		//	});

		// Show all level two menus
		//jQuery(this).parents('#nav').find('.categ > ul ul').css('visibility', 'visible');
	});
	title.className = 'category_name open';
}
