/*
 * toggle ctd (ui effects make problem, so we wrap the whole thing and
 * use normal effects (slide/fade)
 */	

(function($) {
	
	/*
	 * The show function
	 */
	
	$.fn.ctdShow = function(effect, settings, speed, callback) {
		
		return this.each(function() {
			
			if(speed < 2) {
				$(this).show();
				var i = this;
				if($.isFunction(callback))
					window.setTimeout(function() { $(i).each(callback); }, 10);
			}
			else if(effect == "puff")
				$(this).fadeIn(speed, callback);
			else
				$(this).slideDown(speed, callback);
				
			return $(this);
				
		});
		
	}
	
	/*
	 * The hide function
	 */
	
	$.fn.ctdHide = function(effect, settings, speed, callback) {
		
		return this.each(function() {
			
			if(speed < 2) {
				$(this).hide();
				var i = this;
				if($.isFunction(callback))
					window.setTimeout(function() { $(i).each(callback); }, 10);
			}
			else if(effect == "puff")
				$(this).fadeOut(speed, callback);
			else
				$(this).slideUp(speed, callback);
				
			return $(this);
			
		});
		
	}

})(jQuery);
