var win1;
var userCount;   
var userNum;
var seqnum;
var loadHome;

function setParameters(args)
{        
    userCount = args[0];
    userNum = args[1];  
    seqnum = args[2];
	
}

function getLogoffMessage(){
	var msg =
		"<HTML>" +
			"<HEAD>" +
				"<TITLE>Close Session</TITLE>" +
			"</HEAD>" +
			"<BODY BGCOLOR='#CCCC99'>" +
				"<CENTER><B>You are being logged off. " +
					"Thanks for using SharpScreen!</B></CENTER>" +
			"</BODY>" +
		"</HTML>";
	return msg;
}

function getDownloadWaitMessage(){
	var msg = 
		"<HTML>" +
			"<HEAD>" +
			"	<TITLE>SharpScreen: Opening Printer Friendly Version</TITLE>" +
			"</HEAD>" +
			"<BODY BGCOLOR='#CCCC99'>" +
				"<TABLE ALIGN='CENTER'>" +
					"<TR>" +
						"<TD><CENTER><B>Please wait, your download should begin shortly.</B></CENTER></TD>" +
						"</TR>" +
					// *** To add rows to the table duplicate the following lines:
					"<TR>" +
						"<TD>" + 
						"&nbsp;</TD>" +
					"</TR>" +
					// *** End copy.
					"<TR>" +
						"<TD><CENTER><A HREF='javascript:void(0)' ONCLICK='javascript:window.close();'>" +
							"(Close this window once the download has begun.)" +
						"</A></CENTER></TD>" +
					"</TR>" +
				"</TABLE>" +
			"</BODY>" +
		"</HTML>";
	return msg;
}

/*
 * @return String containg featrues for a message window;
 */
function getMessageWindowFeatrues(width, height){
    return "width=" + width + ", height=" + height + ", menubar=no, location=no, status=no, resizable=yes, scrollbars=yes";
}

/*
 * Sumbit the report export form.
 */
function exportReport(){

    pf_win_features = getMessageWindowFeatrues(350, 100);
//    var pf_win = window.open("reportdownloadwait.html", "pf_wait_message", pf_win_features);
	var pf_win = window.open("", "pf_wait_message", pf_win_features);
	pf_win.document.write(getDownloadWaitMessage());
    pf_win.focus();
    var pf_form = document.getElementById("printer_friendly");
    pf_form.target = "pf_wait_message";
    pf_form.submit();
}

/*
 * if a user is logged-on call JSP to decrement user's login count
 */
function closeWindow() 
{
	userCount= document.getElementById("userCount").value;
	userNum= document.getElementById("userNum").value;
	seqnum= document.getElementById("seqnum").value;

	dbg="userCount: '" + userCount + "'\n" + "userNum: '" + userNum + "'\n" + "seqnum: '" + seqnum + "'\n";
		
	
    if(userCount != "undefined" && userCount != null && userNum != "undefined" &&  userNum != null && seqnum != "undefined" && seqnum != null)
    {
        var filename = "/decrement.jsp?userCount="+userCount+"&userNum="+userNum+"&seqNum="+seqnum;
		var msg = getLogoffMessage();
        win1 = window.open("", "LogOff", getMessageWindowFeatrues(200, 50));
		win1.document.write(msg);
		win1.location = filename;
    }
}
