

//CODE FOR HANDLING SENDING OF RESULTS

var UserName = '';
var StartTime = (new Date()).toLocaleString();

var ResultForm = '<html><body><form name="Results" action="[strFormMailURL]" method="post" enctype="x-www-form-encoded">';
ResultForm += '<input type="hidden" name="recipient" value="[strEMail]"></input>';
ResultForm += '<input type="hidden" name="subject" value="[strEscapedExerciseTitle]"></input>';
ResultForm += '<input type="hidden" name="Exercise" value="[strEscapedExerciseTitle]"></input>';
ResultForm += '<input type="hidden" name="realname" value=""></input>';
ResultForm += '<input type="hidden" name="Score" value=""></input>';
ResultForm += '<input type="hidden" name="Start_Time" value=""></input>';
ResultForm += '<input type="hidden" name="End_Time" value=""></input>';
ResultForm += '<input type="hidden" name="title" value="Thanks!"></input>';
[inclPageBGColor]ResultForm += '<input type="hidden" name="bgcolor" value="[strPageBGColor]"></input>';[/inclPageBGColor]
ResultForm += '<input type="hidden" name="text_color" value="[strTitleColor]"></input>';
ResultForm += '<input type="hidden" name="sort" value="order:realname,Exercise,Score,Start_Time,End_Time"></input>';
ResultForm += '</form></body></html>';

function GetUserName(){
	UserName = prompt('[strNamePlease]','');
	UserName += '';
	if ((UserName.substring(0,4) == 'null')||(UserName.length < 1)){
		UserName = prompt('[strNamePlease]','');
		UserName += '';
		if ((UserName.substring(0,4) == 'null')||(UserName.length < 1)){
			history.back();
		}
	}
}

function SendResults(Score){
	var today = new Date;
	var NewName = '' + today.getTime();
      var NewWin = window.open('', NewName, 'toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no,,width=400,height=300');

//If user has prevented popups, no way to proceed -- exit
	if (NewWin == null){
		return;
	}

	NewWin.document.clear();
	NewWin.document.open();
	NewWin.document.write(ResultForm);
	NewWin.document.close();
	NewWin.document.Results.Score.value = Score + '%';
	NewWin.document.Results.realname.value = UserName;
	NewWin.document.Results.End_Time.value = (new Date()).toLocaleString();
	NewWin.document.Results.Start_Time.value = StartTime;
	NewWin.document.Results.submit();
}
