_xGUI = new Object();

function $() {
	if(typeof(arguments[i])=="object") return arguments[i];
	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;
}
function $f(element) {
	return document.getElementsByName(element);
}


/**
_xGUI.FX
*/
_xGUI.FX = new Object();
_xGUI.FX.setOpacity=function(e, percent){
	percent = Math.round(percent);
	if(percent<0)percent = 0;
	if(percent>100)percent = 100;
	e = $(e);
	e.style.MozOpacity = percent/100;
	e.style.opacity = percent/100;
//	e.filters.alpha.opacity = percent;
//	e.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+String(percent)+")"
	e.style.filter = "alpha(opacity="+String(percent)+")"
}
_xGUI.FX.ClassMorph = function(srcClass, targetClass){}

_xGUI.FX.BlinkClass = function(e, targetClass, opts){
	if(!e) return false;
	if(!opts) opts = {};
	if(!opts.count) opts.count = 3;
	if(!opts.rate) opts.rate = 8;
	this.options=opts;
	this.originalClass = e.className;
	this.targetClass = targetClass;
	this.element=e;
	new _xGUI.FX.EffectProcessor(this);
}
_xGUI.FX.BlinkClass.prototype.options = null;
_xGUI.FX.BlinkClass.prototype.state = 0;
_xGUI.FX.BlinkClass.prototype.element = null;
_xGUI.FX.BlinkClass.prototype.originalClass = "";
_xGUI.FX.BlinkClass.prototype.targetClass = "";
_xGUI.FX.BlinkClass.prototype.Process = function(){
	if(this.state%2){
		this.element.className = this.originalClass;
	}else{
		if( (this.state/2) >= this.options.count) return 0;
		this.element.className = this.targetClass;
	}
	this.state++;
	return 1000/this.options.rate;
}


_xGUI.FX.runningEffects = new Array(),

_xGUI.FX.EffectProcessor = function(FX){
	this.FX = FX;
	this.ident = _xGUI.FX.runningEffects.length;
	_xGUI.FX.runningEffects[this.ident] = this;
	this.Resume();
}
_xGUI.FX.EffectProcessor.prototype.FX=null;
_xGUI.FX.EffectProcessor.prototype.ident=0;
_xGUI.FX.EffectProcessor.prototype.Resume = function(arg){
	var delay;
	if(delay = this.FX.Process()){
		setTimeout("_xGUI.FX.runningEffects["+this.ident+"].Resume('msg')", Math.round(delay));
	}else{
		this.FX = null;
		_xGUI.FX.runningEffects[this.ident] = null;
	}
};
