
function ImgPreloader()
{
	this.ImgTarget=null;
	this.IdLoader=null;
	this.IdTarget=null;
	
	this.Loader=null;
	this.Target=null;
	
	this.ImageObj = new Image();
	
	this.timerID = 0;
	this.tStart  = null;

	this.Start=Start;
}

function Start()
{	
	this.Loader = document.getElementById(this.IdLoader);
	this.Target = document.getElementById(this.IdTarget);

	this.Target.style.display = 'none';
	this.Loader.style.display = 'inline';
	
	this.ImageObj.src = this.ImgTarget;   //this.ImgTarget

	DelayCheck(this);
	
	// Load the image loader GIF and display the image loader. Also hide the Target Image.
}

function DelayCheck(Parent)
{
	window.setTimeout(function () {
										
									CheckImageStatus(Parent);
										
								   }, 500);
}

function CheckImageStatus(Parent)
{	
	if (Parent.ImageObj.complete == true)
	{		
		Parent.Loader.style.display = 'none';
		
		// Load the image loader GIF, and hide the Target Image.
		Parent.Target.src = Parent.ImageObj.src;
		Parent.Target.style.display = 'inline';
	}
	else
	{
		window.setTimeout(function () {
										
										CheckImageStatus(Parent);
										
									  }, 500);
	}
}
