/**
 * @author strike
 */
function entry() {
	this.id = document.getElementById("entryBanner");
	this.interval = 10;
	this.jump = 0.2;
	this.preload = 0;
	this.preloadCount = 0;
	
	init(this);
	
	function init(obj) {
		preloadStart(obj);
	}
	
	function preloadStart(obj) {
		images = Array("images/entry_header.jpg","images/image1.jpg","images/image2.jpg","images/entryButton.jpg");
		obj.preloadCount = images.length;
		for (var i=0; i<images.length; i++) {
			imageset = new Image();
			imageset.onload = function() { preloadEvent(obj); };
			imageset.src = images[i];
		};
		
	}
	
	function preloadEvent(obj) {
		obj.preload++;
		if (parseInt(obj.preload) == parseInt(obj.preloadCount)) {
			document.getElementById("preload").style.display = "none";
			reset(obj);
			bringIn(obj);
		}
	}
	
	function bringIn(obj) {
		obj.animation = window.setInterval( function() {
			obj.id.style.opacity = obj.counter/10;
			obj.id.style.filter = 'alpha(opacity=' + obj.counter*10 + ')';
			obj.counter = parseFloat(Number(obj.counter + obj.jump).toPrecision(2));
			if (obj.counter >= 10) {
				clearInterval(obj.animation);
				obj.id.style.opacity = 10/10;
				obj.id.style.filter = 'alpha(opacity=' + 10*10 + ')';
				obj.animation = false;
				if(obj.id.id == "entryBanner") {
					obj.id = document.getElementById("entryImages");
					reset(obj);
					setTimeout(function () { bringIn(obj); },1 * 1000);
				}
				else if(obj.id.id == "entryImages") {
					slide = new slideShow('entryImage',20,0.2,5);
					obj.id = document.getElementById("entryButton");
					reset(obj);
					setTimeout(function () { enterCheck(obj,slide); },1000);
				}
				
			}
		},obj.interval);
	}
	
	function enterCheck(obj,slide) {
		if (slide.ready) {  setTimeout(function () { bringIn(obj); },1000); }
		else { setTimeout(function () { enterCheck(obj,slide); },1000); }
	}
	
	function reset(obj) {
		obj.counter = 0;
		obj.id.style.opacity = 0/10;
		obj.id.style.filter = 'alpha(opacity=' + 0*10 + ')';
		obj.id.style.display = "block";
	}
}
