var siteImages = new Array(
	"http://" + location.hostname + "/_images/layout/bg.jpg",
	"http://" + location.hostname + "/_images/layout/contentBg.jpg",
	"http://" + location.hostname + "/_images/layout/contentWrapBg.jpg",
	"http://" + location.hostname + "/_images/layout/footerdivider.jpg",
	"http://" + location.hostname + "/_images/layout/header.jpg",
	"http://" + location.hostname + "/_images/layout/navbg.jpg",
	"http://" + location.hostname + "/_images/layout/navdivider.gif",
	"http://" + location.hostname + "/_images/layout/logos/acuc.gif",
	"http://" + location.hostname + "/_images/layout/logos/ADNoContentLogo.gif",
	"http://" + location.hostname + "/_images/layout/logos/adventureDiversLogo.gif",
	"http://" + location.hostname + "/_images/layout/logos/padi.gif",
	"http://" + location.hostname + "/_images/layout/logos/sdi.gif",
	"http://" + location.hostname + "/_images/layout/logos/tdi.gif",
	"http://" + location.hostname + "/_images/layout/nav/navSprite.gif");

var imgLen = siteImages.length;

var loaded = new Array(), preImages = new Array(), currCount = 0;

function loadImages() {
	
	for (i = 0; i < imgLen; i++) {
		preImages[i] = new Image();
		
		preImages[i].src = siteImages[i];
		
		loaded[i] = 0;
	}
	
	checkLoad();
}

function checkLoad() {
	
	if (currCount == imgLen) { 
		$('counter').innerHTML = '<center><span style="font-family:arial;font-size:24px;font-weight:bold;color:#fff;">Welcome...</span></center>' 
		setTimeout("go()", 1000); 
		return; 
	}
	
	for (i = 0; i < imgLen; i++) {
		
		if (!loaded[i] && preImages[i].complete) {
			
			loaded[i] = 1; currCount++;
			
			var l = i + 1;
		  var perc = l / imgLen * 100;
			$('counter').innerHTML =  '<center><span style="font-family:arial;font-size:24px;font-weight:bold;color:#fff;">' + Math.round(perc) + '% Loaded.</span></center>';
			 
			setTimeout("checkLoad()", 50);
			return;
		}
	}
	
	setTimeout("checkLoad()",10);
}

function go() {
	window.location = location.href + "home";
}