	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() {
			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=bevlNew', {
					method: 'get',
					parameters: Object.extend({recept_id: this.recept_id, w: 'receptHozzavaloGet'}, tosend),
					onFailure: function () {},
					onSuccess: function(transport, itz) {
						var os = transport.responseJSON || [];
						if (os && os.data) os.data.each(function(o) {
							this[o].obj.addClassName('on');
							this[o].obj.select('a').first().title='Bevásárlólistára került';
						}.bind(itz));
					}.bindAsEventListener(this, itz)
				});
			}
			this.itz = itz;
		},
		changeHV: function(o) {
			var whatto = o.hasClassName('on');
			if (whatto) {
				if (Auchan.protoBL && Auchan.protoBL.isReady) {
					Auchan.protoBL.removeItemReceptHV(this.recept_id, o.__data.p);	
					o.removeClassName('on');
					o.select('a').first().title='Bevásárlólistára teszem';
				}
			} else {
				if (Auchan.protoBL && Auchan.protoBL.isReady) {
					o.addClassName('on');
					o.select('a').first().title='Bevásárlólistára került';
					Auchan.protoBL.addItem({recept_id: this.recept_id, p: o.__data.p, megnevezes: o.__data.title, quantity: o.__data.qt});			
				}
			}
		},
		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", "30", "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);
				}
			});
		}
		if ($('akciosTermekek')) {
			swfobject.embedSWF("http://"+document.domain+"/swf/termeklista_3.swf", "akciosTermekek", "546", "171", "9", "", {dir: 'http://'+document.domain+'/getXML/product?mode=3_akciok_0_'+$$('.recept').first().readAttribute('id').replace('Recept', '')}, {allowScriptAccess: 'always', wmode: 'transparent', background: 'rgb(234,227,189)'}, {});	
		}
	});

