var xmlHttp_g;

function record_score() {
	var score = document.getElementById("current_score").innerHTML;
	var username = 	document.score_60.nickname.value;

	if (username == "") {
		username = "anon";
	}
	
	//document.getElementById("temp_text").innerHTML = username + ": " + score;
	document.getElementById("sub_60").className = "notvisi";
	document.getElementById("sub_60_after").className = "visi";
	
	/* send info */
	xmlHttp_g = GetXmlHttpObject();
	
	if (xmlHttp_g == null)
	{
	alert ("Browser does not support HTTP Request");
	return;
	} 
	
	var url = "scores_add.php";
	url = url + "?n=" +  username + "&s=" + score;
	//url = url + "&sid=" + Math.random();
	 
	xmlHttp_g.onreadystatechange = stateChanged;
	xmlHttp_g.open("GET", url, true);
	xmlHttp_g.send(null);
}

function stateChanged() { 
	 if (xmlHttp_g.readyState == 4 || xmlHttp_g.readyState=="complete") {
	 	var text = xmlHttp_g.responseText;
		
		if (text != "") {
			document.getElementById("score_list").innerHTML = text;	
		}	
 	 }
}

function GetXmlHttpObject() {
	 var xmlHttp = null;

	 try {
 	 	 // Firefox, Opera 8.0+, Safari
 	 	 xmlHttp = new XMLHttpRequest();
		 xmlHttp.overrideMimeType('text/xml');
 	 }
	 catch (e) {
 	 // Internet Explorer
 	 	try {
  	  	   xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  		}
 
 	 	catch (e) {
  	 	   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  	    }
	 }

     return xmlHttp;
}