String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,'');};CSSTools=function(){};CSSTools.prototype={changeBodyBackground:function(_filename){var csr=new CSSRules(window);if(csr){var bodyClass=csr.get('.'+document.body.className);if(bodyClass.style){bodyClass.style.backgroundImage=(_filename.indexOf('/noicon.gif')==-1)? 'url('+doyo.core.getBaseDir()+_filename+')':'';}};}, changeTheme:function(_window){if(doyo.core.lastInvoked()< 2000){return false;}var framez=new Array();doyo.core.collectFrames(framez,top,_window.name);var fromRules=new CSSRules(_window);var toRules;var fromRule;var toRule;var allCSS=new Array();allCSS['.body']=true;allCSS['.selected']=true;allCSS['.polaroid']=true;allCSS['.icon']=true;var cssColor=new Array();cssColor['.normal']=true;cssColor['.normal.subtitle']=true;cssColor['.icon:active']=true;cssColor['.icon:link']=true;cssColor['.icon:focus']=true;cssColor['.icon:hover']=true;cssColor['.icon:visited']=true;cssColor['a:active']=true;cssColor['a:link']=true;cssColor['a:focus']=true;cssColor['a:hover']=true;cssColor['a:visited']=true;for(var ix in framez){toRules=new CSSRules(framez[ix]);if(!toRules)continue;for(var key in allCSS){fromRule=fromRules.get(key);toRule=toRules.get(key);if(fromRule && toRule)toRule.style.cssText=fromRule.style.cssText;};for(var key in cssColor){fromRule=fromRules.get(key);toRule=toRules.get(key);if(fromRule && toRule)toRule.style.color=fromRule.style.color;};};doyo.core.lastInvoked()}};CSSRules=function(_window){this.window=_window;this.doc=(_window)? _window.document:document;this.rules=this.initRules();};CSSRules.prototype.initRules=function(){var result=new Array();if(!this.doc.styleSheets.length)return result;try{var hasCSSRules=(this.doc.styleSheets[0].cssRules);var hasRules=(this.doc.styleSheets[0].rules);}catch(e){};var selText;var sheetRules;for(var i=0;i < this.doc.styleSheets.length;i++){try{if(hasCSSRules){sheetRules=this.doc.styleSheets[i].cssRules;}else if(hasRules){sheetRules=this.doc.styleSheets[i].rules;}else{sheetRules=null;};}catch(e){};this.assimilate(result,sheetRules);};return result;};CSSRules.prototype.assimilate=function(_result,_sheetRules){if(!_sheetRules)return;for(var i=0;i<_sheetRules.length;i++){if(_sheetRules[i].selectorText){for(var sel in this.getSelectors(_sheetRules[i].selectorText)){_result[sel]=_sheetRules[i];};};};};CSSRules.prototype.getSelectors=function(_selectorText){var result=new Array();if(!_selectorText)return result;if(typeof _selectorText !='string')return result;var token=_selectorText.toLowerCase().split(',');for(var i=0;i < token.length;i++){token[i]=new String(token[i]);result[token[i].trim()]=true;};return result;};CSSRules.prototype.get=function(_selector){return(this.rules[_selector])? this.rules[_selector]:null;};if(!doyo)var doyo=new Object();doyo.csstools=new CSSTools();
