/**
 * @author Terry Wooton
 * @desc Adds a background layer to an element
 * @version 1.1
 * @example
 * jQuery("#element").add_background("url('/test.gif') bottom left no-repeat");
 * @license free
 * @param background css
 *
 */
jQuery(document).ready(function() {
  jQuery.fn.add_layer = function(bg,params) {
    jQuery(this).each(function() {
  
      s = jQuery(this).extend({},params || {});      
      
      jQuerylast = (jQuery(this).find('.add_background:last').length > 0 ? jQuery(this).find('.add_background:last') : jQuery(this));
  		jQuerylast.html('<div class="add_background"><div>'+jQuerylast.html()+'</div></div>');
  		jQuerylast = jQuery(this).find('.add_background:last');
  		jQuerylast.css({'background':bg,'width':'100%','height':'100%'});

     jQuerylast = jQuery(this).find('.add_background div:last');
            
      if(s.insideCss){
   		  jQuerylast.css(s.insideCss);
  		}
      if(s.insideClass){
  		  jQuerylast.addClass(s.insideClass);  	
  		}  	  
    });
  }      
});
