﻿// JScript File

var pollTime = 1000 * 60 * 5; // 1000milliseconds * 60seconds * 2 minutes
//var pollTime = 1000 * 6;
var myTimeout;

// Set the initial countdown to load the XML
// No need to load it right away
function startStateChangeAjax() {
	window.clearTimeout( myTimeout );
	myTimeout = window.setTimeout( "startStateChangeAjaxAux()", pollTime );
}

// main repeating function to load the xml
function startStateChangeAjaxAux() {
	window.clearTimeout( myTimeout );
	myTimeout = window.setTimeout( "startStateChangeAjaxAux()", pollTime );
	var url = "../SiteState/SiteState.asp?" + (new Date()).valueOf() ;
	var canItWork = importXML( url, 'readCommands' );
	return false;
}

function readCommands( xmldoc ) {
    var state = xmldoc.getElementsByTagName('state').item(0).firstChild.data;
    //alert( "state: " + state );
    if ( sitestate != state ) {
        window.location = window.location;
    }
}