WTF Javascript

Hi everyone,

I got a javascript problem. I know what is happening but I need some explanation.

I have a function I call when the page is loaded. It sets a variable named content to document.getElementById(‘content’);. I know i have seen this done before but it seems to be the problem. When i set the code up like this. It works in FF but not IE or safari.

function pageLoaded(){
content = document.getElementById('content'); //get the content section
    buildGallery();
}

///function builds the gallery page
function buildGallery(){
    function stampHeaders(){//make the header images
        var urls = new Array("images/web.gif", "images/print.gif", "images/mm.gif");
        for(var i=0; i<3; i++){
            newitem = document.createElement('img');
            newitem.src=urls*;
            newitem.className="title";
            tempElements.push(newitem);
            content.appendChild(newitem);
        }
        
    };//closes stamp headers
    stampHeaders();
}

When I drop the content variable and just get the element in other functions it works in all three. So apparently you cannot assign getElementById to variables?

function pageLoaded(){
    buildGallery();
}

///function builds the gallery page
function buildGallery(){
    function stampHeaders(){//make the header images
        var urls = new Array("images/web.gif", "images/print.gif", "images/mm.gif");
        for(var i=0; i<3; i++){
            newitem = document.createElement('img');
            newitem.src=urls*;
            newitem.className="title";
            tempElements.push(newitem);
           document.getElementById('content').appendChild(newitem);
        }
        
    };//closes stamp headers
    stampHeaders();
}