// ***********************************************************************************************************
//
//	Name: 		DHTML Script Library
//	Version:	 	1.1
//	Description: 	Library providing cross-browser compatibility by introducing a DHTMLObject
//				wrapper class witch provides standard access to a HTML object's methods
//
//	Compatibility:
//				Windows:
//					Microsoft Internet Explorer 4, 5, 5.5
//					Netscape Navigator 4.03, 4.72, 6.01
//					Opera 5
//				Mac:
//					Microsoft Internet Explorer 5
//					Netscape Navigator 4, 6
//				Linux:
//					Netscape Navigator 4, 6
//
//	Author: 		Simon Belak
//	E-mail: 		Simon_Belak@yahoo.com
//
//	Last Modified: 1/19/2002
//
//	Copyright (c) Simon Belak
//	All rights reserved.
//
//	This Software is distributed under the GPL. For a list of your obligations and rights
//	under this license please visit the GNU website at http : //www.gnu.org/
//
// ***********************************************************************************************************

function BrowserInfo()
{
	var agent = navigator.userAgent.toLowerCase();
 	this.major = parseInt(navigator.appVersion);
 	this.minor = parseFloat(navigator.appVersion);
 	this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
 	this.ns4 = (this.ns && (this.major == 4));
 	this.ns6 = (this.ns && (this.major >= 5));
 	this.ie = (agent.indexOf("msie") != -1);
 	this.ie3 = (this.ie && (this.major < 4));
 	this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
 	this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
 	this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
 	this.ie6 = (this.ie && (agent.indexOf("msie 6.0") !=-1));
	this.opera5 = (agent.indexOf("Opera 5") != -1);
	this.mac = (agent.indexOf("Mac") != -1);
	this.dom = (this.ie5 || this.ie55 || this.ie6 || this.ns6 || (document.getElementById ? 1:0));
	this.capable = (this.ie4 || this.ie5 || this.ie55 || this.ie6 || this.ns4 || this.ns6 || this.opera5);
	return this;
}
var bwInfo = new BrowserInfo();

function Page()
{
	this.x0 = 0;
	this.y0 = 0;
	this.x100 = bwInfo.ie && document.body.offsetWidth-5 || innerWidth || 0;
	this.y100 = bwInfo.ie && document.body.offsetHeight-5 || innerHeight || 0;
	if (!this.x100 || !this.y100) return handleError('Document has no width or height');
	this.x50 = this.x2 / 2;
	this.y50 = this.y2 / 2;
	this.x10 = (this.x2*10) / 100;
	this.y10 = (this.y2*10) / 100;
	return this;
}

function DHTMLObject(obj,nest)
{
	function moveTo(x,y)
	{
		this.x = x;
		this.y = y;
		this.style.left = x;
		this.style.top = y;
	}

	function moveBy(x,y)
	{
	 	this.moveTo(this.x+x,this.y+y);
	}

	function resizeTo(w,h)
	{
		this.width = w;
		this.height = h;
		this.style.width = w;
		this.style.height = h;
	}

	function resizeBy(w,h)
	{
		this.resizeTo(this.height+h, this.width + w);
	}

	function show()
	{
	 	this.style.visibility = "visible";
	}

	function hide()
	{
	 	this.style.visibility = "hidden";
	}

	function setBg(color)
	{
		if (bwInfo.dom || bwInfo.ie4) this.style.backgroundColor = color;
		else if (bwInfo.ns4) this.style.bgColor = color;
	}

	function setInnerHTML(text, startHTML, endHTML)
	{
		 if (bwInfo.ns4)
		 {
			 if (!startHTML)
			 {
			 	startHTML = "";
			 	endHTML = ""
			 }
			 this.ref.open("text / html");
			 this.ref.write(startHTML+text+endHTML);
			 this.ref.close();
		}
		else
		{
			 this.obj.innerHTML = text;
		}
	}

	function clipTo(t,r,b,l, setSize)
	{
		this.ct = t;
		this.cr = r;
		this.cb = b;
		this.cl = l;
		if (bwInfo.ns4)
		{
			this.style.clip.top = t;
			this.style.clip.right = r;
			this.style.clip.bottom = b;
			this.style.clip.left = l;
		}
		else
		{
			if (t<0) t = 0;
			if (r<0) r = 0;
			if (b<0) b = 0;
			if (b<0) b = 0;
			this.style.clip = "rect("+t+","+r+","+b+","+l+")";
			if (setSize)
			{
				this.style.width = r;
				this.style.height = b;
			}
		}
	}

	function clipBy(t,r,b,l, setSize)
	{
		this.clipTo(this.ct+t,this.cr+r,this.cb+b,this.cl+l, setSize);
	}

	if (!bwInfo.capable) return handleError('Browser not supported!');
	this.obj = bwInfo.dom && document.getElementById(obj) || bwInfo.ie4 && document.all[obj] || (nest ? bwInfo.ns4 && document[nest].document[obj] : bwInfo.ns4 && document.layers[obj]);
	if (!this.obj) return handleError('The layer does not exist ('+obj+') - Exiting script\n\nIf you are using Netscape check object nesting.');
	this.style = bwInfo.dom || bwInfo.ie4 ? this.obj.style : this.obj;
	this.document = bwInfo.dom || bwInfo.ie4 ? document : this.obj.document;

	this.x = this.style.left || this.style.pixelLeft || this.obj.offsetLeft || 0;
	this.y = this.style.top || this.style.pixelTop || this.obj.offsetTop || 0;
	this.width = this.document.width || this.obj.offsetWidth || this.style.pixelWidth || 0;
	this.height = this.document.height || this.obj.offsetHeight || this.style.pixelHeight || 0;

	this.moveTo = moveTo;
	this.moveBy = moveBy;
	this.resizeTo = resizeTo;
	this.resizeBy = resizeBy;
	this.show = show;
	this.hide = hide;
	this.setInnerHTML = setInnerHTML;
	this.setBg = setBg;
	this.clipTo = clipTo;
	this.clipBy = clipBy;

	var clip = 0;
	if ((bwInfo.dom || bwInfo.ie4) && this.style.clip)
	{
		clip = this.style.clip;
		clip = clip.slice(5,clip.length-1);
		clip = clip.split(' ');
		for (var i = 0;i<4;i++)
		{
			clip[i] = parseInt(clip[i]);
		}
	}

	this.ct = this.style.clip.top || clip[0] || 0;
	this.cr = this.style.clip.right || clip[1] || this.width || 0;
	this.cb = this.style.clip.bottom || clip[2] || this.height || 0;
	this.cl = this.style.clip.left || clip[3] || 0;

	this.backRef = obj + "BackRef";
	eval(this.backRef + " = this");

	return this;
}

var _debugging = 1;

function handleError(msg,ev)
{
	if ( _debugging == 0 ) return false;
	else if ( _debugging == 1 ) alert( msg );
	else self.status = msg;
	if ( ev ) eval( ev );
	return false;
}
