/* copyright Tomas Young 2008 */

/*
document.write('<div id="stars-st" style="position:absolute; left=180px; top=20px; z-index=-5;"> \
                <img name="stars-i" src="stars3.gif" border="0" width=1350 height=800> \
                </div>');
document.write('<div style="position:absolute; left=1330px; top=150px;"> \
                <img name="planet-i" src="mercury.jpg" border="0" width=150 height=150> \
                </div>');
document.write('<div id="rocket-st" style="position:absolute; left=10px; top=750px;"> \
                <img name="rocket-i" src="rocket5b.gif" border="0" width=125 height=60> \
                </div>');
document.write('<div id="astronaut-st" style="position:absolute; left=1350px; top=140px;"> \
                <img name="astronaut-i" src="blank.gif" border="0" width=30 height=40> \
                </div>');
*/

// document.write('<bgsound src="#" id="rocket-s" autostart=true hide=true loop=false volume=-400>');

if(screen.width >= 1400) {
    document.write('<div id="stars-st" style="position:absolute; left:180px; top:20px; z-index:-5;"> \
                    <img name="stars-i" src="stars3.gif" border="0" width=1050 height=650> \
                    </div>');
    document.write('<div style="position:absolute; left:1020px; top:130px;"> \
                    <img name="planet-i" src="mercury.jpg" border="0" width=150 height=150> \
                    </div>');
    document.write('<div id="rocket-st" style="position:absolute; left:10px; top:600px;"> \
                    <img name="rocket-i" src="rocket5b.gif" border="0" width=125 height=60> \
                    </div>');
    document.write('<div id="astronaut-st" style="position:absolute; left:1047px; top:120px;"> \
                    <img name="astronaut-i" src="blank.gif" border="0" width=30 height=40> \
                    </div>');
}
else {
    document.write('<div id="stars-st" style="position:absolute; left:150px; top:20px; z-index:-5;"> \
                    <img name="stars-i" src="stars3.gif" border="0" width=800 height=500> \
                    </div>');
    document.write('<div style="position:absolute; left:780px; top:130px;"> \
                    <img name="planet-i" src="mercury.jpg" border="0" width=150 height=150> \
                    </div>');
    document.write('<div id="rocket-st" style="position:absolute; left:10px; top:465px;"> \
                    <img name="rocket-i" src="rocket5b.gif" border="0" width=100 height=45> \
                    </div>');
    document.write('<div id="astronaut-st" style="position:absolute; left:809px; top:120px;"> \
                    <img name="astronaut-i" src="blank.gif" border="0" width=30 height=40> \
                    </div>');
}

var game_fun_st = null;
var game_fun_s = null;
var game_fun_i = null;

var game_fun_level = 0;
var game_fun_x = 0;
var game_fun_y = 0;
var game_fun_z = 0;

var stObj = null;
var stX = 0;
var stXmax = 0;
var stY = 0;
var x_center = 0;
var parabola_w2 = 1;

var game_loops = 0;
var planets = new Array;

planets[0] = "mercury.jpg";
planets[1] = "venus.jpg";
planets[2] = "earth.jpg";
planets[3] = "mars.jpg";
planets[4] = "jupiter.jpg";
planets[5] = "saturn.jpg";
planets[6] = "uranus.jpg";
planets[7] = "neptune.jpg";
planets[8] = "pluto.jpg";

function flyRocket() {
    stObj = document.getElementById(game_fun_st);
    var d = stX - x_center;
    var yy = parabola_w2 * d * d;
    stObj.style.left = stX;
    yy = yy * .005;
    stObj.style.top = yy + stY - 130;
    stX += 5;
    if(game_fun_level == 1) {
	iObj = document.getElementsByName(game_fun_i)[0];
	iObj.src = "rocket5b.gif";
    }
    if(stX < stXmax) {
	setTimeout('flyRocket()',32);
    }
    else if(game_fun_level == 6) {
	iObj = document.getElementsByName(game_fun_i)[0];
	iObj.src = "rocket6b.gif";
	if(screen.width >= 1400) {
	    iObj.width = 60;
	    iObj.height = 125;
	}
	else {
	    iObj.width = 45;
	    iObj.height = 100;
	}
    }
}

function game_fun(s) {
    game1_delay[1] = 3000;
    if(s == true) {
	parabola_w2 = 1;
	if(game_fun_level == 0) {
	    document["astronaut-i"].src = "blank.gif";
	    // stX = 10; stXmax = 263; stY = 760;
	    if(screen.width >= 1400) {
		stX = 10; stXmax = 240; stY = 580; parabola_w2 = 2;
	    }
	    else {
		stX = 10; stXmax = 197; stY = 492; parabola_w2 = 2;
	    }
	    x_center = stX+(stXmax-stX)/2;
	    if(game_loops > 0) {
		iObj = document.getElementsByName(game_fun_i)[0];
		iObj.src = "blank.gif";
		if(screen.width >= 1400) {
		    iObj.width = 125;
		    iObj.height = 60;
		}
		else {
		    iObj.width = 100;
		    iObj.height = 45;
		}
		document["planet-i"].src = planets[game_loops % 9];
	    }
	}
	else if(game_fun_level == 1) {
	    // stX = 263; stXmax = 492; stY = 700;
	    if(screen.width >= 1400) {
		stX = 240; stXmax = 420; stY = 545; parabola_w2 = 3;
	    }
	    else {
		stX = 197; stXmax = 334; stY = 474; parabola_w2 = 3;
	    }
	    x_center = stX+(stXmax-stX)/2;
	}
	else if(game_fun_level == 2) {
	    // stX = 492; stXmax = 726; stY = 680;
	    if(screen.width >= 1400) {
		stX = 420; stXmax = 600; stY = 530; parabola_w2 = 3;
	    }
	    else {
		stX = 334; stXmax = 471; stY = 467; parabola_w2 = 3;
	    }
	    x_center = stX+(stXmax-stX)/2;
	}
	else if(game_fun_level == 3) {
	    // stX = 726; stXmax = 934; stY = 616;
	    if(screen.width >= 1400) {
		stX = 600; stXmax = 762; stY = 490; parabola_w2 = 3;
	    }
	    else {
		stX = 471; stXmax = 594; stY = 456; parabola_w2 = 2;
	    }
	    x_center = stX+(stXmax-stX)/2;
	}
	else if(game_fun_level == 4) {
	    // stX = 934; stXmax = 1170; stY = 640;
	    if(screen.width >= 1400) {
		stX = 762; stXmax = 947; stY = 498; parabola_w2 = 3;
	    }
	    else {
		stX = 594; stXmax = 733; stY = 465; parabola_w2 = 2;
	    }
	    x_center = stX+(stXmax-stX)/2;
	}
	else if(game_fun_level == 5) {
	    // stX = 1170; stXmax = 1500; stY = 140; parabola_w2 = 3;
	    if(screen.width >= 1400) {
		stX = 947; stXmax = 1200; stY = 143; parabola_w2 = 3;
		x_center = stX+(stXmax-stX)/2;
		// stXmax = 1377;
		stXmax = 1065;
	    }
	    else {
		stX = 733; stXmax = 1000; stY = 149; parabola_w2 = 3;
		x_center = stX+(stXmax-stX)/2;
		stXmax = 830;
	    }
	}
	else if(game_fun_level == 6) {
	    document["rocket-i"].src = "rocket9b.gif";
	    document["astronaut-i"].src = "astronaut3.gif";
	}

	var fly = false;
	if(game_fun_level < 6) {
	    fly = true;
	}

	game_fun_level = (game_fun_level + 1) % 7;
	if(game_fun_level == 0) {
	    game_loops++;
	}

	if(fly) {
	    // document.all[game_fun_s].src = "rocket-fly.wav";
	    Sin(game_fun_s,"rocket-fly.wav");
	    setTimeout('flyRocket()',300);
	}
    }
}

