/*
    Copyright (C) 2005  Zachary J. Medico  <zmedico@yahoo.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    
    
    This script contains slightly modified versions of object detection scripts by Peter-Paul Kock, obtained from http://www.quirksmode.org/
    These functions provice a means to work around differences in browsers.
*/

/*
Browser independent function to get an object representing an element's style

Based on code from http://www.quirksmode.org/js/dhtmloptions.html
*/
function getStyle(element)
{
  if (document.getElementById || document.all)
  {
  	return element.style;
  }
  else if (document.layers)
  {
	//NN4
	return element;
  }
}

/*
Browser independent function to get an element from the document.

Based on code from http://www.quirksmode.org/js/dhtmloptions.html
*/
function getObj(parentWindow, name)
{
  if (parentWindow.document.getElementById)
  {
  	this.obj = parentWindow.document.getElementById(name);
	this.style = this.obj.style;
  }
  else if (parentWindow.document.all)
  {
	this.obj = parentWindow.document.all[name];
	this.style = this.obj.style;
  }
  else if (parentWindow.document.layers)
  {
	this.obj = getObjNN4(parentWindow.document,name);
	this.style = this.obj;
  }
}

/*
Don't call this function directly.  It is for use by the above getObj() function
which is intended to be browser independent.

Based on code from http://www.quirksmode.org/js/dhtmloptions.html
*/
function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}


/*
Browser independent function to get the vertical offset of the page ( due to scrolling withing the window's viewport ).

Based on code from http://www.quirksmode.org/viewport/compatibility.html
*/
function getPageYOffset(parentWindow)
{
	if (parentWindow.pageYOffset) // all except Explorer
	{
		return parentWindow.pageYOffset;
	}
	else if (parentWindow.document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return parentWindow.document.documentElement.scrollTop;
	}
	else if (parentWindow.document.body) // all other Explorers
	{
		return parentWindow.document.body.scrollTop;
	}
}
