/**
 * jQuery ImageToCSS
 *
 * DESCRIPTION
 *   Image elements will be deleted and attached to the parent element as
 *   CSS background-image (necessary for IE). Useful for CMS/frameworks.
 *
 * DEPENDENCIES
 *   - jQuery 1.4.2
 *   - (Any script for rounded corners)
 *
 * COMPABILITY
 *   - Chrome 4.1.2
 *   - Firefox 3.6.3
 *   - IE 6-8
 *   - Konqueror 4.3.2
 *   - Opera 10.5
 *   - Safari 4.0.5
 *
 * ISSUES
 * - Different HTML/CSS structure seems to
 *   destroy functionality in IE / Webkit browsers.
 *
 * @version  1.03
 * @date     2010-04-08
 * @author   Christian Oellers
 * @contact  veryshort@gmx.de
 */

/**
 * Attach IMG element information to parent element 
 * as CSS background and remove the original element.
 */
jQuery.fn.ImageToCSS = function()
{
   if (typeof this == 'object')
   {
      this.parent().css
      ({
         'width'              : this.attr('width'),
         'height'             : this.attr('height'),
         'backgroundImage'    : 'url(' + this.attr('src') + ')',
         'backgroundRepeat'   : 'no-repeat',
         'backgroundPosition' : '0 0'
      });

      this.remove();
      return true;
   }

   return false;
}

/**
 * Add CSS styles for rounded corners.
 * Use this when not using any rounded-corners script.
 * This does not work with IE!
 */
jQuery.fn.roundCornerCSS = function(radius)
{
   if (typeof this == 'object' && radius.length)
   {
      this.css
      ({
         '-webkit-border-radius' : radius,
         '-moz-border-radius'    : radius,
         'border-radius'         : radius
      });

      return true;
   }

   return false;
}

