/*

		 (c) Copyright Ed Schimmel 1999. All Rights Reserved

		 File: layer.js
		 Language: javascript 1.1
		 Description: some functions for handling layers

		 Version  Date    Author        Initials  Comment:
		 1.00     990915  Ed Schimmel		EAS       Start of development, check
																						 	if clipping function can be
																							optimized for newer IE
																							versions
		 2.00     991121  Ed Schimmel		EAS       Added GetSelf()
		 3.00		 	991128  Ed Schimmel		EAS       Added GetStyle()
		 3.00		 	991128  Ed Schimmel		EAS       Added calls to GetSelf()
		 3.01     001005  Ed Schimmel   EAS       Clipping functions to HClippingLayer

 */

var navigator_Explorer = 0;
var navigator_Netscape = 1;
var navigator_Netscape6 = 2;

function HLayerHide()
{
	if (this.mNavigator == navigator_Netscape)
		this.style.visibility = "hide";
	else
		this.style.visibility = "hidden";
}

function HLayerShow()
{
	if (this.mNavigator == navigator_Netscape)
		this.style.visibility = "show";
	else
		this.style.visibility = "visible";
}

function HLayerGetSelf()
{
	return this.self;
}

function HLayerGetStyle()
{
  return this.style;
}

function HLayerSetParent(inParent)
{
	// inParent is the parent layer (so this layer is nested)
	this.parent = inParent;

  this.SetSelf();
  this.SetStyle();
}

function HLayerAdd(inObject)
{
	if (this.mNavigator == navigator_Netscape)
		inObject.SetParent(this.self);
}

function HLayerLoadText(inString)
{
	if (this.mNavigator == navigator_Netscape)
	{
		this.self.document.open();
		this.self.document.write(inString);
		this.self.document.close();
	}
	else
		this.self.innerHTML = inString;
}

function HLayerLoadImage(inImageSrc, inWidth, inHeight)
{
	theString = '<IMG src="'+inImageSrc+'" width="'+inWidth+'" height="'+inHeight+'" border="0">';
	this.LoadText(theString);
}

function HLayerSetSelf() {
	if(document.getElementById) this.self = document.getElementById(this.name);
	else if (this.mNavigator == navigator_Netscape) {
	   	if (this.parent) this.self = this.parent.document.layers[this.name];
		else  this.self = document.layers[this.name];
	} else this.self = document.all[this.name];
}

function HLayerSetStyle()
{
	if (this.mNavigator == navigator_Netscape) this.style = this.self;
	else if(this.self) this.style = this.self.style;
	else ;
}

function HLayerFree()
{
	if (this.self)
		delete this.self;

	this.self = null;
}

function HLayer(inName)
{
	// members
	this.name = inName;
  this.self = null;
  this.parent = null;
  this.style = null;
  this.mNavigator = ((navigator.appName == "Netscape") ? navigator_Netscape : navigator_Explorer);

  if ( (parseInt(navigator.appVersion) >= 5) && (navigator.appName == "Netscape") )
  	this.mNavigator = navigator_Netscape6;

  // methods
  this.Hide = HLayerHide;
  this.Show = HLayerShow;

	this.LoadText = HLayerLoadText;
	this.LoadImage = HLayerLoadImage;

 	this.SetSelf = HLayerSetSelf;
 	this.GetSelf = HLayerGetSelf;
  this.SetStyle = HLayerSetStyle;
  this.GetStyle = HLayerGetStyle;

  this.Add = HLayerAdd;
  this.SetParent = HLayerSetParent;
	this.Free = HLayerFree;

  this.SetSelf();
  this.SetStyle();
}

