//Code for Random Picture Selector
//JavaScript code by Sean Jackson
var numGraphics = 6;
var theGraphics = null;

function getRandomNumber(n) {
        //Returns a pseudorandom number between 1 and n
        today = new Date();
        var bigNum = today.getSeconds() * today.getTime() * Math.sqrt(today.getMinutes());
        var randNum = (bigNum % n) + 1;
        return Math.floor(randNum);
}

function initArray(n) {
        this.length = n;
        for(var i = 1; i <= n; i++) {
                this[i] = "";
                }
        return this;
}

function initGraphics() {
        //Name Graphics: graphicnn where nn is a whole number
        //in the format "01" to "99"
        theGraphics = new initArray(numGraphics);
        for(i = 1; i <= numGraphics; i++) {
                if (i < 10) {
                        theGraphics[i] = "0" + i + ".gif"
                } else {
                        theGraphics[i] = i + ".gif"
                }
        }
}

function getRandomGraphic() {
        var theIndex = getRandomNumber(numGraphics);
        return theGraphics[theIndex];
}

function getGraphic() {
        var theGraphicName = getRandomGraphic();
        theGraphic = "../-/images/anniversary/img_0" + theGraphicName
        return theGraphic
}

function loadGraphic() {
        theGraphic = getGraphic();
        var theTag = '<img src= "' + theGraphic + '"';
        theTag += 'alt="looking back" />'
        document.write(theTag);
}

initGraphics();

loadGraphic();
