/***************************************/
// jQuery Tabber
// By Jordan Boesch
// www.boedesign.com
// Dec 25, 2007 (Merry Christmas!)
/***************************************/

(function(jQuery){
		  
	jQuery.extend(jQuery, {
		jtabber: function(params){
				
				// parameters
				var navDiv = params.mainLinkTag;
				var selectedClass = params.activeLinkClass;
				var hiddenContentDiv = params.hiddenContentClass;
				var showDefaultTab = params.showDefaultTab;
				var showErrors = params.showErrors;
				var effect = params.effect;
				var effectSpeed = params.effectSpeed;
				
				// If error checking is enabled
				if(showErrors){
					if(!jQuery(navDiv).attr('title')){
						alert("ERROR: The elements in your mainLinkTag paramater need a 'title' attribute.\n ("+navDiv+")");	
						return false;
					}
					else if(!jQuery("."+hiddenContentDiv).attr('id')){
						alert("ERROR: The elements in your hiddenContentClass paramater need to have an id.\n (."+hiddenContentDiv+")");	
						return false;
					}
				}
				
				// If we want to show the first block of content when the page loads
				if(!isNaN(showDefaultTab)){
					showDefaultTab--;
					jQuery("."+hiddenContentDiv+":eq("+showDefaultTab+")").css('display','block');
					jQuery(navDiv+":eq("+showDefaultTab+")").addClass(selectedClass);	
				}
				
				// each anchor
				jQuery(navDiv).each(function(){
										
					jQuery(this).click(function(){
						// once clicked, remove all classes
						jQuery(navDiv).each(function(){
							jQuery(this).removeClass();
						})
						// hide all content
						jQuery("."+hiddenContentDiv).css('display','none');
						
						// now lets show the desired information
						jQuery(this).addClass(selectedClass);
						var contentDivId = jQuery(this).attr('title');
						
						if(effect != null){
							
							switch(effect){
								
								case 'slide':
								jQuery("#"+contentDivId).slideDown(effectSpeed);
								break;
								case 'fade':
								jQuery("#"+contentDivId).fadeIn(effectSpeed);
								break;
								
							}
								
						}
						else {
							jQuery("#"+contentDivId).css('display','block');
						}
						return false;
					})
				})
			
			}
	})
	
})(jQuery);	