	var PagerClass	= Class.create();
	PagerClass.prototype = {
		initialize: function () {},
		doPager: function(toPage) {
			var z		= (PagerData.o == -1 ? '' : 'o='+PagerData.o+(toPage != 1 ? '&':'') )+(toPage != 1 ? 'p='+(toPage-1):'');
			if (PagerData.cimke)	z	+= ((z?'&':'')+'cimke='+PagerData.cimke);
			if (PagerData.kereses)	z	+= ((z?'&':'')+'kereses='+PagerData.kereses);
			document.location = 'http://recept.'+Auchan.domain+'/lista'+(z?'?'+z:'');
		}
	}
	
	var ReceptClass	= Class.create();

	ReceptClass.prototype = {
		initialize: function() {
			var r = $$('.recept');
			if (r.length == 1) {
				this.recept_id = r.first().id.replace('Recept', '');	
			} else {
				return;	
			}
			this.validateHozzavalok();
			this.validateKedvenc();
		},
		validateKedvenc: function(isTodo, what) {
			var pars = {};
			var receive = null;
			if (isTodo) {
				pars = {todo: (what?'1':'0')};
				receive = what;
			}
			new Ajax.Request('http://'+document.domain+'/getAjax?m=recept.isKedvenc', {
				method: 'get',
				parameters: Object.extend({recept_id: this.recept_id}, pars),
				onSuccess: function(transport, receive) {
					if (transport.responseText == '1') {
						$('intoKedvenc').down(1).update('eltávolítás kedvencek közül');
						$('intoKedvencIcon').title = 'eltávolítás kedvencek közül';
						$('intoKedvencIcon').addClassName('ac');
						this.isKedvenc = true;
					} else {
						$('intoKedvenc').down(1).update('hozzáadás kedvencekhez');	
						$('intoKedvencIcon').title = 'hozzáadás kedvencekhez';
						$('intoKedvencIcon').removeClassName('ac');
						this.isKedvenc = false;
					}
					$('intoKedvencIcon').up().style.marginLeft = '400px';
					$('intoKedvencIcon').style.display = 'block';
					$('intoKedvenc').style.display = 'block';
					if (receive !== null) {
						//alert(receive);	
					}
				}.bindAsEventListener(this, receive)
			});
		},
		validateHozzavalok: function() {
			if (Auchan.sessionID && Auchan.auchanuser_id) {
				var itz = [];
				var tosend = {};
				var zi = 0;
				$$('.hozzavalok').first().select('.receptelem').each(function(r, i) {
					var don = r.select('span').first();
					if (don.childNodes.length == 2) {
						var t = don.childNodes[1].nodeValue;
						var qt = don.childNodes[0].childNodes[0].nodeValue;
					} else {	
						if (don.childNodes.length) {
							var t = (don.childNodes[0].nodeValue?don.childNodes[0].nodeValue:'');
							var qt = '';
						} else {
							var t = '';
							var qt = '';							
						}
					}
					var cr = crc32(t)+'';
					var newo = {obj: r, title: t, qt: qt, p: i+'x'+cr.substring(0,3)}
					r.__data = newo;
					itz.push(newo);
					var toEval = "tosend = Object.extend(tosend, {hv"+(zi++)+": i+'x'+cr.substring(0,3)});";							
					eval(toEval);
				});		
				if (itz.length) {
					new Ajax.Request('/getAjax?m=recept.hozzavalok', {
						method: 'get',
						parameters: Object.extend({recept_id: this.recept_id}, tosend),
						onFailure: function () {},
						onSuccess: function(transport, itz) {
							var os = transport.responseJSON || [];
							os.each(function(o) {
								this[o].obj.addClassName('on');
								this[o].obj.select('a').first().title='Bevásárlólistán van';
							}.bind(itz));
						}.bindAsEventListener(this, itz)
					});
				}
				this.itz = itz;
			}
		},
		changeHV: function(o) {
			if (!Auchan.checkLoggedIn()) return;
			var whatto = o.hasClassName('on');
			if (whatto) {
				new Ajax.Request('/getAjax?m=recept.hozzavalok&removeItem', {
					method: 'get',
					parameters: Object.extend({recept_id: this.recept_id, p: o.__data.p}),
					onFailure: function () {},
					onSuccess: function(transport, o) {
						o.removeClassName('on');
						o.select('a').first().title='Bevásárlólistára teszem';
					}.bindAsEventListener(this, o)
				});							
			} else {
				new Ajax.Request('/getAjax?m=recept.hozzavalok&addItem', {
					method: 'get',
					parameters: Object.extend({recept_id: this.recept_id, p: o.__data.p, title: o.__data.title, qt: o.__data.qt}),
					onFailure: function () {},
					onSuccess: function(transport, o) {
						o.addClassName('on');
						o.select('a').first().title='Bevásárlólistán van';
					}.bindAsEventListener(this, o)
				});				
			}
		},
		toggleKedvenc: function(id) {
			if (!Auchan.checkLoggedIn()) return;
			this.validateKedvenc(true, !this.isKedvenc);
		}
	};
	
	var Recept;
	var PagerData = {};

	initializes.push( function() {   
		Recept = new ReceptClass();		
		if ($('lapozas') && PagerData.onpage >= 0) {
			Pagers.push(new PagerClass());
			var id = Pagers.length - 1;
			swfobject.embedSWF("http://www."+Auchan.domain+"/swf/lapozo.swf", "lapozas", "180", "24", "9", "", {pagerID: id, frstpg: PagerData.onpage, btnnr: PagerData.pages}, {wmode: 'transparent', background: 'transparent', allowScriptAccess: 'always'}, {});
		}
		if ($('kereses_recept')) {
			Event.observe($('kereses_recept'), 'keypress', function(event) {
				var key_code = event.charCode ? event.charCode : event.keyCode;
				if (Event.KEY_RETURN == key_code) {
					document.location='http://recept.'+Auchan.domain+'/'+(!$('kereses_recept').hasClassName('kedvenc_')?'lista':'kedvenc-receptek')+'?kereses='+encodeURIComponent($('kereses_recept').value);
				}
			});
		}
	});
