function hasBorderRadius() {

  var d = document.createElement("div").style;

  if (typeof d.borderRadius !== "undefined") return true;

  if (typeof d.WebkitBorderRadius !== "undefined") return true;

  if (typeof d.MozBorderRadius !== "undefined") return true;

  return false;

};


if (hasBorderRadius()) { // 1

  $("img.roundedCorners").each(function() { // 2

    $(this).wrap('<div class="roundedCorners" />'); // 3

    var imgSrc = $(this).attr("src"); // 4

    var imgHeight = $(this).height(); // 4

    var imgWidth = $(this).width(); // 4

    $(this).parent()

      .css("background-image", "url(" + imgSrc + ")")

      .css("background-repeat","no-repeat")

      .css("height", imgHeight + "px")

      .css("width", imgWidth + "px"); // 5

    $(this).remove(); // 6

  });

}
