/********************************************************
Copyright (C) 2000 Michael Heuser / Firmamentet A/S

Design and code by Michael Heuser
Testting is made with and by Firmamentet A/S

Date ->
	30/04	2000 - Layers up and running
	07/05	2000 - Scroll functions add
	24/11	2000 - Netscape 6 Support added
********************************************************/


//Layer class function
//
function objLayer(obj, nest) {
        nest=(!nest)? '':'document.' +nest +'.';
        this.obj=bw.dom? document.getElementById(obj):bw.ie4? document.all[obj]: bw.ns? eval(nest +'document.' +obj):0;
        this.css=bw.dom? this.obj.style:bw.ie4? document.all[obj].style: bw.ns? eval(nest+"document.layers." +obj):0;

        this.x	= parseInt(this.css.left);	// Get layer position
        this.y	= parseInt(this.css.top);

        //Original height is not change by the clip function.
		this.height_org		=bw.ie || bw.dom?this.obj.offsetHeight:this.css.clip.height;
		this.width_org		=bw.ie || bw.dom?this.obj.offsetWidth:this.css.clip.width;
		//Visual height and width is change by the clip function.
		this.height			= this.height_org;
		this.width 			= this.width_org;

		this.visible		= '?';		// Visible is set true/false by show/hide.

        this.name			= obj;
        this.scroll_x		= 0;
        this.scroll_y		= 0;

		// Functions...
		this.hide			= oLayerHide;
		this.show			= oLayerShow;
		this.zIndex			= oLayer_zIndex;
		this.move			= oLayerMove;

		this.clip			= oLayerClip;
		this.setheight		= oLayerHeight;
		this.setwidth		= oLayerWidth;

		this.write			= oLayerWrite;

        return this;
}

//Layer functions...
//Show layer.
function oLayerShow()    {this.css.visibility="visible"; this.visible=true}

//Layer functions...
//Hide layer.
function oLayerHide()    {this.css.visibility="hidden";  this.visible=false}

//Layer functions...
//Set index of layer.
function oLayer_zIndex(z) {this.css.zIndex=z;}

//Layer functions...
//Move layer.
function oLayerMove(x,y) {this.x=x; this.y=y; this.css.left=x -this.scroll_x; this.css.top=y -this.scroll_y;}

//Layer functions...
//Scroll visible area on layer.
function oLayerWidth(width) {
	if (typeof(width) == 'undefined') this.width = this.width_org;
	else this.width = width;

	this.clip(0, this.scroll_y, this.width, this.height +this.scroll_y);
}

//Layer functions...
//Scroll visible area on layer.
function oLayerHeight(height) {
	if (typeof(height) == 'undefined') this.height = this.height_org;
	else this.height = height;

	this.clip(this.scroll_x, 0, this.width +this.scroll_x, this.height)
}

//Layer functions...
//Set visible area on layer.
function oLayerClip(x1,y1,x2,y2) {
	if (bw.dom || bw.ie4) {
		this.css.clip="rect("+y1+","+x2+","+y2+","+x1+")";
	} else if(bw.ns4) {
		this.css.clip.left=x1;
		this.css.clip.top=y1;
		this.css.clip.right=x2;
		this.css.clip.bottom=y2;
	}
}

//Layer functions...
//Set contens of the layer.
function oLayerWrite(htmlText) {
	 if (bw.dom || bw.ie4) { // Internet Explorer 4+ & Netscape 6
		this.obj.innerHTML = htmlText;
	} else if (bw.ns) { // Netscape 4.x
		this.obj.document.open();
		this.obj.document.write(htmlText);
		this.obj.document.close();
	} 

	//Get the new Height & Width.
	this.height_org		=bw.ie || bw.dom?this.obj.offsetHeight:this.css.clip.height;
	this.width_org		=bw.ie || bw.dom?this.obj.offsetWidth:this.css.clip.width;

	this.height=this.height_org;
	this.width =this.width_org;
}
