/**
 * @author Han Lin Yap < http://zencodez.net/ >
 * @copyright 2010 zencodez.net
 * @license http://creativecommons.org/licenses/by-sa/3.0/
 * @package Css3-Finalize
 * @version 1.11 - 2010-11-05
 * @website http://github.com/codler/jQuery-Css3-Finalize
 *
 * == Description == 
 * Some css3 attributes needs to have a prefix in front 
 * in order to work in different browser. The plugin takes 
 * care of that so you only need to write without the prefix.
 *
 * == Example Usage ==
 * // This will look for all style-tags and parse them.
 * $.cssFinalize('style');
 */
(function(a){a.cssFinalize=function(e){var b=false;if(a.browser.webkit||a.browser.safari){b="webkit"}else{if(a.browser.mozilla){b="moz"}else{if(a.browser.msie){if(parseInt(a.browser.version.substr(0,1))<=7){return true}b="ms"}else{if(a.browser.opera){b="o"}}}}function h(q){return function(r){return q}}var p={animation:["webkit"],"animation-delay":["webkit"],"animation-direction":["webkit"],"animation-duration":["webkit"],"animation-iteration-count":["webkit"],"animation-name":["webkit"],"animation-timing-function":["webkit"],"backface-visibility":["webkit"],"background-clip":["webkit","khtml"],"background-origin":["webkit","khtml"],"background-size":["moz","webkit","khtml"],"border-image":["moz","webkit"],"border-top-image":["moz","webkit"],"border-right-image":["moz","webkit"],"border-bottom-image":["moz","webkit"],"border-left-image":["moz","webkit"],"border-corner-image":["moz","webkit"],"border-top-left-image":["moz","webkit"],"border-top-right-image":["moz","webkit"],"border-bottom-left-image":["moz","webkit"],"border-bottom-right-image":["moz","webkit"],"border-radius":["moz","webkit"],"border-top-left-radius":[h("-moz-border-radius-topleft"),"webkit"],"border-top-right-radius":[h("-moz-border-radius-topright"),"webkit"],"border-bottom-right-radius":[h("-moz-border-radius-bottomright"),"webkit"],"border-bottom-left-radius":[h("-moz-border-radius-bottomleft"),"webkit"],"box-align":["moz","webkit"],"box-direction":["moz","webkit"],"box-flex":["moz","webkit"],"box-flex-group":["moz","webkit"],"box-lines":["moz","webkit"],"box-ordinal-group":["moz","webkit"],"box-orient":["moz","webkit"],"box-pack":["moz","webkit"],"box-shadow":["moz","webkit"],"box-sizing":["moz","webkit"],"column-count":["moz","webkit"],"column-gap":["moz","webkit"],"column-rule":["moz","webkit"],"column-rule-color":["moz","webkit"],"column-rule-style":["moz","webkit"],"column-rule-width":["moz","webkit"],"column-width":["moz","webkit"],columns:["webkit"],marquee:["webkit"],"marquee-direction":["webkit"],"marquee-speed":["webkit"],"marquee-style":["webkit"],perspective:["webkit"],"perspective-origin":["webkit"],"tab-size":["moz","o"],"text-overflow":["o"],"text-size-adjust":["webkit","ms"],transform:["moz","webkit","o","ms"],"transform-origin":["moz","webkit","o","ms"],"transform-style":["webkit"],transition:["moz","webkit","o"],"transition-delay":["moz","webkit","o"],"transition-duration":["moz","webkit","o"],"transition-property":["moz","webkit","o"],"transition-timing-function":["moz","webkit","o"],"user-modify":["moz","webkit","khtml"],"user-select":["moz","webkit","khtml"]};function i(q){var r="";a.each(q,function(s,t){r+=t.selector+"{";if(a.isArray(t.attributes)){r+=i(t.attributes)}else{a.each(t.attributes,function(v,u){r+=v+":"+u+";"})}r+="}"});return r}function m(s){var r=s.split(/(:[^;]*;?)/);r.pop();var q={};a.map(r,function(u,t){if(t%2==1){q[a.trim(r[t-1])]=a.trim(u.substr(1).replace(";",""))}});return q}function o(y){var s=y.split(/({[^{}]*})/);if(s[s.length-1].indexOf("}")==-1){s.pop()}var u=[];var q=false;var z;var w=0;var x;var v=0;while(v<s.length){if(v%2==0){var r=a.trim(s[v]);if(q){if(r.indexOf("}")!=-1){r=r.substr(1);s[v]=r;x=s.splice(w,v-w);x.shift();x.unshift(z[1]);u[u.length-1].attributes=o(x.join(""));q=false;v=w;continue}}else{if(r.indexOf("{")!=-1){z=r.split("{");r=a.trim(z[0]);q=true;w=v}if(r!=""){u.push({selector:r})}}}else{if(!q){u[u.length-1].attributes=m(s[v].substr(1,s[v].length-2))}}v++}return u}function f(q){q=q.replace(/\/\*((?:[^\*]|\*[^\/])*)\*\//g,"");q=q.replace(/\n/g,"");q=q.replace(/\r/g,"");q=q.replace(/\@import[^;]*;/g,"");return q}function l(q){if(a.isArray(q)){return{}}var r={};a.each(q,function(u,t){var s=k(u);if(s){r[s]=t}var v=j(u,t);if(v){r[u]=v}});return r}function k(q){if(q in p){for(prefix in p[q]){if(a.isFunction(p[q][prefix])){return p[q][prefix](q)}else{if(b==p[q][prefix]||!b){return"-"+p[q][prefix]+"-"+q}}}}return false}function j(r,q){if(b=="moz"){if(q.indexOf("calc")==0){return"-moz-"+q}if(parseInt(a.browser.version.substr(0,1))<4){if(r=="background-clip"||r=="background-origin"){if(q=="padding-box"){return"padding"}else{if(q=="border-box"){return"border"}else{if(q=="content-box"){return"content"}}}}}}return false}function g(q){if(b=="moz"){q=q.replace("::selection","::-moz-selection")}else{if(b=="webkit"){q=q.replace("@keyframes","@-webkit-keyframes")}}return q}function c(r,s){s=f(s);var t=o(s);var q=[];a.each(t,function(u,w){if(w.attributes){var v=l(w.attributes);if(!a.isEmptyObject(v)){q.push({selector:g(w.selector),attributes:v})}else{if(g(w.selector)!=w.selector){q.push({selector:g(w.selector),attributes:w.attributes})}}}});r.addClass("css-finalize-read");if(q.length>0){d(r,q)}}if(!(e instanceof jQuery)){e=a(e)}e.each(function(q,r){var t=a(this);if(t.hasClass("css-finalize-read")||t.hasClass("css-finalized")){return true}if(this.tagName=="LINK"&&t.attr("rel")=="stylesheet"){try{a("<div />").load(this.href,function(u){c(t,u)})}catch(s){}}else{c(t,t.html())}});function d(q,r){q.after('<style class="css-finalized">'+i(r)+"</style>")}if(a().jquery=="1.4.3"){for(property in p){if((newProperty=k(property))!==false){n(property,newProperty)}}}function n(r,q){a.cssHooks[a.camelCase(r)]={get:function(u,t,s){return u.style[a.camelCase(q)]},set:function(s,t){s.style[a.camelCase(q)]=t}}}};a(function(){a.cssFinalize("style, link")})})(jQuery);

