////////////////////////////////////////////////////////////////////////////////
//
// $Header: /cvsroot/richtext/editor/rte/rte_splash.js,v 1.2 2002/08/29 16:01:08 third_of_five Exp $
//
// HTML Text Editing Component for hosting in Web Pages
// Copyright (C) 2001  Ramesys (Contracting Services) Limited
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU LesserGeneral Public License
// along with this program; if not a copy can be obtained from 
//
//    http://www.gnu.org/copyleft/lesser.html
//
// or by writing to:
//
//    Free Software Foundation, Inc.
//    59 Temple Place - Suite 330,
//    Boston,
//    MA  02111-1307,
//    USA.
// 
// Original Developer:
//
//	Austin David France
//	Ramesys (Contracting Services) Limited
//	Mentor House
//	Ainsworth Street
//	Blackburn
//	Lancashire
//	BB1 6AY
//	United Kingdom
//  email: Austin.France@Ramesys.com
//
// Home Page:    http://richtext.sourceforge.net/
// Support:      http://richtext.sourceforge.net/
//
// 
////////////////////////////////////////////////////////////////////////////////
// Authors & Contributers:
//
//   BC      Bill Chalmers      [bill_paula@btinternet.com]
//            Developer
//
//   BC		 10-08-2002
//			 Initial construction.
//			 Usage : var x=new progressbar();
//			 Methods: display (must be called before update)
//					  update (accepts numerics from 1 to 100)
//
//	OZ		29-09-2002
//			Reorganise and restructure for improved performance.
//
//	OZ		29-09-2002
//			Center splash screen in center of browser if possible, otherwise in
//			center of the display.
//
////////////////////////////////////////////////////////////////////////////////

function ProgressBar(parentWindow)
{
	// Method bindings
	this.update = update;
	this.display = display;
	this.hide = hide;

	// create popup object and get reference to popup body
	this.oPopup = window.createPopup();		
	this.oPopupBody = this.oPopup.document.body;
	this.parentWindow = parentWindow;

	// set the border style of the popup
	this.oPopupBody.style.border = "solid black 1px";
	
	// Initialise the HTML inside the popup
	this.oPopupBody.innerHTML =
		'<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="overflow: hidden;">'
		+ '<div style="position:absolute;top:0; left:0; width:100%; height:100%; background:#0066cc"> '
			+ '<div style="padding:20px; background:white; border-bottom:5px solid #cccccc">'
				+ '<img src="images/shim.gif" width="228" height="105" align="absmiddle">'
			+ '</div>'
			+ '<table align="center" width="100%"><tr><td>'
				+ '<div style="font-size:6pt;padding:2px;border:solid black 1px">'
					+ '<div id="progress" style="background-color:#990000;width:0px;"></div>'
				+ '</div>'
			+ '</td></tr></table>'
			+ '<div style="padding:20px; font-size:8pt; line-height:1.5em; font-family:verdana; color:white;">'
				+ 'The Richtext Editor is created entirely using DHTML technologies.'
				+ '<br /><br />'
				+ 'See <a style="color: white" href="http://sourceforge.net/projects/richtext">'
					+ 'http://sourceforge.net/projects/richtext/'
					+ '</a> for more details.'
				+ '<br /><br />'
				+ '<center>Richtext Editor<br />Copyright 2000-2002, Ramesys Construction Services</center>'
			+ '</div>'
		+ '</div>'
		+ '</body>'

	this.oProgress = this.oPopupBody.all("progress");

	// Method to update the popup with the current %age done
	function update(percentDone)
	{
		this.oProgress.style.width = percentDone + '%';
	}

	function display() {
		var w = 414;
		var h = 320;
		var aw, ah, ox, oy;
		if (document.documentElement) {
			// Position the splash screen in the center of the browser window
			aw = document.documentElement.offsetWidth;
			ah = document.documentElement.offsetHeight;
			ox = window.screenLeft;
			oy = window.screenTop;
		} else {
			// unable to determine browser window width and height so center splash screen
			// in center of display
			aw = screen.availWidth;
			ah = screen.availHeight;
			ox = oy = 0;
		}
		this.oPopup.show(((aw-w)/2)+ox, ((ah-h)/2)+oy, w, h);
	}

	function hide() {
		this.oPopup.hide();
	}
}

