var MW = (MW)?MW:{};

MW.Waiter_Class = function(){   
	this.scrollTop = null;
	if (MW.Component && MW.Component.SetObjectAsComponent)
		MW.Component.SetObjectAsComponent(this);

	this.stack = [];
	
	this.showStack = function(pMessage)
	{
		this.stack.push(1);
		this.show(pMessage);
	};
	
	this.hideStack = function()
	{
		this.stack.pop();
		if(this.stack.length == 0)
		{
			this.hide();
		}
	};
	
	this.hideAndResetStack = function()
	{
		this.hide();
		this.stack = [];
	};
	
	this.show = function (pMessage)
	{   
		jQuery("#WaitBack").css("top", document.body.scrollTop);
		jQuery("#Wait").css("top", document.body.scrollTop);
		jQuery("#WaitBack").show();
		if(pMessage)
		{
			jQuery("#Wait").find("#message").show();
			jQuery("#Wait").find("#message").html(pMessage);
		}
		else jQuery("#Wait").find("#message").hide();
		jQuery("#Wait").show();
		
		this.scrollTop=document.body.scrollTop;
		setTimeout("MW.Waiter.hide();",180000);

	};

	this.hide = function ()
	{
		jQuery("#WaitBack").hide();
		jQuery("#Wait").hide();
		
		if(this.scrollTop) document.body.scrollTop = this.scrollTop;
		this.stack = [];
	};     
}
MW.Waiter = new MW.Waiter_Class();
