/**
 * jQuery FadeDropdown plugin
 * This plugin is to be used for galleries in Parade themes (http://getparade.com)
 * @name parade-gallery-0.4.js
 * @version 0.1
 * @date Sept 15, 2009
 * @author Eli Dupuis
 * @copyright (c) 2009 Eli Dupuis (http://elidupuis.com)
 * @license Creative Commons Attribution 3.0 Unported License (http://creativecommons.org/licenses/by/3.0)
 * @requires jQuery 1.3.2 or later (will likely work with previous verions as well)

	Based heavily on snippet from (Steve Taylor) http://sltaylor.co.uk/blog/jquery-hover-drop-down-menu-settimeout/
	Plugin pattern based on (Mike Alsup) http://www.learningjquery.com/2007/10/a-plugin-development-pattern 

*/
(function($) {

$.fn.dropdown = function(options) {
	// ;;;debug(this);

	// build main options before element iteration
	var opts = $.extend({}, $.fn.dropdown.defaults, options);
	var navTimers = []; 

	return this.each(function() {
		$this = $(this);
		// build element specific options
		var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

		$(this).hover(  
			function () {  
				var id = jQuery.data( this );  
				var $this = $( this );  
				navTimers[id] = setTimeout( function() {  
				$this.find( o.child ).fadeIn( o.speedIn );  
				navTimers[id] = "";  
				}, o.delay );
			}, function () {  
				var id = jQuery.data( this );  
				if ( navTimers[id] != "" ) {  
					clearTimeout( navTimers[id] );  
				} else {  
					$( this ).find( o.child ).fadeOut( o.speedOut );  
			}
		});

	});
};

	//
	// private function for debugging
	//
	function debug($obj) {
		if (window.console && window.console.info)
		window.console.info('dropdown element count: ' + $obj.size());
	};

	//
	// plugin defaults
	//
	$.fn.dropdown.defaults = {
		delay: 150,
		speedIn: 300,
		speedOut: 200,
		child: 'ul'
	};
})(jQuery);
