/**
 * jQuery random background fader
 * @name Random Background Fader
 * @based on Charles Harvey's Random Background Image
 * http://www.charles-harvey.co.uk
 * @version 0.1
 */

(function($) {
	$.randombg = {
		defaults: {
			directory: "images/headerblurb/", //where the images are
			howmany: 1 // how many there are, sequentially numbered, i.e. 1.jpg, 2.jpg, 3.jpg etc.
		}
	}
    $.fn.extend({
        randombg:function(config) {
            var config = $.extend({}, $.randombg.defaults, config);
			return this.each(function() {
				var directory = config.directory, howmany = config.howmany;
				var which = Math.floor(Math.random()*howmany)+1;
				$(this).css({"background" : "url(" +directory + which + ".jpg)"});
     			$(this).css("opacity",0);
				$(this).fadeTo("fast",1);			  
            })
        }
    })
})(jQuery);