/**
 * Tools for toggling title-content/container visibility/display and
 * status handling
 *
 * Required element structure:
 * <xx>
 *  <h3>##title##</h3>
 *  <yy class='content'></yy>
 * </xx>
 */

jQuery.fn.hideContent = function(mode,callback){

    afterFinish = (callback)?callback:function(){};
    speed = (callback)?'fast':'slow';

    switch(mode){
        case 'fade' :this.children('.content').fadeOut(speed,afterFinish);break;
        case 'slide':this.children('.content').slideUp(speed,afterFinish);break;
        default: this.children('.content').hide();break;
    }
}

jQuery.fn.showContent = function(mode,callback){

    afterFinish = (callback)?callback:function(){};
    speed = (callback)?'fast':'slow';

    switch(mode){
        case 'fade' :this.children('.content').fadeIn(speed,afterFinish);break;
        case 'slide':this.children('.content').slideDown(speed,afterFinish);break;
        default: this.children('.content').show();break;
    }
}

jQuery.fn.setTitle = function(title){
    this.children('h3').html(title);
}

jQuery.fn.setContent = function(content){
    this.children('.content').html(content);
}

jQuery.fn.enable = function(){
    if(this.hasClass('disabled'))
        this.removeClass('disabled');
    this.addClass('enabled');
}

jQuery.fn.disable = function(){
    if(this.hasClass('enabled'))
        this.removeClass('enabled');
    this.addClass('disabled');
}