﻿/*
-------------------------------------------------------------------------------------------
JQuery Plug-in for the TRI Menu.  This plug-in was written specifically for TRI and not for
general consumption.
-------------------------------------------------------------------------------------------
*/

//Create an enclosure for private members.  Pass the jquery object as '$' to allow use without
//conflict with other javascript libraries.
(function($) {

	//Menu function.
	$.fn.TRI_Menu = function() {

		//Iterate through the wrapped set and return the wrapped set.
		return this.each(function() {

			//The matched element must be a div.  Do nothing if not a div.
			if (this.tagName != "DIV")
				return;

			//Add the menu css class to the containing div.
//			$(this).addClass('TRI_Menu');

			//Initially hide the second and third level menus.
//			$('ul ul', this).css('display', 'none');

			//Create images for the first level menu items with children.
			//$('> ul > li:has(ul) > a', this).append('<img src="/content/Images/MenuArrowDown.png" alt="" border="0" />');

			//Create images for the second-level menu items with children.
			//$('li li:has(ul) > a', this).append('<img src="/content/Images/MenuArrowRight.png" alt="" border="0" />');

			//Select the list items that have child menus.
			$('li:parent', this).hoverIntent(
				function() { $(this).children('ul').fadeIn('fast'); },
				function() { $(this).children('ul').fadeOut('normal'); }
			);

		});

	};

})(jQuery);

