Yeah, id attributes need to be unique, so you can't have two elements with id="foo" on the same page.
You could change id="foo" to class="foo" and then use a loop like this to go through them all...
code:
function fontsize(px) {
var spanElements = document.getElementsByTagName('span');
for(var i = 0; i < spanElements.length; i++) {
if(spanElements[i].className == 'foo') {
spanElements[i].style.fontSize = px;
}
}
}