//
// activeLayer. Rev. 013 (June 27th 2001). 
// Copyright Anders Hammervald 2001
////////////////////////////////////////////////////////////////////////////////////

	dom	= (document.documentElement)? 	true : false;
	ie 	= (document.all)? 				true : false;
	ns 	= (document.layers)? 			true : false;

//
// activeLayer "class"
////////////////////////////////////////////////////////////////////////////////////

	function activeLayer(id, handle) {
	
		this.id 		= id;
		this.handle 	= handle;
		
		if (ie || dom) {
		
			if (ie) { this.obj = document.all[id]; }
			if (dom) { this.obj = document.getElementById(id); }
	
			this.style_ref 	= this.obj.style;
	
			this.top 		= parseInt(this.style_ref.top.substring(0, this.style_ref.top.length - 2));
			this.left 		= parseInt(this.style_ref.left.substring(0, this.style_ref.left.length - 2));
			this.width 		= parseInt(this.style_ref.width.substring(0, this.style_ref.width.length - 2));
			this.height		= parseInt(this.style_ref.height.substring(0, this.style_ref.height.length - 2));
		}
		
		if (ns) {
		
			this.obj 		= this.style_ref = alHelperNetscapeFindLayer(id);
		
			this.top 		= this.style_ref.top;
			this.left 		= this.style_ref.left;
			this.width 		= this.style_ref.clip.width;
			this.height		= this.style_ref.clip.height;
		}
	}

	with (activeLayer) {
	
		prototype.moveTo 	= alMoveTo;
		prototype.moveBy 	= alMoveBy;
		prototype.resizeTo 	= alResizeTo;
		prototype.resizeBy 	= alResizeBy;
		prototype.show 		= alShow;
		prototype.hide 		= alHide;
		prototype.clipTo 	= alClipTo;
		prototype.clipBy 	= alClipBy;
		prototype.writeTo 	= alWriteTo;
	}


//
// MoveTo(x,y)
////////////////////////////////////////////////////////////////////////////////////

	function alMoveTo(x,y) {
	
		this.left 				= x;
		this.style_ref.left 	= x;
		this.top 				= y;
		this.style_ref.top	 	= y;
	
		eval(this.onmove)
	}

	
//
// MoveBy(x,y)
////////////////////////////////////////////////////////////////////////////////////

	function alMoveBy(x,y) {
	
		this.moveTo(this.left + x, this.top + y)
	}
	
	
//
// ResizeTo(x,y)
////////////////////////////////////////////////////////////////////////////////////	

	function alResizeTo(x,y) {
	
		this.width 	= x;
		this.height = y;
	
		if (ns) {
		
			this.style_ref.clip.width 	= x;
			this.style_ref.clip.height 	= y;
			this.clipRight 				= x;
			this.clipBottom 			= y;
		}
	
		if (ie || dom) {
		
			this.style_ref.width 		= x
			this.style_ref.height 		= y
		}
		
		eval(this.onresize);
	}

	
//
// ResizeBy(x,y)
////////////////////////////////////////////////////////////////////////////////////	
	
	function alResizeBy(x,y) {
	
		this.resizeTo(this.width + x, this.height + y);
	}

	
//
// Show()
////////////////////////////////////////////////////////////////////////////////////	

	function alShow() {
	
		this.style_ref.visibility = (ie || dom)? 'visible' : 'show';
		eval(this.onshow);
	}

	
//
// Hide()
////////////////////////////////////////////////////////////////////////////////////	

	function alHide() {
	
		this.style_ref.visibility = (ie || dom)? 'hidden' : 'hide';
		eval(this.onhide);
	}


//
// ClipTo()
////////////////////////////////////////////////////////////////////////////////////	

	function alClipTo(t,r,b,l) {
	
		if (ie || dom) {
	
			this.style_ref.clip = 'rect(' + t + 'px, ' + r + 'px,' + b + 'px,' + l + 'px)';
		}
	
		if (ns) {
	
			var oClip = this.style_ref.clip;
		
				oClip.top 		= t;
				oClip.right 	= r;
				oClip.bottom 	= b;
				oClip.left 		= l;
		}
	
		this.clipTop 		= t;
		this.clipRight 		= r;
		this.clipBottom 	= b;
		this.clipLeft 		= l;
	
		eval(this.onclip);
	}

	
//
// ClipBy()
////////////////////////////////////////////////////////////////////////////////////	
	
	function alClipBy(t,r,b,l) {
	
		if (this.style_ref.clip == "") { this.clipTo(0, this.width, this.height, 0); }
	
		this.clipTo(this.clipTop + t, this.clipRight + r, this.clipBottom + b, this.clipLeft + l);
	}

	
//
// WriteTo()
////////////////////////////////////////////////////////////////////////////////////	
	
	function alWriteTo(html) {
		
		if (ns) {
			
		    with (this.style_ref.document) {
	
				open();
				write(html);
				close();
		    }
		}
		
		if (ie || dom) { this.obj.innerHTML = html; }
	
		eval(this.onchange);
	}


//
// Helpers...
////////////////////////////////////////////////////////////////////////////////////	
	
	function alHelperNetscapeFindLayer(id, parent) {
	
		if (!parent) { parent = document; }
		
		var found = null;
		
		for (var i = 0; i < parent.layers.length; i++) {
		
			if (parent.layers[i].id == id) { found = parent.layers[i]; return found; }
	
			found = alHelperNetscapeFindLayer(id, parent.layers[i]);
		}
		
		return found;
	}

