/*------------------------------------------------------------------------------
Function:       eCSStender.CSS3-transforms.js
Author:         Aaron Gustafson (aaron at easy-designs dot net)
Creation Date:  2010-05-23
Version:        0.3
Homepage:       http://github.com/easy-designs/eCSStender.CSS3-transforms.js
License:        MIT License 
Note:           If you change or improve on this script, please let us know by
                emailing the author (above) with a link to your demo page.
------------------------------------------------------------------------------*/
(function(){if(eCSStender===undefined){return}var d=eCSStender,c=false,f=new a(d),b;function a(y){var A,z="property",t="-moz-",q="-webkit-",h="-khtml-",m="-o-",p=" ",o=": ",u="; ",v="(",g=")",j="transform",l="rotate",x="deg",s="rad",k="matrix(0.7, 0.7, -0.7, 0.7, 0, 0)",w=l+v+"0.79"+s+g,i="filter: progid:DXImageTransform.Microsoft.Matrix",n=i+"(sizingMethod='auto expand')";y.register({fragment:j,filter:{value:/rotate\(-?\d+deg\)/},test:function(){var e=j+o+k;return(!y.isSupported(z,e)&&(y.isSupported(z,t+e)||y.isSupported(z,q+e)||y.isSupported(z,h+e)||y.isSupported(z,m+j+o+w)||y.isSupported(z,m+e)||y.isSupported(z,n)))},fingerprint:"net.easy-designs."+j+v+l+g},false,r);function r(F,J,N){var I,C="",L=C,D=j+o+k,G=y.isSupported(z,m+j+o+w),H=(y.isSupported(z,t+D)||y.isSupported(z,q+D)||y.isSupported(z,h+D)||y.isSupported(z,m+D)),B=y.isSupported(z,n),e,E,K,M,O;if(B&&y.methods.MSSetOrigin===I){if(window.jQuery===I){y.loadScript("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js",function(){c=window.jQuery;r(F,J,N)});return}y.addMethod("MSSetOrigin",function(Q,P,R){b.addToMatrix(Q,{Dx:P,Dy:R})});y.addMethod("MSRotate",function(Q,ag){var ai=c(Q),af="top",ab="left",W="px",ad="auto",ae="height",X="position",T="relative",P="background-color",V=ai.height(),Y=ai.width(),ah=b.degreesToRadians(ag),U=Math.cos(ah),aa=Math.sin(ah),R,Z,ac,S;Q.contentEditable=true;b.addToMatrix(Q,{M11:U,M12:-aa,M21:aa,M22:U,SizingMethod:"auto expand"});R=V-ai.height();Z=ai.width()-Y;if(ai.css(X)=="static"){ai.css({position:T,top:R+W,left:Z+W})}else{ac=ai.css(af);S=ai.css(ab);ai.css({top:(R+parseInt(ac!=ad?ac:0,10))+W,left:(Z+parseInt(S!=ad?S:0,10))+W})}if(ai.css(X)==T){ai.css("margin-bottom",ai.css(af))}if(ai.css(P)=="transparent"){ai.css(P,ai.parent().css(P))}})}if(B){O=c(F)}E=parseInt(J[j].replace(/rotate\((-?\d+)deg\)/,"$1"),10);for(e in J){if(H||G){if(e==j){K=j+o+l+v+E+x+g+u;M=K.replace(/-?\d+deg/,b.degreesToRadians(E)+s)}else{K=M=e+o+J[e]+u}L+=t+K+q+K+h+K+m+M}else{if(B){switch(e){case j:O.each(function(){y.methods.MSRotate(this,E)});break;case j+"-origin":O.each(function(){var S="top",P="bottom",W="left",U="right",V=c(this),aa=V.height(),Q=V.width(),Z=J[e].split(" "),Y,X;if(Z[0]==S||parseInt(Z[0],10)==0||Z[1]==S){Y=0}else{if(Z[0]==P||Z[1]==P){Y=Q}else{if(Z[0].match(/\d+?%/)){Y=Q*(100/parseInt(Z[0],10))}else{if(Z[0].match(/\d+?px/)){Y=parseInt(Z[0],10)}else{Y=Q/2}}}}if(Z[0]==W||Z[1]==W||parseInt(Z[1],10)==0){X=0}else{if(Z[0]==U||Z[1]==U){X=aa}else{if(Z[1].match(/\d+?%/)){X=aa*(100/parseInt(Z[1],10))}else{if(Z[1].match(/\d+?px/)){X=parseInt(Z[1],10)}else{X=aa/2}}}}y.methods.MSSetOrigin(this,Y,X)});break}}}}if(L!=C){y.embedCSS(F+" { "+L+"} ",N)}}}b={degreesToRadians:function(e){return e*(Math.PI*2/360)},addToMatrix:function(g,j){var h=false,m=g.style.filter.replace(/.*?Microsoft\.Matrix\(([^\)]+)\)/,"$1").split(","),l,e,k="progid:DXImageTransform.Microsoft.Matrix(";if(g.style.filter!=""){e=m.length;while(e--){l=m[e].split("=");if(j[l[0]]!==undefined&&j[m[e][0]]!=h){k+=this.getParamString(l[0],j[l[0]]);j[l[0]]=h}else{k+=this.getParamString(l[0],l[1])}}}for(l in j){if(!d.isInheritedProperty(j,l)){k+=this.getParamString(l,j[l])}}k=k.substring(0,k.length-1)+")";g.style.filter=k;g.style.msfilter=k},getParamString:function(h,g){var e=typeof(g),i=h+"=";if(e.toLowerCase()=="number"){i+=g}else{i+="'"+g+"'"}return i+","}}})();
