function initOfferList() {
	$ES(".offer").each(function(elm) {
		elm.fx = new Fx.Style(elm,'opacity',{delay:400,wait:false});
		elm.fx.set(0.7);
		elm.addEvent("mouseenter",function() {
			this.fx.start(0.7,1.0);
		});
		elm.addEvent("mouseleave",function() {
			this.fx.start(1.0,0.7);
		});
	});
	try {
		Nifty("a.offer","small transparent fixed-height");
	} catch(Exception) {}
	$ES(".paginator a").each(function(elm) {
		elm.addEvent("click",function(event) {
			   window.list_offers_component = new Ajax(this.href + "&ajax=1", {
			   	method: 'get',
			   	update:'list_offers_component',
			   	onComplete:function() {
			   		initOfferList();
			   		initTips('#list_offers_component a.tip');
			   		/*$('loader').setStyle('display','none');*/
			   		
			   		/*$('list_offers_component').fx = new Fx.Style($('list_offers_component'),'opacity',{delay:400,wait:false});
			   		$('list_offers_component').fx.start(0.1,1.0);*/
				}
			   });
			   window.list_offers_component.request();
			   $ES('.offersList a').each(function(elm) {
			   		elm.addClass('loading');
			   		elm.setOpacity(0.3);
			   });
			   /*$('loader').setStyle('display','block');*/
			   
			   var event = new Event(event);
			   event.stop();
			   return false;
		});
	});
}
window.addEvent("domready",function() {
	initOfferList();
	
	$ES("#countries a").each(function(elm) {
		elm.addEvent("click",function(event) {
			   window.list_offers_component = new Ajax(this.href + "?ajax=1&ajax=1", {
				method: 'get',
			    data:({
			    	'country':  $(this).getText()
				}),
				update:'list_offers_component',
				onComplete:function() {
			   		initOfferList();
			   		$('loader').setStyle('display','none');
				}
			   });
			   window.list_offers_component.request();
				$ES('.offersList a').each(function(elm) {
			   		elm.addClass('loading');
			   		elm.setOpacity(0.3);
			   });
			   /*$('loader').setStyle('display','block');*/
			   
			   $ES("#countries a, #cities a").each(function(item) {  
			   	item.removeClass('active');
			   });
			   elm.addClass('active');
			   elm.blur();
			   var event = new Event(event);
			   event.stop();
			   return false;
		});
	});
	$ES("#cities a").each(function(elm) {
		elm.addEvent("click",function(event) {
			   window.list_offers_component = new Ajax(this.href + "?ajax=1&ajax=1", {
			    data:({
			    	'country':  ($ES('#countries a.active').length > 0 ? $ES('#countries a.active')[0].getText() : ""),
			    	'city':  $(this).getText()
				}),
				method: 'get',
				update:'list_offers_component',
				onComplete:function() {
			   		initOfferList();
			   		$('loader').setStyle('display','none');
				}
			   });
			   window.list_offers_component.request();
				$ES('.offersList a').each(function(elm) {
			   		elm.addClass('loading');
			   		elm.setOpacity(0.3);
			   });
			   /*$('loader').setStyle('display','block');*/
			   
			   $ES("#cities a").each(function(item) {
			   	item.removeClass('active');
			   });
			   elm.addClass('active');
			   elm.blur();
			   var event = new Event(event);
			   event.stop();
			   return false;
		});
	});
});