﻿/// <reference path="jquery-1.4.1-vsdoc.js" />

function LoadInditcator()
{
	this.Init = function()
	{
		this.div = document.createElement('div');
		this.img = document.createElement('img');
		this.span = document.createElement('span');
		
		jQuery(this.img).attr('src', baseUrl + 'Images/loader.gif').css({ margin: '2px', verticalAlign: 'middle' }).appendTo(this.div);
		jQuery(this.span).text('Loading...').css({ fontWeight: 'bold' }).appendTo(this.div);
		jQuery(this.div)
			.css({
				backgroundColor: 'yellow',
				border: '2px solid red',
				padding: '3px 8px 3px 8px',
				position: 'fixed',
				left: '45%',
				top: 0,
				width: '84px',
				zIndex: 100000
				})
			.prependTo(document.body)
		
		if (jQuery.browser.msie)
		{
			jQuery(this.div).css({ position: 'absolute', top: jQuery(window).scrollTop() });
			jQuery(window).scroll(jQuery.proxy(this, 'OnScroll'));
		}
		
		this.Hide();
		
		jQuery(window).load(jQuery.proxy(this, 'Hide'));
		jQuery(window).unload(jQuery.proxy(this, 'Show'));
	}
	
	this.OnScroll = function()
	{
		jQuery(this.div).css({top: jQuery(window).scrollTop()});
	}
	
	this.Show = function()
	{
		jQuery(this.div).show();
		
		if (jQuery.browser.msie)
			setTimeout(jQuery.proxy(this, 'RefreshImage'), 100);
	}
	
	this.RefreshImage = function()
	{
		jQuery(this.img).attr('src', baseUrl + 'Images/loader.gif');
	}
	
	this.Hide = function()
	{
		jQuery(this.div).hide();
	}
	
	this.Init();
}

jQuery(function(){
	window.loading = new LoadInditcator();
});

