// ----- Dom 1 Change Style (for 1NN6+ and 1IE5+)  ------

// Date 2.4.2001

// Author Rod Fletcher

// This script is Copyright ©1999 - 2001 Rod and Sue Fletcher.


// changeNNStyleBySelector() function changes the value of the style for a given selector.
// e.g. changing value of width property of #whole selector.
// Uses coding suitable for DOM Type 1NN6+
//

function changeNNStyleBySelector(s, p, v){ 			//Only for use with NN6+
							//s is selector
							//p is property
							//v is value

var sheets = document.getElementsByTagName('style');

for (var i=0; i<sheets.length; i++) {
	 var rules = sheets[i].firstChild.data;

	 var selectors = rules.match(/[#\.\w]+\s*\{/g);

	 for (var k=0; k<selectors.length; k++) {
		  var extractedsel = selectors[k].match(/[#\.\w]+/);

		  if (extractedsel == s) {
			  document.styleSheets[i].cssRules[k].style[p] = v;
			  return;
		  }
	 }
}
}




//changeIEStyleBySelector() function changes the value of the style for a given selector.
// e.g. changing value of width property of #whole selector.
// Uses coding suitable for DOM Type 1IE5+
//

function changeIEStyleBySelector(s, p, v){ 			//Only for use with IE5+
							//s is selector
							//p is property
							//v is value

var sheets = document.getElementsByTagName('style');

for (var i=0; i<sheets.length; i++) {
	 var numberOfRules = document.styleSheets[i].rules.length;

	 for (var j=0; j<numberOfRules; j++) {
		  if (document.styleSheets[i].rules[j].selectorText == s) {
			  document.styleSheets[i].rules[j].style[p] = v;
			  return;
		  }
	 }
}
}



// END
