/*
	Copyright (C) 2001 Parvis Mohadjer, neonwerk

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
	OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
	NONINFRINGEMENT. IN NO EVENT SHALL PARVIS MOHADJER OR ANY OTHER
	CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
	WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
	OTHER DEALINGS IN THE SOFTWARE.
*/

function popup(urlDestination, winName, winWidth, winHeight, winSettings, winHtml){
	
	if(urlDestination == null && winHtml == null) return;

	//default settings if none defined							
	if(winName		    == null)
	{
		var curDate = new Date();
		var time = String(curDate.getFullYear()) + String(curDate.getMonth()+1) + String(curDate.getDate()) + String(curDate.getHours()) + String(curDate.getMinutes()) + String(curDate.getSeconds()) + String(curDate.getMilliseconds());
		winName	  = time;
	}
	winName = winName.replaceChrs("-","");
	if(winWidth		    == null) winWidth	  = 450;
	if(winHeight		    == null) winHeight	  = 300;
	if(winSettings		    == null) winSettings  = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no";
	//////////////////////////////////////////////
	
	
	var left     = (window.screen.width / 2) - (winWidth / 2);
	var top      = (window.screen.height / 2) - (winHeight / 2);
	switch(navigator.family){
		case "ie4":
		case "opera":
			var settings = "left=" + left + ",top=" + top
			settings    += "," + winSettings + ",width=" + winWidth + ",height=" + winHeight;	
			break;
		case "gecko":
		case "netscape":
		default:
			var settings = "screenX=" + left + ",screenY=" + top
			settings    += "," + winSettings + ",width=" + winWidth + ",height=" + winHeight;
			break;
	}
	
	var oWindow  = window.open(urlDestination,winName,settings);
	if(oWindow == null) return;
	
	if(winHtml != null && winHtml != '')
	{
		oWindow.document.write(winHtml);
		oWindow.document.close();
	}
	return oWindow;	
}
