// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array. Rememeber
// to increment the theImages[x] index!

theImages[0] = 'images/the_test02.jpg'
theImages[1] = 'images/the_test03.jpg'
theImages[2] = 'images/the_test04.jpg'
theImages[3] = 'images/the_test05.jpg'
theImages[4] = 'images/the_test06.jpg'
theImages[5] = 'images/the_test07.jpg'
theImages[6] = 'images/the_test08.jpg'
theImages[7] = 'images/the_test09.jpg'

// do not change anything below this line

var j = 0
var p = theImages.length;

var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));

var hideLoader = function(){
	dojo.fadeOut({
		node:"preloader",
		duration:100,
		onEnd: function(){
			dojo.style("preloader", "display", "none");
		}
	}).play();
}

function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
    obj.attachEvent( 'on'+type, obj[type+fn] );
  } else
    obj.addEventListener( type, fn, false );
}

/*IE has some serious DOM issues, so we have to wait for the load instead of domready*/
if(dojo.isIE){
	addEvent(window, 'load', function(event) {
		dojo.parser.parse();
		hideLoader();
		showImage();
	});
}else{
	dojo.addOnLoad(function(){
		// notice the second onLoad here:
		dojo.addOnLoad(function(){
			dojo.parser.parse();
			hideLoader();
			showImage();
		});
	});
}



function showImage(){
	if(dojo.byId('imageTopper'))
		dojo.byId('imageTopper').innerHTML = '<img src="'+theImages[whichImage]+'">';
}