jQuery.fn.loadImages = function(callBackFunction) {

    var images = [];
	var allImages = this;

	$(allImages).css({"opacity":"0", "visibility":"visible"}); //IE bug
	$(allImages).wrap("<div class='circle_preloader'></div>");

    for (var i = 0; i < allImages.length; i++) {
		images['img' + i] = allImages[i];
	}
	
	//start the fade from the 1st photo			
	showPhoto(0);
	
	function showPhoto(currentImg)
	{
		//stop recursivity
		if(currentImg == allImages.length)
		{
			if (typeof callBackFunction == 'function') {
                callBackFunction.call();
            }
			return;
		}
		var img = new Image();
		$(img).load(function()
		{
			$(images['img' + currentImg]).animate({"opacity":"1"}, 250, "easeInSine", function()
			{
				//remove the preloader
				$(images['img' + currentImg]).parent().removeClass('circle_preloader');
			});
			setTimeout(function() 
			{
				//go to next photo
				showPhoto(currentImg + 1);			
			}, 100);  
		});
		$(img).attr({src: $(images['img' + currentImg]).attr('src')});
	}
};