var AjaxControls={

	init: function(){

		this._chkLoader();

		this.fs=[]; this.es=[];	this.initAll();

	},

	add: function(fs,es){

		this.fs=fs;	this.es=es;	this.initAll();

	},

	_chkLoader: function(){

		if(!$defined($('loader')))	new Element('img',{'styles':{'display':'none'},'src':'/images/ajax-loader.gif','id':'loader','alt':'preloader'}).injectAfter(document.body.getFirst());	

	},

	initAll: function(){

		this.hideLoader();

		$$('.getPg').each(function(e){

			if(e.rel==null)	e.rel=1;

			pl='pl'+e.rel;

			this._checkPL(e.rel);

			e.removeEvents('click').addEvent('click',function(e){

				new Event(e).stop();	

				AjaxControls._start(this.href,this.rel);

			});

		},this);

		this.fs.each(function(e){	e();	});

		dil();

	},

	stopAll: function(){

		$$('.getPg',this.es).each(function(e){

			e.removeEvents('click').addEvent('click',function(e){	new Event(e).stop();	});	//Add blank event

		});

	},	//Stop All Events

	call: function(href,rel){

		this._checkPL(rel);

		this._start(href,rel);

	},

	_start: function(href,rel){

		this.showLoader(rel);

		new Ajax(href.split('?')[0], {method: 'get', update:$('cc'+rel), onComplete:this.initAll.bind(this)}).request(href.split('?')[1]+'&ajax='+rel);

	},

	showLoader: function(rel){

		if(!$defined(rel))	rel=1;

		$('loader').injectInside('pl'+rel).setStyle('display','block');	this.stopAll();

	},

	hideLoader: function(rel){

		/*if(!$defined(rel))	rel=1;

		this._chkLoader();

		$('loader').setStyle('display','none');*/

	},

	_checkPL: function(rel){

		pl='pl'+rel;

		if(!$defined($(pl))){

			//'<div style="position:relative; top:0; left:0; width: 16px; height:16px; margin: 16px 0 16px '+(  $('paginating'+e.rel).style.width/2  ).round()+'px;" id="'+pl+'"></div>'.injectBefore('cc'+e.rel);

			//<div style="position:relative; top:0; left:0; width: 16px; height:16px; margin: 16px 0 16px 315px;" id="pl1"></div>

			new Element('div',{'id':pl,'styles':{	'position':'relative',

													'top':'0',

													'left':'0',

													'width':'16px',

													'height':'16px',

													'margin':'16px 0 16px '+((  $('paginating'+rel).getStyle('width').toInt()/2  ).round()+16)+'px'}

								}).injectBefore('cc'+rel);

		}

	}

	

};