var elements = document.getElementsByClassName( /* class names other than aid_* ones */
var re = new RegExp('(^|s)aid_(s|$)');
var result = [];
for (var i=0, iLen=elements.length; i<iLen; i++) {
if (re.test(elements[i].className)) {
result.push(elements[i]);
}
}