/*
* @Name CSS3 Selectors
* @Utility Adds function for many CSS3 Selectors
*/
/*------------------------------------------------------------------------------
Function:       eCSStender.css3-selectors.js
Author:         Aaron Gustafson (aaron at easy-designs dot net)
Creation Date:  2009-09-17
Version:        0.1
Homepage:       http://github.com/easy-designs/eCSStender.css3-selectors.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(){var a=eCSStender.methods.findBySelector;if(!(a instanceof Function)){throw ("eCSStender.methods.findBySelector is not defined. eCSStender.css3-selectors.js is quitting.");return}eCSStender.register({selector:/\.\S+?\.\S+/,test:function(){var c=document.createElement("div"),b=document.createElement("p");b.className="foo";c.appendChild(b);return(eCSStender.isSupported("selector","div p.bar.foo",c,b))}},"*",function(e,n,o,c){var d=e.replace(/.*?((?:\.\S+?)+)/,"$1"),b,m,h,l,g,f;d=d.split(".");d.shift();b=d.pop();m=eCSStender.lookup({selector:new RegExp("."+b),specificity:c,media:o},"*");for(g=0;g<m.length;g++){h=a(m[g]["selector"]);for(f=0;f<h.length;f++){eCSStender.applyWeightedStyle(h[f],m[g]["properties"],m[g]["specificity"])}}});eCSStender.register({selector:/\[.*\]/,test:function(){var c=document.createElement("div"),b=document.createElement("p");b.setAttribute("title","a b-c");c.appendChild(b);return(!eCSStender.isSupported("selector","div p[title]",c,b)||!eCSStender.isSupported("selector",'div p[title="a b-c"]',c,b)||!eCSStender.isSupported("selector","div p[title~=a]",c,b)||!eCSStender.isSupported("selector","div p[title^=a]",c,b)||!eCSStender.isSupported("selector","div p[title$=c]",c,b)||!eCSStender.isSupported("selector","div p[title|=c]",c,b))}},"*",function(b,g,c,f){if(c!="screen"){return}var e,d=a(b);for(e=0;e<d.length;e++){eCSStender.applyWeightedStyle(d[e],g,f)}});eCSStender.register({selector:/:nth-child\(\s*(?:even|odd|[+-]?\d+|[+-]?\d*?n(?:\s*[+-]\s*\d*?)?)\s*\)/,test:function(){var c=document.createElement("div"),b=document.createElement("p");c.appendChild(b);return(!eCSStender.isSupported("selector","div p:nth-child( odd )",c,b))}},"*",function(f,j,l,e){f=f.replace(/(child\()\s*/g,"$1").replace(/\s*(\+)\s*/g,"$1").replace(/\s*(\))/g,"$1");var k=f+" {",c,g,h,b=document.createElement("div"),d=document.createElement("p");b.appendChild(d);if((eCSStender.isSupported("selector","p:nth-child(odd)",b,d)&&!eCSStender.isSupported("selector","p:nth-child(2n+1)",b,d)&&f.match(/:nth-child\(\s*(?:even|odd)\s*\)/)!=null)||eCSStender.isSupported("selector","p:nth-child(2n+1)",b,d)){for(c in j){if(eCSStender.isInheritedProperty(j,c)){continue}k+=c+": "+j[c]+"; "}k+="} ";eCSStender.embedCSS(k,l)}else{g=a(f);for(h=0;h<g.length;h++){eCSStender.applyWeightedStyle(g[h],j,e)}}});eCSStender.register({selector:/:nth-last-child\(\s*(?:even|odd|[+-]?\d*?|[+-]?\d*?n(?:\s*[+-]\s*\d*?)?)\s*\)/,test:function(){var c=document.createElement("div"),b=document.createElement("p");c.appendChild(b);return(!eCSStender.isSupported("selector","div p:nth-last-child( odd )",c,b))}},"*",function(f,j,l,e){f=f.replace(/(child\()\s*/g,"$1").replace(/\s*(\+)\s*/g,"$1").replace(/\s*(\))/g,"$1");var k=f+" {",c,g,h,b=document.createElement("div"),d=document.createElement("p");b.appendChild(d);if((eCSStender.isSupported("selector","p:nth-last-child(odd)",b,d)&&!eCSStender.isSupported("selector","p:nth-last-child(2n+1)",b,d)&&f.match(/:nth-last-child\(\s*(?:even|odd)\s*\)/)!=null)||eCSStender.isSupported("selector","p:nth-last-child(2n+1)",b,d)){for(c in j){if(eCSStender.isInheritedProperty(j,c)){continue}k+=c+": "+j[c]+"; "}k+="} ";eCSStender.embedCSS(k,l)}else{g=a(f);for(h=0;h<g.length;h++){eCSStender.applyWeightedStyle(g[h],j,e)}}});eCSStender.register({selector:/:nth-(?:last-)?of-type\(\s*(?:even|odd|[+-]?\d*?|[+-]?\d*?n(?:\s*[+-]\s*\d*?)?)\s*\)/,test:function(){var c=document.createElement("div"),b=document.createElement("p");c.appendChild(b);return(!eCSStender.isSupported("selector","div p:nth-of-type( odd )",c,b))}},"*",function(b,g,c,f){b=b.replace(/(type\()\s*/g,"$1").replace(/\s*(\+)\s*/g,"$1").replace(/\s*(\))/g,"$1");var e,d=a(b);for(e=0;e<d.length;e++){eCSStender.applyWeightedStyle(d[e],g,f)}});eCSStender.register({selector:/:first-child/,test:function(){var c=document.createElement("div"),b=document.createElement("p");c.appendChild(b);return(!eCSStender.isSupported("selector","div :first-child",c,b))}},"*",function(b,g,c,f){var e,d=a(b);for(e=0;e<d.length;e++){eCSStender.applyWeightedStyle(d[e],g,f)}});eCSStender.register({selector:/:(?:last|only)-child/,test:function(){var c=document.createElement("div"),b=document.createElement("p");c.appendChild(b);return(!eCSStender.isSupported("selector","div :last-child",c,b)||!eCSStender.isSupported("selector","div :only-child",c,b))}},"*",function(b,g,c,f){var e,d=a(b);for(e=0;e<d.length;e++){eCSStender.applyWeightedStyle(d[e],g,f)}});eCSStender.register({selector:/:empty/,test:function(){var c=document.createElement("div"),b=document.createElement("p");c.appendChild(b);return(!eCSStender.isSupported("selector","div p:empty",c,b))}},"*",function(b,g,c,f){var e,d=a(b);for(e=0;e<d.length;e++){eCSStender.applyWeightedStyle(d[e],g,f)}});eCSStender.register({selector:/:lang\(.*\)/,test:function(){var c=document.createElement("div"),b=document.createElement("p");b.setAttribute("lang","en");c.appendChild(b);return(!eCSStender.isSupported("selector","div p:lang(en)",c,b))}},"*",function(b,g,c,f){b=b.replace(/:lang\(([^)]*)\)/,"[lang=$1]");var e,d=a(b);for(e=0;e<d.length;e++){eCSStender.applyWeightedStyle(d[e],g,f)}});eCSStender.register({selector:/:(?:(?:en|dis)abled|checked)/,test:function(){var f=document.createElement("div"),b,e,d,c;f.innerHTML='<input type="text" /><input type="text" disabled="disabled" /><input type="checkbox" checked="checked" />';b=f.getElementsByTagName("input");e=b[0];d=b[1];c=b[2];return(!eCSStender.isSupported("selector","div :enabled",f,e)||!eCSStender.isSupported("selector","div :disabled",f,d)||!eCSStender.isSupported("selector","div :checked",f,c))}},"*",function(b,g,c,f){var e,d=a(b);for(e=0;e<d.length;e++){eCSStender.applyWeightedStyle(d[e],g,f)}});eCSStender.register({selector:/:not\([^)]*\)/,test:function(){var d=document.createElement("div"),c=document.createElement("p"),b=c.cloneNode(true);c.setAttribute("id","no");return(!eCSStender.isSupported("selector","div p:not(#no)",d,b))}},"*",function(b,g,c,f){var e,d=a(b);for(e=0;e<d.length;e++){eCSStender.applyWeightedStyle(d[e],g,f)}});eCSStender.register({selector:function(){return(this.match(/\+/)&&!this.match(/:nth-(?:last-)?(?:child|of-type)\(\s*(?:even|odd|[+-]?\d*?|[+-]?\d*?n(?:\s*[+-]\s*\d*?)?)\s*\)/))},test:function(){var d=document.createElement("div"),c=document.createElement("p"),b=c.cloneNode(true);return(!eCSStender.isSupported("selector","div p + p",d,b))}},"*",function(b,g,c,f){var e,d=a(b);for(e=0;e<d.length;e++){eCSStender.applyWeightedStyle(d[e],g,f)}})})();