1/******************************************************************************* 2 CSS0.99.1B :: CSSUtilities 3 ------------------------------------------------------------------------------- 4 Copyright (c) 2010 James Edwards (brothercake) <[email protected]> 5 BSD License See license.txt for licensing information 6 Info/Docs http://www.brothercake.com/site/resources/scripts/cssutilities/ 7 ------------------------------------------------------------------------------- 8 Credits and thanks: 9 ------------------------------------------------------------------------------- 10 Henrik Lindqvist [Selector.js] http://llamalab.com/js/selector/ 11 Dean Edwards [technical help] http://dean.edwards.name/ 12 Stuart Langridge [technical help] http://www.kryogenix.org/ 13 ------------------------------------------------------------------------------- 14 Nevma: some bits have been tampered with, search code for "Nevma". 15 ------------------------------------------------------------------------------- 16*******************************************************************************/ 17 18function CSSUtilities(){}(function(){function dispatchReturn(onfinished,wrapper){if(THIS._allready===BOOLEAN_TRUE||onfinished!=NULL_VALUE){if(onfinished==NULL_VALUE)return wrapper();if(THIS._allready===BOOLEAN_TRUE)onfinished(wrapper());else var readywaiter=window.setInterval(function(){THIS._allready===BOOLEAN_TRUE&&(window.clearInterval(readywaiter),onfinished(wrapper()))},WATCHER_SPEED_TIMER)}}function createAuthorRulesData(oncomplete){function continuation(){function stage1_checkStyleSheetForDataWrapper(cdcount){stage2_checkStyleSheetForData(THIS._cssdata[cdcount],function(cssdata){THIS._cssdata[cdcount]=cssdata,cdcount+1<THIS._cssdata.length?stage1_checkStyleSheetForDataWrapper(cdcount+1):stage3_checkStyleSheetForImportsWrapper()})}function stage2_checkStyleSheetForData(cssdata,oncomplete){cssdata.href==NULL_VALUE?oncomplete(cssdata):requestStyleSheet(cssdata.href,function(dataobject){dataobject.message!=NULL_VALUE?(cssdata.message=dataobject.message,cssdata.stylenode=NULL_VALUE,(cssdata.message==ERROR_NOT_CSS||/^[1-9]{1,3}/.test(cssdata.message))&&(cssdata.media=MEDIA_NONE)):cssdata.text=strainStyleSheet(dataobject.text,BOOLEAN_FALSE),oncomplete(cssdata)})}function stage3_checkStyleSheetForImportsWrapper(){function stage4_checkStyleSheetForImports(cdindex){function localcallback(increment){cdindex+1<THIS._cssdata.length?stage4_checkStyleSheetForImports(cdindex+increment):stage7_processStyleSheetsData()}function stage5_checkImportForDataWrapper(impindex){stage6_checkImportForData(cdindex,impindex,importsheets[impindex],function(cssdata,cdnumber,impnumber){THIS._cssdata.splice(cdindex+impnumber,0,cssdata),impnumber+1<importsheets.length?stage5_checkImportForDataWrapper(impnumber+1):localcallback(0)})}if(THIS._cssdata[cdindex].tested==BOOLEAN_TRUE)localcallback(1);else{var importsheets=extractImportStatements(THIS._cssdata[cdindex].text);THIS._cssdata[cdindex].tested=BOOLEAN_TRUE,THIS._cssdata[cdindex].ssid=THIS.ssidcounter++,importsheets.length>0?stage5_checkImportForDataWrapper(0):localcallback(1)}}stage4_checkStyleSheetForImports(0)}function stage6_checkImportForData(cdcount,impcount,importobj,oncomplete){function finalizedata(fdata){fdata.message!=NULL_VALUE?(cssdata.message=fdata.message,cssdata.stylenode=NULL_VALUE,(cssdata.message==ERROR_NOT_CSS||/^[1-9]{1,3}.*$/.test(cssdata.message))&&(cssdata.media=MEDIA_NONE)):cssdata.text=strainStyleSheet(fdata.text,BOOLEAN_FALSE),oncomplete(cssdata,cdcount,impcount)}var cssdata={tested:BOOLEAN_FALSE,owner:"@import",media:MEDIA_ALL,stylenode:THIS._cssdata[cdcount].stylenode,href:importobj.href,text:""};cssdata.media=importobj.media;for(var n=cdcount,parent=THIS._cssdata[n];parent.href==cssdata.href;)parent=THIS._cssdata[n--];context=parent.media,cssdata.xmedia=importobj.hasownmedia?importobj.media:MEDIA_ALL,cssdata.media=contextualizeMediaTypes(context,cssdata.media),arrayContains(THIS._cssdata,importobj.href,"href")!=NULL_VALUE?finalizedata({text:"",message:MESSAGE_DUPLICATE}):requestStyleSheet(importobj.href,finalizedata)}function stage7_processStyleSheetsData(){for(var i=0;i<THIS._cssdata.length;i++){if(THIS._cssdata[i].href){var arycontains=arrayContains(THIS._stylesheets,THIS._cssdata[i].href,"href");if(arycontains!=NULL_VALUE&&arycontains.message!=MESSAGE_DUPLICATE){THIS._stylesheets.push({ssid:THIS._cssdata[i].ssid,href:THIS._cssdata[i].href,owner:THIS._cssdata[i].owner,media:THIS._cssdata[i].media,xmedia:THIS._cssdata[i].xmedia,stylenode:NULL_VALUE,rules:0,message:MESSAGE_DUPLICATE}),THIS._cssdata[i].stylenode&&(THIS._cssdata[i].stylenode.disabled=BOOLEAN_TRUE);continue}}if(typeof THIS._cssdata[i].message==TYPE_UNDEFINED){var rulecount=parseStyleSheetCSSText(THIS._cssdata[i]);THIS._stylesheets.push({ssid:THIS._cssdata[i].ssid,href:THIS._cssdata[i].href,owner:THIS._cssdata[i].owner,media:THIS._cssdata[i].media,xmedia:THIS._cssdata[i].xmedia,stylenode:THIS._cssdata[i].stylenode,rules:rulecount,message:MESSAGE_OK})}else THIS._stylesheets.push({ssid:THIS._cssdata[i].ssid,href:THIS._cssdata[i].href,owner:THIS._cssdata[i].owner,media:THIS._cssdata[i].media,xmedia:THIS._cssdata[i].xmedia,stylenode:THIS._cssdata[i].stylenode,rules:0,message:THIS._cssdata[i].message})}THIS._cssdata=NULL_VALUE,delete THIS._cssdata,THIS._stylesheets.sort(function(a,b){return a.ssid-b.ssid}),THIS.ssidcounter=NULL_VALUE,delete THIS.ssidcounter,watch===BOOLEAN_TRUE&&watchStyleSheets(),typeof oncomplete==TYPE_FUNCTION&&oncomplete()}for(var stylenodes=getStyleSheetNodes(),i=0;i<stylenodes.length;i++)processStyleNode(stylenodes[i],7==stylenodes[i].nodeType?stylenodes[i].target.toLowerCase():stylenodes[i].nodeName.toLowerCase());0==THIS._cssdata.length?stage7_processStyleSheetsData():stage1_checkStyleSheetForDataWrapper(0)}THIS._cssdata=[],IEXPLORER&&getTheseElements("style").length>0,continuation()}function getStyleSheetNodes(){for(var stylenodes=[],kids=page.childNodes,i=0;i<kids.length;i++)7==kids[i].nodeType&&"xml-stylesheet"==kids[i].target.toLowerCase()&&stylenodes.push(kids[i]);for(var allnodes=getTheseElements("*"),i=0;i<allnodes.length;i++)(/link/i.test(allnodes[i].nodeName)&&/stylesheet/i.test(allnodes[i].getAttribute("rel"))||/style/i.test(allnodes[i].nodeName))&&stylenodes.push(allnodes[i]);return stylenodes}function processStyleNode(node,owner){var cssdata={tested:BOOLEAN_FALSE,owner:owner,media:MEDIA_ALL,stylenode:node,href:NULL_VALUE,text:""};
18if(/xml\-stylesheet/.test(owner))for(var pseudoattrs={},nodedata=node.data.match(/([a-z]+=[\'\"][^\'\"]*[\'\"])/gm),i=0;i<nodedata.length;i++)nodedata[i]=nodedata[i].split("="),pseudoattrs[nodedata[i][0]]=nodedata[i][1].substr(1,nodedata[i][1].length-2);if((SAFARI||KONQUEROR||WEBKIT)&&!/xml\-stylesheet/.test(owner))var isdisabled=node.disabled;else var disnode=node[typeof node.styleSheet!=TYPE_UNDEFINED?"styleSheet":"sheet"],isdisabled=disnode==NULL_VALUE?BOOLEAN_TRUE:disnode.disabled;if(OPERA&&isdisabled&&node.sheet.media.length>0){var realmedia=node.sheet.media.mediaText;node.sheet.media.mediaText=THIS._viewmedia,isdisabled=node.sheet.disabled,node.sheet.media.mediaText=realmedia}if(watch!==NULL_VALUE&&isdisabled&&(cssdata.message=MESSAGE_DISABLED),/xml\-stylesheet/.test(owner))cssdata.href=qualifyHREF(pseudoattrs.href,base);else if(/link/i.test(owner))cssdata.href=qualifyHREF(node.getAttribute("href",2),base);else if(!isdisabled||watch===NULL_VALUE)if(IEXPLORER)typeof node.__css==TYPE_UNDEFINED?cssdata.message=ERROR_NETWORK:cssdata.text+=strainStyleSheet(node.__css,BOOLEAN_FALSE);else{for(var nodedata="",kids=node.childNodes,i=0;i<kids.length;i++)switch(kids[i].nodeType){case 3:nodedata+=kids[i].nodeValue;break;case 4:nodedata+="<![CDATA["+kids[i].nodeValue+"]]>";break;case 8:nodedata+="<!--"+kids[i].nodeValue+"-->"}cssdata.text+=strainStyleSheet(nodedata,BOOLEAN_FALSE)}/xml\-stylesheet/.test(owner)?cssdata.media=typeof pseudoattrs.media!=TYPE_UNDEFINED?pseudoattrs.media:MEDIA_ALL:cssdata.media=node.getAttribute("media")?node.getAttribute("media"):MEDIA_ALL,cssdata.media=cssdata.media.split(/,\s*/).join(", "),cssdata.xmedia=cssdata.media,THIS._cssdata.push(cssdata)}function requestStyleSheet(href,oncomplete){var requestdata={text:"",message:NULL_VALUE};ajaxload(async,href,function(responsetext,contype){if(typeof contype!=TYPE_STRING||""==trim(contype)||/^(text\/css)/.test(contype))requestdata.text=responsetext;else{if(/^(text\/html)/.test(contype)){var matches=responsetext.match(/<title>([1-9]{1,3}[^<]+)<\/title>/i);matches&&matches.length>=2&&(requestdata.message=matches[1])}requestdata.message==NULL_VALUE&&(requestdata.message=ERROR_NOT_CSS)}oncomplete(requestdata)},function(statustext){requestdata.message=statustext,oncomplete(requestdata)})}function extractImportStatements(styletext){var importsheets=[],importreg=/@import\s*(?:url\s*\(\s*[\'\"]?|[\'\"])([^\'\"\)]+)(?:[\'\"]|[\'\"]?\s*\))([^;]*)(;|$)/gi,matches=styletext.match(importreg);if(matches)for(var i=0;i<matches.length;i++){var href=qualifyHREF(matches[i].replace(importreg,"$1"),base),media=trim(trim(matches[i].replace(importreg,"$2")).replace(/^\)/,"")),hasownmedia=BOOLEAN_TRUE;media||(hasownmedia=BOOLEAN_FALSE,media=MEDIA_ALL),importsheets.push({href:href,media:media,hasownmedia:hasownmedia})}return importsheets}function strainStyleSheet(styletext,importsheets){if(styletext=styletext.replace(/(\/\*([^*]|(\*+([^*\/])))*\*+\/)/gm,""),THIS._isXML||(styletext=styletext.replace(/(<\!\[CDATA\[([^\]]|(\]+([^>])))*\]+>)/gm,"")),THIS._isXML&&!(SAFARI||KONQUEROR||WEBKIT)&&(styletext=styletext.replace(/(<\!\-\-([^\-]|(\-+([^>])))*\-+>)/gm,"")),styletext=styletext.replace(/[\t]+/g," ").replace(/[ ][ ]/g," "),styletext=styletext.replace(/[\r\n]/g," "),styletext=styletext.replace(/@(charset|namespace)[^;]+;/gim,""),typeof importsheets!=TYPE_UNDEFINED&&importsheets==BOOLEAN_TRUE)styletext=styletext.replace(/@import[^;]+;/gim,"");else if(/@import[^;]+;/i.test(styletext))for(var cssdata=styletext.replace(/(@import[^;]+;)/gim,"{SPLIT}$1{SPLIT}").split("{SPLIT}"),styletext="",nomoreimports=NULL_VALUE,i=0;i<cssdata.length;i++)""!=trim(cssdata[i])&&(/@import[^;]+;/i.test(cssdata[i])?(nomoreimports===NULL_VALUE&&(nomoreimports=BOOLEAN_FALSE),nomoreimports===BOOLEAN_FALSE&&(styletext+=cssdata[i])):(nomoreimports=BOOLEAN_TRUE,styletext+=cssdata[i]));return styletext=styletext.replace(/@(font\-face|page)[^\}]+\}/gim,""),styletext=styletext.replace(/(<\!\-\-)|(\-\->)|(<\!\[CDATA\[)|(\]\]>)/gm,""),trim(styletext)}function parseStyleSheetCSSText(cssdata){var gencontent=cssdata.text.match(/(content:[^;]+;)/gim);
18if(gencontent)for(var g=0;g<gencontent.length;g++)cssdata.text=cssdata.text.replace(gencontent[g],"[G"+g+"]");cssdata.text=trim(strainStyleSheet(cssdata.text,BOOLEAN_TRUE)).split("}");for(var i=0;i<cssdata.text.length;i++){cssdata.text[i]=trim(cssdata.text[i]).split("{");for(var j=0;j<cssdata.text[i].length;j++)cssdata.text[i][j]=trim(cssdata.text[i][j])}if(gencontent)for(var g=0;g<gencontent.length;g++)for(var i=0;i<cssdata.text.length;i++)for(var j=0;j<cssdata.text[i].length;j++)cssdata.text[i][j]=cssdata.text[i][j].replace("[G"+g+"]",gencontent[g]);for(var rulecount=0,currentmedia=cssdata.media,currentxmedia=cssdata.xmedia,currentowner=cssdata.owner,i=0;i<cssdata.text.length;i++)if(2==cssdata.text[i].length)THIS._cssRules.push({selector:cssdata.text[i][0],css:cssdata.text[i][1],media:currentmedia,xmedia:currentxmedia,owner:currentowner.toLowerCase(),href:cssdata.href,ssid:cssdata.ssid}),rulecount++;else if(3==cssdata.text[i].length){currentmedia=trim(cssdata.text[i][0].replace("@media","")).toLowerCase(),currentowner="@media",currentxmedia=currentmedia;var context=cssdata.media;""==context&&(context=MEDIA_ALL),currentmedia=contextualizeMediaTypes(context,currentmedia),THIS._cssRules.push({selector:cssdata.text[i][1],css:cssdata.text[i][2],media:currentmedia,xmedia:currentxmedia,owner:currentowner,href:cssdata.href,ssid:cssdata.ssid}),rulecount++}else 1==cssdata.text[i].length&&(currentmedia=cssdata.media,currentxmedia=cssdata.xmedia,currentowner=cssdata.owner);return rulecount}function createBrowserRulesData(oncomplete){for(var stylesheets=arrayifize(page.styleSheets),i=0;i<stylesheets.length;i++)if(stylesheets[i].__ssid=THIS.ssidcounter++,typeof stylesheets[i].ownerNode!=TYPE_UNDEFINED)if(SAFARI3&&/xml\-stylesheet/.test(stylesheets[i].ownerNode.nodeName))THIS._stylesheets.push({ssid:stylesheets[i].__ssid,href:qualifyHREF(stylesheets[i].href,base),owner:"xml-stylesheet",media:MESSAGE_UNKNOWN,stylesheet:NULL_VALUE,rules:0,message:MESSAGE_UNSUPPORTED_TYPE}),stylesheets.splice(i,1),i--;else try{parseStyleSheet(stylesheets[i],stylesheets[i].ownerNode.nodeName.toLowerCase(),stylesheets[i].media.length>0?trim(stylesheets[i].media.mediaText):MEDIA_ALL)}catch(err){THIS._stylesheets.push({ssid:stylesheets[i].__ssid,href:MESSAGE_UNKNOWN,owner:MESSAGE_UNKNOWN,media:MESSAGE_UNKNOWN,stylesheet:NULL_VALUE,rules:0,message:ERROR_UNSPECIFIED}),stylesheets.splice(i,1),i--}else typeof stylesheets[i].owningElement!=TYPE_UNDEFINED&&parseIEStyleSheet(stylesheets[i],stylesheets[i].owningElement.nodeName.toLowerCase(),""!=trim(stylesheets[i].media)?trim(stylesheets[i].media):MEDIA_ALL);THIS._stylesheets.sort(function(a,b){return a.ssid-b.ssid}),THIS.ssidcounter=NULL_VALUE,delete THIS.ssidcounter,watch==BOOLEAN_TRUE&&watchStyleSheets(),typeof oncomplete==TYPE_FUNCTION&&oncomplete()}function parseStyleSheet(sheet,owner,media){if(sheet.href&&sheet.href!=base){var testhref=qualifyHREF(sheet.href,base);if(arrayContains(THIS._stylesheets,testhref,"href")!=NULL_VALUE)return THIS._stylesheets.push({ssid:sheet.__ssid,href:testhref,owner:owner,media:media,stylesheet:NULL_VALUE,rules:0,message:MESSAGE_DUPLICATE}),void(sheet.disabled=BOOLEAN_TRUE)}try{var isdisabled=sheet.disabled;if(OPERA&&isdisabled&&sheet.media.length>0){var realmedia=sheet.media.mediaText;sheet.media.mediaText=THIS._viewmedia,isdisabled=sheet.disabled,sheet.media.mediaText=realmedia}if(isdisabled)rulecount=0,message=MESSAGE_DISABLED;else{for(var rules=sheet.cssRules,rulecount=0,i=0;i<rules.length;i++)if(1==rules.item(i).type)rulecount++;else if(4==rules.item(i).type)for(var subrules=rules.item(i).cssRules,j=0;j<subrules.length;j++)1==subrules.item(j).type&&rulecount++;var message=MESSAGE_OK}THIS._stylesheets.push({ssid:sheet.__ssid,href:sheet.href&&sheet.href!=base?qualifyHREF(sheet.href,base):NULL_VALUE,owner:owner,media:media,stylesheet:sheet,rules:rulecount,message:message}),isdisabled||parseCSSRules(sheet,sheet.cssRules,owner,media)}catch(err){THIS._stylesheets.push({ssid:sheet.__ssid,href:sheet.href&&sheet.href!=base?qualifyHREF(sheet.href,base):NULL_VALUE,owner:owner,media:media,stylesheet:NULL_VALUE,rules:0,message:ERROR_SECURITY})}}function parseCSSRules(sheet,rules,owner,media){for(i=0;i<rules.length;i++)if(rule=rules.item(i),3==rule.type){if(media=rule.media.mediaText,""==media)try{media=rule.parentStyleSheet.media.mediaText}catch(err){media=rule.parentStyleSheet.ownerRule.media.mediaText}""==media&&(media=MEDIA_ALL),media=media.toLowerCase();for(var parent=rule.parentStyleSheet;parent;){try{var context=parent.media.mediaText}catch(err){context=parent.ownerRule.media.mediaText}""==context&&(context=MEDIA_ALL),media=contextualizeMediaTypes(context,media),parent=(SAFARI||KONQUEROR||WEBKIT)&&!parent.parentStyleSheet&&parent.ownerRule?parent.ownerRule.parentStyleSheet:parent.parentStyleSheet}rule.styleSheet.__ssid=THIS.ssidcounter++,parseStyleSheet(rule.styleSheet,"@import",media)}for(var i=0;i<rules.length;i++){var rule=rules.item(i);if(1==rule.type){/^(xml\-stylesheet|link|(([a-z]+:)?style))$/i.test(owner)&&(media=rule.parentStyleSheet.media.mediaText,""==media&&(media=MEDIA_ALL),media=media.toLowerCase());var styletext=rule.style.cssText.replace(/[\r\n]/g," ");styletext=styletext.split(";");for(var c=0;c<styletext.length;c++){for(styletext[c]=styletext[c].split(":");styletext[c].length>2;)styletext[c][1]+=":"+styletext[c].pop();1!=styletext[c].length?("important"!=rule.style.getPropertyPriority(trim(styletext[c][0]))||IMPORTANT_RULE.test(styletext[c][1])||
18(styletext[c][1]+=" !important"),styletext[c]=styletext[c].join(":")):(styletext.splice(c,1),c--)}styletext=styletext.join(";"),THIS._cssRules.push({selector:rule.selectorText,css:styletext,media:media,owner:owner,href:sheet.href==NULL_VALUE?NULL_VALUE:qualifyHREF(sheet.href,base),ssid:sheet.__ssid})}}for(i=0;i<rules.length;i++)if(rule=rules.item(i),4==rule.type){media=rule.media.mediaText,""==media&&(media=rule.parentStyleSheet.media.mediaText),""==media&&(media=MEDIA_ALL),media=media.toLowerCase();for(var parent=rule.parentStyleSheet;parent;){try{var context=parent.media.mediaText}catch(err){context=parent.ownerRule.media.mediaText}""==context&&(context=MEDIA_ALL),media=contextualizeMediaTypes(context,media),parent=(SAFARI||KONQUEROR||WEBKIT)&&!parent.parentStyleSheet&&parent.ownerRule?parent.ownerRule.parentStyleSheet:parent.parentStyleSheet}parseCSSRules(sheet,rule.cssRules,"@media",media)}}function parseIEStyleSheet(sheet,owner,media,href){if(sheet.href){var testhref=qualifyHREF(sheet.href,base);if(arrayContains(THIS._stylesheets,testhref,"href")!=NULL_VALUE)return THIS._stylesheets.push({ssid:sheet.__ssid,href:testhref,owner:owner,media:media,stylesheet:NULL_VALUE,rules:0,message:MESSAGE_DUPLICATE}),void(sheet.disabled=BOOLEAN_TRUE)}var importsheets=[],isdisabled=sheet.disabled;if(!isdisabled)for(var i=0;i<sheet.imports.length;i++)if(0!=sheet.imports[i].rules.length){media=trim(sheet.media),""==media&&(media=MEDIA_ALL);var ihref=qualifyHREF(sheet.imports[i].href,base);importsheets.push({sheet:sheet.imports[i],owner:"@import",media:media,href:ihref})}if(importsheets.length>0)for(var i=0;i<importsheets.length;i++)importsheets[i].sheet.__ssid=THIS.ssidcounter++,parseIEStyleSheet(importsheets[i].sheet,importsheets[i].owner,importsheets[i].media,importsheets[i].href);try{if(isdisabled)message=MESSAGE_DISABLED;else{var styletext=sheet.cssText;styletext=styletext.replace(/@(import|charset|namespace)[^;]+;/gim,""),styletext=styletext.replace(/@(font\-face|page)[^\}]+\}/gim,"");var gencontent=styletext.match(/(content\s*:\s*[\'\"].*(;|$))/gim);if(gencontent)for(var g=0;g<gencontent.length;g++)styletext=styletext.replace(gencontent[g],"[G"+g+"]");styletext=trim(styletext).split("}");for(var i=0;i<styletext.length;i++){styletext[i]=trim(styletext[i]).split("{");for(var j=0;j<styletext[i].length;j++)styletext[i][j]=trim(styletext[i][j])}if(gencontent)for(var g=0;g<gencontent.length;g++)for(var i=0;i<styletext.length;i++)for(var j=0;j<styletext[i].length;j++)styletext[i][j]=styletext[i][j].replace("[G"+g+"]",gencontent[g]);typeof href==TYPE_UNDEFINED&&(href=sheet.href==NULL_VALUE||""==sheet.href?NULL_VALUE:qualifyHREF(sheet.href,base));var rules=[],currentmedia=sheet.media;""==currentmedia&&(currentmedia=MEDIA_ALL);for(var currentowner=owner,i=0;i<styletext.length;i++)if(2==styletext[i].length)rules.push({selector:styletext[i][0],css:styletext[i][1],media:currentmedia,owner:currentowner,href:href,ssid:sheet.__ssid});else if(3==styletext[i].length){currentmedia=trim(styletext[i][0].replace("@media","")).toLowerCase(),currentowner="@media";var context=sheet.media;""==context&&(context=MEDIA_ALL),currentmedia=contextualizeMediaTypes(context,currentmedia),rules.push({selector:styletext[i][1],css:styletext[i][2],media:currentmedia,owner:currentowner,href:href,ssid:sheet.__ssid})}else 1==styletext[i].length&&(currentmedia=sheet.media,""==currentmedia&&(currentmedia=MEDIA_ALL),currentowner=owner);var message=MESSAGE_OK}if(!isdisabled)var rulecount=parseIECSSRules(rules);THIS._stylesheets.push({ssid:sheet.__ssid,href:sheet.href?qualifyHREF(sheet.href,base):NULL_VALUE,owner:owner,media:media,stylesheet:sheet,rules:isdisabled?0:rulecount,message:message})}catch(err){THIS._stylesheets.push({ssid:sheet.__ssid,href:sheet.href?qualifyHREF(sheet.href,base):NULL_VALUE,owner:owner,media:media,stylesheet:NULL_VALUE,rules:0,message:ERROR_SECURITY})}}function parseIECSSRules(rules){for(var rulecount=0,i=0;i<rules.length;i++)""!=rules[i].selector&&"UNKNOWN"!=rules[i].selector&&rules[i].selector.indexOf(":unknown")==-1&&(THIS._cssRules.push({selector:lowercaseIETypeSelectors(rules[i].selector),css:lowercaseIEPropertyNames(rules[i].css),media:rules[i].media,owner:rules[i].owner,href:rules[i].href,ssid:rules[i].ssid}),rulecount++);return rulecount}function getCSSRules(element,media,accept,altstates,rules,inherited,ancestors){if
18(accept=processAcceptArgument(accept),typeof rules!=TYPE_UNDEFINED&&rules!=NULL_VALUE||(rules=[]),typeof inherited!=TYPE_UNDEFINED&&inherited!=NULL_VALUE||(inherited=BOOLEAN_FALSE),typeof ancestors==TYPE_UNDEFINED||ancestors==NULL_VALUE){if(ancestors=[element],attributes==BOOLEAN_TRUE&&element.getAttribute("style")){var stylerule=createStyleAttributeRule(element);stylerule!=NULL_VALUE&&THIS._cssRules.push(stylerule)}}else ancestors.push(element);for(var i=0;i<THIS._cssRules.length;i++)if(mediaMatches(media,THIS._cssRules[i])){if("@style"==THIS._cssRules[i].owner&&element==ancestors[0])var nodes=[element],altstate=BOOLEAN_FALSE;else{if(altstates==BOOLEAN_TRUE){for(var altstate=BOOLEAN_TRUE,allnodes=getElementsBySelector(THIS._cssRules[i].selector),j=0;j<allnodes.length;j++)if(allnodes[j]==element){altstate=BOOLEAN_FALSE;break}}else altstate=BOOLEAN_FALSE;nodes=getElementsBySelector(altstates==BOOLEAN_TRUE?THIS._cssRules[i].selector.replace(REGEX_PSEUDO_CLASSES_EXCEPT_NOT,""):THIS._cssRules[i].selector)}if(nodes.length>0)for(var j=0;j<nodes.length;j++)if(nodes[j]==element){var inheritance=[];if(inherited)for(var a=ancestors.length-1;a>0;a--)inheritance.push(ancestors[a]);for(var ruleobj={selector:THIS._cssRules[i].selector,css:THIS._cssRules[i].css,index:i,specificity:[0,0,0,0],inheritance:inheritance,altstate:altstate},optionalprops=["media","xmedia","owner","ssid","href"],k=0;k<optionalprops.length;k++)"*"!=accept&&typeof accept[optionalprops[k]]==TYPE_UNDEFINED||typeof THIS._cssRules[i][optionalprops[k]]!=TYPE_UNDEFINED&&(ruleobj[optionalprops[k]]=THIS._cssRules[i][optionalprops[k]]);rules.push(ruleobj);break}}if(element.parentNode&&1==element.parentNode.nodeType)return getCSSRules(element.parentNode,media,accept,altstates,rules,BOOLEAN_TRUE,ancestors);if(0==rules.length)return rules;for(var i=0;i<rules.length;i++){for(var selectors=rules[i].selector.split(","),specs=[],j=0;j<selectors.length;j++)specs.push(rules[i].inheritance.length>0?[0,0,0,0]:getSelectorSpecificity(selectors[j]));specs.sort(function(a,b){return a[0]!==b[0]?b[0]-a[0]:a[1]!==b[1]?b[1]-a[1]:a[2]!==b[2]?b[2]-a[2]:b[3]-a[3]}),rules[i].specificity=specs[0]}if(rules.sort(function(a,b){return a.specificity.toString()===b.specificity.toString()?a.index===b.index?b.inheritance.length-a.inheritance.length:a.index-b.index:a.specificity[0]!==b.specificity[0]?a.specificity[0]-b.specificity[0]:a.specificity[1]!==b.specificity[1]?a.specificity[1]-b.specificity[1]:a.specificity[2]!==b.specificity[2]?a.specificity[2]-b.specificity[2]:a.specificity[3]-b.specificity[3]}),"*"!==accept&&typeof accept.properties==TYPE_UNDEFINED||(rules=addSortedProperties(rules,BOOLEAN_TRUE)),"*"!==accept)for(var i=0;i<rules.length;i++)for(var props=["selector","css","index","specificity","inheritance","altstate"],j=0;j<props.length;j++)typeof accept[props[j]]==TYPE_UNDEFINED&&(rules[i][props[j]]=NULL_VALUE,delete rules[i][props[j]]);return"@style"==THIS._cssRules[THIS._cssRules.length-1].owner&&THIS._cssRules.splice(THIS._cssRules.length-1,1),rules}function createStyleAttributeRule(element){if(IEXPLORER)try{var matches=element.outerHTML.split(">")[0].match(/.*style\s*=\s*\"([^\"]*)\".*/im),styletext=matches?lowercaseIEPropertyNames(matches[1]):""}catch(err){styletext=""}else styletext=element.getAttribute("style");if(""==styletext)return NULL_VALUE;var ruleobj={selector:"",css:styletext,media:MEDIA_ALL,owner:"@style",href:NULL_VALUE,ssid:1/0};return mode==MODE_AUTHOR&&(ruleobj.xmedia=ruleobj.media),ruleobj}function addSortedProperties(rules,dosort){for(var i=0;i<rules.length;i++){rules[i].properties=parsePropertyText(rules[i].css,{},typeof rules[i].inheritance!=TYPE_UNDEFINED&&rules[i].inheritance.length>0),rules[i].allproperties={};for(var j in rules[i].properties)rules[i].allproperties[j]={value:rules[i].properties[j].property,status:STATUS_ACTIVE};if(dosort)if(rules[i].altstate==BOOLEAN_TRUE)for(var ip in rules[i].allproperties)rules[i].allproperties.hasOwnProperty(ip)&&(rules[i].allproperties[ip].status=STATUS_INACTIVE);else for(var j=0;j<i;j++)for(var jp in rules[j].allproperties)if(rules[j].allproperties.hasOwnProperty(jp)&&rules[j].allproperties[jp].status==STATUS_ACTIVE)for(var ip in rules[i].allproperties)if(rules[i].allproperties.hasOwnProperty(ip)&&rules[i].allproperties[ip].status==STATUS_ACTIVE&&jp==ip){rules[j].allproperties[jp].status=STATUS_CANCELLED;break}}if(dosort){for(var i=0;i<rules.length;i++)if(!(rules[i].inheritance.length>0))for(var j in rules[i].allproperties)if(rules[i].allproperties.hasOwnProperty(j)&&rules[i].allproperties[j].status==STATUS_CANCELLED&&IMPORTANT_RULE.test(rules[i].allproperties[j].value)){for(var precedence=i,x=i+1;x<rules.length;x++)typeof rules[x].allproperties[j]!=TYPE_UNDEFINED&&rules[x].allproperties[j].status==STATUS_CANCELLED&&IMPORTANT_RULE.test(rules[x].allproperties[j].value)&&(precedence=x);for(var x=i;x<rules.length;x++)if(x==precedence){rules[x].allproperties[j].status=STATUS_ACTIVE;for(var y=0;y<x;y++)typeof rules[y].allproperties[j]!=TYPE_UNDEFINED&&rules[y].allproperties[j].status==STATUS_ACTIVE&&(rules[y].allproperties[j].status=STATUS_CANCELLED)}else if(typeof rules[x].allproperties[j]!=TYPE_UNDEFINED&&rules[x].allproperties[j].status==STATUS_ACTIVE){rules[x].allproperties[j].status=STATUS_CANCELLED;break}}for(var i=0;i<rules.length;i++)for(var j in rules[i].allproperties)if(rules[i].allproperties.hasOwnProperty(j)&&rules[i].allproperties[j].status==STATUS_ACTIVE&&typeof LONGHAND_PROPERTIES[j]!=TYPE_UNDEFINED)for(var x=0;x<=i;x++)for(var p=0;p<LONGHAND_PROPERTIES[j].length;p++){var longhand=LONGHAND_PROPERTIES[j][p];if(typeof rules[x].allproperties[longhand]!=TYPE_UNDEFINED&&rules[x].allproperties[longhand].status==STATUS_ACTIVE){if(x==i){var n=0;for(var q in rules[x].allproperties)if(rules[x].allproperties.hasOwnProperty(q)){if(q==j)var jindex=n;
18if(q==longhand)var pindex=n;n++}}(x<i||pindex<jindex)&&!IMPORTANT_RULE.test(rules[x].allproperties[longhand].value)&&(rules[x].allproperties[longhand].status=STATUS_CANCELLED)}}}for(var i=0;i<rules.length;i++){for(var j in rules[i])rules[i].hasOwnProperty(j)&&("properties"!=j&&"allproperties"!=j||0!=howmany(rules[i][j])||(rules[i][j]=NULL_VALUE));if(rules[i].properties=rules[i].allproperties,delete rules[i].allproperties,!dosort)for(var k in rules[i].properties)rules[i].properties.hasOwnProperty(k)&&(rules[i].properties[k]=rules[i].properties[k].value)}return rules}function getSelectorSpecificity(selector){var scores=[0,0,0,0];if(""===selector)return scores[0]+=1,scores;var editedselector=selector.replace(REGEX_ATTR_SELECTORS,""),matches=editedselector.match(REGEX_ID_SELECTORS);matches&&(scores[1]+=matches.length);var matches=editedselector.match(REGEX_CLASS_SELECTORS);matches&&(scores[2]+=matches.length),matches=selector.match(REGEX_ATTR_SELECTORS),matches&&(scores[2]+=matches.length);var matches=editedselector.match(REGEX_PSEUDO_CLASSES_EXCEPT_NOT);matches&&(scores[2]+=matches.length);var typeonlyselector=editedselector.replace(REGEX_PSEUDO_CLASSES_EXCEPT_NOT,"").replace(REGEX_PSEUDO_ELEMENTS,"").replace(/(:not)/gi,"").replace(/(^|\()([_a-z0-9-\.\\]+\|)/gi,"$1").replace(REGEX_ID_SELECTORS,"").replace(REGEX_CLASS_SELECTORS,""),matches=typeonlyselector.match(/([_a-z0-9-:\\]+)/gi);matches&&(scores[3]+=matches.length);var matches=editedselector.match(REGEX_PSEUDO_ELEMENTS);return matches&&(scores[3]+=matches.length),scores}function lowercaseIETypeSelectors(selectorstring){var attrselectors=selectorstring.match(/(^|[^\(])(\[[^\]]+\])($|[^\)])/gi);if(attrselectors)for(var a=0;a<attrselectors.length;a++)"["!=attrselectors[a].charAt(0)&&(attrselectors[a]=attrselectors[a].substr(1,attrselectors[a].length-1)),"]"!=attrselectors[a].charAt(attrselectors[a].length-1)&&(attrselectors[a]=attrselectors[a].substr(0,attrselectors[a].length-1)),selectorstring=selectorstring.replace(attrselectors[a],"{a"+a+"}");var cidselectors=selectorstring.match(/([#\.][a-z]+[_a-z0-9-:\\]*)/gi);if(cidselectors)for(var c=0;c<cidselectors.length;c++)selectorstring=selectorstring.replace(cidselectors[c],"{c"+c+"}");if(selectorstring=selectorstring.replace(/([A-Z1-6]+)/g,function(a){return a.toLowerCase()}),attrselectors)for(a=0;a<attrselectors.length;a++)selectorstring=selectorstring.replace("{a"+a+"}",attrselectors[a]);if(cidselectors)for(c=0;c<cidselectors.length;c++)selectorstring=selectorstring.replace("{c"+c+"}",cidselectors[c]);return selectorstring}function lowercaseIEPropertyNames(styletext){styletext=styletext.split(";");for(var j=0;j<styletext.length;j++){for(var matches=styletext[j].split(":");matches.length>2;)matches[1]+=":"+matches.pop();1!=matches.length?(matches[0]=trim(matches[0]).toLowerCase(),matches[1]=trim(matches[1]),styletext[j]=matches[0]+": "+matches[1]):(styletext.splice(j,1),j--)}return styletext.join("; ")}function parseSelectorText(selectorstring){var selectors=[];if(""==selectorstring)return selectors;selectorstring=selectorstring.split(",");for(var j=0;j<selectorstring.length;j++)selectors.push(trim(selectorstring[j]));return selectors}function parsePropertyText(styletext,properties,inherited){if(""==styletext)return properties;styletext=styletext.replace(/[\r\n]/gm," "),styletext=styletext.split(";");for(var i=0;i<styletext.length;i++)if(styletext[i]=trim(styletext[i]),""!=styletext[i]){for(var matches=styletext[i].split(":");matches.length>2;)matches[1]+=":"+matches.pop();if(1!=matches.length){var key=trim(matches[0]);(!inherited||inherited&&typeof INHERITED_PROPS[key]!=TYPE_UNDEFINED)&&(typeof properties[key]!=TYPE_UNDEFINED&&IMPORTANT_RULE.test(properties[key].property)&&properties[key].inherited!=BOOLEAN_TRUE&&!IMPORTANT_RULE.test(matches[1])||(properties[key]={property:trim(matches[1]),inherited:inherited}))}}return properties}function contextualizeMediaTypes(context,types){var contextTypes=lexiconize(context,","),mediaQuery=/([ \t]and.*$)/i,matches=types.match(mediaQuery),typesQuery=matches?matches[0]:"";if(types=types.replace(mediaQuery,"").replace(/only[ \t]+/i,""),typeof contextTypes.all!=TYPE_UNDEFINED)return types+typesQuery;types=types.split(",");for(var i=0;i<types.length;i++)types[i]=trim(types[i]);for(var i=0;i<types.length;i++){if(types[i]==MEDIA_ALL)for(var m in contextTypes)contextTypes.hasOwnProperty(m)&&(arrayContains(types,m)!=NULL_VALUE||/[\(\)]/.test(m)||types.push(m));typeof contextTypes[types[i]]==TYPE_UNDEFINED&&(types.splice(i,1),i--)}return 0==types.length&&types.push(MEDIA_NONE),types.join(", ")+typesQuery}function mediaMatches(media,rule){for(var mediaTypes=lexiconize(rule.media,","),matches=BOOLEAN_FALSE,j=0;j<media.length;j++)if(typeof mediaTypes[media[j]]!=TYPE_UNDEFINED||typeof mediaTypes[MEDIA_NONE]==TYPE_UNDEFINED&&media[j]==MEDIA_ALL||typeof mediaTypes[MEDIA_ALL]!=TYPE_UNDEFINED&&media[j]!=MEDIA_NONE){matches=BOOLEAN_TRUE;break}return matches}function getViewMedia(){var viewmedia=MEDIA_SCREEN;try{var pagebody=page.getElementsByTagName("body").item(0),testmedianode=pagebody.insertBefore(page.createElement("span"),pagebody.firstChild);testmedianode.id="cssutilitiestestmedianode",testmedianode.style.display="inline";var mediaTypes=MEDIA_TYPES_LIST.split(",");if(mediaTypes.splice(0,0,"fake"),IEXPLORER){var viewmediastylesheet=page.createStyleSheet();viewmediastylesheet.addRule("#cssutilitiestestmedianode","display:block !important;")}else{var viewmedianode=page.getElementsByTagName("head").item(0).appendChild(page.createElement("style"));viewmedianode.setAttribute("type","text/css"),viewmedianode.appendChild(page.createTextNode("#cssutilitiestestmedianode{display:block !important;}"));var viewmediastylesheet=page.styleSheets[page.styleSheets.length-1]}for(var i=0;i<mediaTypes.length;i++)if(IEXPLORER?viewmediastylesheet.media=mediaTypes[i]:viewmediastylesheet.media.mediaText=mediaTypes[i],IEXPLORER&&"block"==testmedianode.currentStyle.display||!IEXPLORER&&"block"==page.defaultView.getComputedStyle(testmedianode,"").getPropertyValue("display")){viewmedia=mediaTypes[i];break}testmedianode.parentNode.removeChild(testmedianode),IEXPLORER&&(viewmedianode=viewmediastylesheet.owningElement),viewmedianode.parentNode.removeChild(viewmedianode)}catch(err){viewmedia=MEDIA_SCREEN}return"fake"==viewmedia&&(viewmedia=MEDIA_SCREEN),viewmedia}function watchStyleSheets(){function createStyleSheetIdents(){for(var idents=[],dsheets=page.styleSheets,i=0;i<dsheets.length;i++)typeof dsheets[i].ownerNode.__ident==TYPE_UNDEFINED&&(dsheets[i].ownerNode.__ident=(new Date).getTime()+""+Math.round(1e4*Math.random())),idents.push(dsheets[i].ownerNode.__ident);return idents}for(var livesheets=[],i=0;i<THIS._stylesheets.length;i++){var stylesheet=mode==MODE_AUTHOR?THIS._stylesheets[i].stylenode==BOO
18LEAN_FALSE||THIS._stylesheets[i].stylenode==NULL_VALUE?NULL_VALUE:SAFARI||KONQUEROR||WEBKIT?THIS._stylesheets[i].stylenode:THIS._stylesheets[i].stylenode[typeof THIS._stylesheets[i].stylenode.styleSheet!=TYPE_UNDEFINED?"styleSheet":"sheet"]:THIS._stylesheets[i].stylesheet; 19stylesheet!=NULL_VALUE&&livesheets.push({stylesheet:stylesheet,disabled:stylesheet.disabled})}if((SAFARI||KONQUEROR||WEBKIT)&&mode==MODE_BROWSER)var controlidents=createStyleSheetIdents(),watcher=window.setInterval(function(){var currentidents=createStyleSheetIdents();controlidents.join()!=currentidents.join()&&(window.clearInterval(watcher),THIS.init(typeof THIS.initcallback!=TYPE_UNDEFINED?THIS.initcallback:NULL_VALUE))},WATCHER_SPEED_TIMER);else var watcher=window.setInterval(function(){for(var i=0;i<livesheets.length;i++){if(livesheets[i].stylesheet.disabled!=livesheets[i].disabled){window.clearInterval(watcher),THIS.init(typeof THIS.initcallback!=TYPE_UNDEFINED?THIS.initcallback:NULL_VALUE);var dobreak=BOOLEAN_TRUE}if(typeof dobreak!=TYPE_UNDEFINED)break}},WATCHER_SPEED_TIMER)}function getElementsBySelector(selector){if(REGEX_SINGLE_PSEUDO_ELEMENT.test(selector)){for(var selectors=selector.split(","),i=0;i<selectors.length;i++)REGEX_SINGLE_PSEUDO_ELEMENT.test(selectors[i])&&(selectors.splice(i,1),i--);selector=selectors.join(",")}if(""==trim(selector))return[];if(api==BOOLEAN_FALSE)try{return page.querySelectorAll(selector)}catch(err){return[]}if(typeof qsa==TYPE_FUNCTION)try{return qsa(selector,page)}catch(err){return[]}try{if(typeof Selector!=TYPE_FUNCTION)throw new Error(FATAL_ERROR_MISSING_SAPI);var r=Selector(selector,page);return typeof r==TYPE_UNDEFINED?[]:r}catch(err){if(err.message==FATAL_ERROR_MISSING_SAPI)throw err;return[]}}function getTheseElements(tagname){try{var thesenodes=arrayifize(THIS._isXML?page.getElementsByTagNameNS("*",tagname):page.getElementsByTagName(tagname))}catch(err){thesenodes=[]}if("*"==tagname)for(var i=0;i<thesenodes.length;i++)1==thesenodes[i].nodeType&&"/"!=thesenodes[i].tagName.charAt(0)||thesenodes.splice(i--,1);return thesenodes}function lateinit(){typeof THIS._cssRules==TYPE_UNDEFINED&&THIS.init()}function processArguments(argsary,keys){keys.push("onfinished");for(var args={},i=0;i<keys.length;i++){if(typeof argsary[i]==TYPE_FUNCTION){for(var j=i;j<keys.length;j++)args[keys[j]]=NULL_VALUE;args.onfinished=argsary[i];break}typeof argsary[i]==TYPE_UNDEFINED?args[keys[i]]=NULL_VALUE:args[keys[i]]=argsary[i]}return args}function processElementArgument(argelement,calledby){if(typeof argelement==TYPE_STRING&&"#"==argelement.charAt(0)&&(argelement=page.getElementById(argelement.substr(1,argelement.length-1))),typeof argelement==TYPE_UNDEFINED||argelement==NULL_VALUE||typeof argelement.nodeType==TYPE_UNDEFINED||1!=argelement.nodeType)throw new Error(errorMessageNoElement.replace("%method",calledby));return argelement}function processMediaArgument(argmedia){typeof argmedia!=TYPE_UNDEFINED&&""!=argmedia&&argmedia!=NULL_VALUE||(argmedia=MEDIA_SCREEN),/(^|,)\*(,|$)/.test(argmedia)&&(argmedia="all,none"),argmedia=argmedia.split(",");for(var i=0;i<argmedia.length;i++)argmedia[i]=trim(argmedia[i]),argmedia[i]==MEDIA_CURRENT&&(argmedia[i]=THIS._viewmedia);return argmedia}function processAcceptArgument(argaccept){return typeof argaccept==TYPE_UNDEFINED||""==argaccept||argaccept==NULL_VALUE||"null"==argaccept?argaccept="*":typeof argaccept==TYPE_STRING&&(argaccept=trim(argaccept),"*"!==argaccept&&(argaccept=/(,\s*\*|\*\s*,)/.test(argaccept)?"*":lexiconize(argaccept,","))),argaccept}function processOnfinishedArgument(argonfinished){return typeof argonfinished!=TYPE_FUNCTION&&(argonfinished=NULL_VALUE),argonfinished}function trim(str){return str.replace(/^\s+|\s+$/g,"")}function arrayContains(ary,member,key){for(var i=0;i<ary.length;i++)if(typeof key!=TYPE_UNDEFINED&&typeof ary[i]==TYPE_OBJECT){if(ary[i][key]==member)return ary[i]}else if(ary[i]==member)return ary[i];return NULL_VALUE}function arrayifize(nodelist){for(var ary=[],i=0;i<nodelist.length;i++)ary.push(nodelist[i]);return ary}function lexiconize(str,delimiter){var obj={};str=str.split(delimiter);var tmp=str[str.length-1];if(/[ \t]and/i.test(tmp)){tmp=tmp.split(/[ \t]and/i),str.splice(str.length-1,1);for(var i=0;i<tmp.length;i++)str.push(tmp[i])}for(var i=0;i<str.length;i++)obj[trim(str[i])]="";return obj}function howmany(obj){var n=0;for(var i in obj)obj.hasOwnProperty(i)&&n++;return n}function qualifyHREF(href,context){if(typeof href==TYPE_UNDEFINED)return"";var parts=context.replace("//","/").split("/"),loc={protocol:parts[0],host:parts[1]};parts.splice(0,2),loc.pathname="/"+parts.join("/");var uri=loc.protocol+"//"+loc.host;if(/^(\.\/)([^\/]?)/.test(href)&&(href=href.replace(/^(\.\/)([^\/]?)/,"$2")),/(^([a-z]+)\:\/\/)/.test(href))uri=href;else if("/"==href.substr(0,1))uri+=href;else if(/^((\.\.\/)+)([^\/].*$)/.test(href)){var lastpath=href.match(/^((\.\.\/)+)([^\/].*$)/);lastpath=lastpath[lastpath.length-1];var references=href.split("../").length-1,parts=loc.pathname.split("/");parts=parts.splice(0,parts.length-1);for(var i=0;i<references;i++)parts=parts.splice(0,parts.length-1);var path="";for(i=0;i<parts.length;i++)""!=parts[i]&&(path+="/"+parts[i]);path+="/",path+=lastpath,uri+=path}else{path="",parts=loc.pathname.split("/"),parts=parts.splice(0,parts.length-1);for(var i=0;i<parts.length;i++)""!=parts[i]&&(path+="/"+parts[i]);path+="/",uri+=path+href}return uri}function ajaxload(async,uri,oncomplete,onfail){function ajaxresponse(requestobject){/(0|200|304)/.test(requestobject.status.toString())?oncomplete(requestobject.responseText,requestobject.getResponseHeader("Content-Type")):onfail(trim(requestobject.statusText),requestobject.status)}var requestobject=NULL_VALUE;if(typeof window.ActiveXObject!=TYPE_UNDEFINED)try{requestobject=new ActiveXObject("Microsoft.XMLHTTP")}catch(err){requestobject=NULL_VALUE}
19if(requestobject==NULL_VALUE&&typeof window.XMLHttpRequest!=TYPE_UNDEFINED)try{requestobject=new XMLHttpRequest}catch(err){requestobject=NULL_VALUE}if(requestobject==NULL_VALUE)throw new Error(FATAL_ERROR_NO_XHR);try{requestobject.open("GET",uri,async)}catch(e){}try{requestobject.setRequestHeader("User-Agent",LIBRARY_VERSION_STRING)}catch(err){}if(async==BOOLEAN_TRUE){requestobject.onreadystatechange=function(){4==requestobject.readyState&&ajaxresponse(requestobject)};try{requestobject.send(NULL_VALUE)}catch(err){onfail(ERROR_NETWORK_OR_SECURITY)}}else{var success;try{requestobject.send(NULL_VALUE),success=BOOLEAN_TRUE}catch(err){success=BOOLEAN_FALSE}success===BOOLEAN_TRUE?ajaxresponse(requestobject):onfail(ERROR_NETWORK_OR_SECURITY)}}var THIS=this;if(this._allready=!1,this.supported=!1,"undefined"!=typeof document.getElementById&&"undefined"!=typeof document.styleSheets&&"undefined"!=typeof document.nodeType){this.supported=!0;var base,busyinit=!1,ERROR_NETWORK_OR_SECURITY="Network Failure or Security Violation",ERROR_NETWORK="Network Failure",ERROR_SECURITY="Security Violation",ERROR_UNSPECIFIED="Unspecified Error",ERROR_NOT_CSS="Data is not CSS",MESSAGE_UNKNOWN="unknown",MESSAGE_OK="OK",MESSAGE_DUPLICATE="Discarded Duplicate",MESSAGE_DISABLED="Stylesheet is disabled",MESSAGE_UNSUPPORTED_TYPE="Unsupported node type",FATAL_ERROR_PREFIX="CSSUtilities (Fatal Error):",FATAL_ERROR_INVALID_MODE=FATAL_ERROR_PREFIX+" The specified mode is not valid",FATAL_ERROR_INVALID_ASYNC=FATAL_ERROR_PREFIX+" The specified async setting is not valid",FATAL_ERROR_NOT_DOCUMENT=FATAL_ERROR_PREFIX+" The specified document is not a Document",FATAL_ERROR_NOT_ABSOLUTE_URI=FATAL_ERROR_PREFIX+" The specified base is not an absolute URL",FATAL_ERROR_INVALID_WATCH=FATAL_ERROR_PREFIX+" The specified watch setting is not valid",FATAL_ERROR_INVALID_ATTRS=FATAL_ERROR_PREFIX+" The specified attributes setting is not valid",FATAL_ERROR_NOT_SAPI=FATAL_ERROR_PREFIX+" The specified api settings are not valid",FATAL_ERROR_INVALID_SAPI=FATAL_ERROR_PREFIX+" Your Selectors API is not returning the right data",FATAL_ERROR_MISSING_SAPI=FATAL_ERROR_PREFIX+" The Selectors API is missing",FATAL_ERROR_NO_XHR=FATAL_ERROR_PREFIX+" Unable to communicate with the network",errorMessageNoElement="CSSUtilities.%method has an invalid Element reference or ID",errorMessageNoSelector="CSSUtilities.%method requires a valid Selector reference",errorMessageMultipleSelector="CSSUtilities.%method can only process one Selector at a time",errorMessageInvalidSSID="CSSUtilities.%method has an invalid Stylesheet ID",errorMessageNotAfterAPI=FATAL_ERROR_PREFIX+' You cannot define "%var" after "api", it must be defined first',MEDIA_ALL="all",MEDIA_SCREEN="screen",MEDIA_NONE="none",MEDIA_CURRENT="current",MEDIA_TYPES_LIST="aural,braille,embossed,handheld,print,projection,reader,screen,speech,tty,tv",INHERITED_PROPS={azimuth:"2","border-collapse":"2","border-spacing":"2","caption-side":"2",color:"2",cursor:"2",direction:"2",elevation:"2","empty-cells":"2",fit:"3","fit-position":"3",font:"2","font-family":"2","font-size":"2","font-size-adjust":"2","font-stretch":"2","font-style":"2","font-variant":"2","font-weight":"2","hanging-punctuation":"3","hyphenate-after":"3","hyphenate-before":"3","hyphenate-character":"3","hyphenate-lines":"3","hyphenate-resource":"3",hyphens:"3","image-resolution":"3","letter-spacing":"2","line-height":"2","line-stacking":"3","line-stacking-ruby":"3","line-stacking-shift":"3","line-stacking-strategy":"3","list-style":"2","list-style-image":"2","list-style-position":"2","list-style-type":"2","marquee-direction":"3",orphans:"2","overflow-style":"3",page:"2","page-break-inside":"2",pitch:"2","pitch-range":"2","presentation-level":"3","punctuation-trim":"3",quotes:"2",richness:"2","ruby-align":"3","ruby-overhang":"3","ruby-position":"3",speak:"2","speak-header":"2","speak-numeral":"2","speak-punctuation":"2","speech-rate":"2",stress:"2","text-align":"2","text-align-last":"3","text-emphasis":"3","text-height":"3","text-indent":"2","text-justify":"3","text-outline":"3","text-replace":"?","text-shadow":"3","text-transform":"2","text-wrap":"3",visibility:"2","voice-balance":"3","voice-family":"2","voice-rate":"3","voice-pitch":"3","voice-pitch-range":"3","voice-stress":"3","voice-volume":"3",volume:"2","white-space":"2","white-space-collapse":"3",widows:"2","word-break":"3","word-spacing":"2","word-wrap":"3","-moz-force-broken-image-icon":"m","-moz-image-region":"m","-moz-stack-sizing":"m","-moz-user-input":"m","-x-system-font":"m","-xv-voice-balance":"o","-xv
19-voice-pitch":"o","-xv-voice-pitch-range":"o","-xv-voice-rate":"o","-xv-voice-stress":"o","-xv-voice-volume":"o","-ms-text-align-last":"e","-ms-text-justify":"e","-ms-word-break":"e","-ms-word-wrap":"e"},LONGHAND_PROPERTIES={margin:["margin-top","margin-right","margin-bottom","margin-left"],padding:["padding-top","padding-right","padding-bottom","padding-left"],outline:["outline-width","outline-style","outline-color"],border:["border-width","border-style","border-color","border-top","border-right","border-bottom","border-left","border-top-width","border-right-width","border-bottom-width","border-left-width","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-color","border-right-color","border-bottom-color","border-left-color"],"border-width":["border-top-width","border-right-width","border-bottom-width","border-left-width"],"border-style":["border-top-style","border-right-style","border-bottom-style","border-left-style"],"border-color":["border-top-color","border-right-color","border-bottom-color","border-left-color"],"border-top":["border-top-width","border-top-style","border-top-color"],"border-right":["border-right-width","border-right-style","border-right-color"],"border-bottom":["border-bottom-width","border-bottom-style","border-bottom-color"],"border-left":["border-left-width","border-left-style","border-left-color"],"list-style":["list-style-type","list-style-image","list-style-position"],font:["font-weight","font-style","font-variant","font-size","line-height","font-family"],background:["background-color","background-image","background-repeat","background-attachment","background-position","background-size","background-clip","background-origin"],"line-stacking":["line-stacking-strategy","line-stacking-ruby","line-stacking-shift"],"column-rule":["column-rule-width","column-rule-style","column-rule-color"],columns:["column-width","column-count"],pause:["pause-before","pause-after"],rest:["rest-before","rest-after"],cue:["cue-before","cue-after"],mark:["mark-before","mark-after"],transition:["transition-property","transition-duration","transition-timing-function","transition-delay"],animation:["animation-name","animation-duration","animation-timing-function","animation-delay","animation-iteration-count","animation-direction"],target:["target-name","target-new","target-position"]},REGEX_SINGLE_PSEUDO_ELEMENT=/[:]{1,2}(?:first\-(letter|line)|before|after|selection|value|choices|repeat\-(item|index)|outside|alternate|(line\-)?marker|slot\([_a-z0-9\-\+\.\\]*\))/i,REGEX_PSEUDO_ELEMENTS=/([:]{1,2}(?:first\-(letter|line)|before|after|selection|value|choices|repeat\-(item|index)|outside|alternate|(line\-)?marker|slot\([_a-z0-9\-\+\.\\]*\)))/gi,REGEX_PSEUDO_CLASSES_EXCEPT_NOT=/([:](?:(link|visited|active|hover|focus|lang|root|empty|target|enabled|disabled|checked|default|valid|invalid|required|optional)|((in|out\-of)\-range)|(read\-(only|write))|(first|last|only|nth)(\-last)?\-(child|of\-type))(?:\([_a-z0-9\-\+\.\\]*\))?)/gi,REGEX_ATTR_SELECTORS=/(\[\s*[_a-z0-9-:\.\|\\]+\s*(?:[~\|\*\^\$]?=\s*[\"\'][^\"\']*[\"\'])?\s*\])/gi,REGEX_ID_SELECTORS=/(#[a-z]+[_a-z0-9-:\\]*)/gi,REGEX_CLASS_SELECTORS=/(\.[_a-z]+[_a-z0-9-:\\]*)/gi,IMPORTANT_RULE=/\!\s*important\s*$/i,LIBRARY_VERSION_STRING="CSSUtilities/.99",TYPE_UNDEFINED="undefined",TYPE_OBJECT="object",TYPE_STRING="string",TYPE_FUNCTION="function",TYPE_BOOLEAN="boolean",BOOLEAN_TRUE=!0,BOOLEAN_FALSE=!1,NULL_VALUE=null,MODE_BROWSER="browser",MODE_AUTHOR="author",STATUS_ACTIVE="active",STATUS_CANCELLED="cancelled",STATUS_INACTIVE="inactive",SAFARI="Apple Computer, Inc."==navigator.vendor,SAFARI3=SAFARI&&/version\/3/i.test(navigator.appVersion),KONQUEROR="KDE"==navigator.vendor,WEBKIT=/applewebkit/i.test(navigator.userAgent),IEXPLORER=typeof document.uniqueID!=TYPE_UNDEFINED,OPERA=typeof window.opera!=TYPE_UNDEFINED,WATCHER_SPEED_TIMER=200,mode=MODE_BROWSER,async=BOOLEAN_FALSE,page=document,watch=BOOLEAN_FALSE,attributes=BOOLEAN_TRUE,api=NULL_VALUE,qsa=NULL_VALUE,apidefined=BOOLEAN_FALSE;this.define=function(varname,value1,value2){switch(varname){case"mode":if(typeof value1!=TYPE_STRING||!/^(author|browser)$/i.test(value1))throw new Error(FATAL_ERROR_INVALID_MODE);if(mode=value1,mode==MODE_BROWSER&&watch===NULL_VALUE)throw new Error(FATAL_ERROR_INVALID_WATCH);break;case"async":if(typeof value1!=TYPE_BOOLEAN)throw new Error(FATAL_ERROR_INVALID_ASYNC);async=value1;break;case"page":if(apidefined==BOOLEAN_TRUE)throw new Error(errorMessageNotAfterAPI.replace("%var","page"));if(typeof value1.nodeType==TYPE_UNDEFINED||9!=value1.nodeType)throw new Error(FATAL_ERROR_NOT_DOCUMENT);page=value1;break;case"base":if(apidefined==BOOLEAN_TRUE)throw new Error(errorMessageNotAfterAPI.replace("%var","base"));if(typeof value1!=TYPE_STRING||!/^(((ht|f)tp[s]?)\:)/i.test(value1))throw new Error(FATAL_ERROR_NOT_ABSOLUTE_URI
19);base=value1;break;case"attributes":if(typeof value1!=TYPE_BOOLEAN)throw new Error(FATAL_ERROR_INVALID_ATTRS);attributes=value1;break;case"watch":if(typeof value1!=TYPE_BOOLEAN&&(mode!=MODE_AUTHOR||value1!=NULL_VALUE))throw new Error(FATAL_ERROR_INVALID_WATCH);watch=value1;break;case"api":if(typeof value1!=TYPE_BOOLEAN)throw new Error(FATAL_ERROR_NOT_SAPI);if(typeof value2!=TYPE_UNDEFINED&&typeof value2!=TYPE_FUNCTION)throw new Error(FATAL_ERROR_NOT_SAPI);if(api=value1==BOOLEAN_FALSE?typeof page.querySelectorAll==TYPE_UNDEFINED:BOOLEAN_TRUE,apidefined=BOOLEAN_TRUE,typeof value2==TYPE_FUNCTION){var nodes=value2("*",page);if(typeof nodes!=TYPE_OBJECT||nodes==NULL_VALUE||typeof nodes.length==TYPE_UNDEFINED)throw new Error(FATAL_ERROR_INVALID_SAPI);qsa=value2}}},this.init=function(callback){function localcallback(){busyinit=BOOLEAN_FALSE,CSSUtilities._allready=BOOLEAN_TRUE,typeof callback==TYPE_FUNCTION?(CSSUtilities.initcallback=callback,CSSUtilities.initcallback()):(CSSUtilities.initcallback=NULL_VALUE,delete CSSUtilities.initcallback)}busyinit!==BOOLEAN_TRUE&&(busyinit=BOOLEAN_TRUE,this._allready=BOOLEAN_FALSE,api=typeof page.querySelectorAll!=TYPE_UNDEFINED&&api!==BOOLEAN_TRUE?BOOLEAN_FALSE:BOOLEAN_TRUE,base==NULL_VALUE&&(base=page.location.href),this._isXML=OPERA&&page.documentElement.namespaceURI!=NULL_VALUE||!OPERA&&typeof page.xmlVersion!=TYPE_UNDEFINED&&page.xmlVersion!=NULL_VALUE,this._viewmedia=getViewMedia(),this._cssRules=NULL_VALUE,delete this._cssRules,this._stylesheets=NULL_VALUE,delete this._stylesheets,THIS._cssRules=[],THIS._stylesheets=[],THIS.ssidcounter=0,mode==MODE_AUTHOR?createAuthorRulesData(localcallback):createBrowserRulesData(localcallback))},this.getCSSStyleSheets=function(){var args=processArguments(arguments,[]);return args.onfinished=processOnfinishedArgument(args.onfinished),lateinit(),dispatchReturn(args.onfinished,function(){return THIS._stylesheets})},this.getCSSRules=function(){var args=processArguments(arguments,["element","media","accept","altstates"]);return args.element=processElementArgument(args.element,"getCSSRules"),args.media=processMediaArgument(args.media),args.accept=processAcceptArgument(args.accept),args.altstates==NULL_VALUE&&(args.altstates=BOOLEAN_FALSE),args.onfinished=processOnfinishedArgument(args.onfinished),lateinit(),dispatchReturn(args.onfinished,function(){return getCSSRules(args.element,args.media,args.accept,args.altstates)})},this.getCSSStyleSheetRules=function(){var args=processArguments(arguments,["media","accept","ssid"]);if(args.media=processMediaArgument(args.media),args.accept=processAcceptArgument(args.accept),typeof args.accept.properties!=TYPE_UNDEFINED&&typeof args.accept.css==TYPE_UNDEFINED){args.accept.css="";var deletecss=BOOLEAN_TRUE}if(args.ssid===NULL_VALUE&&(args.ssid=-1),args.onfinished=processOnfinishedArgument(args.onfinished),lateinit(),args.ssid!==-1&&arrayContains(this._stylesheets,args.ssid,"ssid")==NULL_VALUE)throw new Error(errorMessageInvalidSSID.replace("%method","getCSSStyleSheetRules"));return dispatchReturn(args.onfinished,function(){for(var rules=[],i=0;i<THIS._cssRules.length;i++){var cssrule={};if(mediaMatches(args.media,THIS._cssRules[i])){if(args.ssid!==-1&&THIS._cssRules[i].ssid!==args.ssid)continue;for(var j in THIS._cssRules[i])THIS._cssRules[i].hasOwnProperty(j)&&("*"!=args.accept&&typeof args.accept[j]==TYPE_UNDEFINED||(cssrule[j]=THIS._cssRules[i][j]));"*"!=args.accept&&typeof args.accept.index==TYPE_UNDEFINED||(cssrule.index=i),rules.push(cssrule)}}if(typeof args.accept.properties==TYPE_UNDEFINED&&"*"!==args.accept||(rules=addSortedProperties(rules,BOOLEAN_FALSE)),typeof deletecss!=TYPE_UNDEFINED)for(var i=0;i<rules.length;i++)rules[i].css=NULL_VALUE,delete rules[i].css;return rules})},this.getCSSProperties=function(){var args=processArguments(arguments,["element","media"]);return args.element=processElementArgument(args.element,"getCSSProperties"),args.media=processMediaArgument(args.media),args.onfinished=processOnfinishedArgument(args.onfinished),lateinit(),dispatchReturn(args.onfinished,function(){var properties={},rules=getCSSRules(args.element,args.media,"properties",BOOLEAN_FALSE);if(0==rules.length)return NULL_VALUE;for(var i=0;i<rules.length;i++)for(var j in rules[i].properties)rules[i].properties.hasOwnProperty(j)&&rules[i].properties[j].status==STATUS_ACTIVE&&(properties[j]=rules[i].properties[j].value);return properties})},this.getCSSSelectors=function(){var args=processArguments(arguments,["element","media","directonly"]);return args.element=processElementArgument(args.element,"getCSSSelectors"),args.media=processMediaArgument(args.media),args.directonly==NULL_VALUE&&(args.directonly=BOO
19LEAN_TRUE),args.onfinished=processOnfinishedArgument(args.onfinished),lateinit(),dispatchReturn(args.onfinished,function(){for(var allselectors=[],rules=getCSSRules(args.element,args.media,"selector",BOOLEAN_TRUE),i=0;i<rules.length;i++)for(var selectors=parseSelectorText(rules[i].selector),j=0;j<selectors.length;j++)arrayContains(allselectors,selectors[j])==NULL_VALUE&&allselectors.push(selectors[j]);if(args.directonly==BOOLEAN_FALSE){for(var node=args.element,ancestors=[node];node.parentNode;)ancestors.push(node.parentNode),node=node.parentNode;for(var i=0;i<allselectors.length;i++){for(var applies=BOOLEAN_FALSE,j=0;j<ancestors.length;j++){var nodes=getElementsBySelector(allselectors[i].replace(REGEX_PSEUDO_CLASSES_EXCEPT_NOT,""));if(nodes.length>0)for(var k=0;k<nodes.length;k++)if(nodes[k]==ancestors[j]){applies=BOOLEAN_TRUE;break}if(applies==BOOLEAN_TRUE)break}applies==BOOLEAN_FALSE&&(allselectors.splice(i,1),i--)}return allselectors}for(var selectors=[],i=0;i<allselectors.length;i++){var nodes=getElementsBySelector(allselectors[i].replace(REGEX_PSEUDO_CLASSES_EXCEPT_NOT,""));if(nodes.length>0)for(var j=0;j<nodes.length;j++)if(nodes[j]==args.element){selectors.push(allselectors[i]);break}}return selectors})},this.getCSSSelectorSpecificity=function(){var args=processArguments(arguments,["selector","element"]);if(typeof args.selector!=TYPE_STRING||args.selector==NULL_VALUE||""==trim(args.selector))throw new Error(errorMessageNoSelector.replace("%method","getCSSSelectorSpecificity"));if(args.selector.indexOf(",")!=-1)throw new Error(errorMessageMultipleSelector.replace("%method","getCSSSelectorSpecificity"));return args.element!=NULL_VALUE&&(args.element=processElementArgument(args.element,"getCSSSelectorSpecificity")),args.onfinished=processOnfinishedArgument(args.onfinished),lateinit(),dispatchReturn(args.onfinished,function(){if(args.selector=trim(args.selector),args.element!=NULL_VALUE){var applies=BOOLEAN_FALSE,nodes=getElementsBySelector(args.selector.replace(REGEX_PSEUDO_CLASSES_EXCEPT_NOT,""));if(nodes.length>0)for(var j=0;j<nodes.length;j++)if(nodes[j]==args.element){applies=BOOLEAN_TRUE;break}if(applies==BOOLEAN_FALSE){for(var node=args.element,ancestors=[node];node.parentNode;)ancestors.push(node),node=node.parentNode;for(var i=0;i<ancestors.length;i++){if(nodes.length>0)for(var j=0;j<nodes.length;j++)if(nodes[j]==ancestors[i]){applies=BOOLEAN_TRUE;break}if(applies==BOOLEAN_TRUE)break}return applies==BOOLEAN_TRUE?[0,0,0,0]:NULL_VALUE}}return getSelectorSpecificity(args.selector)})}}}).apply(CSSUtilities);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.