function rotate(obj, angle, centered){
   var rad = angle * Math.PI * 2 / 360,
      cos = Math.cos(rad),
      sin = Math.sin(rad),
      height = obj.clientHeight,
      width = obj.clientWidth;
   obj.style.filter = obj.style['-ms-filter'] = 'progid:DXImageTransform.Microsoft.Matrix(sizingMethod="auto expand", M11 = ' + cos + ', M12 = ' + (-sin) + ', M21 = ' + sin + ', M22 = ' + cos + ')';
   
   if (centered) {
      if (obj.style.position != 'absolute' && obj.style.position != 'fixed') obj.style.position = 'relative';
      obj.style.top += (height - obj.offsetHeight) / 2;
      obj.style.left += (width - obj.offsetWidth) / 2;
   }
}
