/******************************************************************************
 *                                                                            *
 *   (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()      * 
 *                                                                            *
 ******************************************************************************/

var navigator_Explorer = 0;
var navigator_Netscape = 1;
 
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 HLayerSetClipRectangle(inLeft, inTop, inRight, inBottom)
{
  if (this.mNavigator == navigator_Netscape)
	{
	  this.style.clip.left = inLeft;
		this.style.clip.top = inTop;
		this.style.clip.right = inRight;
		this.style.clip.bottom = inBottom;
	}
	else
	{
	  theString = 'rect('+inTop+','+inRight+','+inBottom+','+inLeft+')';

    this.mClipLeft = inLeft;
    this.mClipTop = inTop;
    this.mClipRight = inRight;
    this.mClipBottom = inBottom;    
    
	  this.style.clip = theString;
	}
}

function HLayerGetClipLeft()
{
  if (this.mNavigator == navigator_Netscape)
	  return this.style.clip.left;
	else
	  return this.mClipLeft;
}

function HLayerGetClipTop()
{
  if (this.mNavigator == navigator_Netscape)
	  return this.style.clip.top;
	else
	  return this.mClipTop;
}

function HLayerGetClipWidth()
{
  if (this.mNavigator == navigator_Netscape)
	  return this.style.clip.width;
	else
	  return this.mClipWidth;
}

function HLayerGetClipHeight()
{
  if (this.mNavigator == navigator_Netscape)
	  return this.style.clip.height;
	else
	  return this.mClipHeight;
}

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)
{
	inObject.SetParent(this.self);
}  

function HLayerLoadText(inString)
{
	if (this.mNavigator == navigator_Netscape)
	{
		this.self.document.write(inString);
		this.self.document.close();
	}	
	else
		this.self.innerHTML = inString;
}			

function HLayerClearText()
{
	if (this.mNavigator == navigator_Netscape)
	{
		this.self.document.write("");
		this.self.document.close();
	}	
	else
		this.self.innerHTML = "";
}			


function HLayerSetSelf()
{  
  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
	  this.style = this.self.style;
}	

function HLayerFree()
{
	if (this.self)
		delete this.self;
		
	this.self = null;
}		

function HLayer(inName)
{
	// members
	this.name = inName;
  this.self = '';
  this.parent = '';  
  this.style = '';

  this.mNavigator = ((navigator.appName == 'Netscape') ? navigator_Netscape : navigator_Explorer);  
  
  this.mClipLeft = 0;
  this.mClipTop = 0;
  this.mClipRight = 0;
  this.mClipBottom = 0;

  // methods
  this.Hide = HLayerHide;
  this.Show = HLayerShow;

  this.SetClipRectangle = HLayerSetClipRectangle;
  this.GetClipLeft = HLayerGetClipLeft;
  this.GetClipTop = HLayerGetClipTop;
  this.GetClipWidth = HLayerGetClipWidth;
  this.GetClipHeight = HLayerGetClipHeight;

	this.ClearText = HLayerClearText;
	this.LoadText = HLayerLoadText;
	
 	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();
}  
  

