	var PagerData = {};
	
	var KategViewer	= Class.create();
	KategViewer.prototype = {
		initialize: function (obj) {
			this.obj = obj;
			this.besorolas_id = obj.rel.replace('x', '')*1;
			this.opened = false;
			this.progr = false;
		},
		open: function () {},
		close: function () {
			if (this.progr) return;
			if (!this.opened) return;
			this.progr = true;	
			var f = function() {
				this.newDiv.remove();
				this.opened = false;		
				this.progr = false;		
			}.bind(this);
			this.obj.removeClassName('on');
			new Effect.Morph(this.newDiv, {style: 'height: 0px;', duration: .2, afterFinish: f});
		},
		click: function (event) {
			Event.stop(event);			
			if (this.progr) return;
			if (this.opened) return this.close();
			this.progr = true;
			if (!this.opened) {
				try {if (pageTracker) pageTracker._trackEvent('termekKategoria', 'open', this.obj.innerHTML);} catch(err) {}
				this.obj.addClassName('on');
				this.newDiv = new Element('div');
				var d = this.newDiv;
				d.addClassName('insideContent');
				this.obj.insert({after: this.newDiv});
				var f = function() {
					this.newDiv.update('<img class="loader" src="/i/termekek/loaderWhite.gif" height="11" width="16"/>');		
					new Ajax.Request('/getAjax?m=termek.besorolas', {
						method: 'get',
						parameters: {besorolas_id: this.besorolas_id},
						onSuccess: this.loaded.bindAsEventListener(this),
						onFailure: function () {alert('Hiba történt, kérjük frissítse az oldalt!');}
					});
				};
				new Effect.Morph(d, {style: 'height: 56px;', duration: .2, afterFinish: f.bind(this)});
			}
		},
		loaded: function (resp) {
			var r = resp.responseJSON || {success: 0};
			if (!r.success) {
				this.opened = true;
				this.progr = false;
				this.close();
			}
			this.newDiv.update('<div class="fstX"><div class="katli"></div><div class="termekekX"></div></div><img src="/i/termekek/bottomshadow_kateg.png" class="bottom" height="25" width="550">');	
			this.newDiv.addClassName('loaded');			
			var talalat = 0;
			r.cs.each(function(csalad) {
				/*if (csalad.acs.length == 1 && csalad.acs[0].name == csalad.name) {
					if (csalad.acs[0].tCount == 0) return;
					var e = new Element('A');
					e.href = '/'+r.url+'/'+csalad.url+'/'+csalad.acs[0].url;
					e.addClassName('xcsalad');
					e.update(csalad.name+(csalad.acs[0].tCount > 0?' ('+csalad.acs[0].tCount+')':''));
					this.newDiv.select('.katli').first().insert({bottom: e});						
				} else {*/
					var e = new Element('A');
					e.href = '/'+r.url+'/'+csalad.url;
					e.subLinks = 0;
					e.addClassName('xcsalad');
					var counter = 0;
					csalad.acs.each(function(alcsalad, i) {
						var e2 = new Element('A');
						e2.href = '/'+r.url+'/'+csalad.url+'/'+alcsalad.url;
						e2.addClassName('xalcs');
						e2.update(alcsalad.name+(alcsalad.tCount > 0?' ('+alcsalad.tCount+')':''));
						if (alcsalad.tCount > 0) {
							e.subLinks++;
							if (counter == 0) this.newDiv.select('.katli').first().insert({bottom: e});								
							this.newDiv.select('.katli').first().insert({bottom: e2});	
							counter += 1*alcsalad.tCount;
						}
					}.bind(this));
					talalat += counter;
					e.update(csalad.name /*+(counter > 0?' ('+counter+')':'')*/);
				//}
			}.bind(this));
			this.newDiv.select('.katli a.xcsalad').each(function(e) {
				if (e.subLinks == 1) {
					e.href = e.next().href;	
				}
			}.bind(this));
			var f2 = function() {
				if (talalat) {
					var tx = this.newDiv.select('.termekekX').first();
					r.termeks.each(function (t, index) {
						if (this.usedHeight < 196) {
							if (this.usedHeight > 144) {
								if (index > 5) return;
							} else {
								if (this.usedHeight > 92) {
									if (index > 2) return;
								} else {
									return;
								}
							}
						} else {
							if (this.usedHeight < 248) {	
								if (index > 8) return;
							}
						}
						var i = new Image();
						var a = new Element('a');
						a.style.marginLeft = ((index % 3) * 52)+'px';
						a.style.marginTop = (Math.floor(index/3)*52)+'px';
						a.href = this.obj.href+t.link;
						a.addClassName('im');
						a.title = t.usedName;
						i.alt = t.usedName;
						i.width = t.imgX;
						i.height = t.imgY;
						i.style.top = Math.round((50-t.imgY)/2)+'px';
						i.style.left = Math.round((50-t.imgX)/2)+'px';
						a.update('<div class="feherito"></div><img class="csucsok" src="/i/termekek/feher_csucsok.png" width="50" height="50" />');
						i.onload = function(index) {
							Element.fade.delay(index*.35, this, {duration: .7});	
						}.bind(a.select('.feherito').first(), index);
						i.src = 'http://static.'+Auchan.domain+'/'+t.md5hash+t.attach_id;
						a.insert({bottom: i});
						tx.insert({bottom: a});
					}.bind(this));
				}								
			}.bind(this);
			if (!talalat) {
				this.newDiv.select('.katli').first().update('<div class="nincs">Jelenleg nem található termék a kategóriában.</div>');
			}			
			this.usedHeight = this.newDiv.down().getHeight();
			new Effect.Morph(this.newDiv, {style: 'height: '+(this.usedHeight)+'px;', duration: .4, afterFinish: f2});
			this.opened = true;
			this.progr = false;
		}
	}
	

	initializesAlways.push(function() {		
		$$('.alcsalad ul.list li').each( function(li) {
			var L1 = li.select('.tx');
			if (!L1.length) return;
			var h = L1.first().getHeight();
			li.down(0).style.height = Math.max(108+(h-92), 108)+'px';	
			li.style.height = 'auto';
		} );
		
		if ($('MoreSzegme')) {
			$('MoreSzegme').select('a').findAll(function(i){return i.hasClassName('ktg');}).each(function (i) {
				i.KV = new KategViewer(i);
				Event.observe(i, 'click', i.KV.click.bindAsEventListener(i.KV));
			});
		}
		
	});

