
// (C) 2004 CodeLifter.com
function nrcIE(){
if (document.all){return false;}}
function nrcNS(e){
if(document.layers||(document.getElementById&&!document.all)){ 
if (e.which==2||e.which==3){
return false;}}} 
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=nrcNS;
}else{document.onmouseup=nrcNS;document.oncontextmenu=nrcIE;}
document.oncontextmenu=new Function("return false");

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		if(navRoot != null){
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
}
window.onload=startList;


// Global variables
TimeOutMinutes = 40;
RefreshInterval = 9 * 60000;
//RefreshInterval = 3000;
StartTime = new Date();
StartMils = Date.parse(StartTime.toLocaleString());
TimeOutMils = StartMils + (60000 * TimeOutMinutes);

function do_keepalive(urltoken) {
	var myConnEmail = new XHConn();
	var fnWhenDoneKA = function (oXML) { 
		//alert('refreshed');
	};
	myConnEmail.connect("index.cfm?fuseaction=keepalive", "POST", urltoken, fnWhenDoneKA);
}

function kaLoop(urltoken){
	//alert('he1');
	//clearTimeout(timerLoop);
	CurrentTime = new Date();
	CurrentMils = Date.parse(CurrentTime.toLocaleString());
	RemainingMils = TimeOutMils - CurrentMils;
	//window.status = RemainingMils / 60000;
	do_keepalive(urltoken);
	if(RemainingMils > 1){
	timerLoop = setTimeout('kaLoop("' + urltoken + '")', RefreshInterval);
	}
}

/*String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};*/

function do_keepaliveUpload(urltoken) {
	var myConnEmail = new XHConn();
	var fnWhenDoneKAUpload = function (oXML) { 
		//alert('refreshed:' + oXML.responseText.replace(/^\s+/, ''));
		window.status=oXML.responseText.replace(/^\s+/, '');
		//defaultStatus=oXML.responseText.replace(/^\s+/, '');
		$("statusMessage").innerHTML = oXML.responseText.replace(/^\s+/, '');
	};
	myConnEmail.connect("index.cfm?fuseaction=keepaliveUpload", "POST", urltoken, fnWhenDoneKAUpload);
}

function kaLoopUpload(urltoken){
	//alert('he1');
	if (typeof(timerLoop) != "undefined"){
		clearTimeout(timerLoop);
	}
	CurrentTime = new Date();
	CurrentMils = Date.parse(CurrentTime.toLocaleString());
	//upload loop waits for 160 min
	RemainingMils = 9600000 - CurrentMils;
	
	do_keepaliveUpload(urltoken);
	if(RemainingMils > 1){
	timerLoop = setTimeout('kaLoopUpload("' + urltoken + '")', 8000);
	}
}
