/*
 ** changeStyleSheet(cssSelector,styleElement,newValue)
 **
 ** Arguments:
 **   cssSelector      selector from stylesheet, eg #main   NOTE: Stylesheet rule must START with this text. No check is done on remainder of text.
 **   styleElement    which style element to change. NOTE: This is a javascript (eg camelCase) name. Eg use "fontSize" NOT "font-size" or "fontsize" !!!
 **   newValue         the new value
 **
 ** Example:
 ** changeStyleSheet("div#main", "fontSize", "8px");
 */
function changeStyleSheet(cssSelector, styleElement, newValue) {
	
	// alles opslaan
	is4_setCookie('cssSelector ', cssSelector ,1);
	is4_setCookie('styleElement', styleElement,1);
	is4_setCookie('newValue', newValue,1);

	if (!document.styleSheets || !cssSelector || !styleElement ) { return; }
	var theRules = new Array();
	if (document.styleSheets[0].cssRules) {
		theRules = document.styleSheets[0].cssRules
	} else if (document.styleSheets[0].rules) {
		theRules = document.styleSheets[0].rules
	} else {
		return;
	}
	for(var r in theRules) {
		if ( theRules[r].selectorText ) { // Used cssText previously,  but didn't work in IE7
			var tgtIdx = theRules[r].selectorText.indexOf(cssSelector);
			if (tgtIdx != -1 && tgtIdx == 0) { // cssSelector must start with the given text
				eval("theRules[r].style."+styleElement+" = newValue;");
				// theRules[r].style.fontSize = newValue;
				return;
			}
		}
	}


}

// boel herstellen
var cssSelector		= is4_getCookie('cssSelector');
var styleElement	= is4_getCookie('styleElement');
var newValue		= is4_getCookie('newValue');
changeStyleSheet(cssSelector, styleElement, newValue);


function is4_getCookie(c_name) {
  if (document.cookie.length > 0) {
    c_start = document.cookie.indexOf(c_name + "=");
    if (c_start != -1) {
      c_start = c_start + c_name.length + 1;
      c_end = document.cookie.indexOf(";", c_start);
      if (c_end == -1) c_end = document.cookie.length;
      return unescape(document.cookie.substring(c_start, c_end));
    }
  }
  return "";
}
function is4_setCookie(c_name, value, expireHours, path) {
  var exdate = new Date();
  if (!path) {
    path = "/";
  }
  exdate.setHours(exdate.getHours() + expireHours);
  document.cookie = c_name + "=" + escape(value) + ((expireHours == null) ? "": ";expires=" + exdate.toGMTString()) + "; path=" + path;
}

