/**
 * Simple jQuery random image changer
 * @name Random Image Changer
 * @author Colin Redpath - http://www.wildfire-it.com
 * @version 0.1
 * @date October 31 2010
 * @category jQuery plugin
 * @copyright (c) 2010 Wildfire Technology Limited
 */

(function($){  
  
    $.fn.extend({   
          
        randomimg: function(config) {  
  
            var defaults = {  
				directory: "images/template/backgrounds/",
				imgtype: "src",
				howmany: 3
            }  
                  
            var config =  $.extend(defaults, config);  
  
            return this.each(function() {  
                var which = Math.floor(Math.random()*config.howmany)+1;
                if(config.imgtype == 'src')
               		$(this).attr("src",config.directory+which+".jpg");
               	else if (config.imgtype == 'background')
               		$(this).css("background","url("+config.directory+which+".jpg) top no-repeat");
            });  
        }  
    });  
      
})(jQuery);  
