/*!
 * Copyright 2011 France Télécom
 * This software is distributed under the terms of either the MIT
 * License or the GNU General Public License (GPL) Version 2 or later.
 * See licence.txt file for more details.
 */
 
/* cssrule.js
 * Version : 1
 * 
 * Authors: Julien Wajsberg <julien.wajsberg@orange.com>
 * 
 * This module can insert CSS rules in a cross-browser way.
 * It was inspired by http://code.google.com/p/doctype/wiki/ArticleInstallStyles
 *
*/


var cssrule = (function($, document, undefined) {
	var stylesheet;
	
	var possibleprops = "cssText,innerText,innerHTML".split(",");
	var propToSet;
	
	function init() {
		if (document.createStyleSheet) {
			// in IE
			stylesheet = document.createStyleSheet();
		} else {
			stylesheet = $("<style type='text/css' id='cssrule'></style>").get(0);
			$("head").append(stylesheet);
		}

		var i, cur;
		for (i = 0; i < possibleprops.length; i++) {
			cur = possibleprops[i];
			if (stylesheet[cur] !== undefined) {
				propToSet = cur;
				break;
			}
		}
	}
	
	function add(style) {
		stylesheet[propToSet] += style;
		return cssrule;
	}
	
	return {
		/**
		 * you must call "init" function on dom ready
		 * TODO: should we run it automatically when "add" is used the first time ?
		 */ 
		init: init,
		add: add
	};
})(jQuery, document);

@@ -486,11 +486,8 @@
 ion(
-$, 
 docu
@@ -510,88 +510,8 @@
  %7B%0A%09
-var stylesheet;%0A%09%0A%09var possibleprops = %22cssText,innerText,innerHTML%22.split(%22,%22);
 %0A%09va
@@ -523,13 +523,24 @@
 pToS
+et, styleshe
 et;%0A
-%09
 %0A%09fu
@@ -546,19 +546,31 @@
 unction 
-ini
+createStyleshee
 t() %7B%0A%09%09
@@ -690,78 +690,163 @@
 t = 
-$
+document.createElement
 (%22
-%3C
 style
- type='text/css' id='cssrule'%3E%3C/style%3E%22).get(0);%0A%09%09%09$
+%22);%0A%09%09%09stylesheet.id = %22cssrule%22;%0A%09%09%09%0A%09%09%09// TODO: should we test if there is a head ?%0A%09%09%09document.getElementsByTagName
 (%22head%22)
 .app
@@ -845,15 +845,23 @@
 ad%22)
+%5B0%5D
 .append
+Child
 (sty
@@ -878,22 +878,107 @@
 %09%09%7D%0A
-%0A%09%09var i, cur;
+%09%7D%0A%09%0A%09function findPropToSet() %7B%0A%09%09var possibleprops = %22cssText,innerText,innerHTML%22.split(%22,%22);%0A%09%09
 %0A%09%09f
@@ -1126,32 +1126,114 @@
 ;%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%09%0A
+%09function init() %7B%0A%09%09var i, cur;%0A%09%09%0A%09%09createStylesheet();%0A%09%09findPropToSet();%0A%09%7D%0A%09%0A
 %09function add(st
@@ -1481,16 +1481,8 @@
 %0A%7D)(
-jQuery, 
 docu

remove the jQuery dependency