var formSubmitSW = false;

function showMessage()
{
    if ( !formSubmitSW )
	{
	    centerMessage("infobox");
	    document.getElementById("infobox").style.visibility = "visible";
		window.unloadTimer = setInterval("hideMessage();clearInterval(window.unloadTimer);",100);

		return "You have not completed submitting the form yet!";
	}
}

function hideMessage()
{
    document.getElementById("infobox").style.visibility = "hidden";
}

function flipFormSubmitSw()
{
	formSubmitSW = true;
}

function redirectPage( redirectLink )
{
    if ( !formSubmitSW && redirectLink != null && redirectLink.length > 0 )
	{
	    window.open( redirectLink );
	}
}

function centerMessage(divid) {
// First, determine how much the visitor has scrolled

	var scrolledX, scrolledY;
	if( self.pageYOffset ) 
	{
		scrolledX = self.pageXOffset;
		scrolledY = self.pageYOffset;
	} 
	else if ( document.documentElement && document.documentElement.scrollTop ) 
	{
		scrolledX = document.documentElement.scrollLeft;
		scrolledY = document.documentElement.scrollTop;
	}
	else if( document.body ) 
	{
		scrolledX = document.body.scrollLeft;
		scrolledY = document.body.scrollTop;
	}

	// Next, determine the coordinates of the center of browser's window

	var centerX, centerY;
	if( self.innerHeight ) 
	{
		centerX = self.innerWidth;
		centerY = self.innerHeight;
	} 
	else if( document.documentElement && document.documentElement.clientHeight ) 
	{
		centerX = document.documentElement.clientWidth;
		centerY = document.documentElement.clientHeight;
	} 
	else if( document.body ) 
	{
		centerX = document.body.clientWidth;
		centerY = document.body.clientHeight;
	}

	// Xwidth is the width of the div, Yheight is the height of the
	// div passed as arguments to the function:
	var leftOffset = scrolledX + ( centerX - document.getElementById( divid ).offsetWidth ) / 2;
	var topOffset = scrolledY + ( centerY - document.getElementById( divid ).offsetHeight ) / 2;
	// The initial width and height of the div can be set in the
	// style sheet with display:none; divid is passed as an argument to // the function
	var o = document.getElementById( divid );
	var r = o.style;
	r.position = "fixed";
	//r.top = topOffset + 'px';
	r.top = "25px";
	r.left = leftOffset + "px";
} 
