var IMG_LOADER = {
	/*PUBLIC*/
	'oLoading':'', //id do objeto que contém a imagem de loading no padrão jquery '#loading'
	'oImgDestination':'',  //id do objeto que receberá a imagem lida no padrão jquery '#img_destination'
	'callback':'null', //função executada no fim do carregamento da imagem
	
	/*PRIVATE*/
	'tImg':null,
	'loadedImg':false,
	'imgLoad':null,
	
	'checkLoad': function(){
		clearTimeout(this.tImg);
		if(this.loadedImg){
			$(this.oImgDestination).attr("src",this.imgLoad.src);
			$(this.oLoading).hide();
			$('#bgSite').hide();
			
			this.loadedImg = false;
			if (this.callback != 'null') this.callback();
		}else{
			this.tImg = setTimeout("IMG_LOADER.checkLoad()",400);
		}
	},

	'load': function(img){
		$(this.oLoading).show();
		$("#bgSite").fadeTo("fast", 0.5);
		$('#bgSite').show();
		
		this.imgLoad = new Image();
		this.imgLoad.src = img;
		if(this.imgLoad.complete){
			IMG_LOADER.loadedImg = true;
			this.checkLoad();
			return;
		}
		this.imgLoad.onload = function(){
			IMG_LOADER.loadedImg = true;
		}
		this.checkLoad();
	}
};
