Old code: CSS rules on the fly from JavaScript (2006)

Again, some old code I'm not using anymore since I switched to jQuery but that might be useful for someone:

/*
 * Public Domain
 * Created by Toni Corvera <outlyer@outlyer.net> in September, 2006
 *
 * Creates a new CSS ruleset, should work with multiple rules correctly
 * e.g.:
 *    loadCssRules('body{font-family:sans-serif;}a:link{color:red;}');
 */
// void function loadCssRules(String rules)
function loadCssRules(r) {
	if (!document.createElement) return;
	var newStyle=document.createElement('STYLE');
	newStyle.setAttribute('type', 'text/css');
	newStyle.appendChild(document.createTextNode(r));
	document.getElementsByTagName('HEAD')[0].appendChild(newStyle);
}

Downloadable file: http://p.outlyer.net/graveyard/net_outlyer_dyn_css.js