(function ($) {
	$.mtvn = $.mtvn ? $.mtvn : {};
	$.mtvn.dropdown = function (options) {
		// Extend the default options with those provided.
		var opts = $.extend({}, $.mtvn.dropdown.defaults, options);
		// Close Menus
		$(document).click(function() {
			$.mtvn.dropdown.hide(opts);
		});
		$('object').bind('focus', function () {
			$.mtvn.dropdown.hide(opts);
		});
		$($.mtvn.dropdown.defaults.closeOn).bind('click', function() {
			$.mtvn.dropdown.hide(opts);
			return false;
		});
		// Fire a click event
		$(document).trigger('click');
		// Return for chaining
		return this.each(function () {
			// Extend with meta plugin if it is included
			opts = $.meta ? $.extend({}, opts, $(this).data()) : opts;
			var dropdown = this;
			// Stop propagation on a click to prevent closing
			$(this).click(function (event) {
				event.stopPropagation();
				$.mtvn.dropdown.hide(opts);
				$.mtvn.dropdown.show(dropdown, opts);
			});
			// Override default mouseover/mouseout
			$(this).unbind('mouseover').unbind('mouseout');
		});
	}
	
	$.mtvn.dropdown.show = function (dropdown, opts) {
		$(dropdown).css(opts.cssActiveOptions).children(opts.bySelector).css({
			'left': opts.offsetLeft,
			'top': opts.offsetTop
		});
	}
	
	$.mtvn.dropdown.hide = function (opts) {
		$('*').children().filter(opts.bySelector).css({
			'left': '-999em'
		});
		
		$('*').children('.filterTop').css(opts.cssInactiveOptions);
	}
	
	$.mtvn.dropdown.defaults = {
		cssActiveOptions: {
			'background-position': '-364px 0px'
		},
		cssInactiveOptions: {
			'background-position': '0 0'
		},
		bySelector: '.leftMenu',
		closeOn: '.leftMenu li:first-child a',
		offsetLeft: '0',
		offsetTop: '0'
	}
	
	$.fn.mtvnDropdown = $.mtvn.dropdown;

})(jQuery);