"use strict";

var Logging_request=null;
function Logging_Save_Score(){
	/*if (!GLOBAL_SPEEDRUN){
		alert("Completed the demo! ...but not in a single sitting.  Time is invalid.")
		return;
	}

	if (!_GET["handle"]){ // PHP timelogging
		alert("Completed the demo! ...but you weren't registered.  Time does not count.")
		return;
	}

	var browser = navigator.appName; 
	if(browser == "Microsoft Internet Explorer"){
		Logging_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else{
		Logging_request = new XMLHttpRequest();
	}
	*/
	var completion=0;
	for (var i=0; i<GLOBAL_DIARY.narrative.length; i++){
		if (GLOBAL_DIARY.narrative[i].chaptergory!="DIARIES") completion++;
	}
	/*
	var reqStr = 'logging.php'
		+'?handle='	+ encodeURIComponent(_GET["handle"])
		+'&completion=' + completion
		+'&hours=' + GLOBAL_TIME_HOURS
		+'&minutes=' + GLOBAL_TIME_MINUTES
		+'&seconds=' + GLOBAL_TIME_SECONDS
		+'&frames=' + GLOBAL_TIME_FRAMES
		+'&donation=' + encodeURIComponent((_GET["donation"]?_GET["donation"]:"anything"));

	Logging_request.open('get', reqStr);

	Logging_request.onreadystatechange = _Logging_confirm; 

	Logging_request.send('');*/

	if (GLOBAL_SPEEDRUN){
		GLOBAL_TIME_IN=true;
		GLOBAL_COMPLETION=completion;
	}
}

function _Logging_confirm(){
	if(Logging_request.readyState == 1){
		//document.getElementById('my_div').innerHTML = 'Loading...';
	}
	if(Logging_request.readyState == 4){ 

		var answer = Logging_request.responseText;

		alert(answer);
	}

	//alert("completion logged!");
}
