
(function($) {

	$.randombg = {
		defaults: {
			directory: "img/bg/",
			howmany: 12

		}
	}
    $.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-image" : "url(" +directory + which + ".jpg)",
					"backgroundRepeat": "no-repeat",
                  	"backgroundPosition": "top center"
				});
			  
            })
        }
    })
})(jQuery);
