
function stopError() {
  return true;
}

window.onerror = stopError;

var isNav4, isIE4
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
  isNav4 = (navigator.appName == "Netscape") ? true : false;
  isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
}

function makesound(soundobj) {
	if (isIE4) {
		var thissound = eval("document."+soundobj)
		thissound.play();
	}
}

action = new Object();
action[0] = "_df"
action[1] = "_ov"
action[2] = "_ot"
action[3] = "_dn"

function flip(id, act) {
	if(document.images) document.images[id].src = eval( "button." + id + action[act] + ".src");
}


var steps=2
var speed=1
var direction="Left"

var trainRight = new Image();
trainRight.src = "images/train_ani_r.gif";
var trainLeft = new Image();
trainLeft.src = "images/train_ani_l.gif";

function moveTrain() {
	if (isNav4) {
		var position = document.train.left;
	}
	if (isIE4) {
		var position = document.all.train.style.pixelLeft;
	}
	if (direction == "Right") {
		setTimeout("moveTrain()", speed);
		moveRight(position);
	} else {
	setTimeout("moveTrain()", speed);
        moveLeft(position);
	}
}


function moveRight(position) {
	if (position < 650) {
		if (isNav4) {
			document.train.left += steps;
		}
		if (isIE4) {
			document.all.train.style.pixelLeft += steps;
		}
	} else {
    	changeDirection();
    }	
}


function moveLeft(position) {
	if (position > 0) {
		if (isNav4) {
			document.train.left -= steps;
		}
		if (isIE4) {
			document.all.train.style.pixelLeft -= steps;
		}
	} else {

    	changeDirection();
    }	
}


function changeDirection () {
	if (isNav4) {
		var test = document.train.document.images["traingif"];
	}
	if (isIE4) {
		var test = document.all.traingif;
	}
	if (direction == "Right") {
		direction = "Left";
		test.src = trainLeft.src;
	} else {
		direction = "Right";
		test.src = trainRight.src;
	}
	return;
}

window.onload = moveTrain;

