 
generic.progress = Class.create(
{

    // summary:
    //      Swap content with progress indicator
    
    progressNode: null, // node to show on progress start
    containerNode: null, // node to hide on progress start 
    
    initialize: function(/* Object */args) {
        generic.updateProperties.apply(this, [args]);
        this.containerNode = $(args.containerId);
        this.progressNode = $(args.progressId);
        if (args.matchDimensions) {
            this._setDimensions();
        }
    },
    
    start: function() {
        if (!this.progressNode || !this.containerNode) { return; }
        this.containerNode.style.display = "none";
        this.progressNode.style.display = "block";
    },
    
    clear: function() {
        if (!this.progressNode || !this.containerNode) { return; }
        this.containerNode.style.display = "block";
        this.progressNode.style.display = "none";
    },
    
    onComplete: function() {
        this.clear();
    },
    
    onException: function() {
        this.clear();
    },
    
    onFailure: function() {
        this.clear();
    },
    
    onTimeout: function() {
        this.clear();
    },
    
    _setDimensions: function() { 
        this.progressNode.style.width = this.containerNode.getWidth() + "px";
        this.progressNode.style.height = this.containerNode.getHeight() + "px";    
    }
});

generic.progressOverlay = Class.create (generic.progress, 
{

    // summary:
    //      Progress overlay
    
    offset: {w: 0, h: 0},
    
    initialize: function(/* Object */args) {
        this.containerNode = $(args.containerId);
        this.progressNode = $(args.progressId);
        if (args.offset) {
            this.offset = args.offset;
        }
        
        // set dimensions 
        this.progressNode.style.width = (this.containerNode.getWidth() + this.offset.w) + "px";
        this.progressNode.style.height = (this.containerNode.getHeight() + this.offset.h) + "px";
    },
    
    start: function() {
        if (!this.progressNode) { return; }
        this.progressNode.style.display = "block";
    },
    
    clear: function() {
        if (!this.progressNode) { return; }
        this.progressNode.style.display = "none";
    }
});