// JavaScript Document
var GetRandomNum = function(thenum) {
	var rndm = Math.floor(Math.random()*thenum);
	return rndm;
};

// DATA

var theHomeImages = [];
// Image file
theHomeImages[0] = ["ANT1.jpg"];
theHomeImages[1] = ["ANT2.jpg"];
theHomeImages[2] = ["CENTIPEED.jpg"];
theHomeImages[3] = ["EBT.jpg"];
theHomeImages[4] = ["PENGUIN.jpg"];
theHomeImages[5] = ["RABBIT.jpg"];
theHomeImages[6] = ["ZEBRA.jpg"];

// FUNCTION THAT CHECKS THE DOM 
function getObj(name){
if (document.getElementById)
{this.obj = document.getElementById(name);}
else if (document.all)
{this.obj = document.all[name];}
else if (document.layers)
{this.obj = document.layers[name];}
}

function getHomeImage() {
var thisImageNum = GetRandomNum(theHomeImages.length);
var thisImageFile = "home_images\/" + theHomeImages[thisImageNum][0];
var thisImageHTML = "<img src='" + thisImageFile + "' alt='Welcome' border='0' \/>";
var thisImage = new getObj("home_image");
thisImage.obj.innerHTML = thisImageHTML;
}

// CENTER WINDOW //
function getWindowHeight() {
var windowHeight=0;
if (typeof(window.innerHeight) == 'number') {
windowHeight = window.innerHeight;
}
else {
if (document.documentElement && document.documentElement.clientHeight) {
windowHeight = document.documentElement.clientHeight;
}
else {
if (document.body&&document.body.clientHeight) {
windowHeight = document.body.clientHeight;
}
}
}
return windowHeight;
}


function setSpacing() {
if (document.getElementById) {
var windowHeight = getWindowHeight();
if (windowHeight > 0) {
var contentElement = new getObj('wrapper');
var contentHeight = contentElement.obj.offsetHeight;
if (windowHeight - contentHeight > 0) {	
contentElement.obj.style.position = 'relative';
contentElement.obj.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
}
else {
contentElement.obj.style.position = 'relative';
contentElement.obj.style.top = "0px";
}
}
}
}
