// Browser gestalt
Browser = {
 id		: function() {return navigator.userAgent.toLowerCase();},
 ver	: function() {
	var x = 0;
 	if (this.isIE()) {
		x = this.id().indexOf("msie ");
		ver = parseFloat(this.id().substring(x + 5));
	} else {
	  x = this.id().length - 1;
	  while (x >= 0 && this.id().charAt(x) != ' ' && this.id().charAt(x) != '/')
		  x--;
	  if (x >= 0)
		  ver = parseFloat(this.id().substring(x + 1));
	  else
		  ver = parseFloat(navigator.appVersion);
	}
  	return ver;
 },

 mozVer			: function() {return parseFloat(navigator.appVersion);},
 isAdvanced		: function() {return Boolean(this.hasDOM() && this.hasCreateElement());},

 isWindows		: function() {return this.id().indexOf("win")!=-1;},
 isMac			: function() {return this.id().indexOf("mac")!=-1;},

 isIE			: function() {return this.id().indexOf("msie")!=-1 && !this.isOpera();},
 isFirefox		: function() {return this.id().indexOf("firefox")!=-1;},
 isGecko		: function() {return this.id().indexOf("gecko")!=-1;},
 isOpera		: function() {return this.id().indexOf("opera")!=-1;},
 isSafari		: function() {return this.id().indexOf("safari")!=-1;},
 isOmniWeb		: function() {return this.id().indexOf("omniweb")!=-1;},
 isKonqueror	: function() {return this.id().indexOf("konqueror")!=-1;},
 isWebTV		: function() {return this.id().indexOf("webtv")!=-1;},
 isNetscape		: function() {return !this.isGecko() && this.id().indexOf("compatible")<0;},
 isMozilla		: function() {return this.isGecko() && !this.isFirefox() && !this.isSafari() && !this.isNetscape();},

 hasLayers		: function() {return Boolean(document.layers);},
 hasAll			: function() {return Boolean(document.all);},
 hasImages		: function() {return Boolean(document.images);},
 hasForms		: function() {return Boolean(document.forms);},
 hasCreateElement	: function() {return Boolean(document.createElement);},
 hasCreateDoc	: function() {return Boolean(document.implementation && document.implementation.createDocument);},
 hasRegExp		: function() {return Boolean(window.RegExp);},
 hasDOM			: function() {return Boolean(document.getElementById);},
 hasGEBI		: function() {return this.hasDOM();},
 hasGEBTN		: function() {return Boolean(document.getElementsByTagName);},
 hasActiveX		: function() {return Boolean(window.ActiveXObject);},
 WindowOnload	: function(f) {
	var prev = window.onload;
	window.onload = function() { if (prev) prev(); f(); }
 }
}

function popup(url, id, w, h, x, y, resize, scrollbar, menubar, status, toolbar) {
  var opt = '';
  var noDef;

  if (Browser.isSafari()) {
   w += 3;		// avoid scroll bars
   h += 3;
  }

  if (w != noDef) {
	opt += 'width=' + w + ',';
	if (x == noDef)
		x = (screen.width - w) / 2;
	opt += 'left=' + x  + ',';
  }

  if (h != noDef) {
	opt += 'height=' + h + ',';
	if (y == noDef)
		y = (screen.height - h) / 2;
	opt += 'top=' + y + ',';
  }

  if (resize != noDef)		opt += 'resizable=no,';
  if (scrollbar != noDef)	opt += 'scrollbars=' + scrollbar + ',';
  if (menubar != noDef)	opt += 'menubar=' + menubar + ',';
  if (status != noDef)		opt += 'status=' + status + ',';
  if (toolbar != noDef)	opt += 'toolbar=' + toolbar + ',';

  var win = window.open(url, id, opt);
  if (win)
	win.focus();
  else
    alert("You appear to have a pop-up blocker that prevents the requested window from opening. Please enable pop-ups for this site and try again. Thank you.");
//	alert("Failed to open window: " + url + "\nID = " + id + "\nOpts = \n" + opt);

}
