Javascript Utility Functions

Change Class Names

Example: changeClassNames( "metercontainer", "metercontainer_hidden");

function changeClassNames(oldClassName,newClassName) { //thanks, google
var divs = document.getElementsByTagName(‘div’)
for (var i=0;iGet Elements By Class Name

Example: var elementsArray = getElementsByClassName(document, 'div', 'meterbar');

function getElementsByClassName(oElm, strTagName, strClassName){ //thanks, google
var arrElements = (strTagName == “*” && document.all)? document.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, “\\-“);
var oRegExp = new RegExp(“(^|\\s)” + strClassName + “(\\s|$)”);
var oElement;
for(var i=0; i