
	window.noFlashData = '<div class="noFlash">Az akciók és bizonyos tartalmak megtekintéséhez <br/>flash lejátszó szükséges.<br/><br/>Igyenes letöltéséhez kattintson az alábbi ikonra: <a href="http://get.adobe.com/flashplayer/" target="_flash"><img src="http://wwwimages.adobe.com/www.adobe.com/downloadcenter/images/flash/flash_128.jpg" /></a></div>';
	
	String.prototype.htmlspecialchars = function(){ 
	    var str = this.replace(/&/g, '&amp;');
	    str = str.replace(/</g, '&lt;');
	    str = str.replace(/>/g, '&gt;');
	    str = str.replace(/"/g, '&quot;');
	    return str;
	};

	Element.addMethods({
	  scrollTo: function(element, left, top){
	    var element = $(element);
	    if (!element) return;
	    if (arguments.length == 1){
	      var pos = element.cumulativeOffset();
	      window.scrollTo(pos[0], pos[1]);
	    } else {
	    	if (!element) return;
		    element.scrollLeft = left;
		    element.scrollTop  = top;
	    }
	    return element;
	  }
	});	
	
	function addTermekItemPepe(id, megnevezes) {
		 if(Auchan.protoBL) {
		 	Auchan.protoBL.addItem({termek_id: id, megnevezes: megnevezes, quantity: ""});	
		 	return true;
		 }
		 return false;	
	}
	
	var protoBevlist = Class.create();
	
	protoBevlist.prototype = {
		initialize: function () {
			this.isReady = true;
			this.element = new Element('div');
			this.nullObject = {
				counter: 0,
				bevasarlolista_id: 0,
				updated: 0
			};
			this.loaderEffect = null;
			this.object = Object.clone(this.nullObject);
			this.element.id = 'PBL_element';
			this.element.update('<div class="hold"><div class="lft"></div><div class="rt"></div><div><div id="PBL_loader">BEVÁSÁRLÓLISTA: TÖLTŐDIK..</div><div id="PBL_body"><span>BEVÁSÁRLÓLISTA: </span><div id="PBL_counter"><div class="l"></div><div class="r"></div><div class="dt"></div></div></div></div></div>');
			this.loaderE = this.element.select('#PBL_loader').first();
			this.counterE = this.element.select('#PBL_counter .dt').first();
			this.bodyE = this.element.select('#PBL_body').first();
			this.element.observe('click', function() {Auchan.createIframeBox('bevasarlolista', '/getAjax?m=bevlistaNew', {});});
			if ($('header')) $('header').insert({top: this.element});
			this.items = [];
			this.isOpen = false;
			this.layerLoaded = false;
			this.refresh();
		},
		openClose: function(isOpen) {
			this.isOpen = isOpen;
			if (this.isOpen) {
				this.kedvencStatus = false;
				if (!$('BLI_add_textHolder')) return;
				if (!$('BLI_add_textHolder').hasClassName('ready')) {
					var f = function(event) {
						var key_code = event.charCode ? event.charCode : event.keyCode;
						if (Event.KEY_RETURN == key_code) {
							this.addLayerItem();										
						}	
					}.bindAsEventListener(this);
					$('BLI_add_text').observe('keypress', f);
					$('BLI_add_qt').observe('keypress', f);
					Event.observe($('BLI_add_text'), 'keyup', function() {
						if ($('BLI_add_text').value.length) $('BLI_add_textHolder').removeClassName('error');
					});
					$('BLI_add_text').focus();
					$('BLI_add_textHolder').addClassName('ready');
					this.layerLoaded = false;					
				}
				this.refresh(true);				
			}
		},
		setCounter: function() {
			var q = this.object.counter*1;
			this.counterE.update(q && q > 0 ? q+'<i>termék</i>' : 'üres');
			if (q) Element.removeClassName('emp'); else Element.addClassName('emp');	
		},
		saveItem: function(id, mode, value) {
			if (!this.isReady) return;
			this.loadOn();
			new Ajax.Request('/getAjax?m=bevlNew', {
				method: 'post',
				parameters: {text: value, mode: mode, id: id, w: 'save'},
				onSuccess: function(response) {
					this.loadOff();
					this.refresh();
				}.bind(this),
				onFailure: function() {alert('Error');}
			});		
		},
		addItem: function(o) {
			if (!this.isReady) return;
			this.loadOn();
			var nullObject = {
				termek_id: '',
				megnevezes: '',
				quantity: '',
				recept_id: '',
				p: ''
			};			
			var data = Object.extend(nullObject, o);
			new Ajax.Request('/getAjax?m=bevlNew', {
				method: 'post',
				parameters: {t: data.megnevezes, ti: data.termek_id, q: data.quantity, w: 'add', p: data.p, ri: data.recept_id},
				onSuccess: function(response) {
					if (this.isOpen && $('BLI_add_text')) {
						$('BLI_add_text').value = '';
						$('BLI_add_qt').value = '';
						$('BLI_add_text').focus();
					}
					this.loadOff();
					this.refresh();
				}.bind(this),
				onFailure: function() {}
			});					
		},
		addLayerItem: function() {
			if (!$('BLI_add_textHolder')) return;
			if (!this.isReady) return;
			var t = $('BLI_add_text').value;
			var q = $('BLI_add_qt').value;
			if (t != '') {
				this.addItem({megnevezes: t, quantity: q});
			} else {
				$('BLI_add_textHolder').addClassName('error');
				$('BLI_add_text').focus();
			}		
		},
		clearLista: function() {
			if (this.object.counter*1 <= 0) {
				alert('Az Ön bevásárlólistája üres!');
				return;
			}
			if(window.confirm('Biztos, hogy minden elemet töröl a listáról?')) {
				this.loadOn();
				new Ajax.Request('/getAjax?m=bevlNew', {
					method: 'get',
					parameters: {w: 'clear'},
					onSuccess: function() {
						this.loadOff();
						this.refresh();
					}.bind(this),
					onFailure: function() {alert('Error');}				
				});				
			}
		},
		checkIfEmpty: function() {
			if (this.object.counter*1 <= 0) {
				alert('Az Ön bevásárlólistája üres!');
				return true;
			}			
			return false;
		},
		startKuldes: function() {
//			if (!Auchan.checkLoggedIn(2)) return;
			if (this.checkIfEmpty()) return;
			Auchan.createIframeBox('bevasarlolista_kuldese', '/getAjax?m=bevasarlolista.kuldes');
		},
/*		startNyomtatas: function() {
			//if (!Auchan.checkLoggedIn(1)) return;
			if (this.checkIfEmpty()) return;
			Auchan.createIframeBox('bevasarlolista', '/getAjax?m=bevlistaNew', {});			
		},*/
		startMobilKuldes: function() {
			if (!Auchan.checkLoggedIn(3)) return;
			if (this.checkIfEmpty()) return;
			Auchan.createIframeBox('bevasarlolista_mobil', '/getAjax?m=bevasarlolista_quickID', {});			
		},
		removeItem: function(id) {
			if (!this.isReady) return;
			this.loadOn();
			new Ajax.Request('/getAjax?m=bevlNew', {
				method: 'post',
				parameters: {w: 'del', id: id},
				onSuccess: function(response) {
					this.loadOff();
					this.refresh();
				}.bind(this),
				onFailure: function() {alert('Error');}
			});
		},
		removeItemReceptHV: function(recept_id, p) {
			if (!this.isReady) return;
			this.loadOn();
			new Ajax.Request('/getAjax?m=bevlNew', {
				method: 'post',
				parameters: {w: 'delReceptHV', recept_id: recept_id, p: p},
				onSuccess: function(response) {
					this.loadOff();
					this.refresh();
				}.bind(this),
				onFailure: function() {alert('Error');}
			});
		},
		kedvencClicked: function(e) {
			if (!this.isReady) return;
			var el = Event.element(e);
			if (el.tagName == 'DIV') {
				this.addItem({megnevezes: el.innerHTML.substring(13), quantity: ''});
			}
		},
		showKedvencek: function() {
			if (this.kedvencStatus) {
				if (this.kedvencEffect) this.kedvencEffect.cancel();
				this.kedvencEffect = new Effect.Morph('KedvencekDiv', {style: 'height: 0px', duration: .5, afterFinish: function() {if ($('KedvencekDiv')) {$('KedvencekDiv').style.display = 'none';} if ($('showKedvenc')) $('showKedvenc').style.background = 'inherit';}});
				this.kedvencStatus = false;
				return;	
			}
			if (!this.isReady) return;
			this.loadOn();
			this.kedvencStatus = true;
			$('showKedvenc').style.background = '#bc180f';
			if (Auchan.sessionID && Auchan.auchanuser_id) {
				new Ajax.Request('/getAjax?m=bevlNew', {
					method: 'post',
					parameters: {w: 'getKedvencek'},
					onSuccess: function(response) {
						this.loadOff();
						if (response.responseJSON.list) {
							var x = $('KedvencekDiv');
							if (this.kedvencEffect) this.kedvencEffect.cancel();
							if (x) {
								var y = x.select('.contk').first();
								y.update('');
								y.stopObserving();
								y.observe('click', this.kedvencClicked.bindAsEventListener(this));
								for (var j = 0; j < response.responseJSON.list.length; j++) {
									y.insert({bottom: new Element('div').update('<span></span>'+response.responseJSON.list[j])});
								}
								x.style.display = 'block';
								this.kedvencEffect = new Effect.Morph(x, {style: 'height: 200px', duration: .5});
								y.scrollTo(0,0);
							}
							return;							
						}									
					}.bind(this),
					onFailure: function() {alert('Error');}
				});			
			} else {
				this.loadOff();
				var x = $('KedvencekDiv');
				if (this.kedvencEffect) this.kedvencEffect.cancel();
				if (x) {
					var y = x.select('.contk').first();
					y.update('<a href="'+"javascript:Auchan.setCookie('bevlista-onLoginInit', 1, 0, '/', '.'+Auchan.domain); Auchan.createIframeBox('belepes', '/getAjax?m=login&ness', {});"+'">A funkció használatához be kell lépnie!<br/><br/>A belépéshez kattintson ide!</a>');
					x.style.display = 'block';
					this.kedvencEffect = new Effect.Morph(x, {style: 'height: 200px', duration: .5});
				}
				return;							
			}
		},
		loadOn: function() {
			this.isReady = false;
			this.bodyE.style.display = 'none';
			this.loaderE.style.display = 'block';
			if ($('load-listaratesz')) {
				if (this.loaderEffect) this.loaderEffect.cancel();
				this.loaderEffect = new Effect.Appear($('load-listaratesz-load'), {to: 1, duration: 0, beforeStart: function() {if($('load-listaratesz-load'))$('load-listaratesz-load').style.display = 'block';}});
			}
		},
		loadOff: function() {
			this.loaderE.style.display = 'none';
			this.isReady = true;
			this.bodyE.style.display = 'block';
			if ($('load-listaratesz')) {
				if (this.loaderEffect) this.loaderEffect.cancel();
				this.loaderEffect = new Effect.Opacity($('load-listaratesz-load'), {to: 0, duration: 0, afterFinish: function() {if($('load-listaratesz-load'))$('load-listaratesz-load').style.display = 'none';}});			
			}
			if (!this.periodical) {
				this.periodical = new PeriodicalExecuter(function(pe) {
					if (this.isReady) {
						new Ajax.Request('/getAjax?m=bevlNew', {
							method: 'post',
							parameters: {w: 'upd', i: this.object.bevasarlolista_id, td: this.object.updated},
							onSuccess: function(resp) {
								var hasTo = (resp.responseJSON && (resp.responseJSON.r == 1));
								if (this.isReady && hasTo) {
									this.refresh();	
								}
							}.bind(this),
							onFailure: function() {}	
						});
					}
				}.bind(this), 30);
			}
		},
		checkForUpdate: function() {
			// check for update
			// XXX
		},
		refreshTableList: function() { // obsolete
			if (this.tableElement) {
				var l = this.tableElement.select('tr');
				l.each(function(o, i) {
					var id = o.id.replace('bvlitem__', '');
					isPtlan = (i-1) % 2;
					if (isPtlan) {
						o.addClassName('ptlan');
					} else {
						o.removeClassName('ptlan');
					}
				});
				if (!l.length) $('bevlistaIsEmpty').style.display = 'block';
			}
		},
		refresh: function(isFirst) {
			if (!this.isReady) return;
			this.loadOn();
			var f = function(response) {
				var r = response.responseJSON;
				if (r == null) {
					r = Object.clone(this.nullObject);
				}
				this.object = r;
				this.setCounter();
				if (this.isOpen) {			
					var BLelement = $('bevlistaContent');
					if (BLelement) {
						var ta = BLelement.select('.holdTable').first();
						this.tableElement = ta;
						if (!this.layerLoaded) {
							var lo = BLelement.select('.loading');
							if (lo.length) {
								this.loadingElement = lo.first();
								new Effect.Opacity(lo.first(), {duration: .5, to: 0, afterFinish: function() {
									if (this.loadingElement) {
										this.loadingElement.style.display = 'none';
										this.tableElement.style.display = 'table';
									}
									// alert('init stuff'); ------------- scrollbar
								}.bind(this)});
							}
							this.layerLoaded = true;
						}
						if (r.c && r.c.length) {	
							$('bevlistaIsEmpty').style.display = 'none';
							var in_act = new Array();
							var prevx = null;
							for (var j = 0; j < r.c.length; j++) {
								var name = r.c[j].n.htmlspecialchars(); 
								var quantity = r.c[j].q.htmlspecialchars();
								in_act[r.c[j].i] = 1;
								if ($('bvlitem__'+r.c[j].i)) {

									var dname = $('bvlitem__'+r.c[j].i).select('.nm').first();																		
									if (dname.select('span').first().innerHTML != name) {
										new Effect.Opacity(dname.select('span').first(), {duration: .5, from: .2, to: 1});
										dname.select('span').first().update(name);
										dname.select('input').first().value = name;																		
									}

									var dqt = $('bvlitem__'+r.c[j].i).select('.qt').first();									
									if (dqt.select('span').first().innerHTML != quantity) {
										new Effect.Opacity(dqt.select('span').first(), {duration: .5, from: .2, to: 1});										
										dqt.select('span').first().update(quantity != '' ? quantity:'&nbsp;&nbsp;&nbsp;&nbsp;');																		
										dqt.select('input').first().value = quantity;	
									}
									
								} else {
									var tr = new Element('tr');
									tr.id = 'bvlitem__'+r.c[j].i;
									
									var dele = new Element('TD').addClassName('left');
									dele.update('<div></div>');
									tr.insert({bottom: dele});
									
									var tdn = new Element('TD').update('<input type="text" value="'+name+'" id="bitm-'+r.c[j].i+'" maxlength="128"/><b title="mentés"></b><span>'+name+'</span>');
									tdn.addClassName('nm');
									tr.insert({bottom: tdn});
									
									/* modify */
									
										tdnS = tdn.select('span').first();
										tdnI = tdn.select('input').first();
										tdnB = tdn.select('b').first();
										
										fSave = function(tdnS, tdnI, tdnB) {
											if (!this.isReady) return;
											val = tdnI.value;
											tdnI.style.display = 'none';
											tdnS.style.display = 'block';
											tdnB.style.display = 'none';
											if (val != '') {
												this.saveItem(tdnI.id.replace('bitm-', ''), 'name', val);
											} else {
												this.removeItem(tdnI.id.replace('bitm-', ''));
											}
											tdnI._timxSave = new Date().getTime();	
										}.bind(this, tdnS, tdnI, tdnB);
										
										tdnI.observe('blur', fSave);	
										var fKP = function(event) {
											var key_code = event.charCode ? event.charCode : event.keyCode;
											if (Event.KEY_RETURN == key_code) {
												$('BLI_add_text').focus();										
											}	
										}.bindAsEventListener(this);																	
										tdnI.observe('keypress', fKP);	
										tdnS.up().observe('click', function(e, tdnS, tdnI, tdnB, fSave) {
											var DT = new Date().getTime();
											if (tdnI._timxSave && (tdnI._timxSave > (DT-500) )) {
												return;
											}
											tdnI.style.display = 'block';
											tdnI.focus();
											tdnI.value = tdnI.value+'';
											tdnS.style.display = 'none';
											tdnB.style.display = 'block';
										}.bindAsEventListener(this, tdnS, tdnI, tdnB, fSave));




									var de = new Element('TD').addClassName('sep');
									tr.insert({bottom: de});

									var tdq = new Element('TD').update('<input type="text" value="'+quantity+'" id="bitm2-'+r.c[j].i+'" maxlength="128"/><b title="mentés"></b><span>'+(quantity == '' ? '&nbsp;&nbsp;&nbsp;&nbsp;' : quantity)+'</span>');
									tdq.addClassName('qt');
									tr.insert({bottom: tdq});
									
									
										tdqS = tdq.select('span').first();
										tdqI = tdq.select('input').first();
										tdqB = tdq.select('b').first();
										
										fSaveQ = function(tdqS, tdqI, tdqB) {
											if (!this.isReady) return;
											val = tdqI.value;
											tdqI.style.display = 'none';
											tdqS.style.display = 'block';
											tdqB.style.display = 'none';
											this.saveItem(tdqI.id.replace('bitm2-', ''), 'quantity', val);
											tdqI._timxSave = new Date().getTime();									
										}.bind(this, tdqS, tdqI, tdqB);
										
										tdqI.observe('blur', fSaveQ);	
										var fKPQ = function(event) {
											var key_code = event.charCode ? event.charCode : event.keyCode;
											if (Event.KEY_RETURN == key_code) {
												$('BLI_add_text').focus();										
											}	
										}.bindAsEventListener(this);																	
										tdqI.observe('keypress', fKPQ);	
										tdqS.up().observe('click', function(e, tdqS, tdqI, tdqB, fSaveQ) {
											var DT = new Date().getTime();
											if (tdqI._timxSave > 0 && (tdqI._timxSave > (DT-500) )) {
												return;
											}
											tdqI.style.display = 'block';
											tdqI.focus();
											tdqI.value = tdqI.value+'';
											tdqS.style.display = 'none';
											tdqB.style.display = 'block';
										}.bindAsEventListener(this, tdqS, tdqI, tdqB, fSaveQ));
										

									
									var de = new Element('TD').addClassName('remove');
									de.update('<div title="levesz a listáról"></div>');
									de.down().observe('click', this.removeItem.bind(this, r.c[j].i));
									tr.insert({bottom: de});
									tr.insert({bottom: new Element('TD').addClassName('rig')});
									//tr.setOpacity(0); XXXXXXXXX -> ?
									if (prevx) {
										prevx.insert({after: tr});
									} else {
										ta.down().insert({bottom: tr});										
										BLelement.scrollTo(0, 2000);
										if (!isFirst) {
											tdn.style.color = '#EDEDED';
											tr._morph = new Effect.Morph(tdn, {duration: .5, style: {color: '#1c1c1c'}});
											dele.down().style.marginLeft = '-30px';
											tr._morph = new Effect.Morph(dele.down(), {duration: .5, style: {marginLeft: '30px'}});
										}
									}
									//new Effect.Opacity(tr, {duration: 1, 100});
								}
							}
					
							in_act[-1] = 0;
							ta.select('tr').each(function(beobj, o) {
								var id = o.id.replace('bvlitem__', '');
								if (!this[id]) {
									if (o.hasClassName('removing')) return;
									o.id = 'temporary-'+id;
									o.addClassName('removing');
									o.style.background = '#f28d7f';
									new Effect.Morph(o.select('.nm').first(), {duration: .5,  style: {color: '#f28d7f'}, afterFinish: function(d) {
										if (this) {
											this.remove();
											d.refreshTableList();
										}
									}.bind(o, beobj)});
								}
								
								this[-1]++;
								isPtlan = this[-1] % 2;
								if (isPtlan) {
									o.addClassName('ptlan');
								} else {
									o.removeClassName('ptlan');
								}

							}.bind(in_act, this));					
						} else {
							this.tableElement.select('tr').invoke('remove');
							$('bevlistaIsEmpty').style.display = 'block';
						}
					}
				}
				this.loadOff();
			}.bind(this);
			
			new Ajax.Request('/getAjax?m=bevlNew', {
				method: 'get',
				parameters: {w: 'data', isOpen: this.isOpen},
				onSuccess: f,
				onFailure: function() {
					try {if (pageTracker) pageTracker._trackEvent('JavascriptError', 'bevlNew', '');} catch(err) {}	
				}				
			});
		}
	}

	function callLink(param, param2, param3) {
		if (param == 'utvonal') {
			Auchan.createIframeBox('megkozelites', '/getAjax?m=utv&a='+param2);
		}		
		if (param == 'aruhaz' || param == 'uzletsor') {
			var subdomain;
			eval('subdomain = Auchan.aruhazak.aruhaz_'+param2);
			if (param == 'aruhaz') {
				document.location = 'http://www.'+Auchan.domain+'/'+subdomain+'-akciok?utm_source=site&utm_medium=aruhazMap&utm_campaign=link';
			} else {
				document.location = 'http://'+subdomain+'.'+Auchan.domain+'/';
			}
		}
		if (param == 'aruhazak') {
			Auchan.createIframeBox('aruhazak', 'map', {});
		}
		if (param == 'Video') {
			document.location = param2;
		}		
		if (param == 'bList') {
			if (!Auchan.checkLoggedIn()) return false;
			document.location = "http://bevasarlolista."+Auchan.domain+"/";
			return;
		}
		if (param == 'ertesit' || param == 'ertesites') {
			Auchan.createIframeBox('ertesitesek', '/getAjax?m=ertesitesek', {});
			return true;
		}
		/*if (param == 'changeMinimap') {
			if ($('akciosTermekek')) {
				var z = '';
				eval('z = Auchan.aruhazData.name_'+param2+';');
				swfobject.embedSWF("http://"+document.domain+"/swf/termeklista_3.swf", "akciosTermekek", "546", "171", "9", "", {dir: 'http://'+document.domain+'/getXML/product?mode=3_akciok_'+param2+'_'+Auchan.receptId}, {allowScriptAccess: 'always', wmode: 'transparent', background: 'rgb(234,227,189)'}, {});	
				$('akciosTermekekName').update(': '+z);
				return;
			}
			if (document.domain != 'www.'+Auchan.domain) return;
			if ($('mainFlashDiv')) {
				var z = '';
				swfobject.embedSWF("http://"+document.domain+"/swf/termeklista_3x3.swf", "mainFlashDiv", "546", "530", "9", "", {mode: 'akcio', aruhaz_id: param2}, {allowScriptAccess: 'always', wmode: 'transparent', background: 'rgb(234,227,189)'}, {});
			}
		}*/
		if (param == 'stat') {
			if (param2.substring(0, 5) == 'video') {
				var u = (document.location.host.substring(0, 5) == 'jatek' ? 'demok/':'');
				Auchan.initSzavazas('/'+u+param3+'/');
				Auchan.location = 'http://'+document.location.host + '/'+u+param3+'/';
			}
			new Ajax.Request('http://'+document.domain+'/getAjax?m=stat', {
				method: 'get',
				parameters: {p: param2}
			});
		}
		if (param == 'carussel') {
			if (!param2 || !/\.pdf$/.test(param2)) {
				var o = new Element('form');
				o.action = param2;
				o.method = 'post';
				o.target = '_blank';
				$('Cont').insert({top: o});
				o.submit();				
			} else {
				try {
					if (pageTracker) pageTracker._trackEvent('PDF catalog', param2);
				} catch(err) {}					
				document.location = param2;				
			}

		}
		Auchan.initLogout();
	}

	var MegaDDClass = Class.create();
	
	MegaDDClass.prototype = {
		initialize: function (params) {
			this.activeIndex	= -1;
			this.params			= Object.extend({
				tagName: 'H2',
				className: '',
				obj: false,
				offsetMin: 0,
				width: 0,
				global: 'Site'
			}, params || {});
			if (this.params.obj) {
				this.pid		= 0;
				this.obj		= this.params.obj;
				this.objs		= (this.params.className ? this.params.obj.select(this.params.tagName+'.'+this.params.className) : this.params.obj.select(this.params.tagName));
				this.width		= (this.params.width ? this.params.width : this.obj.getWidth());
				var z		= this.objs.toArray();
				var fin		= z.clone();
				this.objs.each(function(o, i) {
					o.ddobj = $('mdd_'+i);
					if (!o.ddobj) {
						fin = fin.without(o);
						return;
					}					
					Event.observe(o, 		'mouseover', this.onmouseover.bindAsEventListener(this, i));
					Event.observe(o.ddobj, 	'mouseover', this.onmouseover.bindAsEventListener(this, i));					
					Event.observe(o, 		'mouseout', this.onmouseout.bindAsEventListener(this, i));
					Event.observe(o.ddobj, 	'mouseout', this.onmouseout.bindAsEventListener(this, i));					
				}.bind(this));				
				this.objs = fin;
			}
		},
		setWidths: function() {
			this.objs.each(function(o, i) {
				var offset		= this.obj.cumulativeOffset();
				this.offset		= offset.left;				
				o.ddobj = $('mdd_'+i);
				if (!o.ddobj) {
					return;
				}
				var offsetx		= o.cumulativeOffset();
				var oWidth		= o.ddobj.getWidth();
				if ((offsetx.left - this.offset + oWidth > this.width) && (this.width >= oWidth)) {
					o.offsLeft		= offsetx.left - this.offset - oWidth + o.getWidth() - this.params.offsetMin;												
				} else {
					o.offsLeft		= offsetx.left - this.offset;					
				}
				if (o.offsLeft == 0) o.offsLeft = -1;
			}.bind(this));	
		},
		onmouseover: function(event, i) {
			if (this.pid == 0) {
				this.setWidths();
			}
			if (this.timer) {
				window.clearTimeout(this.timer);
				this.timer = 0;
			}	
			this.pid++;
			this.timerOn = window.setTimeout(this.params.global+".megaDD.changed("+i+","+this.pid+")", 100);
		},
		onmouseout: function(event, i) {
			if (this.timer) {
				window.clearTimeout(this.timer);
				this.timer = 0;
			}
			this.pid++;
			this.timer = window.setTimeout(this.params.global+".megaDD.changed(-1,"+this.pid+")", 300);
		},
		changed: function(activeIndex, id) {
			if (activeIndex == this.activeIndex) return;
			this.activeIndex = activeIndex;
			var label = '';
			this.objs.each(function(o, i) {
				if (!o.ddobj) return;
				if (!o.offsLeft) {
					Auchan.megaDD.setWidths();
				}
				if (!o.offsLeft) return;
				var orfs = o.offsLeft+0;
				if (orfs == -1) orfs = 0;
				if (i == activeIndex) {
					var tmps = orfs+'px';
					o.ddobj.style.marginLeft = tmps;
					o.ddobj.style.visibility = 'visible';
					o.addClassName('on');
					label = o.select('a').first().innerHTML;
				} else {
					o.ddobj.style.visibility = 'hidden';
					o.removeClassName('on');
				}
			});
			if (this.activeIndex != -1) {
				try {if (pageTracker) pageTracker._trackEvent('MegaDrop', 'hover', label);} catch(err) {}
			}
		}
	}
	
	var AuchanAkcioLayer = Class.create();
	
	AuchanAkcioLayer.prototype = {
		initialize: function() {
			this.activeIndex	= -1;
			this.timer = 0;
			this.pid		= 0;
			this.objs = $('lapozokData').select('div.lakk');
			this.holdElement = $('lapozokData');
			this.bw = $$('#mdd_0 .akcbody').first();
			this.objs.each(function(o, i) {
				o.ddobj = $('mdAruhaz'+o.id.replace('lap', '')).up();
				Event.observe(o, 		'mouseover', this.onmouseover.bindAsEventListener(this, i));
				Event.observe(o, 		'mouseout', this.onmouseout.bindAsEventListener(this, i));
				Event.observe(o.ddobj, 	'mouseover', this.onmouseover.bindAsEventListener(this, i));
				Event.observe(o.ddobj, 	'mouseout', this.onmouseout.bindAsEventListener(this, i));
			}.bind(this));				
		},	
		onmouseover: function(event, i) {
			if (this.timer) {
				window.clearTimeout(this.timer);
				this.timer = 0;
			}	
			if (this.timerOn) {
				window.clearTimeout(this.timerOn);
				this.timerOn = 0;
			}	
			this.pid++;
			this.timerOn = window.setTimeout("Auchan.akcLayer.changed("+i+","+this.pid+")", 50);
		},		
		onmouseout: function(event, i) {
			if (this.timer) {
				window.clearTimeout(this.timer);
				this.timer = 0;
			}
			this.pid++;
			this.timer = window.setTimeout("Auchan.akcLayer.changed(-1,"+this.pid+")", 200);
		},	
		changed: function(activeIndex, id) {
			if (activeIndex == this.activeIndex) return;
			this.activeIndex = activeIndex;
			var label = '';
			// this.holdElement.style.display = 'block';
			this.objs.each(function(o, i) {
				if (i == activeIndex) {
					o.style.display = 'block';
					o.ddobj.addClassName('ho');
					this.holdElement.style.left = (this.bw.getWidth()+10)+'px';
					var mx = +40+i*26 + 13 - Math.round(o.getHeight()/2);
					this.holdElement.style.top = Math.max(10, mx)+'px';
					// XXX from page bottom and top !!!
				} else {
					o.style.display = 'none';
					o.ddobj.removeClassName('ho');
				}
			}.bind(this));
			// if (this.activeIndex == -1) this.holdElement.style.display = 'none';
			this.holdElement.style.display = 'none';
			/*if (this.activeIndex != -1) {
				try {if (pageTracker) pageTracker._trackEvent('MegaDrop', 'hover', label);} catch(err) {}
			}*/
		}				
	}	

	var AuchanClass	= Class.create();
	
	AuchanClass.prototype = {
		initialize: function() {
			this.location = document.location;
			document.observe('keydown', function(event) {
				var key_code = event.charCode ? event.charCode : event.keyCode;
				if (key_code == 116) {
					if (!Auchan) return;
					if(document.all){event.keyCode = 0;}
					Event.stop(event);
					Auchan.refresh();
				}
			});			
			this.domain = window._cd;			
			this.bInit = this.getCookie('b-init');
			window.setTimeout(this.initBg.bind(this), (this.bInit ? 0 : 100));

			this.sessionID = null;
			this.auchanuser_id = null;
			this.activeMenu = null;
			this.isIE6 = (typeof ie6IsSet != 'undefined' ? true:false);

			initializes.push(function() {Auchan.protoBL = new protoBevlist();});
			initializesAlways.push(this.roundify.bind(this));
			initializesAlways.push(this.headerReplacer.bind(this));
			initializesAlways.push(this.inputInitializer.bind(this));		
			initializesAlways.push(this.loadImageBlocks.bind(this));	
			initializesAlways.push(this.fixHeightMainContent.bind(this));	
			initializesAlways.push(this.correctBackLinks.bind(this));
			initializesAlways.push(this.bgResized.bind(this));				
			initializesAlways.push(this.growLength.bind(this));				
			Event.observe(window, 'load', this.fixHeightMainContent.bind(this));
			window.setInterval(this.fixHeightMainContent.bind(this), 2500);
			window.setInterval(this.bgResized.bind(this), 4000);

			this.initIframeLayer();			
			this.setMenuActive();
			this.setMenuLayout();

			this.initHeader();
			this.initKereses();
			this.initLogout();	

			this.initStandardTabs();
			this.initSubTabs();
			this.initAruhaz();
			this.initProcessingHashLike();			
			this.initSzavazas(0);	
			if (this.isIE6) this.startIE6();
			this.makeAruhazBold();			

		},
		
		initIframeLayer: function() {
			this.iframeLoading	= false;	
			this.iframeID		= 0;				
		},
		
		loadImageBlocks: function() {
			$$('.simple-image-block').each(function(o) {
				if (!o.hasClassName('preloader')) return;
				var i = new Image();
				i._binded = o;
				i.onload = function() {
					var i = Element.extend(this);
					i._binded.removeClassName('preloader');
					if (!i._binded.select('img').length) i._binded.insert({top: i});
				};
				var inname = o.id.replace('Block-im-', '');
				i.src = '/i11/img-'+inname+'.png';
				if (o.title && o.title != '') i.alt = o.title;
			});
		},
		
		correctBackLinks: function() {
			if (!Auchan) return;
			var adom = new RegExp(Auchan.domain);
			if (!document.referrer || !adom.test(document.referrer)) return;
			$$('.stdContentBack').each(function(x){if(x.hasClassName('inited')) return; x.addClassName('inited'); x.onclick = function(){window.history.back();}; });
		},
		fixHeightMainContent: function() {
			if (!this.mcontHolder) {
				this.mcontHolder = $('MCHolderID');
				if (!this.mcontHolder) return;
				var l = $A(this.mcontHolder.immediateDescendants());
				this.mcontHolder_L = l.find(function(i){return i.hasClassName('SC_L')});
				this.mcontHolder_R = l.find(function(i){return i.hasClassName('SC_R')});
			}
			if (this.mcontHolder) {
				if (this.mcontHolder.hasClassName('flash')) return;
				var h = this.mcontHolder.getHeight();				
				if (h != this.mcHH) {
					this.mcHH = h;
					this.mcontHolder_L.style.height = Math.max(10, (h-120))+'px';
					this.mcontHolder_R.style.height = Math.max(10, (h-85))+'px';
				}
			}
		},
		
		roundify: function() {
			var o = {position: 'absolute', top: '0px', background: 'transparent url(/i11/transp-sprites.png) 0px 0px no-repeat', width: '3px', height: '3px'};
			$$('.roundify-top').each(function(ox, h, i) {
				if (Element.hasClassName(h, 'done')) return;
				Element.addClassName(h, 'done');
				var o = new Element('div');
				o.setStyle(Object.extend(ox, {left: '0px', backgroundPosition: '-7px -64px'}));
				h.insert({top: o});
				var o = new Element('div');
				o.setStyle(Object.extend(ox, {left: 'auto', right: '0px', backgroundPosition: '-11px -64px'}));
				h.insert({top: o});				
			}.bind(this, o));

			Object.extend(o, {position: 'absolute', background: 'transparent url(/i11/transp-sprites.png) 0px 0px no-repeat', width: '5px', height: '5px'});
			$$('.simple-box').each(function(ox, h, i) {
				if (Element.hasClassName(h, 'done')) return;
				Element.addClassName(h, 'done');
				var w = h.getWidth();
				var holder = h.down();
				holder.addClassName('sc-h-1');
				var p = new Element('div').addClassName('sc-h-2');
				holder.insert({before: p});
				p.insert({top: holder});
				var p2 = new Element('div').addClassName('scv');
				p2.setStyle({width: w+'px', top: '0px'});
				var p3 = new Element('div').addClassName('scv');
				p3.setStyle({width: w+'px', bottom: '0px'});
				h.insert({top: p2});
				h.insert({top: p3});				
				
				var o = new Element('div');
				o.setStyle(Object.extend(ox, {left: '0px', top: '0px', right: 'auto', bottom: 'auto', backgroundPosition: '-23px -64px'}));
				h.insert({bottom: o});
				var o = new Element('div');
				o.setStyle(Object.extend(ox, {left: 'auto', top: 'auto', right: '0px', bottom: '0px', backgroundPosition: '-28px -69px'}));
				h.insert({bottom: o});				
				var o = new Element('div');
				o.setStyle(Object.extend(ox, {left: '0px', top: 'auto', right: 'auto', bottom: '0px', backgroundPosition: '-23px -69px'}));
				h.insert({bottom: o});
				var o = new Element('div');
				o.setStyle(Object.extend(ox, {left: 'auto', top: '0px', right: '0px', bottom: 'auto', backgroundPosition: '-28px -64px'}));
				h.insert({bottom: o});		
				
			}.bind(this, o));			
		},
		inputInitializer: function() {
			$$('.inp').each(function (o) {
				if (!o.hasClassName('done')) {
					o.addClassName('done');
					var i = o.select('input').first();
					if (i) {
						i.observe('focus', function() {this.addClassName('hover');}.bind(o));
						i.observe('blur', function() {this.removeClassName('hover');}.bind(o));
					}
				}
			});
		},
		headerReplacer: function() {
			var i = new Image();
			var f = function() {
				$$('.simple-box h3, .hdrReplacer').each(function (o) {
					if (!Element.hasClassName(o, 'donehr')) {
						var d = new Element('div');
						d.addClassName('hdr');
						o.addClassName('donehr');
						o.insert({top: d});
					}
				});
			}.bind(this);
			i.onload = f;
			i.src = '/i11/fejlec-sprites.png';			
			var i2 = new Image();
			var f2 = function() {
				$$('.hdrReplacer-2').each(function (o) {
					if (!o.hasClassName('donehr') && !o.hasClassName('skip')) {
						var d = new Element('div');
						d.addClassName('hdr');
						o.addClassName('donehr');
						o.insert({top: d});
					}
				});
			}.bind(this);
			i2.onload = f2;
			i2.src = '/i11/fejlecek-2.png';
		},
		bgResized: function() {
			var wr = $('Wr');
			if (!wr) return;
			var bl = $('bg-left');
			var br = $('bg-right');
			if (!bl) {
				var b = $$('body').first();
				var bl = new Element('div');
				bl.id = 'bg-left';
				bl.insert({top: new Element('div').setStyle({position: 'absolute', right: '0px', width: '5px', background: 'url(/i11/bg-h-sprites.png) 0 top repeat-y'})});
				var br = new Element('div');
				br.id = 'bg-right';
				br.insert({top: new Element('div').setStyle({position: 'absolute', left: '0px', width: '5px', background: 'url(/i11/bg-h-sprites.png) -5px top repeat-y'})});
				b.insert({top: bl});
				b.insert({top: br});
				if (!this.bInit) {
					bl.setOpacity(0);
					br.setOpacity(0);
				}
			}
			if (document.viewport.getWidth() >= 1005) {
				var h = Math.max(wr.getHeight());					
				var w = Math.max(0, wr.cumulativeOffset().left);
				bl.setStyle({zIndex: 10, position: 'absolute', display: 'block', left: '0px', width: w+'px', top: '0px', height: h+'px', background: 'transparent '+(this.initializedImages != 2?'none':'url(http://www.'+this.domain+'/i11/xmas-left.jpg)')+' right top no-repeat'});
				br.setStyle({zIndex: 10, position: 'absolute', display: 'block', left: (w+1005)+'px', width: (Math.max(0, w-1))+'px', top: '0px', height: h+'px', background: 'transparent '+(this.initializedImages != 2?'none':'url(http://www.'+this.domain+'/i11/xmas-right.jpg)')+' left top no-repeat'});
				bl.down().style.height = h+'px';
				br.down().style.height = h+'px';
			} else {
				bl.style.display = 'none';
				br.style.display = 'none';
			}		
			this.alayerPos();
		},
		initBg: function() {
			if (!$('Wr')) return;
			this.initializedImages = 0;
			Event.observe(window, 'resize', this.bgResized.bind(this)); 
			Event.observe(window, 'load', this.bgResized.bind(this)); 
			this.bgResized();
			var i = new Image();
			var i2 = new Image();
			i.onload = this.initializedImagesAdd.bind(this);
			i2.onload = this.initializedImagesAdd.bind(this);
			i.src = 'http://www.'+this.domain+'/i11/bg-left.jpg';
			i2.src = 'http://www.'+this.domain+'/i11/bg-right.jpg';
		},
		initializedImagesAdd: function() {
			this.initializedImages++;
			if (this.initializedImages == 2) {
				$('bg-left').style.backgroundImage = 'url(http://www.'+this.domain+'/i11/xmas-left.jpg)';
				$('bg-right').style.backgroundImage = 'url(http://www.'+this.domain+'/i11/xmas-right.jpg)';
				if (!this.bInit) {
					new Effect.Opacity('bg-left', {to: 1, duration: 3});
					new Effect.Opacity('bg-right', {to: 1, duration: 3});
					this.setCookie('b-init', 1, 0, '/', '.'+this.domain);				
				}
			}
		},
		initHeader: function() {
			$$('#h_right li a').each(function(o) {o.insert({top: new Element('div')})});
			if (!$('topmenu')) return;
			var mdb = $$('.mdbgbd').first();
			var h = mdb.getHeight();
			var w = mdb.getWidth();
			for (var k = 0; k <= 8; k++) {
				var d = new Element('div');
				mdb.insert({top: d});
				d.addClassName('bord');
				switch (k) {
					case 0:
						d.setStyle({bottom: '5px', right: '0px', height: (h-10)+'px', background: 'url(/i11/bg-h-sprites.png) -17px 0 repeat-y'});
						break;
					case 1:
						d.setStyle({bottom: '0px', left: '0px', background: 'url(/i11/dd-sprites.png) left -10px no-repeat'});
						break;
					case 2:
						d.setStyle({bottom: '0px', right: '0px', background: 'url(/i11/dd-sprites.png) left -15px no-repeat'});
						break;
					case 3:
						d.setStyle({bottom: '0px', left: '5px', width: (w-10)+'px', background: 'url(/i11/bg-v-sprites.png) 0 -114px repeat-x'});
						break;
					case 4:
						d.setStyle({bottom: '5px', left: '0px', height: (h-10)+'px', background: 'url(/i11/bg-h-sprites.png) -11px 0 repeat-y'});
						break;
					case 5:
						d.setStyle({top: '0px', right: '5px', width: (w-10-72)+'px', background: 'url(/i11/bg-v-sprites.png) 0 -120px repeat-x'});
						break;
					case 6:
						d.setStyle({top: '0px', right: '0px', background: 'url(/i11/dd-sprites.png) left -5px no-repeat'});
						break;
					case 7:
						d.setStyle({top: '0px', left: '0px', background: 'url(/i11/bg-h-sprites.png) -11px 0 repeat-y'});
						break;
					case 8:
						d.setStyle({top: '0px', left: '5px', width: '72px', background: '#003716'});
						break;
					default: break;	
				}
			}
			this.megaDD = new MegaDDClass(
				{global: 'Auchan', className: 'md', tagName: 'LI', width: 991, obj: $('topmenu')}
			);
			var lis = $$('.mdbgbdContainer .akcbody .al');
			lis.each(function(w, len, o, i) {
				o.insert({top: new Element('div').addClassName('arr')});	
				//if (len-1 != i) o.insert({top: new Element('div').addClassName('bott').setStyle({width: (w-20)+'px'})});	
			}.bind(this, w, lis.length));
			/*var fm = $$('.akcpre').first();
			fm.insert({top: new Element('div').addClassName('arr')});	
			fm.insert({top: new Element('div').addClassName('bott').setStyle({width: (w-20)+'px'})});	*/
			this.akcLayer = new AuchanAkcioLayer();
			var akcDiv = $$('#topmenu .akc.md').first();
			if (akcDiv) Event.observe(akcDiv, 'click', function(e) {
				if(Auchan)Auchan.createIframeBox('aruhazak', 'map', {});
				Event.stop(e);
				return false;
			});
		},

		initAutoLayers: function() {
			if (this.categoryInited) return;
			var loaded = function(resp) {
				var i = 0;
				var currTime = Math.round(new Date().getTime() / 1000);
				var shown = false;
				while (i < resp.length) {
					var L = resp[i];
					i++;
					var cookieName = 'lyr_'+L.id;
					var lastViewCookieName = 'lyr_'+L.id+'_lastView';
					var clickedCookieName = 'lyr_'+L.id+'_clkd';
					if (!this.layerPreview) {
						var cookieValue = this.getCookie(cookieName);
						var cookieLastView = this.getCookie(lastViewCookieName);
						if (L.doc && this.getCookie(clickedCookieName) != '') continue;
					} else {
						var cookieValue = false;
						var cookieLastView = false;
					}
					if (!cookieValue) cookieValue = 0;
					cookieValue++;					
					if (cookieValue > L.sc) continue;		
					if (cookieLastView != '' && (currTime <= (L.sh * 60 * 60) + cookieLastView*1)) continue;
					if (L.mode == 'p') {
						if (L.pic) {
							
							var d = new Element('div');
								d.id = 'auchan_layerbanner';
								d.style.position = 'absolute';
								d.style.width = '635px';
								d.style.height = '394px';
								d.style.margin = '100px 0px 0px 185px';
								d.style.zIndex = 4000;	
								d.update('<div style="background: url(/i/layer/background.png) left top no-repeat; position: relative; width: 635px; height: 394px;"></div>');
								var i = new Element('a');
								var prms = {cname: clickedCookieName};
								Event.observe(i, 'click', function(e, prms){
									if (!this.layerPreview) this.setCookie(prms.cname, 1, L.dc, '/', '.'+this.domain);
									if ($('auchan_layerbanner')) $('auchan_layerbanner').remove();
									if ($('auchan_layerbanner_closer')) $('auchan_layerbanner_closer').remove();									
								}.bindAsEventListener(this, prms));
								i.href = '#';
								if (L.ib) i.target = '_blank';
								if (L.link) i.href = L.link;
								i.style.display = 'block';
								i.style.background = 'url('+L.pic+') center center no-repeat';
								i.style.width = '597px';
								i.style.height = '356px';
								i.style.position = 'absolute';
								i.style.top = '19px';
								i.style.left = '19px';
								d.down().insert({top: i});	
								$('Wr').insert({top: d});	
	
							var iz = new Element('div');		
								iz.style.position = 'absolute';
								iz.id = 'auchan_layerbanner_closer';
								iz.style.zIndex = 9999;
								iz.style.cursor = 'pointer';
								iz.style.height = '20px';
								iz.style.background = 'url(/i/layer/closer.png) left top repeat';
								iz.style.width = '62px';
								iz.style.margin = '134px 0px 0px 720px';
								$('Wr').insert({top: iz});					
								Event.observe(iz, 'click', function() {
									$('auchan_layerbanner').style.display = 'none';
									$('auchan_layerbanner_closer').style.display = 'none';
								});
								
							if (L.to) {
								window.setTimeout(function() {
									if ($('auchan_layerbanner')) $('auchan_layerbanner').remove();
									if ($('auchan_layerbanner_closer')) $('auchan_layerbanner_closer').remove();
								}, L.to*1000);	
							}
							try {if (pageTracker) pageTracker._trackEvent('LayerView', 'view', L.id);} catch(err) {}
							var	shown = true;																				
						} else {
							continue;	
						}							
					} else {
						if (L.c != '') {
							this.createIframeBox('contentOverride', '<div id="layerCoordinated_'+L.id+'" class="managedLayerContent">'+L.c+'</div>', {}, false);	
							if (L.to) {
								window.setTimeout(function(L) {
									if ($('layerCoordinated_'+L.id)) {
										this.closeBox();	
									}
								}.bind(this, L), L.to*1000);	
							}
							try {if (pageTracker) pageTracker._trackEvent('LayerView', 'view', L.id);} catch(err) {}								
							var	shown = true;
						} else {
							continue;	
						}						
					}
					if (!this.layerPreview) {
						this.setCookie(cookieName, cookieValue, L.dc, '/', '.'+this.domain);
						this.setCookie(lastViewCookieName, currTime, L.dc, '/', '.'+this.domain);
					}
					break;
				}
				if (!shown) {
					this.initSurvey();
				}
				
			}.bind(this);	
			var prms = {};
			if (this.layerPreview) {
				var l = this.layerPreview.split('_');
				prms = {
					forceId: l[0],
					md5: l[1]
				}
			}
			new Ajax.Request('/getAjax?m=getLayers', {
				method: 'post',
				parameters: prms,
				onSuccess: function(transport, loaded) {
					if (transport.responseText != '') {
						loaded(transport.responseJSON);
					}
				}.bindAsEventListener(this, loaded),
				onFailure: function() {}
			});
		},
		setKerdoivIframeHeight: function(h) {
			if ($('kerdoivIframe')) $('kerdoivIframe').style.height = h;
		},
		initSurvey: function(isFromInside) {

            var suId = 'SzuroGlobal';
			var cookieName = 'AUSV_'+suId;

			if (this._calculatedHash == 'kerdoiv2012') {
				//var suId = 'MiskolcInf';
				//var cookieName = 'AUSV_'+suId;
				if (!isFromInside) {
					this.setCookie(cookieName, '', 0, '/', '.'+this.domain);
					this.setCookie('kerdoiv_'+suId, '', 0, '/', '.'+this.domain);
				}
			} else {
				return;
				/*if (this.getTimeString()*1 >= 2011052712) return;*/
			}
			
			var cookieValue = this.getCookie(cookieName);
			if (!cookieValue) {
				this.createIframeBox('kerdoiv', '/getAjax?m=kerdoiv-'+suId.toLowerCase()+'&iframe=1', {fixTop: 1}, true);		
				this.setCookie(cookieName, '1', 120, '/', '.'+this.domain);
			}
			else {
				if (cookieValue == 2) {
					if (Auchan) Auchan.createIframeBox('kerdoiv', '/getAjax?m=kerdoiv-'+suId.toLowerCase()+'&iframe=1', {fixTop: 1}, true);					
					this.setCookie(cookieName, '3', 120, '/', '.'+this.domain);
				}
			}
		},
		
		makeAruhazBold: function() {
			if ($('valasztottAruhazID') && $('valasztottAruhazID').value) {
				var o = $('mdAruhaz'+$('valasztottAruhazID').value);
				if (o) {
					o.style.fontSize = '16px';
					o.style.lineHeight = '22px';
				}
			}
		},
		
		recalculateOnKeyPressVTSZ: function() { // XXX kiv
			var d = $('leiras');
			var len = 1024;		
			var leiras_szamlalo = $('leiras_szamlalo');			
			leiras_szamlalo.setStyle({position: 'absolute', font: '11px/40px Trebuchet MS', color: 'red', width: '566px', textAlign: 'right'});
			if (d.value.length > len) d.value = d.value.substring(0, len);	
			var rem = len - d.value.length;
			if (rem > 0) {
				leiras_szamlalo.setStyle({color: '#888'});
				leiras_szamlalo.update('Felhasználható karakterek száma: <b>'+rem+'</b>');
			} else {
				leiras_szamlalo.setStyle({color: 'red'});
				leiras_szamlalo.update('A leírás hossza elérte a maximális 1024 karaktert.');
			}
		},
		startIE6: function() {
			if ($$('.block.reg').length) {
				div = new Element('div');
				$('Wr').insert({top: div});
				div.style.font = '11px/16px Trebuchet MS';
				div.style.color = '#DA2419';
				div.style.width = '430px';
				div.style.marginLeft = '260px';
				div.style.marginTop = '15px';
				div.style.position = 'absolute';
				div.update('Az Ön böngészője nem támogatott, ezért a megjelenés és a funkciók korlátozottan állnak rendelkezésére. A támogatott böngészők listáját megtalálja a felhasználási feltételekben.');
			}
		},
		getTimeString: function() {
			var currentTime = new Date()
			var month = currentTime.getMonth() + 1;
			if (month*1 < 10) month = '0'+month;		
			var day = currentTime.getDate();
			if (day*1 < 10) day = '0'+day;			
			var year = currentTime.getFullYear();
			var hours = currentTime.getHours();
			if (hours*1 < 10) hours = '0'+hours;	
			var xtod = year+""+month+""+day+""+hours;
			return xtod;
		},
		initCategoryWelcome: function() {
			if (this.isIE6) return;			
			if (document.location.pathname != '/' || (document.location.host != 'kerteszet.'+Auchan.domain && document.location.host != 'sport.'+Auchan.domain)) return;
			keys = $A();
			keyRe= /[^=; ]+(?=\=)/g;
			str  = document.cookie;
			var mode = (document.location.host == 'kerteszet.'+Auchan.domain ? 'kerteszet':'sport');
			while((match = keyRe.exec(str)) != undefined) {
				if (match[0] == 'auchan_categWelcome'+mode) {
					return;
				}
			}
			this.categoryInited = true;
			if (mode == 'kerteszet') {
				this.createIframeBox('kerteszet', '/getAjax?m=welcomeCateg&c=kerteszet', {}, true);				
			} else {
				this.createIframeBox('sportvilag', '/getAjax?m=welcomeCateg&c=sport', {}, true);
			}
			window.setTimeout("if($('welcome_is_not_closed')) Auchan.closeBox(); if(Auchan.autobezaro)window.clearInterval(Auchan.autobezaro);", 30000);
			Auchan.msLeft = 29;
			Auchan.autobezaro = window.setInterval("if($('szamlalo_welcome'))$('szamlalo_welcome').update(Auchan.msLeft--);", 1000);
		},
		initLogout: function() {
			if (this.logoutTimer) window.clearTimeout(this.logoutTimer);
			this.logoutTimer = window.setTimeout('Auchan.logout(true);', 3600000);
		},
		getCookie: function(c_name) {
			if (document.cookie.length>0)
			  {
			  c_start=document.cookie.indexOf(c_name + "=");
			  if (c_start!=-1)
			    {
			    c_start=c_start + c_name.length+1;
			    c_end=document.cookie.indexOf(";",c_start);
			    if (c_end==-1) c_end=document.cookie.length;
			    return unescape(document.cookie.substring(c_start,c_end));
			    }
			  }
			return '';
		},
		setCookie: function(name, value, expires, path, domain, secure) {
			// set time, it's in milliseconds
			var today = new Date();
			today.setTime( today.getTime() );
			
			/*
			if the expires variable is set, make the correct
			expires time, the current script below will set
			it for x number of days, to make it for hours,
			delete * 24, for minutes, delete * 60 * 24
			*/
			if ( expires )
			{
			expires = expires * 1000 * 60 * 60 * 24;
			}
			var expires_date = new Date( today.getTime() + (expires) );
			
			document.cookie = name + "=" +escape( value ) +
			( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
			( ( path ) ? ";path=" + path : "" ) +
			( ( domain ) ? ";domain=" + domain : "" ) +
			( ( secure ) ? ";secure" : "" );

		},
		initProcessingHashLike: function() {
			this.layerPreview = false;
			var lo = document.location + '';
			if (lo.indexOf('?')) {
				var h		= lo.split('?', 2);
				if (!h[1]) return;
				var param = '';
				if (h[1].indexOf('&')) {
					var sp = h[1].split('&', 2);
					var mode = sp[0];
					var param = sp[1];
				} else {
					var mode	= h[1];
					var param	= '';
				}
				switch (mode) {
					case 'leiratkozas':
						this.createIframeBox('hirlevel', '/getAjax?m=hirlevel&do-leir=1', {});
						//this.createIframeBox('hirlevel', '/getAjax?m=hirlevel.hash.leiratkozas&p='+param, {});
						break;
					case 'regDeleted':
						this.createIframeBox('adataim_modositasa', '/getAjax?m=registration.success.delete', {});
						break;
					case 'regisztracio':
						this.createIframeBox('regisztracio', '/getAjax?m=registration', {});
						break;
					case 'lejart_idokorlat':
						this.createIframeBox('lejart_a_biztonsagi_idokorlat', '/getAjax?m=lejart.idokorlat', {});
						break;
					case 'vevoszolgalat':
						this.createIframeBox('vevoszolgalat', '/getAjax?m=vevoszolgalat', {});						
						break;
					case 'hirlevel':
						this.createIframeBox('hirlevel', '/getAjax?m=hirlevel'+(param ? '&p='+param : ''), {});
						break;
					case 'belepes':
						this.createIframeBox('belepes', '/getAjax?m=login', {});
						break;
					case 'auchan-kartya':
					case 'auchan_kartya_igenylese':
						this.createIframeBox('auchan_kartya_igenylese', '/getAjax?m=kartya', {});
						break;
					case 'aruhazak':
						this.createIframeBox('aruhazak', 'map', {});
						break;	
					case 'aruhaz-terkep':
						var j = $$('.head.uzletsor');
						if (j.length) {
							var o = j.first();
							var h = o.id.replace('Aruhaz', '');
							var v = h*1;
							var r = new RegExp(/^\d+$/);
							if (r.test(h) && !isNaN(v) && (v > 0)) {
								this.createIframeBox('megkozelites', '/getAjax?m=utv&a='+h);
							}
						}
						break;
					case 'layerPreview':
						this.layerPreview = param;
						break;
					case 'bevasarlolista':
						window.setTimeout('if (Auchan.protoBL) Auchan.createIframeBox(\'bevasarlolista\', \'/getAjax?m=bevlistaNew\', {});', 2000);
						break;
					default:
						this._calculatedHash = mode;
						return;
				}
			}
		},
		setMenuActive: function(i) {
			if (!$('topmenu')) return;
			var elements = $('topmenu').select('li');
			var index = -1;
			var regexp = new RegExp("^http://"+document.location.hostname+".*$");		
			elements.each(function(element, i) {
				var twith = element.select('a').first().href;
				if (regexp.test(twith)) {
					index = i;
					return;
				}
			});
			if (this.activeMenu) this.activeMenu.removeClassName('selected');
			if (index > -1) {
				this.activeMenu = elements[index];
				this.activeMenu.addClassName('selected');				
			}
		},
		setMenuLayout: function() {
			var i = new Image();
			i.onload = function() {
				if (!$('topmenu')) return;				
				var h = $('topmenu').select('li.hiperarak a').first();
				h.setStyle({padding: '0px'});
				var w = 977;
				var g = {w: 0};
				$('topmenu').select('li a').each(function(a, i, g) {
					a.insert({top: new Element('div').addClassName('l')});
					a.insert({top: new Element('div').addClassName('r')});					
					a._calcWidth = a.up().getWidth();
					this.w += a._calcWidth;
				}.bind(g));
				if (g.w <= w) {
					h.setStyle({padding: '0px', width: (h._calcWidth+(w - g.w))+'px'});
				}
			}.bind(this);
			i.src = 'http://www.'+this.domain+'/i11/menu-sprites.png';			
		},
				
		initSzavazas: function(defUrl, reInit, szavazat) {			
			if (reInit && this.preSzavazasParams) {
				var params = this.preSzavazasParams;
			} else {
				var subdomain = document.location.host.replace('.'+this.domain, '');
				var url	= (defUrl?defUrl:document.location.pathname);
				var params = Object.clone({subdomain: subdomain, url: url});
				this.preSzavazasParams = params;
			}
			var v = '/getAjax?m=banner&subdomain='+encodeURIComponent(params.subdomain)+'&url='+encodeURIComponent(params.url);
			if (typeof(rbbx) != 'undefined') {
				window.setTimeout("eval(\"if (typeof(rbbx) != 'undefined') $('rbbx').src = '"+v+"';\");", 1000);
			}
			
			if (szavazat) {
				try {
					if (pageTracker) pageTracker._trackEvent('Szavazas', szavazat);
				} catch(err) {}				
				Object.extend(params, {szavazat: (szavazat-2)});
			}
			if (!$$('#C3 #do_szav').length) return;
			new Ajax.Request('http://'+document.domain+'/getAjax?m=szavazas', {
				method: 'get',
				parameters: params,
				onSuccess: function(transport) {				
					if (transport.responseText) {
						var j = $$('#C3 #do_szav').first();
						j.update(transport.responseText);
						$$('#C3 #do_szav').each(function (o) {o.style.display = 'block';});
					} else {					
						$$('#C3 #do_szav').each(function (o) {o.style.display = 'none';});		
						//var x = '/getAjax?m=banner&subdomain='+encodeURIComponent(params.subdomain)+'&url='+encodeURIComponent(params.url);
						//window.setTimeout("eval(\"if (typeof(rbbx) != 'undefined') $('rbbx').src = '"+x+"';\");", 1000);					
					}
				},
				onFailure: function() {
					//var x = '/getAjax?m=banner&subdomain='+encodeURIComponent(params.subdomain)+'&url='+encodeURIComponent(params.url);
					//window.setTimeout("eval(\"if (typeof(rbbx) != 'undefined') $('rbbx').src = '"+x+"';\");", 1000);					
				}
			});				
		},

		initKereses: function() {
			if (!$('h_srch')) return;
			var e = $('kereses_top');
			e.observe('focus', function() {this.value = (this.value=='KERESÉS'?'':this.value);});
			e.observe('blur', function() {this.value = (this.value==''?'KERESÉS':this.value);});
			var f = function(e) {
				Event.stop(e);
				if ($('kereses_top').value == 'KERESÉS') $('kereses_top').value = '';
				document.location = 'http://kereses.'+Auchan.domain+($('kereses_top').value.length?'/?kereses='+encodeURIComponent($('kereses_top').value):'');				
			}
			$$('#h_srch a').first().observe('click', f);
			e.value = 'KERESÉS';
			if ($('kereses_top')) {
				$('kereses_top').observe('keypress', function(event) {
					var key_code = event.charCode ? event.charCode : event.keyCode;
					if (Event.KEY_RETURN == key_code) this(event);
				}.bind(f));	
			}						
		},
		
		// iframe layer boxes 
		
		alayerPos: function() {
			var a = $('alayer');
			if (!a) {
				if (this.windowAlayer) window.clearInterval(this.windowAlayer);
				return;
			}
			var he = 60;
			var aHe = a.getHeight();
			if (!a.hasClassName('fixTop')) {
				var he = document.viewport.getHeight() / 2 - Math.max(aHe, 360) / 2;
			}
			var me = Math.max(-90, he-180);
			a.style.marginTop = me+'px';
			var bo = a.select('.relizer').first().childElements();
			for ( var j = 0; j < bo.length; j++ ) {
				var e = bo[j];
				if (e.hasClassName('left') || e.hasClassName('right')) {
					e.style.height = Math.max(0, (aHe-7))+'px';				
				}
			}
			
		},		
		createIframeBox: function(name, url, params, special) {
			if (name == 'ertesites' || name == 'ertesitesek') {
				var name = 'hirlevel';
				var url = '/getAjax?m=hirlevel';
			}
			this.initLogout();
			if (this.iframeLoading) {
				this.iframeID++;	
			}
			var myid = this.iframeID+'';
			scrollTo(0,0);
			if (this.windowAlayer) window.clearInterval(this.windowAlayer);
			this.windowAlayer = window.setInterval('Auchan.alayerPos()', 10000);
			if (!$('alayer')) {
				var dv = new Element('div');
				dv.id = 'alayer';
				dv.style.display = 'none';
				$('Cont').insert({before: dv});
				dv.addClassName('ilayer');
				if (params && params.fixTop && params.fixTop == 1) dv.addClassName('fixTop');
				//dv.update('<div class="titler"><div class="c"><div class="left"><div class="name"><div class="closer" onclick="if(Auchan)Auchan.closeBox();"></div></div></div></div></div><div class="center"><div class="right"><div id="contenter"></div></div></div><div class="bottom"><div class="r"><div class="c"></div></div></div>');
				dv.update(
					'<div class="relizer"><div class="closer" onclick="if(Auchan)Auchan.closeBox();" title="bezár"></div><div id="contenter"></div>'+
					'<div class="TL"></div><div class="TR"></div><div class="BR"></div><div class="BL"></div><div class="top"></div><div class="bottom"></div><div class="left"></div><div class="right"></div>'+
					'</div>'
				);
				this.alayerPos();
				dv.style.display = 'block';
				this.alayerPos();
				var fader = new Element('div');
				fader.style.position = 'absolute';
				fader.style.zIndex = '999';
				fader.id = 'alayer_fader';
				fader.setOpacity((special ? 0 : .01));
				fader.style.background = '#000000';
				fader.style.width = $$('body').first().getWidth()+'px';
				fader.style.height = $('Wr').getHeight()+'px';
				fader.style.left = '0px';
				fader.style.top = '0px';
				if (this.isIE6) fader.style.display = 'none';
				$$('body').first().insert({top: fader});
				Event.observe(window, 'resize', function() {
					var a = $('alayer_fader');
					if (a) {
						a.style.width = $$('body').first().getWidth()+'px';
						a.style.height = $('Wr').getHeight()+'px';
					}
				});
				var fader_white = new Element('div');
				//Event.observe(fader, 'click', function() {if(Auchan) Auchan.closeBox();});
				fader_white.style.position = 'absolute';
				fader_white.style.zIndex = '998';
				fader_white.id = 'alayer_fader_white';
				fader_white.setOpacity((special ? .3 : .7));
				fader_white.style.background = '#FFFFFF';
				fader_white.style.width = $('Wr').getWidth()+'px';
				fader_white.style.height = $('Wr').getHeight()+'px';
				if (this.isIE6) fader_white.style.display = 'none';
				$('Wr').insert({top: fader_white});
			} else {
				var dv = $('alayer');
				var fader = $('alayer_fader');
			}
			try {
				if (pageTracker) pageTracker._trackEvent('LayerView', url);
			} catch(err) {}			
			if (name == 'contentOverride') {
				if ($('alayer')) $('alayer').select('#contenter').first().update(url+'<script type="text/javascript">Auchan.iframeActivizer();</script>');				
				this.alayerPos();
				return;	
			}			
			if (url == 'map') {
				$('contenter').update('<div class="layerHead" style="margin-bottom: 5px;"><div class="repl-aruhazak hdrReplacer-2" style="background-position: 10px -386px;">Auchan áruházak</div></div><div style="height: 350px;"><div id="mapDivBig"></div></div>');
				swfobject.embedSWF("http://"+document.domain+"/swf/terkep.swf", "mapDivBig", "640", "350", "9", "", {dir: "http://"+document.domain+"/getXML/left?bigterkep", isAkcioLink: (params.isAkcioLink ? params.isAkcioLink : 0)}, {allowScriptAccess: 'always', wmode: 'transparent', background: 'transparent'}, {});
				this.iframeActivizer();
				this.alayerPos();
			} else {
				this.setIframeBoxLoading(true);
				this.alayerPos();
				new Ajax.Request('http://'+document.domain+url, {
					method: 'get',
					parameters: params,
					onSuccess: function(transport, myid) {
						if (transport.responseText == '') {
							this.closeBox();
						} else {
							this.iframeLoaded(transport.responseText, myid);
						}
					}.bindAsEventListener(this, myid),
					onFailure: function() {
						this.closeBox();
					}.bind(this)
				});								
			}
		},
		
		iframeLoaded: function(cont, id) {
			if (this.iframeID != id || !this.iframeLoading) return;
			if ($('alayer')) $('alayer').select('#contenter').first().update(cont+'<script type="text/javascript">Auchan.iframeActivizer();</script>');
			this.setIframeBoxLoading(false);				
			this.alayerPos();
		},
		
		iframeActivizer: function() {
			initializesAlways.each(function(f) {f();});			
		},
		setIframeBoxLoading: function(stat) {
			if (stat) {
				this.iframeLoading = true;
				this.setContentDefLoading($('contenter'));				
			} else {
				this.iframeLoading = false;	
			}	
		},
		setContentDefLoading: function(div) {
			if(div) $(div).update('<div class="loader IlayerLoader"><img width="24" height="24" src="/i11/ajaxloader.layer.gif" alt="az oldal betöltése folyamatban.."> az oldal betöltése folyamatban..</div>');
		},
		closeBox: function() {
			this.iframeLoading = false;
			this.iframeID++;
			if (this.windowAlayer) {
				window.clearInterval(this.windowAlayer);
				this.windowAlayer = 0;
			}
			$('alayer_fader_white').remove();
			$('alayer_fader').remove();
			$('alayer').remove();	
			if (this.bevlistaAfterClose) {
				this.bevlistaAfterClose = false;
				this.createIframeBox('bevasarlolista', '/getAjax?m=bevlistaNew', {});
			}
		},

		loadStandardTabModified: function(a, url) {
			a._temporaryLink = url;
			this.loadStandardTab(a);			
		},
		
		loadStandardTab: function(a) {
			this.initLogout();
			this.loader = (this.loader ? this.loader++ : 0);
			var myloader = this.loader;
			this.setStandardTabActive(a);
			var stdc = $$('.stdContent').first();
			var he = stdc.getHeight();
			stdc.style.visibility = 'hidden';
			stdc.update('<div class="stdloader"><img src="/i11/ajaxloader.layer.gif" width="24" height="24" alt="az oldal betöltése folyamatban"> az oldal betöltése folyamatban</div>');	
			stdc.style.height = Math.max(he, stdc.getHeight())+'px';
			stdc.style.visibility = 'visible';		
			var xlink = (a._temporaryLink ? a._temporaryLink : a.href);
			this.location = xlink;		
			try {
				if (pageTracker) pageTracker._trackEvent('TabView', xlink);
			} catch(err) {}
			a._temporaryLink = null;
			new Ajax.Request(xlink, {
				method: 'get',
				parameters: {ajaxContentOnly: true},
				onSuccess: function(transport, a, stdc, he, myloader, xlink) {
					if (myloader != this.loader) return;
					this.setStandardTabActive(a);
					var response = transport.responseText || '';
					stdc.style.visibility = 'hidden';
					stdc.update(response);
					initializesAlways.each(function(f) {f();});
					stdc.style.height = 'auto';
					stdc.style.visibility = 'visible';
					this.initSubTabs();
					scrollTo(0,0);
					Auchan.initSzavazas(xlink);
				}.bindAsEventListener(this, a, stdc, he, myloader, xlink)
			});		
		},
		initStandardTabs: function(event) {
			var regexp = new RegExp("[\\?#].*$");
			var d = document.location + '';
			d = d.replace(regexp, '');
			regexp = new RegExp("/+$");
			d = d.replace(regexp, '');			
			$$('.tabs').each(function(tbs) {
				var aktuell		= null;
				var semiaktuell = {tab: null, matchlength: 0};
				var ax = tbs.select('a'); 
				ax.each(function (a, j) {
					var zInd = 7;
					a.setStyle({zIndex: Math.max(1, zInd - j)});
					if (a.hasClassName('ajax')) {a.observe('click', function(event){
						event.stop();
						this.loadStandardTab(a);
					}.bindAsEventListener(this));}
					if (!Element.hasClassName(a, 'done')) {
						Element.addClassName(a, 'done');
						var e = new Element('div').addClassName('TR');
						a.insert({top: e});	
						var e = new Element('div').addClassName('TL');
						a.insert({top: e});								
						var e = new Element('div').addClassName('TPW');
						a.insert({top: e});								
						var e = new Element('div').addClassName('TPB');
						a.insert({top: e});		
					}
				}.bind(this));
				if (tbs.hasClassName('man')) return;				
				var i = 0;
				while (aktuell == null && i < ax.length) {
					var t = ax[i].href + '';
					var myregexp = new RegExp(t+".+$");
					if (t.replace(regexp, '') == d) aktuell = ax[i];
					if (!aktuell && myregexp.test(d) && t.length > semiaktuell.matchlength) {
						semiaktuell.tab			= ax[i];
						semiaktuell.matchlength	= t.length;
					}
					i++;
				}
				if (aktuell) {
					this.setStandardTabActive(aktuell);
				} else {
					if (semiaktuell.tab) {
						this.setStandardTabActive(semiaktuell.tab);
					}
				}
			}.bind(this));			
		},
		setStandardTabActive: function(tab, cancel) {
			tab.up().select('a').each(function(a){a.removeClassName('active');});
			if (!cancel) {
				tab.addClassName('active');
				var v = tab.select('.TPW');
				if (v.length) v.first().style.width = (tab.getWidth()-5)+'px';
			}
		},

	
		/* sub-tabs */
		
			setSubTabActive: function(tab, cancel) {
				tab.up().select('a').each(function(a){a.removeClassName('on')});
				if (!cancel) {
					tab.addClassName('on');	
				}
			},
			initSubTabs: function(event) {
				var regexp = new RegExp("[\\?#].*$");
				var d = document.location + '';
				d = d.replace(regexp, '');
				regexp = new RegExp("/+$");
				d = d.replace(regexp, '');			
				$$('.smalltabs a').each(function(a) {
					if (!a.hasClassName('skip')) {
						a.observe('click', function(event){
							event.stop();
							this.loadSubTab(a);
						}.bindAsEventListener(this));
					}
					if (!Element.hasClassName(a, 'done')) {
						Element.addClassName(a, 'done');
						var e = new Element('div').addClassName('TR');
						a.insert({top: e});	
						var e = new Element('div').addClassName('TL');
						a.insert({top: e});			
						var e = new Element('div').addClassName('TPB');
						a.insert({top: e});														
					}						
				}.bind(this));			
			},		
			loadSubTab: function(a, anotherHref) {
				this.initLogout();
				this.subloader = (this.subloader ? this.subloader++ : 0);
				var myloader = this.subloader;
				this.setSubTabActive(a);
				var stdc = $$('.subTabContent').first();
				var he = stdc.getHeight();
				stdc.style.visibility = 'hidden';
				stdc.update('<div class="stdloader"><img src="/i11/ajaxloader.layer.gif" width="24" height="24" alt="az oldal betöltése folyamatban"> az oldal betöltése folyamatban</div>');	
				stdc.style.height = Math.max(he, stdc.getHeight())+'px';
				stdc.style.visibility = 'visible';		
				this.location = (anotherHref ? anotherHref : a.href);		
				try {
					if (pageTracker) pageTracker._trackEvent('TabView', (anotherHref ? anotherHref : a.href));
				} catch(err) {}
				new Ajax.Request((anotherHref ? anotherHref : a.href), {
					method: 'get',
					parameters: {ajaxSubContentOnly: true},
					onSuccess: function(transport, a, stdc, he, myloader) {
						if (myloader != this.subloader) return;
						this.setSubTabActive(a);
						var response = transport.responseText || '';
						stdc.style.visibility = 'hidden';
						stdc.update(response);
						initializesAlways.each(function(f) {f();});
						stdc.style.height = 'auto';
						stdc.style.visibility = 'visible';
						scrollTo(0,0);
						Auchan.initSzavazas(a.href);
					}.bindAsEventListener(this, a, stdc, he, myloader)
				});		
			},		

		growLength: function(control) {
			$$('.autoFacebook').each(function(a){
				a.href += encodeURIComponent(document.location);
				a.removeClassName('autoFacebook');
			});
			//return;
			if (window.growerInt && control != 'skip') return;
			var growths = $$('.autoHeight');
			growths.each(function(g) {
				var p = null;
				if (!g._sup) {
					g._sup = g.up();
				}
				p = g._sup;
				if (p) {
					g.style.height = 'auto';
					g.style.height = Math.max(g.getHeight(), p.getHeight())+'px';
				}
			});
			if (growths.length)	{
				if (this.isIE6) return;
				if (!window.growerInt) window.growerInt = window.setInterval("if(Auchan)Auchan.growLength('skip')", 6000);
			} else {
				if (window.growerInt) {
					window.clearInterval(window.growerInt);
					window.growerInt = 0;
				}				
			}
		},
		refreshFejlec: function(userKeresztNev, valasztottAruhazID) {
			if ($('valasztottAruhazID')) $('valasztottAruhazID').value = valasztottAruhazID;
			if ($('LoginKeresztnev')) $('LoginKeresztnev').update(userKeresztNev);
		},
		refresh: function() {
			var z = this.location+'';
			this.location = z.replace(/lejart_idokorlat/, '').replace(/regDeleted/, '').replace(/\?belepes/, '?');
			document.location = this.location;	
		},
		logout: function(isSecurity) {
			if (!this.sessionID || !this.auchanuser_id) return;
			document.location = 'http://www.'+Auchan.domain+'/c?'+(isSecurity?'lejart_idokorlat&':'')+'c=logout'/*&l='+encodeURIComponent(Auchan.location)*/;	
		},
		checkLoggedIn: function(bevlistaActivator, skipLogin) {
			if (!this.sessionID || !this.auchanuser_id) {
				if (bevlistaActivator) {this.setCookie('bevlista-onLoginInit', bevlistaActivator, 0, '/', '.'+this.domain);}
				if (!skipLogin) Auchan.createIframeBox('belepes', '/getAjax?m=login&ness', {});
				return false;
			}
			return true;	
		},
		initAruhaz: function() {
			this.aruhaz_id = 0;
			if ($('AruhazSpecifiedID')) {this.aruhaz_id = $('AruhazSpecifiedID').value*1};
		},
		bubon: function(o, pic, hOffset, vOffset, txt, down) {
			this.bubbleElement = o;
			if (!this.bubbleObj) {
				this.bubbleObj = new Element('div').addClassName('bubble').update('<div class="im"></div><div class="im imL"></div><div class="top"></div>');	
				this.bubbleObj.style.display = 'none';
				this.bubbleObjImageDiv = this.bubbleObj.select('.im').first();
				$$('body').first().insert({top: this.bubbleObj});
			}
			if (down === true) {
				this.bubbleObj.addClassName('updown');	
			}
			var dim = Element.getDimensions(o);
			if ($('b_items')) {	
				var offs = {left: Element.cumulativeOffset(o).left, top: Element.cumulativeOffset(o).top-$('b_items').scrollTop};
			} else {
				var offs = {left: Element.cumulativeOffset(o).left, top: Element.cumulativeOffset(o).top};
			}
			if (!hOffset) hOffset = 0;
			if (!vOffset) vOffset = 0;
			this.bubbleObj.style.left = (offs.left+Math.round(dim.width/2) - 57 + hOffset)+'px';
			this.bubbleObj.style.top = (offs.top - 98 + vOffset)+'px';
			this.bubbleObjImageDiv.style.backgroundImage = 'none';			
			if (pic) {
				this.bubbleObjImageDiv.style.backgroundImage = 'url('+pic+')';
			} else {
				this.bubbleObjImageDiv.style.backgroundImage = 'none';
			}
			if (txt) {
				this.bubbleObjImageDiv.update(txt);
			} else {
				this.bubbleObjImageDiv.update('');
			}
			this.bubbleObj.style.display = 'block';
		},		
		bubof: function(o) {
			this.bubbleElement	= null;
			if (this.bubbleObj) {
				this.bubbleObjImageDiv.style.backgroundImage = 'none';
				this.bubbleObj.style.display = 'none';				
			}
		},
		makeLinksVisibleForPrint: function() {
			$$('.scoright a').each(function(a) {
				if (!a.select('div.PrintAnchorVisible').length) {
					var d = new Element('span');
					d.addClassName('PrintAnchorVisible');
					d.update("(link:"+a.href+")");
					a.insert({bottom: d});
				}
			});	
		}
	}
	
	Event.observe(window, 'beforeprint', function() {if(Auchan)Auchan.makeLinksVisibleForPrint();});

	var Auchan;
	var Pagers = [];
	var initializes = [];
	var afterInitializes = [function() {
		if (Auchan && Auchan.sessionID && Auchan.auchanuser_id) {
			var bi = Auchan.getCookie('bevlista-onLoginInit') * 1;
			if (bi) {
				switch (bi) {
					case 1:
						Auchan.createIframeBox('bevasarlolista', '/getAjax?m=bevlistaNew', {});
						break;
					case 2:
						Auchan.createIframeBox('bevasarlolista_kuldese', '/getAjax?m=bevasarlolista.kuldes');
						break;
					case 3:
						Auchan.createIframeBox('bevasarlolista_mobil', '/getAjax?m=bevasarlolista_quickID');	
						break;
					default: break;
				}
				Auchan.setCookie('bevlista-onLoginInit', '', 0, '/', '.'+Auchan.domain);				
			}
		}	
	}];
	var initializesAlways = [];		

	document.observe("dom:loaded", function() { 
		Auchan = new AuchanClass();	
		Auchan.initCategoryWelcome();
		Auchan.initAutoLayers();
		initializes.each(function(f) {f();});
		initializesAlways.each(function(f) {f();});
		afterInitializes.each(function(f) {f();});
		if ($('C1-aruhazi')) swfobject.embedSWF("http://"+document.domain+"/swf/aruhaz_valaszto.swf", 'C1-aruhazi-content', "193", "280", "9", "", {dir: "http://"+document.domain+"/getXML/left"+(Auchan.aruhaz_id?"?aruhaz_id="+Auchan.aruhaz_id:'')}, {allowScriptAccess: 'always', wmode: 'transparent', background: 'transparent'}, {});
		if ($('C1-tankoljon')) swfobject.embedSWF("http://"+document.domain+"/swf/benzinkut_valaszto.swf", 'C1-tankoljon-content', "193", "147", "9", "", {dir: "http://"+document.domain+"/getXML/left"+(Auchan.aruhaz_id && Auchan.aruhaz_id != '0'?"?aruhaz_id="+Auchan.aruhaz_id:'')}, {allowScriptAccess: 'always', wmode: 'transparent', background: 'transparent'}, {});
		if ($('C1-ujsagok')) swfobject.embedSWF("http://"+document.domain+"/swf/akcios_ujsagok_doboz.swf", 'C1-ujsagok-content', "193", "202", "9", "", Object.extend({dir: "http://lapozo-control."+Auchan.domain+'/'}, (Auchan.aruhaz_id && Auchan.aruhaz_id != '0' ?{aruhaz_id: Auchan.aruhaz_id}:{})), {allowScriptAccess: 'always', wmode: 'transparent', background: 'transparent'}, {});
		if ($('videoThumb')) {swfobject.embedSWF("http://"+document.domain+"/swf/videothumb.swf", "videoThumb", "187", "110", "9", "", {dir: "http://"+document.domain+"/getXML/right"}, {allowScriptAccess: 'always', wmode: 'transparent', background: 'transparent'}, {});}
	});
	
	function pager(pagerID, toPage) {
		if (Pagers[pagerID]) {
			Pagers[pagerID].doPager(toPage);	
		}
	}
	
	function encodeRE(s) { return s.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1') }
	function diffChars(s) {
		var li	= [
			['u','Ã¼','Å±','Ãº'],
			['o','Ã¶','Å‘','Ã³'],
			['i','Ã­'],
			['a','Ã¡'],
			['e','Ã©']	
		];	
		var va = s;
		for (var z = 0; z < li.length; z++) {
			var stri		= li[z].join('');
			var RE			= new RegExp("["+stri+"]", "gi");
			va 				= va.replace(RE, '['+stri+']');
		}
		return va;
	}
	
	function crc32(str) {
 
		function Utf8Encode(string) {
			string = string.replace(/\r\n/g,"\n");
			var utftext = "";
	 
			for (var n = 0; n < string.length; n++) {
	 
				var c = string.charCodeAt(n);
	 
				if (c < 128) {
					utftext += String.fromCharCode(c);
				}
				else if((c > 127) && (c < 2048)) {
					utftext += String.fromCharCode((c >> 6) | 192);
					utftext += String.fromCharCode((c & 63) | 128);
				}
				else {
					utftext += String.fromCharCode((c >> 12) | 224);
					utftext += String.fromCharCode(((c >> 6) & 63) | 128);
					utftext += String.fromCharCode((c & 63) | 128);
				}
	 
			}
	 
			return utftext;
		};
	 
		str = Utf8Encode(str);
	 
		var table = "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";
	 
		if (typeof(crc) == "undefined") { crc = 0; }
		var x = 0;
		var y = 0;
	 
		crc = crc ^ (-1);
		for( var i = 0, iTop = str.length; i < iTop; i++ ) {
			y = ( crc ^ str.charCodeAt( i ) ) & 0xFF;
			x = "0x" + table.substr( y * 9, 8 );
			crc = ( crc >>> 8 ) ^ x;
		}
	 
		return crc ^ (-1);
 
	};	

