/* =========================================================

// jquery.nortel.js
// By Rebecca Murphey
// webslingerz
// rmurphey@webslingerz.com

// ========================================================= */


(function($) {
					
	$.fn.hoverClass = function(c) {
		return this.each(function() {
			$(this).hover(
				function() { $(this).addClass(c); },
				function() { $(this).removeClass(c); }
			);
		});
	}
	
	$.fn.tabs = function(tabsClass,showTitles,useWrapper,contentHeight) {
		
		return this.each(function() {
		
			$(this).before('<ul class="' + tabsClass + '"></ul>');
			var tabs = $(this).prev('ul');
			
			var maxHeight = contentHeight ? contentHeight : 0;
			
			if (! contentHeight) {
				$('dd',this).each(function() {
					if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
				});
			}
			
			$(this).css({ height: maxHeight });
			
			$('dd, dt', this).hide();

			var tabsText = $('dt',this);
			var content = this;
			
			$(tabsText).each(function() {
				var tabContent = $(this).next();
				var tabText = $(this).html();
				
				$(tabs).append('<li>' + tabText + '</li>');
				
				if (showTitles) { $(tabContent).prepend('<h3>' + tabText + '</h3>'); }
				if (useWrapper) { 
					$(tabContent).wrap('<div class="wrapper"></div>'); 
					$(tabContent).parent().css({ padding:5, overflow: 'auto', height: '90%' });
				}
				
				$('li:last',tabs).click(function() { 
					$('li',tabs).removeClass('active');
					$(this).addClass('active'); 
					$('dd, div.wrapper',content).hide();											
					$(tabContent).parent().show().end().fadeIn(500);
				});
			});
			
			$('ul.' + tabsClass + ' li').
				css({ cursor: 'pointer' }).
				hoverClass('hover');
			
			$(this).show();
			$(this).css({marginTop: 0});
			$('li',tabs).eq(0).click();
			
		});

	};
		
})(jQuery);

