(function($) {
	$.widget('ui.smnav', {
		options: {
			
		},
		
		_create: function() {

			var self = this,			
			o = self.options, e = self.element;
			
			e.children('li').bind('mouseenter', function() {	
			
				e.children('li.active').removeClass('active');
				e.children('li div.subnav-wrapper').hide();

			
				$(this).addClass('active');
				$(this).find('div.subnav-wrapper').fadeIn();
			}).bind('mouseleave', function() {						
				$(this).removeClass('active');
			});
			
			//remove nav menus
			$('body').bind('click', function(event) {
				$('#topnavigation ul#navigation li.active').removeClass('active');
			});
			
			//stop click from propagating to the body when top nav is clicked
			e.bind('click', function(event) {
				event.stopPropagation();
			});

			
			/*
			e.children('li').bind('mouseleave', function() {
				$(this).removeClass('active');
				$(this).find('div.subnav-wrapper').hide();
			});
			*/
			
		},
		
		destroy: function() {
			
		}
	});
})(jQuery);
