﻿
function DelayedContent (varName, containerId, loadContentScript, isLoaded, loadImmediately)
{
	this._variableName = varName;
	this._container = document.getElementById(containerId);
	this._loadContentFunction = new Function('argument', 'callback', loadContentScript);
	this._xmlHttpRequest = null;
	this._isLoaded = isLoaded;
	
	this.IsLoaded = function()
	{
	    return this._isLoaded;
	}
	
	this.Load = function(argument)
	{
	    if (!this.IsLoaded())
	        this.Reload(argument);
	}

	this.Reload = function(argument)
	{
	    this._container.style.cursor = 'progress';

	    this._loadContentFunction(argument, new Function('result', this._variableName + '._setContent(result);'));
	}
	
	this._setContent = function(result)
	{
	    if (result != null)
	    {
	        Telligent_Common.DisposeContent(this._container);
	    
	        this._container.innerHTML = result;
	        this._isLoaded = true;
	    }
	    
	    this._container.style.cursor = 'default';
	}
	
	if (loadImmediately)
	    window.setTimeout(new Function(this._variableName + '.Load();'), 249);
}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();