// WindowSessionFunctions.js
//
// Author:      J Robar/DataCom Sciences, Inc.
// Created:     Monday, 23 June, 2003
// Purpose:     Handles sessions
// alert ("TimeSession arguments:" + " minutes: " + minutes + " url: " + url);

var reloader = 1

function TimeWindow(seconds,reload) {
//check for reload argument; set if not
 if (!reload) { var reloader = 0 }
//check for previous entry; clear timer if found
 if (timerID) { clearTimeout(timerID); var init = 1; }
	else { var init = 0; }

//check for 'seconds' argument; set to 1 min if not set - convert to milli
 if (seconds == "") { var millisecs = 60000; }
 else if (seconds == 0) { var millisecs = 60000; }
	else { var millisecs = seconds*1000; }
	if (millisecs == 0) { var millisecs = 60000; }

//set timer to close window and put time left in status bar
	var timerID = setTimeout("KillWindow(reloader)",millisecs);
 MessageWindow(millisecs,init);
}

function MessageWindow(millisecs) {
 var one_min = 60000;
	var inc = 1000;
	var mins = millisecs/one_min;
	var int_mins = Math.floor(mins);
	var secs = (millisecs-(one_min*int_mins))/inc;
	if (int_mins > 1) { window.status = "This window will close in " + int_mins + " minutes " + secs + " seconds"; }
	else if (int_mins == 1) { window.status = "This window will close in " + int_mins + " minute " + secs + " seconds"; }
	else { window.status = "This window will close in " + secs + " seconds"; }
 timeleft = millisecs-inc;
 var timerID = setTimeout("MessageWindow(timeleft)",inc);
}

function KillWindow(reload) { 
 var xwin = window.close();
 self.opener.location.reload() 
}

function PopUpWindow(url,desc,config,winname) {
 winname = window.open(url,desc,config);
}

// WindowFunctions.js
//
// Author:      J. Robar/Uniband, Inc.
// Created:     17 July, 2000
// Purpose:     reload calling window

function reload_opener() {
 self.opener.location.reload();
 self.close();
}

function ReloadOpenerOnly() {
 self.opener.location.reload();
}

function FocusWindow() { self.focus(); window.focus(); }

function ReFocusWindow1() {
// if (!self.window) window.focus();
// if (!window.top) window.focus();
// if (!window.top) self.window();
// if (window.blur()) window.focus();
 var timerID = setTimeout("ReFocusWindow()",1000);
}
function ReFocusWindow() {
 window.focus();
 var timerID = setTimeout("ReFocusWindow()",1000);
}

// Close the dialog
function closeme() {
	window.close()
}

// Handle click of OK button
function handleOK() {
	if (opener && !opener.closed) {
		top.dlogBody.transferData()
		opener.dialogWin.returnFunc()
	} else {
		alert("You have closed the main window.\n\nNo action will be taken on the choices in this dialog box.")
	}
	closeme()
	return false
}

// Handle click of Cancel button
function handleCancel() {
	closeme()
	return false
}

function WindowBlockEvents() { if (opener) opener.blockEvents() }

function WindowUnBlockEvents() { if (opener) opener.unblockEvents() }

