var theDate = new Date();
var end,t1,t2,t3,t4,t5,t6,t7,t8,t8,t0;
var SID;
var timer;

function setSID(id) {
	SID = id;
}

function setExpire(numSeconds) {
theDate = new Date();
end = theDate.getTime() + (numSeconds*1000);
}

function doHTMLTime() {
var now = new Date();
	try {
		var expiry = Math.round((end-(now.getTime()))/1000);
		if(expiry<=0) location.href="/timeout.php?"+SID;
		
		if (isNaN(expiry)) {
			document.getElementById("thetimer").innerHTML = "--:--";
		}else { 		
			var min = Math.floor(expiry/60);
			var minLeft = Math.floor(min/10);
			var minRight= Math.floor(min%10);
			var sec = Math.floor(expiry%60);
			var secLeft = Math.floor(sec/10);
			var secRight = Math.floor(sec%10);
			document.getElementById("thetimer").innerHTML = ""+minLeft+minRight+":"+secLeft+secRight;
		}
	} catch (error) {
	}
	timer = window.setTimeout("doHTMLTime();", 1000);
}

function stopHTMLTime() {
	try {
		document.getElementById("thetimer").innerHTML = "--:--";
		window.clearTimeout(timer);
	} catch (error) {
	}
}

function doGoing() {
	var now = new Date();
	var text = document.getElementById("going").innerHTML;
	if (text.length>=30) {
		text = " . ";
	} else { 
		text +=" . ";
	}
	document.getElementById("going").innerHTML = text;
	newgoing = window.setTimeout("doGoing();", 1000);
}

var showMode = 'table-cell';
if (document.all) showMode='block';
function toggleVis(thaID, show) {
	cells = document.getElementsByName(thaID);
	if (show) mode = showMode;
	else mode = 'none';
	for(j = 0; j < cells.length; j++) cells[j].style.display = mode;
}