var showProgress = function(message){
    if(!message){ message = 'loading...'; }
    $('#progress').show();
    $('#progress').find('.message').html(message);
}

jQuery(document).ready(function ($) {

    // PANEL LAYOUT
    var layoutSettings = {
        name: "MapCakesLayout",
        defaults: {
            size: "auto",
            togglerTip_open: "Close This Pane",
            togglerTip_closed: "Open This Pane",
            resizerTip: "Resize This Pane"
        },
        north: {
            minSize: 125
        },
        south: {
            minSize: 50
        },
        west: {
            size: 280
        },
        east: {
            size: 310
        }
    };
    $('body').layout(layoutSettings);

    // MAP OVERLAYS:
    $('#overlayPanel').css({'opacity':0.8});

    // PROGRESS:
    $('#progress').css({'opacity':0.8});
    $('.showLoading').click(function(){ showProgress('loading...'); });
    $('.showSaving').click(function(){ showProgress('saving...'); });
    $('.showSubmitting').click(function(){ showProgress('submitting...'); });
    $('.showUpdating').click(function(){ showProgress('updating...'); });

    // TEXT AREAS:
    // requires: jQuery AutoResize Plugin
    $('textarea').autoResize({
        onResize: function(){ $(this).css({opacity:0.8}); },
        animateCallback: function(){ $(this).css({opacity:1}); },
        animateDuration : 300,
        extraSpace : 20
    });

    // WIDGETS:
    $('<span />')
      .addClass('toggleWidget')
      .html('<span style="display:none">+</span><span>-</span>')
      .prependTo($('.widget-head'));

    var toggleWidget = function(widget){
        widget.find('.toggleableContent').toggle();
        widget.find('.toggleWidget').children('span').toggle();
    };

    toggleWidget($('.closedWidget'));

    $('.widget-head').click(function(){
      toggleWidget($(this).parent());
    });

    // BUTTONS:
    $('button, a.button').button();
    
});



