// $Id: score.js,v 1.4 2005/05/18 15:00:17 kai Exp $
// $Log: score.js,v $
// Revision 1.4  2005/05/18 15:00:17  kai
// Fehler bei validtiles behoben
//
// Revision 1.3  2004/07/10 21:13:57  kai
// Refaktorisiert und HTML-Element-Stuktur überarbeitet
//
// Revision 1.2  2004/07/09 23:20:31  kai
// Dummy Hiscoreliste eingefügt, fertige Reihen beschleunigen die Steine
//
// Revision 1.1.1.1  2004/07/09 22:36:28  kai
// Erster Import
//

function score(left, top)
{
	// Members
	this.myscore;
	this.mylines;
	this.left;
	this.top;
	this.scorewindow;

	// Member functions
	this.add = score_add;
	this.reset = score_reset;
	this.get = score_get;
	this.update = score_update;
	this.show = score_show;

	// Init
	this.left = left;
	this.top = top;
	divhtml = "<form><span style=\"font-family:Arial,Helvetica,sans-serif;font-size:10pt;font-weight:bold;\">Score:</span><br><input type=\"text\" style=\"width:90px;\" id=\"thescore\" value=\"0\"><br><br><span style=\"font-family:Arial,Helvetica,sans-serif;font-size:10pt;font-weight:bold;\">Lines:</span><br><input type=\"text\" style=\"width:90px;\" id=\"thelines\" value=\"0\"><br><br><input style=\"width:90px;\" type=\"button\" value=\"Neues Spiel\" onClick=\"location.reload();\"><br><br><input style=\"width:90px;\" type=\"button\" value=\"Pause\" onClick=\"if(thetile.paused)thetile.paused=false;else thetile.paused=true;\"></form>";

	div = document.createElement("div");
	with(div.style)
	{
		position = "absolute";
		left = this.left;
		top = this.top;
	}
	div.innerHTML = divhtml;

	document.getElementById("tetris").appendChild(div);

	this.reset();

	return;
}

function score_update()
{
	document.getElementById("thescore").value=this.myscore;
	document.getElementById("thelines").value=this.mylines;
	return;
}

function score_show()
{
	if(this.scorewindow = open("", "HiScores", "height=300,width=400"))
	{
		this.scorewindow.document.open();
		this.scorewindow.document.write("<html><body bgcolor=\"#cccccc\" text=\"#000000\"><table><tr><td>Pos.</td><td>Name:</td><td>Score:</td><td>Lines:</td></tr>");
		for(i = 0; i < 10; i++)
		{
			this.scorewindow.document.write("<tr><td>" + (i + 1) + "</td><td>" + hiscore[i][2] + "</td><td>" + hiscore[i][0] + "</td><td>" + hiscore[i][1] + "</td></tr>");
		}
		this.scorewindow.document.write("</table></body></html>");
	}
	return;
}

function score_add(addscore, addlines)
{
	this.myscore += addscore;
	this.mylines += addlines;
	this.update();
	return;
}

function score_reset()
{
	this.myscore = 0;
	this.mylines = 0;
	this.update();
	return;
}

function score_get()
{
	return this.myscore;
}