function moveIdTo(id, x, y ) {
	document.getElementById(id).style.left = x;
	document.getElementById(id).style.bottom = window.height - y;
}

yoffset = document.height-285;

toad1x = 505;
toad1y = yoffset+224;
toad1xi = 0;
toad1a = 1;

toad2x = 775;
toad2y = yoffset+224;
toad2xi = 1;
toad2a = 1;

toad3x = 1200;
toad3y = yoffset+201;
toad3xi = 1;
toad3a = 1;

toad4x = 1300;
toad4y = yoffset+201;
toad4xi = 1;
toad4a = 1;

shell1x = 848;
shell1y = yoffset+158;
shell1xi = 1;
shell1a = 1;
shell1path = 0;

flying1x = 1400;
flying1y = yoffset+132;
flying1xi = 1;
flying1a = 1;

mushroomx =360 ;
mushroomy = yoffset+78;
mushroompath = 0;


function animateToads() {

	if (toad1a == 1) {
		if (toad1xi == 0)
			toad1x = toad1x + 2;
		else
			toad1x = toad1x - 2;
		if (toad1x > 505)
			toad1xi = 1
		if (toad1x < 0)
			toad1xi = 0	
		moveIdTo("toad1", toad1x, toad1y);
	}

	if (toad2a == 1) {
		if (toad2xi == 0)
			toad2x = toad2x + 2;
		else
			toad2x = toad2x - 2;
		if (toad2x > 910)
			toad2xi = 1
		if (toad2x < 575)
			toad2xi = 0
		moveIdTo("toad2", toad2x, toad2y);
	}

	if (toad3a == 1) {
		if (toad3xi == 0)
			toad3x = toad3x + 2;
		else
			toad3x = toad3x - 2;
		if (toad3x > 1606)
			toad3xi = 1
		if (toad3x < 1009)
			toad3xi = 0	
		moveIdTo("toad3", toad3x, toad3y);
	}

	if (toad4a == 1) {
		if (toad4xi == 0)
			toad4x = toad4x + 2;
		else
			toad4x = toad4x - 2;
		if (toad4x > 1606)
			toad4xi = 1
		if (toad4x < 1009)
			toad4xi = 0
		moveIdTo("toad4", toad4x, toad4y);
	}

	if (shell1a == 1) {
		if (shell1xi == 0)
			shell1x = shell1x + 2;
		else
			shell1x = shell1x - 2;
	
		if (shell1x > 888) {
			document.getElementById('shell1').style.background = 'url(shell1.gif)';
			shell1xi = 1;
		}
	
		if (shell1x < 770) {
			document.getElementById('shell1').style.background = 'url(shell0.gif)';
			shell1xi = 0;
		}
	}

	moveIdTo("shell1", shell1x, shell1y);

	if (flying1a == 1) {
		if (flying1xi == 0)
			flying1x = flying1x + 2;
		else
			flying1x = flying1x - 2;
		if (flying1x > 1606)
			flying1xi = 1;
		if (flying1x < 1009)
			flying1xi = 0;
	}

	setTimeout(animateToads,45);
}

function startup() {
	moveIdTo("box1a", 263, yoffset+150);
	moveIdTo("box1b", 288, yoffset+150);
	moveIdTo("box2a", 360, yoffset+78);
	moveIdTo("box2b", 335, yoffset+78);
	moveIdTo("box3", 624, yoffset+102);
	moveIdTo("box4", 984, yoffset+198);
	moveIdTo("box5", 1055, yoffset+150);

	moveIdTo("coin0", 1625, yoffset+110);
	moveIdTo("coin1", 1695, yoffset+60);
	moveIdTo("coin2", 1765, yoffset+10);

	animateToads();
}

$(document).ready(function() { startup(); });

