var isDisplay = function(el){
	if(el.getStyle('display') == 'block') return true; else return false;
}

var isActive = function(a){
	if(a.hasClass('active')) return true; else return false;
}

var isVisible = function(el){
	if(el.getStyle('visibility') == 'visible') return true; else return false;
}


/* *************************************
*
*  UMI REQUEST
*
************************************ */

var umiRequest = new Class({
	Implements: [Events, Options],
	options: {
		url: '/content/get_ajax_content/',
		method: 'post',
		callback: function(text){return text},
		params: new Hash,
		mode: 'update' //update or result

	},
	initialize: function (){
		var params = Array.link(arguments, {options: Object.type, elements: $defined});
		this.setOptions(params.options || null);
	},
	setValue: function(key, value){
		this.options.params.set(key,value);
	},
	setValues: function(values){//must be an object
		this.options.params.extend(values);
	},
	send: function (request){
		this.cook = document.cookie;//получаем все куки
		request.setHeader('Cookie', this.cook);
		request.send();
	},

	commit: function(id, params, url, callback){
		if(!this.options.url) alert('Не указан целевой адрес!');
		var _self = this;
		var data = this.options.params.toQueryString();

		var request = new Request({
			method: this.options.method,
			url: this.options.url,
			data: data,
			evalScripts: true,
			onComplete: function(text){
				if(_self.options.mode == 'result') return text;
				else _self.options.callback(text);
			}
		});
		this.send(request);
	}
	
});

//var umi = new umiRequest();




function getStyle(el, cssprop){
 if (el.currentStyle) //IE
  return el.currentStyle[cssprop]
 else if (document.defaultView && document.defaultView.getComputedStyle) //Firefox
  return document.defaultView.getComputedStyle(el, "")[cssprop]
 else //try and get inline style
  return el.style[cssprop]
}



var Loading = new Class({
	Implements: [Events, Options],
	
	options: {
		url: '/gif/wait/loading-small.gif',
		className: 'temp',
		size: {x:32,y:32},
		delay: 500
	},
	
	initialize: function(options){
		var params = Array.link(arguments, {options: Object.type, elements: $defined});
		this.setOptions(options);
		
		var _self = this;
		this.div = new Element('div', {
			'class': _self.options.className
		});
		var img = new Element('img',{
			'width': this.options.size.x,
			'height': this.options.size.y,
			'src': this.options.url
		});
		/*img.src = this.options.url;
		img.width = this.options.size.x;
		img.height = this.options.size.y;*/
		img.inject(this.div);
	},
	
	start: function(el){
		el.empty();
		this.div.inject(el);
		//this.img.inject(this.div);
	},
	
	flush: function(el, text){
		var setText = function (text){
			this.set('html',text);
		}
		setText.delay(this.options.delay,el,text);
	}
	
});

