/**
 * 
 * This plugin allows you to rotate an DOM element (e.g. div) by the amount of degrees given.
 *
 * @param degress int 		Degrees (0-360)
 * @param options Object	Options (not yet implemented in version 0.1)
 *                  
 */
$.fn.jqrotate = function(degrees, options)
{
    var options = $.extend({ 
        animate : false // not yet implemented
    }, options);
			    
    return this.each(function()
    {
        var $this = $(this);
			  
        var oObj = $this[0];
        var deg2radians = Math.PI * 2 / 360;
			      
        var rad = degrees * deg2radians;
        var costheta = Math.cos(rad);
        var sintheta = Math.sin(rad);
			      
        var a = parseFloat(costheta).toFixed(8);
        var b = parseFloat(-sintheta).toFixed(8);
        var c = parseFloat(sintheta).toFixed(8);
        var d = parseFloat(costheta).toFixed(8);
			      
        if((!$.browser.msie) || ($.browser.msie && parseInt($.browser.version,10)< 9) ){
            
            $this.css({
                'filter' : 'progid:DXImageTransform.Microsoft.Matrix(M11=' + a + ', M12=' + b + ', M21=' + c + ', M22=' + d + ',sizingMethod=\'auto expand\')',
                '-moz-transform' :  "matrix(" + a + ", " + c + ", " + b + ", " + d + ", 0, 0)",
                '-webkit-transform' :  "matrix(" + a + ", " + c + ", " + b + ", " + d + ", 0, 0)",
                '-o-transform' :  "matrix(" + a + ", " + c + ", " + b + ", " + d + ", 0, 0)",
                'transform' :  "matrix(" + a + ", " + c + ", " + b + ", " + d + ", 0, 0)"
            });
            
        }else{

            $this.css({
                '-ms-transform' :  "rotate("+degrees+"deg)"
            });
        }
			        
    });  
};
