var PingMsgID;
var WindowPtr = null;
var KillWindow = false;
var bDone = false;
var bWait = false;

function fnStartFromNav() {
	var strWaitMsg;

	//Create the strWaitMsg and strCallIfTimerPop string if we not getting a response from the KM Server.
	strWaitMsg = "fnDisplayWindow()";
	//Clear out the timers
	clearTimeout(PingMsgID);
	bDone = false;
	//alert('Get Ready to disply message');
	PingMsgID = setTimeout(strWaitMsg, 1000);

}

function fnStart() {
	var strWaitMsg;

	//Create the strWaitMsg and strCallIfTimerPop string if we not getting a response from the KM Server.
	strWaitMsg = "fnDisplayWindow()";
	//Clear out the timers
	clearTimeout(PingMsgID);
	//If the Ping Image does not load in 5 seconds, display Please Wait message
	//Polling set for 5 seconds.
	bDone = false;
	//alert('Get Ready to disply message');
	PingMsgID = setTimeout(strWaitMsg, 3000);

}

function fnWait() {
	bWait = true;
	//alert ('Called Wait');
	if (WindowPtr != null) {
		//alert('Window is displayed');
		fnEndDisplay();
	}
	clearTimeout(PingMsgID);
}

function fnDisplayWindow() {

	//alert('Get Ready to disply message');

	if (KillWindow == 'true') {
		//alert('Content already displayed');
	} else {

		if (bWait == 'true') {
			clearTimeout(PingMsgID);
			bWait = false;
			//alert ('Wait Called Do nothing');

		} else {
			//alert ('Not Waiting ' + bWait);

			var leftpos;
			var toppos;
			var height = 400;
			var width = 400;

			leftpos = (screen.width - width) / 2;
			toppos = (screen.height - height) / 2;

			var args = 'left=' + leftpos + ',top=' + toppos + ',height=' + height +',width=' + width+ ',toolbar=no,resizable=no,scrollbars=no,status=no';
			var url = base + '/result/progress.aspx?' + stdAppParms;
			WindowPtr = window.open(url, 'progress', args, false);
		}
	}
}

//Called from dcDocumentFeatureText.aspx.cs
function fnEndDisplay() {
	//Clear out the timers
	//alert('In End Display');
	clearTimeout(PingMsgID);
	if (WindowPtr != null) {
		//alert('Kill the Window');
		WindowPtr.close();
	}
}

if(typeof(Sys) !== "undefined") {
	Sys.Application.notifyScriptLoaded();
}