// JavaScript Document

/*
*	Some simple Javascript tools ...
*/

//	Gets objects ids as string parameters or objects themselves as parameters and
//	returns an array of these objects retrieved by the getElementById method
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

//	Gets objects ids as string parameters or objects themselves as parameters or
//	objects composed from :
//		node :		object id as string or object himself and
//		active :	active display state as string
//		inactive:	inactive display state as string
//	sets these objects' display property to nothing or the active display state
//	sets these objects' display property to none or the inactive display state
//	toggles these objects' display property from none to nothing or nothing to none or
//	from active display state to inactive display state or from inactive display state to active display state
var toggleDisplay = {
	show : function() {
		for ( i=0; i < arguments.length; i++ ) {
			if (typeof arguments[i] != 'string' && 'node' in arguments[i] && 'active' in arguments[i]) {
				$(arguments[i].node).style.display = arguments[i].active;
			}
			else {
				$(arguments[i]).style.display = '';
			}
		}
	},
	hide : function() {
		for ( i=0; i < arguments.length; i++ ) {
			if (typeof arguments[i] != 'string' && 'node' in arguments[i] && 'inactive' in arguments[i]) {
				$(arguments[i].node).style.display = arguments[i].inactive;
			}
			else {
				$(arguments[i]).style.display = 'none';
			}
		}
	},
	toggle : function() {
		for ( i=0; i < arguments.length; i++ ) {
			if (typeof arguments[i] != 'string' && 'node' in arguments[i] && 'inactive' in arguments[i]) {
				$(arguments[i].node).style.display = ($(arguments[i].node).style.display != arguments[i].inactive ? arguments[i].inactive : arguments[i].active);
			}
			else {
				$(arguments[i]).style.display = ($(arguments[i]).style.display != 'none' ? 'none' : '');
			}
		}
	}
};

//	Gets objects composed from :
//		node :		object id as string or object himself and
//		active :	class name as string
//		inactive:	class name as string
//	as parameters and
//	sets these objects' class name to active string
//	toggles these objects' class name from active to inactive or from inactive to active
var toggleClassName = {
	changeto : function() {
		for ( i=0; i < arguments.length; i++ ) {
			$(arguments[i].node).className = arguments[i].active;
		}
	},
	toggle : function() {
		for ( i=0; i < arguments.length; i++ ) {
			$(arguments[i].node).className = ($(arguments[i].node).className != arguments[i].inactive ? arguments[i].inactive : arguments[i].active);
		}
	}
};
