//-----------------------------------------------------------------------------

// BrowserCheck Object
// provides most commonly needed browser checking variables
// 19990326

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynduo/

function BrowserCheck() {
	var b = navigator.appName;
	if (b=="Netscape") this.b = "ns";
	else if (b=="Microsoft Internet Explorer") this.b = "ie";
	else this.b = b;
	this.v = parseInt(navigator.appVersion);
	this.ns = (this.b=="ns" && this.v>=4);
	this.ns4 = (this.b=="ns" && this.v==4);;
	this.ns5 = (this.b=="ns" && this.v==5);
	this.ie = (this.b=="ie" && this.v>=4);
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0);
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0);
	if (this.ie5) this.v = 5;
	this.min = (this.ns||this.ie);
}

// automatically create the "is" object
is = new BrowserCheck()

var isFlat = !(is.min); // flat popups?

//-----------------------------------------------------------------------------

// URL popup - alternate between two windows (to give NS a chance to close lingering window)
var bWnd1 = null;
var bWnd2 = null;
var pWnd1 = null;
var pWnd2 = null;

var maxW = 800;
var maxH = 680;
var minW = 620;
var minH = 460;


function popupScreen(w, h, url)
{
	popupURL0(url, w, h, w, h, "no", "popupScreen");
}

function popupScroll(w, h, url)
{
	popupURL0(url, w, h, w, h, "yes", "popupScroll");
}

function popupURL(url)
{
	popupURL0(url, minW, minH, maxW, maxH, "yes", "popupURL");
}

function popupURL1(url) // small popup
{
	popupURL0(url, 620, 460, 700, 500, "yes", "popupSmallURL");
}

function popupURL2(url) // City Sites popup
{
	popupURL0(url, 790, 490, 800, 520, "yes", "popupCitySitesURL");
}


function popupURL0(url, minW, minH, maxW, maxH, allowScroll, winName)
{
	// screen width and height
	if (window.screen)
	{
	  winW = window.screen.width; // client width
	  winH = window.screen.height; // client height
	}
	else
	{
	  winW = 800; // defaults
	  winH = 600;
	}

	// window width and height
	if (winW > maxW + 20)
	  w = maxW;
	else if (winW > minW)
	  w = winW - 20;
	else
	  w = minW;

	if (winH > maxH + 20)
	  h = maxH;
	else if (winH > minH)
	  h = winH - 20;
	else
	  h = minH;

	// window position
	x = (winW - w)/2;	
	y = (winH - h)/2;

	if (!isFlat)
	{
	  if (is.min)
	    options = "location=no,menubar=no,toolbar=no," + 
		  	  "scrollbars=" + allowScroll + ",status=no," +
	    	 	  "width=" +w + ",height=" + h + ",left=" + x + ",top=" + y +
			  ",screenX=" + x + ",screenY=" + y;
	  else
  	    options = "location=no,menubar=no,toolbar=no," + 
			  "scrollbars=" + allowScroll + ",status=no," +
	    	 	  "width=" +w + ",height=" + h;

	  if (winName.indexOf("URL")>0)
		{
			if (bWnd1==null || bWnd1.closed)
		  {
		    if (bWnd2!=null)
		      if (!bWnd2.closed)
		        bWnd2.close();
		    bWnd1=window.open(url, winName + "1", options);
		  }
		  else
		  {
		    bWnd1.close();
		    bWnd2=window.open(url, winName + "2", options);
		  }
		}
		else
		{
			if (pWnd1==null || pWnd1.closed)
		  {
		    if (pWnd2!=null)
		      if (!pWnd2.closed)
		        pWnd2.close();
		    pWnd1=window.open(url, winName + "1", options);
		  }
		  else
		  {
		    pWnd1.close();
		    pWnd2=window.open(url, winName + "2", options);
		  }
		}
	}
	else
	{
	  // browser before version 4
	  location.href = url;
	}
}

// called from the onUnload event ...
function closePopups()
{
	if (!isFlat)
	{
	  if (bWnd1!=null && !bWnd1.closed)
	    bWnd1.close();
	  if (bWnd2!=null && !bWnd2.closed)
	    bWnd2.close();
	  if (pWnd1!=null && !pWnd1.closed)
	    pWnd1.close();
	  if (pWnd2!=null && !pWnd2.closed)
	    pWnd2.close();
	}
}

// called from OK button at foot of page ...
function OK()
{
	if (!isFlat)	
	  window.close();
	else
	  history.back();
}

function screenMsg()
{
	alert("Remember. This is a screen dump!")
}

//-----------------------------------------------------------------------------



