/**
 * dom.js - Using the Document Object Model
 *
 * $Id:$
 *
 * Copyright(c)2004, didier Belot <dib@idee-informatique.com>
 *
 */

//-----------------------------------------------------------------------------
// some compatibility functions

/**
 *
 * Node access for (almost) every browser
 *
 */
function getNodeById(id){
	if(document.getElementById) {
		return document.getElementById(id);
	}
	if(document.layers){
		if(document.layers[id]) {
			return document.layers[id];
		}
		var x,y,form;
		for(x=0; x < document.forms.length; x++){
			form=document.forms[x];
			for(y=0; y<form.elements.length; y++){
				if(form.elements[y].name && form.elements[y].name == id){
					return form.elements[y];
				}
			}
		}
		return null;
	}
	if(document.all){
		return document.all[id];
	}
	return null;
}

/**
 * className manipulation object
 *
 * (c)2005, didier Belot
 *
 */
function ClassName(s) {
	this._s=s;
	this.trim = function() {
		this._s = this._s.replace(/(^\s*|\s*$)/,'');
		return this._s;
	};
	this.addClass = function(name) {
		if ( this._s.indexOf(name) != -1 ) return;
		this._s += ( this._s.length ? ' ' : '' ) + name;
	};
	this.removeClass = function (name) {
		if ( this._s.indexOf(name) == -1 ) return;
		this._s = this._s.replace(name,'').replace(/(^\s*|\s*$)/,'');
	};
	this.hasClass = function(name) {
		return this._s.indexOf(name) != -1;
	};
	this.get = function() { return this._s; };
}

//-----------------------------------------------------------------------------
// Miscellaneous functions

// Adapted to overlib from jwin by Jason Anderson -- http://www.jwinlib.com
function pageLocation(o, t){
	var x = 0;
	if(!o) return x;
	
	while(o.offsetParent){
		x += o['offset' + t]
		o = o.offsetParent
	}
	x += o['offset' + t]

	return x
} 


