function strt(){
	//if (document.form2.tx.value == ""){
		d1=new Date;
		t1=d1.getTime();
		ticker = 0;
		runclk();
		document.getElementById('readcontent').style.visibility = "visible";
		//document.getElementById('stopbutton').style.display = "block";
		document.getElementById('linenumber').style.display = "block";
	// Comment Out by Kannan on 30 May 2011 due copyright --- 	backgroundmusic.innerHTML = "<object type=\"application/x-shockwave-flash\" data=\"images/player_mp3_maxi.swf\" width=\"200\" height=\"20\"><param name=\"movie\" value=\"images/player_mp3_maxi.swf\"><param name=\"FlashVars\" value=\"mp3=images/shadow_dancer_short.mp3&autoplay=1&showstop=1&volume=150&showvolume=1&showloading=always&loop=1\"></object>";
	//} else {
		//alert("You have done this speed reading test.");
	//}
}

function stp(){
	d2=new Date;
	//document.form2.tx.value=Math.round((60000/(d2.getTime()-t1))*177);
	intSpeed = Math.round((60000/(d2.getTime()-t1))*188);
	tx.innerHTML = intSpeed+" ";
	document.form2.tx.value = intSpeed;
	document.cookie = "speed=" +escape(intSpeed);
	clearTimeout(id);
	timer.innerHTML = min+":"+sec;
	backgroundmusic.innerHTML = "";
	document.getElementById('bottomcontent').style.display = "block";
}

function runclk() {
	min = Math.floor(ticker/60);
	sec = (ticker-(min*60))+'';
	if (sec >= 10) {document.getElementById('stopbutton').style.display = "block"};
	if(sec.length == 1) {sec = "0"+sec};
	ticker++;
	timer.innerHTML = min+":"+sec;
	id = setTimeout('runclk()', 1000);
}

var ca=new Array;
var done=new Array;
var vls=new Array;
var resu=0;
var nbQ=5;
ca[1]="B";
ca[2]="C";
ca[3]="C";
ca[4]="B";
ca[5]="C";
var lst=5;

function chk(q, a){
	if(!done[q]){
		done[q]=1;
		vls[q]=a;
		if(a==ca[q]){
			disp(q,"<font class=\"commtest3\">"+ca[q]+", well done!</font>");
			resu++;
		} else disp(q,"<font class=\"commtest4\">No, it was "+ca[q]+"</font>");
		} else if (vls[q]!=a)disp(q,"<font class=\"commtest4\">Already done!</font>");
}

function disp(q,msg){
	//document.forms[q-1].t.innerHTML=msg;
	xyz = eval("t"+q+"");
	xyz.innerHTML = msg;
	if (q != 5){
		document.getElementById('loading'+q).style.display = "block";
	}
	document.getElementById('reason'+q).style.display = "block";
	var k = setTimeout(function(){ document.getElementById('loading'+q).style.display = 'none'; document.getElementById('gonext'+q).style.display = 'block'; }, 3000);
	if (q == lst) clearTimeout(k);
}

function gonext(q){
	document.forms[q-1].style.display = "block";
}

function showcal(){
	document.getElementById('calresult').style.display = "block";
}

function showcalbutton(){
	document.getElementById('calbutton').style.display = "block";
}

function chkFull(){
	i=1;
	while(i<=nbQ&&done[i])i++;
	if(i<=nbQ) alert("Q "+i+".  not answered !"); else return 1; return 0;
}

function calc(){
	if(chkFull()){
		showcal();
		document.forms[lst].Percent.value=Math.round(resu*100/nbQ);
		intPercent = Math.round(resu*100/nbQ);
		document.forms[lst].Score.value=resu;
		document.forms[lst].Total.value=nbQ;
		showScore.innerHTML = resu+" ";
		showTotal.innerHTML = nbQ;
		showPercent.innerHTML = intPercent+"%";
		document.cookie = "percent=" +escape(intPercent);
		document.getElementById('conbotcopy').style.display = "block";
		
		var xmlhttp;
		if (window.XMLHttpRequest){
			// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		} else if (window.ActiveXObject){
			// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		} else {
		  alert("Your browser does not support XMLHTTP!");
		}
		
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				xmlhttp.responseText;
			}
		}
		xmlhttp.open("POST","sendreply.php",true);
		xmlhttp.send(null);
	}
}

function chkS(a){
	if(a=="C")document.forms[lst].t.value="Well done!"; else document.forms[lst].t.value="No, it was C"
}

