numberOfImages = 11;	 /* increment this if you add images */
time = 60;		 /* seconds before rotate */
path = "/glam/images/";
timerSet = 0;
var imgs = new Array();

function preLoad() {
    for ( var i = 0; i <= numberOfImages; i++ ) {
        imgs[ i ] = document.createElement( 'img' );
        imgs[ i ].setAttribute( 'src', path + "doodle" + i + ".gif" );
    };

    imgs[ 20 ] = document.createElement( 'img' );
    imgs[ 20 ].setAttribute( 'src', path + "doodle0-z.gif" );
    imgs[ 21 ] = document.createElement( 'img' );
    imgs[ 21 ].setAttribute( 'src', path + "doodle2-z.gif" );
    imgs[ 22 ] = document.createElement( 'img' );
    imgs[ 22 ].setAttribute( 'src', path + "doodle3-z.gif" );
    imgs[ 23 ] = document.createElement( 'img' );
    imgs[ 23 ].setAttribute( 'src', path + "doodle6-z.gif" );
    imgs[ 26 ] = document.createElement( 'img' );
    imgs[ 26 ].setAttribute( 'src', path + "doodle7-z.gif" );
    imgs[ 24 ] = document.createElement( 'img' );
    imgs[ 24 ].setAttribute( 'src', path + "doodle8-z.gif" );
    imgs[ 25 ] = document.createElement( 'img' );
    imgs[ 25 ].setAttribute( 'src', path + "doodle9-z.gif" );
    imgs[ 27 ] = document.createElement( 'img' );
    imgs[ 27 ].setAttribute( 'src', path + "graduate_linguist_lettering.gif" );
};

function setBG( image ) {
index = Math.floor( Math.random() * numberOfImages );

var i = document.getElementById( "image" );
i.style.visibility = "hidden";
var z = document.getElementById( "z_image" );
z.style.visibility = "hidden";

i.setAttribute( "src", imgs[ index ].getAttribute( 'src' ));
i.style.visibility = "visible";

switch ( index ) {
    case 0:
    case 2:
    case 3:
    case 6:
    case 7:
    case 8:
    case 9:
	z.setAttribute( "src", path + "doodle" + index + "-z.gif" );
	z.style.visibility = "visible";
	break;
    default:
	    break;
    }

    if ( timerSet ) {
	clearTimeout( timerSet );
    }
    timerSet = window.setTimeout( "setBG()", time * 1000 );
}

onload = function() {
    preLoad();
    setBG();
}
