var timer;

//----------------------------------------> send messages from the browser to the applet
function stopit() {
	document.applets[0].cmd_stop();
}
function playOne(id) {
	if (document.applets[0].cmd_isID(id)) {
		clearTimeout(timer);
		reponse = document.applets[0].cmd_playS(id);
		if (reponse) {
			timer = setTimeout("loop()", 500);
		}
	}
}

function playFrom(id) {
	if (!document.applets[0].isActive()) {
		alert("Please wait until the applet is active.");
	} else {
		if (document.applets[0].cmd_isID(id)) {
			clearTimeout(timer);
			reponse = document.applets[0].cmd_playFrom(id);
			if (reponse) {
				timer = setTimeout("loop()", 500);
			}
		}
	}
}

function loop() {
	document.applets[0].cmd_nextEvent();
	timer = setTimeout("loop()", 10);
}

//----------------------------------------> send messages from the applet to the browser
function startplay(id) {
	highlight(true, id);
}
function endplay(id) {
	highlight(false, id);
}
function stopplay() {
	clearTimeout(timer);
}
function highlight(bool, id) {
	if (document.all.item(id)) {
		var theItem = document.all.item(id);
		if (bool) {
			theItem.style.color = "#FF00FF";
		} else {
			theItem.style.color = "black";
		}
	}
}