function getElementsByClassName(classname) {
var elements;
var pattern;
var i;
var results = [];
if (doc.querySelectorAll) { // IE8
return doc.querySelectorAll('.' + classname);
}
if (doc.evaluate) { // IE6, IE7
pattern = './/*[contains(concat(" ", @class, " "), " " + classname + " ")]';
elements = doc.evaluate(pattern, d, null, 0, null);
while ((i = elements.iterateNext())) {
results.push(i);
}
} else {
elements = doc.getElementsByTagName('*');
pattern = new RegExp('(^|\s)' + classname + '(\s|$)');
for (var i = 0, length = elements.length; i < length; i++) {
if (pattern.test(elements[i].className)) {
results.push(elements[i]);
}
}
}
return results;
}