/**
 * Fade Menu for jQuery
 * 
 * http://www.renderrobot.com
 * 
 * Copyright (c) 2009 Alex Fish
 *
 * alex@renderrobot.com
 *
 * Dual licensed under MIT and GPL.
 *
 */

(function($){
	
	$.fn.fademenu = function(options){
		
		var 
			defaults = {
				fadeout : 150,
				fadein : 75,
				slideup : 400,
				slidedown : 200
			},
			settings = $.extend({}, defaults, options);
			
			this.each(function(){
			
					$("dd:not(dd#open)").hide();
					$("dt a").click(function(){
    					if ($.css(this, "display") !== "none" && $.css(this,"visibility") !== "hidden") {

    					    $("dd").fadeTo(settings.fadeout, 0);

    					    $("dd").children().attr('style', 'color:#ddd !important;');
							$("dd:visible").slideUp(settings.slideup);

							$(this).parent().next().slideDown(settings.slidedown);

							$(this).parent().next().children().attr('style', 'color:#ddd !important;');

							$(this).parent().next().fadeTo(settings.fadein, 1, fadeinCallback);

						//	$("dd:visible").show();
							
							}
						return false;
						});
		
			});
		
			return this;
	}



})(jQuery);







function fadeinCallback() {



    $(this).attr('style', 'visibility:hidden;');

    $(this).children().attr('style', 'color:#333 !important;');    

    $(this).attr('style', 'visibility:visible;');

}
