// 1. Img clicked, change img
// 2. change coin to gif
// 3. start changing the imag sizes
// 4. coin hits ground 
// 5. clicked all imgs reset result in new window

var height;
var direction;
var width;

function ct_begin(notused)
{
	// 1
	document.mainimg.src='images/rfterh.jpg';

	// 3.1 
	direction="juststarted";
	height=20;
	width=150;
	setTimeout("coininspace()",500);
}

// 3
function coininspace()
{
	if (direction=="down") {
		height=height-10;
		if (height<=1) {
			direction="hitfloor"
		}
		document.bottomcontrol.height=height;
		document.topcontrol.height=150-height;
	}
	if (direction=="up") {
		height=height+10;
		if (height>=150) {
			direction="down"
		}
		document.bottomcontrol.height=height;
		document.topcontrol.height=150-height;
	}

	document.airpush.width=width;
	width=width-5;

	if (direction=="hitfloor" ) {
		document.coin.src='images/coinflat.gif';
		setTimeout("resetcoin()",2500);
	} else if (direction=="juststarted"){
		// 2
		document.coin.src='images/coin.gif';
		direction="up";
		setTimeout("coininspace()",500);
	} else {
		setTimeout("coininspace()",100);
	}
	window.status=height;
	//alert(height);
}

// 4 & 5
function resetcoin()
{
	window.open("win.html","naffall");
	document.airpush.width=150;
	document.mainimg.src='images/b4h.jpg';
	document.coin.src='images/coinspace.gif';
}
