/*------------------------------------------------------------------------------
Function:       eCSStender.CSS3-color.js
Author:         Aaron Gustafson (aaron at easy-designs dot net)
Creation Date:  2010-04-25
Version:        0.1
Homepage:       http://github.com/easy-designs/eCSStender.CSS3-color.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(typeof eCSStender=="undefined"){return}var f=eCSStender,g=new b(f),g=new a(f),d;function b(x){var B,u=false,y=null,q=",",n=":",t="; ",w="(",s=")",m="color",z="property",o="hsl",j=o+"a",k="rgb",r=k+"a",A=m+n+o+w+"0, 0, 0"+s,i=m+n+r+w+"0, 0, 0, 1"+s,h=m+n+j+w+"0, 0, 0, 1"+s,p="filter: progid:DXImageTransform.Microsoft.Gradient",v=["background","background-"+m,m,"border","border-left","border-right","border-top","border-bottom"];x.register({property:["background","background-"+m],filter:/(:?rgba|hsla)\([^\)]+\)/,test:function(){return(!x.isSupported(z,i)&&x.isSupported(z,p+"(startColorstr=#99000050,endColorstr=#99000050)"))},fingerprint:"net.easy-designs.alpha-backgrounds-in-IE"},u,c);x.register({property:v,filter:/hsla\([^\)]+\)/,test:function(){return(!x.isSupported(z,h))},fingerprint:"net.easy-designs."+j},u,l);x.register({property:v,filter:/hsl\([^\)]+\)/,test:function(){return(!x.isSupported(z,A))},fingerprint:"net.easy-designs."+o},u,l);function l(C,F,K){var I="",e,H=/(.*)(hsla?)\(([^\)]+)\)(.*)/,E,J,G,D;for(e in F){if(x.isInheritedProperty(F,e)){continue}E=F[e].match(H);if(E!=y){D=k;J=E[3].split(q);G=d.hslToRGB(x.trim(J[0]),x.trim(J[1]),x.trim(J[2]));if(E[2]==j){D=r;G[3]=x.trim(J[3])}I+=e+n+E[1]+D+w+G.join(q)+s+E[4]+t}}if(I!=""){x.embedCSS(C+" { "+I+"} ",K)}}function c(C,E,J){var H="",e,G=/(.*)(rgba|hsla)\(([^\)]+)\)(.*)/,D,I,F;for(e in E){if(x.isInheritedProperty(E,e)){continue}D=E[e].match(G);if(D!=y){value=D[3].split(q);alpha=d.base16(x.trim(value[3])*255);if(D[2]==j){value=d.hslToHex(x.trim(value[0]),x.trim(value[1]),x.trim(value[2]))}else{value=d.rgbToHex(x.trim(value[0]),x.trim(value[1]),x.trim(value[2]))}H+=e+n+D[1]+D[4]+t+"zoom"+n+"1"+t+p+w+"startColorstr=#"+alpha+value+",endColorstr=#"+alpha+value+s+t}}if(H!=""){x.embedCSS(C+" { "+H+"} ",J)}}}function a(n){var m,o=false,k=null,i=": ",j="; ",h=")",s="property",r="opacity",q="filter"+i+"progid:DXImageTransform.Microsoft.Alpha("+r+"=",l=r+i+0,c=q+0+h;n.register({property:r,test:function(){return(!n.isSupported(s,l)&&n.isSupported(s,c))},fingerprint:"net.easy-designs.opacity"},o,p);function p(e,u,t){var v="",w;for(w in u){if(n.isInheritedProperty(u,w)){continue}v+=q+(u[w]*100)+h+j+"zoom"+i+"1"+j}if(v!=""){n.embedCSS(e+" { "+v+"} ",t)}}}d={rgbToHex:function(e,c,h){return this.base16(e)+this.base16(c)+this.base16(h)},hexToRGB:function(c){return[parseInt(c.substr(0,2),16),parseInt(c.substr(2,2),16),parseInt(c.substr(4,2),16)]},rgbToHSL:function(j,i,l){j/=255;i/=255;l/=255;var c=Math.max(j,i,l),h=Math.min(j,i,l),e=[0,0,(c+h)/2],k=c-h;if(k!==0){e[1]=(e[2]>0.5)?k/(2-k):k/(c+h);switch(c){case j:e[0]=(i-l)/k+(i<l?6:0);break;case i:e[0]=(l-j)/k+2;break;case l:e[0]=(j-i)/k+4;break}e[0]/=6}return e},hslToRGB:function(k,j,c){k=parseInt(k,10)/360;j=parseInt(j,10)/100;c=parseInt(c,10)/100;var e=[0,0,0],l,m,h=3;if(j===0){e[0]=e[1]=e[2]=c}else{l=(c<0.5)?c*(1+j):c+j-(c*j);m=(2*c)-l;e[0]=this.hue(m,l,k+1/3);e[1]=this.hue(m,l,k);e[2]=this.hue(m,l,k-1/3)}while(h--){e[h]=Math.round(e[h]*255)}return e},hslToHex:function(i,h,c){var e=this.hslToRGB(i,h,c);return this.rgbToHex(e[0],e[1],e[2])},base16:function(i){var h=16,e="0123456789ABCDEF",c="";while(i>0){c=e.charAt(i%h)+c;i=Math.floor(i/h)}if(c==""){c="00"}return c},hue:function(h,e,c){if(c<0){c+=1}if(c>1){c-=1}if(c*6<1){return h+(e-h)*6*c}if(c*2<1){return e}if(c*3<2){return h+(e-h)*(2/3-c)*6}return h}};window.ColorUtils=d})();
