/*
Hide and show html objects class
*/

objects = Class.create();
objects.prototype = {
	
	initialize: function () {
		this.checkBrowser();
		this.obj = new Array();
		this.timer = new Array();
		this.id = null;
	},


	changeObject: function (pAction, pIdName, pTime) {		
		this.id = pIdName;
		this.getObject();
		if (pAction == 'show') {
			if (pTime) {
				this.timer[this.id] = setTimeout(this.showObject.bind(this), pTime);
			} else {
				this.showObject();
			}
		} else if (pAction == 'hide') {
			if (pTime) {			
				this.timer[this.id] = setTimeout(this.hideObject.bind(this), pTime);
			} else {
				this.hideObject();
			}
		} else if (pAction == 'display') {
			if (pTime) {
				this.timer[this.id] = setTimeout(this.displayObject.bind(this), pTime);
			} else {
				this.displayObject();
			}
		} else if (pAction == 'undisplay') {
			if (pTime) {
				this.timer[this.id] = setTimeout(this.undisplayObject.bind(this), pTime);
			} else {
				this.undisplayObject();
			}
		}

	},


	showObject: function () {	
		var elementId = this.id;	
		this.obj[elementId].visibility = (this.dom||this.ie)? 'visible' : 'show';

	},


	hideObject: function () {	
		var elementId = this.id;
		this.obj[elementId].visibility = (this.dom||this.ie)? 'hidden' : 'hidden';	
	},


	displayObject: function () {
	        var elementId = this.id;
		this.obj[elementId].display = (this.dom||this.ie)? 'block' : 'block';
	},


	undisplayObject: function () {
		var elementId = this.id;
		this.obj[elementId].display = (this.dom||this.ie)? 'none' : 'none'
	},


	getObject: function () {
		var elementId = this.id;
		if (! this.obj[elementId]) {
			this.obj[elementId] = (this.dom)? document.getElementById(elementId).style : this.ie? document.all.elementId : document.elementId;
		}
		if (this.timer[elementId]) {
			clearTimeout(this.timer[elementId]);
		}
	},


	checkBrowser: function () {
		this.ie = document.all;
		this.dom = document.getElementById;
		this.ns4 = document.layers;
	}

}
