function BrowserCheck() {
var b = navigator.appName;
if (b == "Netscape") this.b = "NS";
else if (b == "Microsoft Internet Explorer") this.b = "IE";
else this.b = b;
this.v = parseInt(navigator.appVersion);
this.NS = (this.b == "NS" && this.v>=4);
this.NS4 = (this.b == "NS" && this.v == 4);
this.NS5 = (this.b == "NS" && this.v == 5);
this.IE = (this.b == "IE" && this.v>=4);
this.IE4 = (navigator.userAgent.indexOf('MSIE 4')>0);
this.IE5 = (navigator.userAgent.indexOf('MSIE 5')>0);
if (this.IE5 || this.NS5) this.VER5 = true;
if (this.IE4 || this.NS4) this.VER4 = true;
this.OLD = (! this.VER5 && ! this.VER4) ? true : false;
this.min = (this.NS||this.IE);
}
is = new BrowserCheck();



iter = 0;
setId = 0;
down = true;
up = false;
bHide = false;

winH = (is.NS) ? window.innerHeight - 75 : document.body.offsetHeight - 75;



var DukeX = 0;
var DukeY = 0;
var DukeId = 0;
var DukeDirection = 0;
var DukeMaxAnim = 0;



function doAnimDuke() {
	var dukeMsg = (is.VER5) ? document.getElementById('divDukeMsg').style: (is.NS) ? document.layers['divDukeMsg']: document.all['divDukeMsg'].style;
	dukeMsg.visibility = "hidden";

	if(DukeDirection == 0) {
		DukeX = DukeX - 20;
	} else {
		DukeX = DukeX + 20;
	}

	if(((DukeDirection == 0) && (DukeX > 380)) || ((DukeDirection == 1) && (DukeX < 500))) {
		moveContainer("divDuke", DukeX , DukeY);
		DukeId = setTimeout("doAnimDuke()", 20);
	} else {
		clearTimeout(DukeId);

		if(DukeDirection == 0) {
			DukeDirection = 1;
		} else {
			DukeDirection = 0;
		}
	}
}



function doAnimDuke2() {
	var dukeObj = (is.VER5) ? document.getElementById('divDuke'): (is.NS) ? document.layers['divDuke']: document.all['divDuke'];
	var duke = (is.VER5) ? document.getElementById('divDuke').style: (is.NS) ? document.layers['divDuke']: document.all['divDuke'].style;
	var dukeMsg = (is.VER5) ? document.getElementById('divDukeMsg').style: (is.NS) ? document.layers['divDukeMsg']: document.all['divDukeMsg'].style;
	
	dukeMsg.visibility = "hidden";
	dukeObj.onclick = "";
	duke.top = 130;
	duke.cursor = "auto";

	iter = 0;
	setId = setInterval("generateGravity('divDuke')", 20);
}



function doHideDuke() {
	var duke = (is.VER5) ? document.getElementById('divDuke').style: (is.NS) ? document.layers['divDuke']: document.all['divDuke'].style;
	var dukeMsg2 = (is.VER5) ? document.getElementById('divDukeMsg2').style: (is.NS) ? document.layers['divDukeMsg2']: document.all['divDukeMsg2'].style;

	dukeMsg2.visibility = "hidden";
	duke.visibility = "hidden";
}



function doShowDuke() {
	var duke = (is.VER5) ? document.getElementById('divDuke').style: (is.NS) ? document.layers['divDuke']: document.all['divDuke'].style;	

	duke.visibility = "visible";
	DukeMaxAnim = 0;
}



function doDuke() {
	var dukeMsg = (is.VER5) ? document.getElementById('divDukeMsg').style: (is.NS) ? document.layers['divDukeMsg']: document.all['divDukeMsg'].style;
	var dukeMsg2 = (is.VER5) ? document.getElementById('divDukeMsg2').style: (is.NS) ? document.layers['divDukeMsg2']: document.all['divDukeMsg2'].style;

	DukeMaxAnim++;
	if(DukeMaxAnim <= 2) {
		dukeMsg.visibility = "visible";

		DukeId = setTimeout("doAnimDuke2()", 400);
	} else {
		dukeMsg2.visibility = "visible";
		setTimeout("doHideDuke()", 600);

		setTimeout("doShowDuke()", 10000);
	}
}



function generateGravity(bo) {
	eval("var bouncingBall = (is.VER5) ? document.getElementById('" + bo + "').style: (is.NS) ? document.layers['" + bo + "']: document.all['" + bo + "'].style;");
	eval("var bouncingBallObj = (is.VER5) ? document.getElementById('" + bo + "'): (is.NS) ? document.layers['" + bo + "']: document.all['" + bo + "'];");

	if ((parseInt(bouncingBall.top)+iter < winH) && down) {
		bouncingBall.top = parseInt(bouncingBall.top) + iter;
		iter++;
		return;
	} else {
		if ((parseInt(bouncingBall.top)< winH) && down) {
		bouncingBall.top = winH + 5;
		return;
		}

		down = false;
		up = true;

		if (iter < 0 && parseInt(bouncingBall.top) > winH) {
			clearInterval(setId);
			setId = 0;

			if(bHide) {
				bouncingBall.visibility = "hidden";
			} else {
				setTimeout("doAnimDuke()", 300);

				bouncingBall.cursor = "hand";
				DukeX = bouncingBall.left.substring(0, bouncingBall.left.length - 2);
				DukeY = bouncingBall.top.substring(0, bouncingBall.top.length - 2);
				bouncingBallObj.onclick = doDuke;
			}
		}

		if (parseInt(bouncingBall.top) > 0 && up && iter >= 0) {
			bouncingBall.top = parseInt(bouncingBall.top) - iter;
			iter--;
			if (iter%3 == 0) iter--;
			return;
		}

		down = true;
		up = false;
   	}
}
