/**
 * This file contains functions for style manipulation in a document. This file is based on
 * <a href="http://rule52.com/2008/06/css-rule-page-load/">Adding CSS rules with JavaScript</a>.
 * 
 * @version 10-08-2010
 * @author <a href="mailto:r.tennapel@griponservice.nl?SUBJECT=css.js">R. ten Napel, ing.</a>
 **/

/**
 * A static class with all the CSS functions.
 **/
function CSSRules() {};

// Globals:
CSSRules.head = document.getElementsByTagName("HEAD")[0];
CSSRules.style = document.createElement("STYLE");
CSSRules.style.type = "text/css";
CSSRules.head.appendChild(CSSRules.style);

/**
 * Add / extend a style.
 * 
 * @param selector			The selector to add / extend.
 * @param rule				The rule to add / extend with.
 **/
CSSRules.add = function(selector, rule) {
	// IE doesn't allow you to append text nodes to <style> elements:
	if (CSSRules.style.styleSheet) {
		CSSRules.style.styleSheet.cssText += selector + " { " + rule + " }";
	} else {
		CSSRules.style.appendChild(document.createTextNode(selector + " { " + rule + " }"));
	}
};
