<script type="text/javascript">
/* This script section contains the reusable functions */
/* Copyright 2002 Thor Larholm, jscript.dk */
function getClassRule(sClass, sStyle){
if(typeof sClass!="string" ) return;
sClass = sClass.replace(/^([^\.])/,".$1" );
var oStyle, cStyle=document.styleSheets;
if(sStyle) return getRuleByStart( sClass, cStyle[sStyle]);
else
for(var i=0, il=cStyle.length, C; i<il; i++){
C = getRuleByStart( sClass, cStyle[i] );
if(C) return C;
}
}
function getRuleByStart( sName, oStyle){
if(typeof sName!="string" ) return;
var bUpper = /^[^#\.]/.test(sName);
if(bUpper) sName = sName.toUpperCase();
for(var i=0, R=oStyle.rules||oStyle.cssRules, il=R.length, C; i<il; i++){
C = R[i].selectorText; if(typeof C!="string" ) continue;
if(bUpper) C = C.toUpperCase();
if( C.indexOf( sName )==0) return R[i];
}
}
</script>
|