/*
	jQuery DropDownMenu plugin
	2008, Paul van Dam
*/

;(function($){
$.fn.dropdownmenu = function (options) {
	
	var opt = {
	};

	if (options) $.extend(opt, options);

	return this.each (function () {

		var self = $(this);
		var selfid = self.attr('id');

		// Remove background from last main item
		$('>li:last',self).css({
			backgroundImage: 'none'
		});

		// Check all items for child-menu's and add arrow
		$('ul>li',self).each(function(){
			var li = this;
			if ($('>ul',this).length > 0) {
				$(li).addClass('daddy');
			}
		});

		// Bind hover events
		$('li',self).hover(menuOver,menuOut);

		function menuOver () {
			// Only reposition level 3+ (where parent is not main menu)
			if ($(this).parent().attr('id') != selfid) {
				$('>ul',this).css({
					marginLeft: $(this).width(),
					marginTop: -$(this).height()-2
				});
			}

			$('>ul',this).show();
			$('a:first',this).addClass('opener');
			$(this).addClass('hover');
		}

		function menuOut () {
			$('>ul',this).hide();
			$('a:first',this).removeClass('opener');
			$(this).removeClass('hover');
		}
	});
};
})(jQuery);