//
// $Id: site.js 587 2007-04-16 22:25:52Z dtlrjt $
//
// Jeromes site javascript code
//

// 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(); }
 },

 // Browser-independent return of DOM element by ID attribute (most modern browsers)
 getElementById : function(id) {
    if (document.getElementById)
        return document.getElementById(id);
    else if (document.all)
        return document.all[id];

    alert('Browser not supported');
    return null;
 },

 // Get a style object for item by id
 getStyleObj : function(id, obj) {
  if (id != '')
  	obj = this.findObj(id);
  if (obj) {
   if ((this.hasDOM() || this.hasAll()))
    return obj.style;
   else if (this.hasLayers())
    return obj;
  }
  alert("JavaScript error: could not find style object for '" + id + "'");
  return null;
 },

 // Set opacity (%) on an object by id or obj
 setOpacity : function(pct, id, obj) {
  if (id != '')
  	obj = this.findObj(id);
  if (obj.filters)
   obj.filters("alpha").opacity = pct;
  else if (obj.style) {
   var amt = pct / 100;
   if (amt > .99999)
   	amt = .99999;
   obj.style.MozOpacity = amt;
   obj.style.khtmlOpacity = amt;
   obj.style.opacity = amt;
  }
 },

 // get opacity (%) on an object by id or obj
 getOpacity : function(id, obj) {
  if (id != '')
  	obj = this.findObj(id);
  if (obj.filters)
   return obj.filters("alpha").opacity;
  else if (obj.style) {
  	var amt = obj.style.MozOpacity ||
			  obj.style.khtmlOpacity ||
   			  obj.style.opacity;

	return Math.round(amt * 100);
  }

 },

 // xGetElementsByTagName r4, Copyright 2002-2007 Michael Foster (Cross-Browser.com)
 // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

 xGetElementsByTagName : function(t,p) {
   var list = null;
   t = t || '*';
   p = p || document;
   if (typeof p.getElementsByTagName != 'undefined') { // DOM1
	 list = p.getElementsByTagName(t);
	 if (t=='*' && (!list || !list.length)) list = p.all; // IE5 '*' bug
   }
   else { // IE4 object model
	 if (t=='*') list = p.all;
	 else if (p.all && p.all.tags) list = p.all.tags(t);
   }
   return list || new Array();
 },

 // xGetElementsByClassName r5, Copyright 2002-2007 Michael Foster (Cross-Browser.com)
 // Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

 xGetElementsByClassName : function(c,p,t,f) {
  var r = new Array();
  var re = new RegExp("(^|\\s)"+c+"(\\s|$)");
//  var e = p.getElementsByTagName(t);
  var e = this.xGetElementsByTagName(t,p); // See xml comments.
  for (var i = 0; i < e.length; ++i) {
    if (re.test(e[i].className)) {
      r[r.length] = e[i];
      if (f) f(e[i]);
    }
  }
  return r;
}


}; // class Browser


function nw(url) {
	window.open(url);
	return false;
}


// FAQ

/**
 * Returns the true nextSibling object
 *
 * This is needed (using obj.nextSibling won't always work)
 * because Firefox will return intervening #text nodes while IE
 * will skip them.
 */
function getSibling(obj) {
	while ((obj = obj.nextSibling) && obj.nodeType != 1)
		;
	return obj;
}

/**
 * Show or hide my sibling
 *
 * This also toggles the onclick event to reverse the show/hide.
 */
function faq_showSibling(me, show) {
	sib = getSibling(me);
	sib.style.display = show ? 'block' : 'none';
	me.onclick = function() { faq_showSibling(me, !show); }
	me.onmouseover = function() { this.style.cursor = show ? 'hand' : 'help' };
}

/**
 * Prepares the lists of DT/DD items
 *
 * This also sets the mouse over/out cursor
 */
function faq_show(show) {
	dt = document.getElementsByTagName('dt');
	for (var i = 0; i < dt.length; i++) {
		dt[i].onmouseout = function() { this.style.cursor = 'default' };
		faq_showSibling(dt[i], show);
	}
}
