/*
* jQuery centR 0.1 by Pierre Bertet (pierrebertet.net), based on an original idea by Raphaël Bastide (raphaelbastide.com)
* Licensed under the MIT LICENSE ( http://www.opensource.org/licenses/mit-license.php )
*/
(function($){
  $.fn.centR = function(){
    return this.each(function(){
      var $this = $(this);
      var $parent = $this.parent();
      
      while ($parent.css("display") !== "block" &&  !$parent.is("body")) {
        $this = $parent;
        $parent = $parent.parent();
      }
      
      var $thisWidth = ($this.is("embed"))? $this.attr("width")-0 : $this.outerWidth();
	  
      var $parentWidth = $parent.width();
      
      if ($thisWidth > $parentWidth) {
        $this.css({ position: "relative",left: ($parentWidth/2) - ($thisWidth/2) + "px" });
      }
    });
  };
})(jQuery);
