		
		var SiteClass = Class.create();
		SiteClass.prototype = {
			initialize: function() {
				this.location	= document.location;
				this.domain		= 'pre'+location.domain;			
				this.domainCore		= 'pre'+location.domain;	
			    var js = /default\.js(\?.*)?$/;
			    $$('head script[src]').findAll(function(s) {
					return s.src.match(js);
		    	}).each(function(s) {
					var path = s.src.replace(js, ''),
					domx = s.src.match(/\?.*d=([a-z,.\/-]*)/);
					domain = (domx ? domx[1] : location.domain);
					domxSafe = s.src.match(/\?.*d=([a-z,.-]*)/);
					domainCore = (domxSafe ? domxSafe[1] : location.domain);				
				});	
				this.domain = (domain ? domain : this.domain);
				this.domainCore = (domainCore ? domainCore : this.domainCore);			
				this.initPager();
				this.initLangSelector();
				this.initProductDownloadAll();
				this.initContactForm();
				this.initProdMenu();
				this.initTipusValasztek();
				this.initDealerList();
				this.imgBoxPreInit();
			},
			initDynamicDimensions: function() {
				this.imgBoxInit();
				this.initVerticals();				
				this.initNewsBoxHeight();
				this.initMinHeights();		
			},
			initMinHeights: function() {
				$$('.News.In').each(function(i){if (i.getHeight() < 220) i.setStyle({height: '220px'});});
			},
			initNewsBoxHeight:function () {
				$$('.newsbox').each(function (b) {if(b.getHeight()<110)b.setStyle({height:'110px'})});
			},
			initTipusValasztek: function() {
				if (!$('tpvtek')) return;
				$('armster-tipusvalasztek').select('.brand').each(function(e) {
					e._opened = false;
					e.insHeight = e.down().next().getHeight();
					e.down().next().style.height = '0px';
					e.down().observe('click', function(e) {
						if (!e._opened) {
							e.down().addClassName('on');
							new Effect.Morph(e.down().next(), {style: {height: (e.insHeight+10)+'px'}, duration: .5, afterFinish: function(e){e._opened = true;}.bind(this, e)});
						} else {
							e.down().removeClassName('on');
							new Effect.Morph(e.down().next(), {style: {height: '0px'}, duration: .1, afterFinish: function(e){e._opened = false;}.bind(this, e)});							
						}
					}.bind(this, e));
				}.bind(this));
				$('tpvtek').up().observe('click', function() {
					if ($('armster-tipusvalasztek')) $('armster-tipusvalasztek').style.visibility = 'visible';
					$('nearest-dealer').style.visibility = 'hidden';
				});
				$('armster-tipusvalasztek').select('.close').first().observe('click', function() {$('armster-tipusvalasztek').style.visibility = 'hidden';});
			},
			initDealerList: function() {
				if (!$('nearest-dealer')) return;
				if ($('dealersLink')) $('dealersLink').up().observe('click', function() {
					if ($('armster-tipusvalasztek')) $('armster-tipusvalasztek').style.visibility = 'hidden';
					$('nearest-dealer').style.visibility = 'visible';
				});
				$('nearest-dealer').select('.close').first().observe('click', function() {$('nearest-dealer').style.visibility = 'hidden';});				
				if (!$('prod-menu')) return;
				var v = $('prod-menu').select('a');
				if (v.length > 2) {
					v.last().observe('click', function() {
						if ($('armster-tipusvalasztek')) $('armster-tipusvalasztek').style.visibility = 'hidden';
						$('nearest-dealer').style.visibility = 'visible';
					});
				}
			},			
			initProdMenu: function() {
				if (!$('headster-menu')) return;
				$$('#headster-menu a div').each(function(e) {
					e.observe('click', function() {document.location = this.up().href;}.bind(e));
				});					
			},
			initVerticals: function() {
				$$('.vertical-pos').each(function(e) {
					e.style.display = 'block';
					var h = e.getHeight();	
					var ah = e.up(!e.hasClassName('dbl')?0:1).getHeight();
					e.style.marginTop = Math.round((ah-h)/2)+'px';
				});
				if (!this.verticalInits) {
					this.verticalInits = window.setInterval(this.initVerticals.bind(this), 3000);
				}
			},
			initProductDownloadAll: function() {
				if (!$('downloadAllTermek')) return;
				var dt = $('downloadAllTermek');
				f = function(z, x) {
					var g = function(x) {
						this(this, x*-1);
					}.bind(z, x);
					$('downloadAllTermek').effect = new Effect.Morph('downloadAllTermek', {style: {borderRightColor: x == 1?'#FFFFFF':'rgb(218,37,29)'}, duration: .6, afterFinish: g});	
				}			
				dt.observe('mouseover', function() {
					this.addClassName('tkover');
					this.update(term_DownloadProductCats);
					if (this.ddl) {
						window.clearTimeout(this.ddl);
						this.ddl = 0;
					}
					if (this.effect) this.effect.cancel();
				}.bind(dt));
				dt.observe('mouseout', function(f) {
					if (this.ddl) {
						window.clearTimeout(this.ddl);
						this.ddl = 0;
					}
					this.ddl = window.setTimeout(
						function () {
							this.update('');
							this.removeClassName('tkover');
							f(f, 1);
						}.bind(this, f), 1000
					);
				}.bind(dt, f));
				f(f, 1);
				$('downloadAllTermek').style.borderColor = 'rgb(218,37,29)';
				
			},
			initLangSelector: function() {
				if (!$('langSel')) return;
				this.NYVsp = function() {
					var state = ($('langData').vis == 1);					
					if (!state) {
						this.showNYV();
					}					
					if (this.LLS) {
						window.clearTimeout(this.LLS);
						this.LLS = 0;
					}
				};
				$('langSel').observe('mouseover', function() {
					this.NYVsp();
				}.bind(this));
				$('langData').observe('mouseover', function() {
					this.NYVsp();
				}.bind(this));
				var f = function() {
					if (this.LLS) {
						window.clearTimeout(this.LLS);
						this.LLS = 0;
					}
					this.LLS = window.setTimeout(Site.hideNYV, 2000);
				}.bind(this);
				$('langSel').observe('mouseout', f);				
				$('langData').observe('mouseout', f);				
				$('langData').vis = false;
				$('langData').setOpacity(0);				
				$('langData').style.display = 'block';
				this.hideNYV = function() {
					new Effect.Opacity($('langData'), {to: 0, duration: .2, afterFinish: function() {$('langData').vis = false}});
				};
				this.showNYV = function() {
					new Effect.Opacity($('langData'), {to: 1, duration: .2, beforeStart: function() {$('langData').vis = true}});
				};
			},
			imgBoxInit: function() {
				$$('.imgBox img').each(function(o){
					var height = 88;
					var width = 88;
					if (o.hasClassName('certificate')) {width = 142; height = 211;}
					var marginTop = Math.round((height-o.getHeight())/2);
					o.style.marginTop = marginTop+'px';
					if (o.getHeight() < height-4) o.setStyle({borderTop: '1px solid white', borderBottom: '1px solid white', marginTop: (marginTop-1)+'px'});
					if (o.getWidth() < width-4) o.setStyle({borderRight: '1px solid white', borderLeft: '1px solid white'});					
					new Effect.Opacity(o.up(), {to: 1, duration: .5});
				});
			},
			imgBoxPreInit: function() {
				$$('.imgBox img').each(function(o){o.up().setOpacity(0);});				
			},
			initPager: function() {
				$$('.pager').each(function(pg) {
					var asa = pg.select('.arr');
					var f = asa.first();
					if (f) {
						if (asa.length == 1 && !f.hasClassName('f')) {f.addClassName('big');}
						var sps = pg.select('span');
						if (sps.length) sps.first().style.marginRight = '15px';
					}
				});
			},
			initContactForm: function() {
				if ($('foo3')) {
                    var form = $('foo3').select('form').first();
					form.observe('submit', function(e) {
                        e.stop();
			            new Ajax.Request('/contact', {
			                method: 'POST',
                            parameters: form.serialize({ hash: true, submit: false }),
                            onSuccess: function(r) {
			                	var res = new Element('div').addClassName('contactResult').update('<p>'+r.responseJSON.message+'</p><i>'+r.responseJSON.forNewClickHere+'</i>');
								res.observe('click', res.remove);
								$('foo3').insert(res);
								$('from').value = '';
								$('msg').value = '';
							},
			                onFailure: function(r){
								var res = new Element('div').addClassName('contactResult').update('<p>'+r.responseJSON.errorMessage+'</p><i>'+r.responseJSON.forNewClickHere+'</i>');
								res.observe('click', res.remove);	
								$('foo3').insert(res);
							}
			            });
					});
                }
			},
			initStdMenu: function() {
				if (!$('stdMenu')) return;
				$('stdMenu').select('a').each(function(a){
					if (a.up().hasClassName('on') && a.up().next()) {
						a.up().next().addClassName('preOn');
					}
					a.observe('click', function() {this.up().addClassName('active');}.bind(a));
					a.observe('mouseout', function() {
						this.up().removeClassName('hover');
						if (this.up().next()) {
							this.up().next().removeClassName('preHov');	
						}
					}.bind(a));
					a.observe('mouseover', function() {
						this.up().addClassName('hover');
						if (this.up().next()) {
							this.up().next().addClassName('preHov');	
						}
					}.bind(a));
				}.bind(this));
				$('stdMenu').select('li').last().addClassName('l');
			},
			
			setMenuOn: function(i) {
				if ($('stdMenu')) $('stdMenu').select('li').each(function(o,j){if(o.down().id == 'topMenu'+this)o.addClassName('on');}.bind(i));
				if ($('footerMenu')) $('footerMenu').select('li').each(function(o,j){if(o.down().id == 'footerMenu'+this)o.addClassName('on');}.bind(i));
			},
			
			setUpImgLayer: function() {
				var o = new Element('div');
				var oContent = new Element('div');
				o.setStyle({display: 'none', zIndex: 10000, left: 0, top: 0, cursor: 'default', position: 'absolute', background: '#888'});
				o.setOpacity(.7);
				oContent.setStyle({textAlign: 'left', width: '300px', height: '300px', display: 'none', zIndex: 10001, left: 0, top: 0, cursor: 'pointer', position: 'absolute', background: '#FFF url(/i/rati-logo.png) center center no-repeat'});
				o.insert({bottom: oContent});
				$$('body').first().insert({top: oContent});
				$$('body').first().insert({top: o});
				o.observe('click', this.closeImageLayer.bindAsEventListener(this));
				//oContent.observe('click', this.closeImageLayer.bindAsEventListener(this));
				this._setUp = true;
				this.imageLayerObj = oContent;
				this.imageLayerOverlay = o;
				this.positionImageLayer();
				Event.observe(window, 'resize', this.positionImageLayer.bindAsEventListener(this));
				Event.observe(window, 'scroll', this.positionImageLayer.bindAsEventListener(this));
			},
			
			positionImageLayer: function(includeImage) {
				var a = document.viewport.getScrollOffsets();
				var b = document.viewport.getDimensions();
				this.imageLayerOverlay.setStyle({
					width: b.width+'px',
					height: b.height+'px',
					left: a.left+'px',
					top: a.top+'px'
				});
				var i = this.imageLayerObj;
				if (i && includeImage === true) {
					this.imageLayerObj.setStyle({
						left: a.left+(Math.max(0, Math.round((b.width - i.getWidth()) / 2)))+'px',
						top: a.top+(Math.max(10, Math.round((b.height - i.getHeight()) / 2)))+'px'
					});
				}
			},
			
			showImageLayer: function(src, closedomain) {
				if (!this._setUp) this.setUpImgLayer();
				if (this.imageLayerActive) this.closeImageLayer();
				this.imageLayerObj.update('');
				var iLoader = new Element('img');
				iLoader.src = 'http://' + src.split(/\/+/g)[1] + '/i/ajax-loader-wheel.gif';
				iLoader.addClassName('iLoader');
				iLoader.setStyle({marginLeft: '150px', marginTop: '150px'});
				this.imageLayerObj.setStyle({width: '316px', height: '316px', display: 'block'});
				this.imageLayerObj.insert({bottom: iLoader});	
				Site.positionImageLayer(false);			
				var iCloser = new Element('img');
				iCloser.setStyle({position: 'absolute', right: '-32px', top: '0px', background: 'white', padding: '0px'});
				iCloser.src = 'http://' + (closedomain ? closedomain.split(/\/+/g)[1] : src.split(/\/+/g)[1]) + '/i/gallery-close.png';
				this.imageLayerObj.insert({bottom: iCloser});	
				iCloser.observe('click', this.closeImageLayer.bindAsEventListener(this));
				if (src.indexOf('http://www.youtube.com/v/') == 0) {
					var x = new Element('div');
					x.update('<div id="imageFlashEmbedder"></div>');
					var WX = 640;
					var WY = 385;
					iLoader.remove();
					this.imageLayerObj.insert({bottom: x});
					x.setStyle({
						width: WX+'px',
						height: WY+'px',
						marginLeft: '5px',
						marginTop: '5px'
					});
					swfobject.embedSWF(
						src,
						"imageFlashEmbedder",
						WX, WY,
						"8", null, {}, {allowScriptAccess: "always", allowFullScreen: true, wmode: 'transparent'}, {id: "myytplayerx"}
					);					
					this.imageLayerObj.style.display = 'block';
					this.imageLayerObj.setStyle({
						width: (WX+10)+'px',
						height: (WY+10)+'px'
					});
					Site.positionImageLayer(true);

				} else {
					var i = new Element('img');
					this.imageLayerObj.observe('click', this.closeImageLayer.bindAsEventListener(this));
					this.imageLayerObj.insert({bottom: i});
					i.setStyle({marginLeft: '5px', marginTop: '5px', display: 'none'});
					i.observe('load', function() {
						this.up().down().remove();
						this.style.display = 'block';
						this.up().style.display = 'block';
						this.up().setStyle({
							width: (this.getWidth()+10)+'px',
							height: (this.getHeight()+10)+'px'
						});
						Site.positionImageLayer(true);
					}.bind(i));	
					i.src = src;
				}
				this.imageLayerOverlay.setStyle({display: 'block'});
				this.imageLayerActive = true;
				Site.positionImageLayer(true);	
			},
			
			closeImageLayer: function() {
				this.imageLayerObj.setStyle({display: 'none'});
				this.imageLayerOverlay.setStyle({display: 'none'});
				this.imageLayerActive = false;
			}
			
		};	
		
		var inits = [];
		var onLoad = function() {
			if (Site) Site.initDynamicDimensions(); else window.setTimeout("onLoad()", 500);	
		};
		Event.observe(window, 'load', onLoad);
		document.observe("dom:loaded", function() { 
			Site = new SiteClass();
			inits.each(function(f){f();});
			Site.initStdMenu();
		});


