﻿function AjaxLoader(jTarget, wait, srcLoader) {
    this.target = jTarget;
    this.loader = (srcLoader == null ? "/images/ajax-loader.gif" : srcLoader);
    this.oldContents = jTarget.html();
    this.wait = (wait == null ? 0 : wait);
    this.isShowing = false;
}

AjaxLoader.prototype.SetTarget = function(jTarget) {
    this.target = jTarget;
    this.isShowing = false;
}

AjaxLoader.prototype.Show = function() {
    
    this.isShowing = true;
    var _this = this;
    setTimeout(function() {
    if (_this.isShowing) {        
            _this.target.html("<img src='" + _this.loader + "'/>");
        }
    }, this.wait);

}

AjaxLoader.prototype.ReplaceOld = function() {
    this.target.html(this.oldContents);
}

AjaxLoader.prototype.Replace = function(newContents) {
    this.target.html(newContents);
}
