//
//  layers.js
//  A simple "layer" wrapper object.
//
//  If you want to use this in your websites (or anything else) go right ahead,
//  I won't stop you. :-)
//
//  Copyright (c) 2002 - 2005 Joe Stenger and Razberry Design. All rights reserved.
//

var pxEnd = "";

function ObtainLayer( id, parent, objName )
{
	var layer = new Object();
	
	/*
		Wrapper Utility Functions
	*/
	
	layer.top = function( nTop ) {
		if ( !isNaN( nTop ) ) {
			this.style.top = nTop+pxEnd;
		} else return parseInt( this.style.top );
	}
	layer.left = function( nLeft ) {
		if ( !isNaN( nLeft ) ) {
			this.style.left = nLeft+pxEnd;
		} else return parseInt( this.style.left );
	}
	
	layer.height = function( nHeight ) {
		if ( isNS4 ) {
			if ( !isNaN( nHeight ) ) this.ref.document.height = nHeight+pxEnd;
			else return parseInt( this.ref.document.height );
		} else {
			if ( !isNaN( nHeight ) ) this.style.height = nHeight+pxEnd;
			else return parseInt( this.ref.offsetHeight );
		}
	}
	layer.width = function( nWidth ) {
		if ( isNS4 ) {
			if ( !isNaN( nWidth ) ) this.ref.document.width = nWidth+pxEnd;
			else return parseInt( this.ref.document.width );
		} else {
			if ( !isNaN( nWidth ) ) this.style.width = nWidth+pxEnd;
			else return parseInt( this.ref.offsetWidth );
		}
	}
	
	layer.vis = function( vis ) {
		if ( vis != null ) this.style.visibility = (vis ? "visible" : "hidden");
		else return (this.style.visibility == "visible");
	}
	
	
	/*
		Layer Property Initialization
	*/
	
	layer.ref = GetReference( id, parent );
	layer.style = GetStyle( id, parent );
	
	layer.nativeName = id;
	
	if ( objName != null ) layer.obj = objName;
	else layer.obj = id+"Layer";
	eval( layer.obj+"=layer" );
	
	return layer;
}