(function($){
	$.calcBandwidth = function(options,callback) {
		 var settings = jQuery.extend({
			 url: "",
			 size: "1"
		 }, options);
		 
		 
		 if (settings.url == "")
			return 0;
		
		
		//start the clock
		var start = (new Date()).getTime();
		
		//download the file
		var ajaxImg = new Image();
		$(ajaxImg).load(function(){//when the file is downloaded
			//stop the clock
			var end = (new Date()).getTime();
			
			//calculate the bandwidth speed in kbps
			var connectSpeed = (Math.floor((((settings.size * 8) / ((end - start) / 1000)) / 1024) * 10) / 10);
			
			//return the speed to the caller
			callback(connectSpeed);
		}).attr('src',settings.url+"?t="+start);
	};
 })(jQuery);
