/* $Id: popup.js,v 1.1 2006/10/04 17:12:14 jeremy Exp $ */

function showPopup(name, URL, h, w, x, y, scrollbars){

  if (isEmpty(h)) h = 300;
  if (isEmpty(w)) w = 300;

  if (isEmpty(x)) x = 100;
  if (isEmpty(y)) y = 200;

  var defaultOptions = "location=no,menubar=no,resizable=yes,scrollbars=" + (scrollbars ? "yes" : "no") +
  	",status=no,titlebar=no,toolbar=no,directories=no";

  var dimensions = "height=" + h + ",width=" + w + ",top=" + x + ",left=" + y;

  var win = window.open(URL, name, dimensions + "," + defaultOptions);
  win.focus();
}

function showPopupStatus(name, URL, h, w, x, y, scrollbars){

  if (isEmpty(h)) h = 300;
  if (isEmpty(w)) w = 300;

  if (isEmpty(x)) x = 100;
  if (isEmpty(y)) y = 200;

  var defaultOptions = "location=no,menubar=no,resizable=yes,scrollbars=" + (scrollbars ? "yes" : "no") +
  	",status=yes,titlebar=no,toolbar=no,directories=no";

  var dimensions = "height=" + h + ",width=" + w + ",top=" + x + ",left=" + y;

  var win = window.open(URL, name, dimensions + "," + defaultOptions);
  win.focus();
}

/* Return true if object is empty, false otherwise */
function isEmpty(s) {
  if (typeof s == "undefined") return true;
  return ((s == null) || (s.length == 0))
}

/* http://www.htmldog.com/articles/suckerfish/focus/ */
sfFocus = function() {
	var sfEls = document.getElementsByTagName("INPUT");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
	var sfEls = document.getElementsByTagName("SELECT");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
	var sfEls = document.getElementsByTagName("TEXTAREA");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfFocus);


