(function($){

    $.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;
        var event = params.event;
        var thisidframe = params.thisidframe;
        var oncomplete = params.oncomplete;
				
        // If error checking is enabled
        if(showErrors){
            if(!$(navDiv).attr('title')){
                alert("ERROR: The elements in your mainLinkTag paramater need a 'title' attribute.\n ("+navDiv+")");
                return false;
            }
            else if(!$("."+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--;
            $("."+hiddenContentDiv+":eq("+showDefaultTab+")").css('display','block');
            $(navDiv+":eq("+showDefaultTab+")").addClass(selectedClass);
        }
				
        // each anchor
        $(navDiv).each(function(){
            if($(this).attr('title')){
                $(this).bind(event, function(){
                    // once clicked, remove all classes
                    $(navDiv).each(function(){
                        $(this).removeClass();
                    })
                    // hide all content
                    $("."+hiddenContentDiv).css('display','none');
						
                    // now lets show the desired information
                    $(this).addClass(selectedClass);
                    var contentDivId = $(this).attr('title');
						
                    if(effect != null){
							
                        switch(effect){
                            case 'both':
                                $("#"+contentDivId).fadeIn(effectSpeed);
                                $("#"+contentDivId).slideDown(effectSpeed);
                                //$("#"+contentDivId).css('display','block');
                                break;
                            case 'slide':
                                $("#"+contentDivId).slideDown(effectSpeed);
                                break;
                            case 'fade':
                                $("#"+contentDivId).fadeIn(effectSpeed);
                                break;
								
								
                        }
								
                    }
                    else {
                        $("#"+contentDivId).css('display','block');
                    }
                    if (thisidframe!=""){
                        if (parent.$('#'+thisidframe+'').length>0){
                                                        
                            parent.$('#'+thisidframe+'').css('height',($(document.body).height()+30+'px'));
                        }
                    }
                    if (oncomplete!=undefined){
                        oncomplete();
                    }
                    return false;
                })
            }
        })
			
    }
	
})(jQuery);	
