/*
 * jQuery Preload plugin
 * Developed by Pete DeLaurentis
 *
 * Copyright (C) ShapeTools 2010
 * 
 */

// Put ourselves into a jQuery function
(function($) {

	// Define our object that we'll use
	function Preload()
	{
	}
	
	// Takes anything with the preloaded class and hides it
	$.preload = function(urls) {

		// Go through the list of images given and load them all
		$.preloadCountdown = urls.length;
		for ( var index=0; index<urls.length; index++ ) {
			var url = urls[index];
			var image = new Image();
			image.onload = function() {
				$.preloadCountdown -= 1;
				if ( $.preloadCountdown <= 0 ) {
					$(".preloaded").removeClass("preloaded");
				}
			};
			image.src = url;
		}
	}
	
	// This is our countdown for preloading for the page
	$.preloadCountdown = 0;

})(jQuery);

