////////////////////////////////////////////////////////////////////////
//
//	ElementObject Positioning (pObj)
//	Dependency: core.js
//	Tabsize: 4
//
//	Copyright (c) 2002 Marcus Nijssen
//
////////////////////////////////////////////////////////////////////////


//============================================
//	Constructor
//============================================

function pObj(o) {
	this.o = o;
	this.f = 0;
	if (o) {
		this.id = (typeof o.id=='string') ? o.id : '';
		this.s = ns4 ? o : o.style;
		this.p = ns4 ? (o.parentLayer!=self) ? o.parentLayer : null :
			o.parentNode ? o.parentNode : o.parentElement;
		this.ofsP = ns4 ? this.p : (typeof o.offsetParent != 'undefined' &&
			o.offsetParent != document.body) ?	o.offsetParent : null;
	}
	else
		this.id = '';
}

function p_Obj(id) {
	return new pObj(getEl(id));
}

//============================================
//	Setup
//============================================

function pObjSetup() {

	function f(fname, fscript, farg) {
		if (arguments.length<3) farg = '';
		eval("pObj.prototype."+fname+"=function("+farg+"){"+fscript+"}");
	}

	f('show', 'this.s.visibility="'+(ns4? 'show' : 'visible')+'"');
	f('hide', 'this.s.visibility="'+(ns4? 'hide' : 'hidden')+'"');

	f('getPosX', 'return this.o.'+(ns4? 'x' : 'offsetLeft'));
	f('getPosY', 'return this.o.'+(ns4? 'y' : 'offsetTop'));

	pObj.prototype.getPageX = function() {return oPageX(this.o)}
	pObj.prototype.getPageY = function() {return oPageY(this.o)}

	f('setPosX',   'this.s.'+((ie4||ope)? 'pixelLeft=x'   :dmc? 'left=x+"px"'   :ns4? 'left=x'        :''), 'x');
	f('setPosY',   'this.s.'+((ie4||ope)? 'pixelTop=y'    :dmc? 'top=y+"px"'    :ns4? 'top=y'         :''), 'y');
	f('setWidth',  'this.s.'+((ie4||ope)? 'pixelWidth=w'  :dmc? 'width=w+"px"'  :ns4? 'clip.width=w'  :''), 'w');
	f('setHeight', 'this.s.'+((ie4||ope)? 'pixelHeight=h' :dmc? 'height=h+"px"' :ns4? 'clip.height=h' :''), 'h');

	pObj.prototype.setPosXY  = function(x,y) {this.setPosX(x);this.setPosY(y);}
	pObj.prototype.setPageX  = function(x)   {this.setPosX(x-oPageX(this.ofsP))}
	pObj.prototype.setPageY  = function(y)   {this.setPosY(y-oPageY(this.ofsP))}
	pObj.prototype.setPageXY = function(x,y) {this.setPageX(x);this.setPageY(y);}

	f('getWidth',  'return this.'+(ope? 's.pixelWidth'  :ns4? 'o.document.width'  : 'o.offsetWidth'  ));
	f('getHeight', 'return this.'+(ope? 's.pixelHeight' :ns4? 'o.document.height' : 'o.offsetHeight' ));
}

onLoadHandler(pObjSetup);

