// If Core doesn't exist, make it an empty object
Core = Core || {};
Core.getElementsByClass = function(theclass) {
var matchedArray = [];
if (typeof document.all != "undefined") { //Explorer 5.x and other browsers only
elementArray = document.all; //support document.all to retrieve all document
} //elements
else {
elementArray = document.getElementsByTagName("*");
}
//the following variable uses RegExp to find a particular string pattern.
//in this case, it is the name of the class we are searching for.
var pattern = new RegExp("(^| )" + theclass+ "( |$)");
var matchedArray[]; //to hold matched class name elements
//now we need to search through all the collected elements in the document and
//see if they match the class pattern described in the var pattern
for (var i=0; i
matchedArray[matchedArray.length]=elementArray[i];
}
} //end for loop
return matchedArray;
} //end Core.getElementsByClass
alert("Hello there");