/*
 * mbd core js library
 * @copyrightBarcroft Digital 23/06/2009
*/
function mbD()
{
/*
  * grabs the  properties of a given css rule
 */
function getCSSRule(ruleName) 
{
ruleName=ruleName.toLowerCase();
if (document.styleSheets) 
	{
    for (var i=document.styleSheets.length-1; i>-1; i--) 
		{
        var styleSheet=document.styleSheets[i];
        var ii=0;
        var cssRule=false;
        do
			{
            if (styleSheet.cssRules) 
				{
				cssRule = styleSheet.cssRules[ii];
				}
			else 
				{
                cssRule = styleSheet.rules[ii];
				}
            if (cssRule)  
				{
				if (cssRule.selectorText.toLowerCase()==ruleName) 
					{
                     return cssRule;
					}
				}
            ii++;
			} 
		while (cssRule)
		}
	}
return false;
}
this.getCSSRule = getCSSRule;

/*
 * converts a given value to it's hex component
*/
function toHex(N) 
{
if (N==null)
	{
	return "00";
	}
N=parseInt(N); 
if (N==0 || isNaN(N))
	{
	return "00";
	}
N=Math.max(0,N);
N=Math.min(N,255);
N=Math.round(N);
return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16);
}
this.toHex = toHex;


}
var mbD = new mbD();
