// Maintains user session with server hits every x minutes //

var counter = 0;
var dsKeepAlive = new Spry.Data.XMLDataSet("TW_assets/xml/keepalive.asp", "export/row",{useCache:false,loadInterval:180000});

dsKeepAlive.addObserver(initialLoad);
function initialLoad(notificationType, dataSet, data) {
	var msg = "";
	if (notificationType == 'onLoadError') { 
		msg = 'Session Status: Error';
		Spry.Utils.setInnerHTML('SessionKeepAlive', msg);
		alert("There was a problem refreshing your session.  You may want to reload this page (F5) or visit another to keep your session active.");
	}
	if (notificationType == 'onPostLoad') {
		var rows = dsKeepAlive.getData();
		var status = rows[0]["keepalive"];	
		counter++; 
		msg = 'Session Status: '+status+'; Reloads: '+String(counter);
		Spry.Utils.setInnerHTML('SessionKeepAlive', msg); 
	}
}

