var IE = /*@cc_on!@*/false;
var IE5 = (IE && (navigator['appVersion'].indexOf('MSIE 5') > 0)) ? true : false;
var IE6 = (IE && (navigator['appVersion'].indexOf('MSIE 6') > 0)) ? true : false;
var IE7 = (IE && (navigator['appVersion'].indexOf('MSIE 7') > 0)) ? true : false;
var IE8 = (IE && (navigator['appVersion'].indexOf('MSIE 8') > 0)) ? true : false;
var IE9 = (IE && (navigator['appVersion'].indexOf('MSIE 9') > 0)) ? true : false;

if (IE9) {Cufon.set('engine', 'canvas');}


var site = function() {

	$(document).ready(function() {
		site.initialize();
	});

	return {

		hint: {
			htpl: '<div class="hint" id="hint">' + ((IE6) ? '<iframe frameborder="0" scrolling="no"></iframe>' : '') + '<div class="bg"></div><div class="inner">##hint##</div></div>',
			html: '',
			obj: null,
			show: function(o, e) {
				if (this.obj) {this.obj.remove();}
				if (!o.hint) {
					o.hint = o.title;
					o.title = '';
				}
				this.html = String(this.htpl).split('##hint##').join(o.hint);
				this.obj = $(this.html);
				$('body').append(this.obj);
				this.obj.css({'left': e.pageX+'px', 'top': (e.pageY - $('body').offset().top - this.obj.height())+'px'});
				$(o).mousemove(function(e) {
					site.hint.obj.css({'left': e.pageX+'px', 'top': (e.pageY - $('body').offset().top - site.hint.obj.height())+'px'});
				});
			},
			hide: function() {
				if (this.obj) {
					this.obj.remove();
				}
			}
		},
		// /hint

		// showImage
		showImage: function(imgURL) {

			// new gallery
			var img = imgURL.split('/').pop().split('.').join('_');
			$('div#galleryhidden div.item a.' + img).trigger('click');
			return true;
			// /new gallery


			var imgPos = 0;

			var _phoneImages = phone_images.split(',');
			if(_phoneImages.length > 1) {
				// ha tobb kep van es lapozhato

				$('div#popupwrp a.next').unbind().click(function(e){
					e.preventDefault();

					imgPos++;
					if (imgPos > _phoneImages.length-1){
						imgPos = 0;
					}
					_showPic(_phoneImages[imgPos]);

				});
				$('div#popupwrp a.prev').unbind().click(function(e){
					e.preventDefault();

					imgPos--;
					if (imgPos < 0){
						imgPos = _phoneImages.length-1;
					}
					_showPic(_phoneImages[imgPos]);

				});

			} else {
				// ha csak 1 kep van
				$('div#popupwrp a.prev, div#popupwrp a.next').hide();
				$('div#popupwrp div.info').css('margin-left',50);
			}

			/* ----------- kep lapozo ---------- */
			function _showPic(_imgURL){
				$('div#popupwrp div.imageBox div.image img').attr({'src': _imgURL});
			}
			/* ----------- kep lapozo ---------- */


			$('div#popupwrp div.imageBox div.image img').attr({'src': _phoneImages[imgPos], 'title': 'Kattints a bezáráshoz'}).css({width: 'auto', height: '', margin: '0 auto'}).click(function(e){
				setTimeout(function(){
					$('div#popupwrp a.prev, div#popupwrp a.next').show();
					$('div#popupwrp div.info').css('margin-left', 0);
				},500);
				$("div#popupwrp div.popup a.close").click();
			});
			$('div#popupwrp div.imageBox span.title').html($(this).attr('title'));
			$('div#popupwrp div.imageBox span.description').html($(this).find('img').attr('alt'));
			$('div#popupwrp div.imageBox span.counter').empty();

			var _img = new Image();
			_img.onload = function(){
				if (_img.height > 420){
					$('div#popupwrp div.imageBox').addClass('big');
				}
				setTimeout(function(){
					$('div#popupwrp div.imageBox div.image img, div#popupwrp div.imageBox div.viewer div.info div.image').css({ width: _img.width, height: _img.height+'px', overflow: 'visible'});
				},1);

				if (IE6){
					site.pngFix($('div#popupwrp div.imageBox div.image img'));
				}


			}
			_img.src = _phoneImages[imgPos];

			$('<div id="fader"></div>').appendTo('body').fadeTo(500, 0.5, function()
			{
					if(IE)
						$('div#popupwrp div.imageBox').show();
					else
						$('div#popupwrp div.imageBox').fadeIn();

			});

			return false;

		},
		// /showImage

		// android app popup
		showAndroidApp: function(id){

			$('<div id="fader"></div>').appendTo('body').fadeTo(500, 0.5, function(){

				if (IE){
					$('.androidApp:eq('+id+')').fadeIn();
				} else {
					$('.androidApp:eq('+id+')').show();
				}
			});

		},
		// /android app popup

		// showMap
		showMap: function(title, desc, lat, lng) {
			$('#fader').remove();
			$('<div id="fader"></div>').appendTo('body').fadeTo(500, 0.5, function() {
				/*
				if(IE)
					$('div#popupwrp div.imageBox').show(0,site.showMapG(title, desc, lat, lng));
				else
					$('div#popupwrp div.imageBox').fadeIn(300,site.showMapG(title, desc, lat, lng));
				*/
				$('div#popupwrp div.imageBox').show(0);
				site.showMapG(title, desc, lat, lng);
			});
			$('div#popupwrp div.imageBox').addClass('nonav');
		},

		showMapG: function(title, desc, lat, lng){
			if (!title) title = 'Telenor Magyarország Zrt.';
			if (!desc) desc = 'Törökbálint, Pannon út 1.';
			if (!lat) lat = 47.43037;
			if (!lng) lng = 18.93657;

			var imbox = $('#popupwrp .imageBox');
			$('span.title', imbox).html(title);
			$('span.description', imbox).html(desc);
			$('span.counter', imbox).empty();

			var latlng = new google.maps.LatLng(lat, lng);
			var myOptions = {
				zoom: 15,
				center: latlng,
				mapTypeId: ((lat == 47.43037) && (lng = 18.93657)) ? google.maps.MapTypeId.SATELLITE : google.maps.MapTypeId.ROADMAP
			};
			var map = new google.maps.Map($('#popupwrp div.image')[0], myOptions);
				var marker = new google.maps.Marker({
				position: new google.maps.LatLng(latlng.lat(), latlng.lng()),
				map: map
			});
			var infowindow = new google.maps.InfoWindow({
				content: '<b>' + title + '</b><br />' + desc
			});
			google.maps.event.addListener(marker, 'click', function() {
				infowindow.open(map,marker);
			});
		},
		// /showMap

		// IE fixes
		IEfix: function() {
			if (IE) {
				setTimeout(function() {
				}, 10);
			}
			return false;
		},
		IE6fix: function() {
			if (IE6) {

				// png fixek
				var pngFixElements = $('.item_phone img')
				.add('div.submenu div.additional div.promo a.device img')
				.add('body.mobilelist div.cont div.mobile img:not(.featured)')
				.add('.box_product img')
				.add('#news-scroll ul.items li img');

				site.pngFix(pngFixElements);
			}
			return false;
		},
		IE7fix: function() {
			if (IE) {
				var orderButton = $('body.mobilelist div.cont div.toolbar a.order');
				orderButton.find('span').css('float', 'left');
				orderButton.css('width',orderButton.width());
				orderButton.find('span').css('float', 'right');
				$('div.cont div.questionlist > ul, div.cont div.goodtoknow > ul').each(function(){
					var _QLh = 0;
					$(this).find('li').each(function(){
						_QLh += $(this).height();
					});
					$(this).height(_QLh);
				});
			}
		},
		// /IE fixes

		/*setTabsheet: function(ts, obj) {
			var tabsheet = $(obj).hasClass('tabsheet') ? $(obj).eq(0) : $('body .tabsheet').eq(0);
			var ts0 = tabsheet.attr('class').split('ts')[1];
			ts0 = (ts0) ? ts0.substr(0,1) : '';
			var ts1 = String(ts);
			ts1 = (ts1) ? ts1.substr(0,1) : '';
			tabsheet.removeClass('ts'+ts0);
			tabsheet.addClass('ts'+ts1);
			site.IEfix();
		},*/
		pngFix: function(el){
			el.each(function(){
				if ($(this).is('img')){
					$(this)[0].style.cssText = 'filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src="'+$(this).attr('src')+'")';
					$(this).attr('src','/i/none.gif');
				} else {
					$(this).find('img')[0].style.cssText = 'filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src="'+$(this).attr('src')+'")';
					$(this).find('img')[0].attr('src','/i/none.gif');
				}
			});
		},
		selMainPage: function (){
			if ($('#selMainPage').length>0){
				$('#selMainPage').insertBefore('.container');
				setTimeout(function(){
					var sMP = $('#selMainPage');
					sMP.slideDown(300).find('.close').click(function(e){
						setCookie($(this).attr('rel'), 1, 365 * 5);
						var h = -sMP.outerHeight() - parseInt(sMP.css('margin-bottom'));
						sMP.animate({marginTop: h, opacity: 0}, 250, function(){
							sMP.remove();
						});
						return false;
					});
					sMP.find('.ok').click(function() {
						setCookie('startPage', $(this).attr('rel'), 365 * 5);
						return false;
					});
				},500);
			}
		},
		slider: function(selector,opts,content){
			var _this = this;
			var obj = $(selector);
			obj.slider({
				range:'min',
				min:opts.minmax[0],
				max:opts.minmax[1],
				value:opts.value || opts.minmax[0],
				step:opts.step || 1,
				slide:function(event,ui){
					if (typeof(opts.options) != 'undefined') {
						event.target.children[0].value = "";
						$(event.target).next('div.desc').find('p').html("&nbsp;");
						for (var i in opts.options) {
							if (opts.options[i] == content[ui.value]) {
								event.target.children[0].value = i;
								$(event.target).next('div.desc').find('p').html(content[ui.value]);
								break;
							}
						}
					} else {
						event.target.children[0].value = content[ui.value];
						//event.target.children[1].value = ui.values[1];
					}
				},
				change: function(event, ui) {
					_this.counter.update(-8,obj.attr('id'));
				}
			});
			obj.find('.min').val((opts.value && content[opts.value]) || content[0]);
			//obj.find('.max').val((opts.values && opts.values[1]) || opts.minmax[1]);
		},
		counter: function(){
			var display = '#soho-form-counter span';
			var cache = [];
			var maxtime = [];
			function gettotal(){
				return parseFloat($(display).html());
			}
			function update(number,id){ // id nem #id, csak azonosito. Akar 'name=' is lehet tobb radio eseten.
				if(cache[id])return; // csak az elso kitoltesnel fut az update
				cache[id] = 1;
				$(display).text(gettotal() + (number));
			}
			return {
				update:update,
				addinputs:function(array){
					$.each(array,function(index,value){
						if ($.inArray(value, maxtime) == -1) {
							maxtime.push(value);
						}
						$('[name*="'+value+'"]').one('click',function(){
							update(-8,value);
						});
					})
				},
				settime: function() {
					$(display).html(maxtime.length * 8);
				}
			}
		}(),
		initialize: function() {

			var a = null;
			var obj = null;
			var tmp = null;
			var sid = null;

			// common settings
			$('a._blank').click(function() {
				window.open(this.href);
				this.blur();
				return false;
			});
			$('input.autocomplete, form.autocomplete').attr('autocomplete', 'off');
			// /common settings

			// setashomepage
			$('div.setashomepage a').click(function() {
				if (IE) {
					this.style.behavior = 'url(#default#homepage)';
					this.setHomePage(this.href);
				} else {
				}
				return false;
			});
			// setashomepage

			// addtofavorites
			$('div.addtofavorites a').click(function() {
				if (window.sidebar) {
					window.sidebar.addPanel(document.title, this.href, "");
				} else if(window.external) {
					window.external.AddFavorite(this.href, document.title);
				}
				return false;
			});
			// addtofavorites

			// head.menu megadropdown
			setTimeout(function() {
				$('div.head div.menu > ul > li:gt(1) div.submenu').addClass('reverse');
				$('div.head div.menu > ul > li').each(function(i) {
					var sm = $(this).find('div.submenu').eq(0);
					var smmi = $(this).find('div.submenu div.menuitems ul').eq(0);
					var fullwidth = false;

					$(this).css({backgroundPosition: '-' + String($(this).offset().left - $('div.head div.menu').offset().left + 120 - 10) + 'px 0px'});

					var smmi2 = $('<ul></ul>');
					tmp = false;
					if (!sm.parent().parent().parent().hasClass('has-single-column-submenu')) {
						sm.find('div.menuitems ul li').each(function() {
							if (($(this).offset().top+$(this).outerHeight() - smmi.offset().top > 234) || tmp) {
								$(this).appendTo(smmi2);
								tmp = true;
							}
						});
						if (tmp) {
							smmi.after(smmi2);
						}
					}

					if (sm.width() == 940) {
						fullwidth = true;
					}

					if (sm.length > 0) {
						var sm_mi = $(this).find('div.submenu > div.menuitems').eq(0);
						var sm_ad = $(this).find('div.submenu > div.additional').eq(0);
						sm.find('div.promo').each(function(i) {
							$(this).addClass((i%2==0) ? 'odd' : 'even');
						});

						if ((sm_mi.length < 0) && (sm_ad.length < 0)) {$(this).addClass('nosubmenu');}

					} else {
						$(this).addClass('nosubmenu');
					}

					if (!fullwidth && !sm.parent().parent().parent().hasClass('has-single-column-submenu')) {
						var pos = $(this).offset().left - $('div.head div.menu').offset().left - (Math.floor((sm.width() - 188) / 188) * 188);
						if (Math.floor(sm.width() / 188) == 1) {
							pos = pos - 10;
						}
						if (pos < -120) {
							pos = -120;
						} else if (pos + sm.width() + 130 > 940) {
							pos = pos - ((pos + sm.width() + 130) - 940);
						}
						sm.css({left: pos});
						sm.find('div.submenu-end').css({right: -10});
						sm.addClass('col' + Math.floor(sm.width() / 188));
					}

					$(this).mouseenter(function(e) {
						e.preventDefault();
						e.stopPropagation();
						$(this).stop().animate({
							opacity:1
						}, 150, function() {
							sm.find('div.submenu-end').show();
							sm.show();
							$(this).addClass('hover')
						});
					}).mouseleave(function(e) {
						sm.find('div.submenu-end').hide();
						sm.hide();
						$(this).removeClass('hover').stop();
					});

				});

				// sidemenu
				$('div.side div.menu li.open > a > b').append('<ins class="open"></ins>');
				$('div.side div.menu li.active > a > b').append('<ins class="topleft"></ins><ins class="botleft"></ins>');

				if($('div.head div.menu.has-single-column-submenu').size() > 0){
					$('div.head div.menu.has-single-column-submenu ul li div.menuitems').each(function(){
						var $li = $(this).parent().parent();
						$li.css('background-position', '0 0');
					});
				}

			}, 500);
			// /head.menu megadropdown

			// borderbox
			$('div.cont div.borderbox').each(function() {
				$(this).prepend('<div class="bg"><div class="tl"></div><div class="t"></div><div class="tr"></div><div class="r"></div><div class="br"></div><div class="b"></div><div class="bl"></div><div class="l"></div></div>');
			});
			// /borderbox

			// highlight
			$('div.content p.highlight1, div.content p.highlight2, div.content p.highlight3, div.content p.highlight4').each(function() {
				$(this).wrap('<div class="highlight ' + this.className + '"></div>');
			});
			// /highlight

			// tabsheet handling
			if (document.location.toString().indexOf('pdf=1') == -1) {
				$('div.cont div.tabsheet').each(function() {
					$(this).addClass('tabsheetHandler');
					if (($(this).parents('.tabsheetHandler').length == 0) && (!$(this).hasClass('nojs'))) {
						var tmp = '';
						$(this).find('div.tab').each(function(i) {
							tmp += '<li class="t' + i + '"><a href="#" class="' + this.className.split('tab').join('') + ' tab t' + i + '"><b>' + $.trim($(this).text()) + '</b></a></li>';
							$(this).remove();
						});
						$(this).prepend('<div class="tabs"><ul>' + tmp + '</ul></div>');
						$(this).find('div.sheet').each(function(i) {
							$(this).addClass('s'+i);
						});
						if (this.className.indexOf('ts') < 0) {
							$(this).addClass('ts0');
						}
					}
				});
			}
			$('div.cont .tabsheetHandler .tab').click(function() {
				this.blur();
				$(this).parent().find('input').blur();
				var ts0 = $(this).parents('.tabsheetHandler').eq(0).attr('class').split('ts')[1];
				ts0 = (ts0) ? ts0.substr(0,1) : '';
				var ts1 = $(this).attr('class').split('tab t')[1];
				ts1 = (ts1) ? ts1.substr(0,1) : '';
				$(this).parents('.tabsheetHandler').eq(0).removeClass('ts'+ts0);
				$(this).parents('.tabsheetHandler').eq(0).addClass('ts'+ts1);

				if ($(this).hasClass('ajax')) {
					var sheet = $(this).parents('.tabsheetHandler').eq(0).find('.sheet.s'+ts1);
					//onTabChange($(this).parents('.tabsheet').eq(0).find('.sheet.s'+ts1));
					var sheetIndex = String(sheet.attr('class')).split('sheet s')[1];
//					alert(sheetIndex);
				}
				site.IEfix();
				if (this.nodeName.toLowerCase() == 'a') {
					return false;
				}
			});
			// /tabsheet handling

			//$('#soho-tabsheet .tab.t2').trigger('click');

			// tabshee4 handling (becsukhato tabok)
			if ($('div.cont .tabsheet4').length > 0){
				$('div.cont .tabsheet4 .openSearch, div.cont .tabsheet4 .tab').click(function(e){
					e.preventDefault();
					var s = $('.tabsheet4 div.sheet');

					if (s.hasClass('closed')){
						s.removeClass('closed');
						$('div.cont .tabsheet4 .openSearch').addClass('up');
					} else {
						// ha a ki/becsuko gomb
						if ($(this).hasClass('openSearch')){
							s.addClass('closed');
							$('div.cont .tabsheet4 .openSearch').removeClass('up');
						}
					}

				});
			}

			// /tabshee4 handling (becsukhato tabok)

			// popup (soho wizard akcio)
			/*
			$('a[href$="?embed=1"]').bind('click',function(e){
				e.preventDefault();
				var w = 800;
				var h = 600;
				var top = screen.height/2-h/2;
				var left = screen.width/2-w/2;
				var popup = window.open('http://www.telenor.hu/'+$(this).attr('href').split('?')[0],'','width='+w+',height='+h+',left='+left+',top='+top);
			});
			*/

			// slideDown
			$('.slide-content').wrap('<div class="slide-hide" style="display:none;"></div>');
			$('.slide-title').bind('click',function(e){
				$(this).toggleClass('open').next().slideToggle();
			});

			// slideDown2
			$('.grey-slide-content').each(function(i) {
				$(this).wrap('<div class="grey-slide-hide" style="display:none;"></div>');
			});

			$('.slide-group .grey-slide-hide').eq(0).show()
				.prev('.grey-slide-title').addClass('open');

			$('.grey-slide-title, .green-slide-title').bind('click',function(e){
				$(this).toggleClass('open').next().slideToggle();
			});

			// custom scrollbar
			if ($('.tinyscrollbar').length) {
				$('.tinyscrollbar').tinyscrollbar({sizethumb:21})
			}
			// condense floated items
			$('.condensed').each(function() {
				obj = $(this);
				a = Array();
				tmp = null;
				obj.find('> *').each(function(i) {
					if (a[$(this).offset().left]) {
						tmp = a[$(this).offset().left];
						$(this).css({'marginTop': - ( $(this).offset().top - (tmp.offset().top + tmp.outerHeight()) - 2*($(this).outerHeight(true) - $(this).height()) ) + 'px'});
					}
					a[$(this).offset().left] = $(this);
				});
			});
			// condense floated items

			// table handling
			$('div.content table[class!=normal]')
			.not('div.content table.hipernet-table-1-slider1')
			.not('div.content table.hipernet-table-1-lime-slider1')
			.not('div.content table.hipernet-table-2-slider1')
			.not('div.content table.hipernet-table-3-slider1')
			.not('div.content table.hipernet-table-1-fullwide')
			.not('div.content table.hipernet-table-1-lime-fullwide')
			.not('div.content table.hipernet-table-2-fullwide')
			.not('div.content table.hipernet-table-3-fullwide')
			.not('div.content table.hipernet-table-3-private-fullwide')
				.each(function() {
				$(this).wrap('<div class="table"></div>');
				$(this).find('tbody tr:first').addClass('first');
				if (!$(this).hasClass('lines')) {
					if ($(this).find('tbody tr.odd, tbody tr.even').length == 0) {
						$(this).find('tbody tr').each(function(i) {
							$(this).addClass((i%2==0) ? 'odd' : 'even');
						});
					}
				}
				$(this).find('tbody td').each(function() {
					if (($(this).attr('colspan') > 1) && !$(this).hasClass('center')) {$(this).addClass('center');}
					if (($(this).attr('rowspan') > 1) && !$(this).hasClass('middle')) {$(this).addClass('middle');}
				});

				if ($(this).hasClass('detailed')) {
					$(this).find('tr td a.bull.dn').click(function() {
						this.blur();
						$(this).toggleClass('dn').toggleClass('up');
						$(this).parents('tr:eq(0)').next('tr.details').toggleClass('closed');
						return false;
					});
					$(this).find('tr.details').addClass('closed');
				}
			});
			/*$('div.content table[class!=normal]').each(function() {
				if ($(this).parent().parent().parent().get(0).className != 'table') {
					$(this).wrap('<div class="table ' + this.className + '"><div><div></div></div></div>');
					site.IEfix();
				}
			});*/
			// /table handling

			// sider align
			/*
			$('div.content div.sider').each(function() {
				var h1 = $(this).parent().find('div.inner h1:first');
				var promo = $(this).parent().find('div.inner div.promo:first');
				if ((h1.length > 0) && (h1.outerWidth() > h1.parent().outerWidth())) {
					$(this).css({marginTop: String(h1.offset().top - h1.parent().offset().top + h1.outerHeight()) + 'px'});
				}
				if ((promo.length > 0) && (promo.outerWidth(true) - promo.width() < 0) && ($(this).offset().top + $(this).outerHeight(true) > promo.offset().top)) {
					$(this).css({marginTop: String(promo.offset().top - promo.parent().offset().top + promo.outerHeight()) + 'px'});
				}
			});
			*/
			// /sider align

			// head - search
			obj = $('div.head div.search input#q').eq(0);
			if (obj.get(0).value == '') {
				obj.get(0).value = obj.get(0).title;
			}
			obj.focus(function() {
				if (this.value == this.title) {
					this.value = '';
				}
			});
			obj.blur(function() {
				if (this.value == '') {
					this.value = this.title;
				}
			});
			$('div.cont').click(function() {
				$('div.head div.search').removeClass('result');
			});
			// /head - search

			// form handling
			if ($('div.content form').length > 0) {
				$('div.content > form div.field, div.content > div.inner > form div.field').addClass('rounded');
				$('div.content form input:file').each(function() {
					$(this).parents('div.file').eq(0).find('input:text').attr('readonly', 'readonly');
					$(this).parents('div.file').eq(0).find('input:text').attr('value', $(this).attr('value').split('/').pop().split('\\').pop());
					$(this).mouseout(function() {
						$(this).parents('div.file').eq(0).find('input:text').attr('value', $(this).attr('value').split('/').pop().split('\\').pop());
					});
				});
			}
			$('div.cont select:not([multiple]):not(.hidden)').each(function() {
				$(this).parent().find('input:text').attr('readonly', 'readonly');
				$(this).parent().find('input:text').attr('value', $(this).find('option:selected').text());
				$(this).parent().find('span.optiontext').text($(this).find('option:selected').text());
				$(this).change(function() {
					$(this).parent().find('input:text').attr('value', $(this).find('option:selected').text());
					$(this).parent().find('span.optiontext').text($(this).find('option:selected').text());
				});
			});
			// /form handling

			// package selector
			if ($('div.packsel').length > 0) {
				$('div.packsel input:radio').removeAttr('checked');
				$('div.packsel label').click(function() {
					if ($(this).parents('div.packsel div.phase0').eq(0).length > 0) {
						$(this).parents('div.packsel').eq(0).find('li').removeClass('active');
						$(this).parents('div.packsel').eq(0).find('div.phase1 radio:checked').removeAttr('checked');
					} else {
						$(this).parents('ul').eq(0).find('li').removeClass('active');
					}
					$(this).parent().addClass('active');
				});
			}
			// /package selector

			// rounded handling
			if (!IE6) {
				$('div.cont div.promo').prepend('<div class="tl"></div><div class="bl"></div>');
				$('div.content div.sider div.box').prepend('<div class="tl"></div><div class="bl"></div><div class="tr"></div><div class="br"></div>');
				$('img.rounded').wrap('<div class="rounded"></div>');
				$('.rounded:parent').append('<div class="tl"></div><div class="bl"></div><div class="tr"></div><div class="br"></div>');
				$('.roundedleft').append('<div class="tl"></div><div class="bl"></div>');
				$('.roundedright').append('<div class="tr"></div><div class="br"></div>');
			}
			// /rounded handling


			// phone page handling
			if (($('div#phoneAttr').length > 0) && ($('div#phonePack').length > 0)) { /* <- removable this */
				phone.initialize();
			}


			// /phone page handling
			if ($('div#phonepage').length > 0) {
				setTimeout(function() {phonepage.initialize();}, 333);
			}

			// carnation
			if ($(document).width() > 1080) {
				$('div#carnation').show();
			}
			// /carnation

			// h4 > a klikk
			$('h4.orange:not(.nojs), h4.blue:not(.nojs), h4.green:not(.nojs), h4.purple:not(.nojs), h4.brown:not(.nojs)').live('click',function(){
				window.location.href = $(this).find('a').attr('href');
			});
			// h4 > a klikk

/*
			// faq handling
			$('div.content div.faq dl dt a').click(function() {
				this.blur();
				var faqitem = $(this).parents('dl').eq(0);
				faqitem.toggleClass('open');
				site.IEfix();
				return false;
			});
			// /faq handling
*/
			// hint
			$('.hashint[title!=""]').hover(
				function(e) {
					site.hint.show(this, e);
				},
				function() {
					site.hint.hide();
				}
			);
			// /hint



			// tudakozo
			var _tudakozo_first = $('div.tudnew #gsm1');
			var _tudakozo_second = $('div.tudnew #gsm2');
			var _tudakozo_all = $('div.tudnew #gsm');

			$('div.tudnew #tudsubmit').click(function(e) {
				e.preventDefault();
				if (_tudakozo_all.val().length == 7) {
					_tudakozo_first.val(_tudakozo_all.val().substr(0,3));
					_tudakozo_second.val(_tudakozo_all.val().substr(3,4));
					$('div.tudnew #enquiry-form').submit();
				} else {
					alert('Ellenőrizd a formátumot!');
				}
			});

			/* OLD
			var _tudakozo_first = $('div.enquiryBox input.first');
			var _tudakozo_second = $('div.enquiryBox input.second');

			_tudakozo_first.keyup(function(){
				if($(this).val().length==3){
					_tudakozo_second.focus();
				} else {
					_tudakozo_second.val('');
				}
			});

			_tudakozo_second.keyup(function(e){
				if (_tudakozo_first.val().length<3){
					$(this).val('');
					var chr = String.fromCharCode(e.which);
					_tudakozo_first.val(_tudakozo_first.val() + chr).focus();
				} else {
					if($(this).val().length==0){
						_tudakozo_first.focus();
					}
				}
			});

			_tudakozo_second.click(function(e){
				if(_tudakozo_first.val().length<3){
					_tudakozo_first.focus();
				}
			});
			//caret position ie fix
			if(IE){
				$('div.enquiryBox input:text').bind('focus',function(){
					var r = this.createTextRange();
					r.moveStart('character', this.value.length);
					r.select();
				});
			}
			*/


			// slider

			if ($('.slider').length > 0){

				var sliderMin = parseInt($('#min-price').val());
				var sliderMax = parseInt($('#max-price').val());
				var sliderMinInit = parseInt($('#min-price-init').val()) || sliderMin;
				var sliderMaxInit = parseInt($('#max-price-init').val()) || sliderMax;
				var _price_span = $('.mobile-price span.price');
				var _price_span_pos = 0;

				$('.slider').slider({
					range: true,
					values: [sliderMinInit, sliderMaxInit],
					step: 1000,
					min: sliderMin,
					max: sliderMax,
					slide: function(event, ui) {

							var minPercent = (ui.values[0] * 100) / (sliderMax - sliderMin);
							var maxPercent = (ui.values[1] * 100) / (sliderMax - sliderMin);

							_price_span.html(ui.values[0] + ' Ft – ' + ui.values[1] + ' Ft');
							$('#min-price').val(ui.values[0]);
							$('#max-price').val(ui.values[1]);

							_price_span_pos = (minPercent + ( maxPercent - minPercent ) / 2)/100*338 - parseInt(_price_span.width())/2;

							if (_price_span_pos < 0){
								_price_span_pos = 0;
							} else if(_price_span_pos > 338 - parseInt(_price_span.width())) {
								_price_span_pos = 338 - parseInt(_price_span.width());
							}

							_price_span.css('margin-left', _price_span_pos);
						}
				});

				_price_span.html(sliderMinInit + ' Ft – ' + sliderMaxInit + ' Ft');
				var minPercent = (sliderMin * 100) / (sliderMax - sliderMin);
				var maxPercent = (sliderMax * 100) / (sliderMax - sliderMin);

				_price_span_pos = (minPercent + ( maxPercent - minPercent ) / 2)/100*338 - parseInt(_price_span.width())/2;

				if (_price_span_pos < 0){
					_price_span_pos = 0;
				} else if(_price_span_pos > 338 - parseInt(_price_span.width())) {
					_price_span_pos = 338 - parseInt(_price_span.width());
				}

				_price_span.css('margin-left', _price_span_pos);

			}



			// keszulek kereso
			if ($('div.mobile-holder').length > 0){
				$('div.mobile-holder ul li, div.brands ul li a').click(function(e){
					e.preventDefault();
				});
				$('div.mobile-holder ul li, div.brands ul li').click(function(e){

					if ($(this).hasClass('sel')){
						$(this).removeClass('sel').find('input').attr('checked', false);
					} else{
						$(this).addClass('sel').find('input').attr('checked', true);
					}

				});
			}

			// internet csomag valaszto gombok
			if ($('#package_net').length > 0){

				var _package_net = $('#package_net');

				Calculator.init();

				$('button', _package_net).click(function(e){
					$(this).addClass('sel').siblings('button').removeClass('sel');
					var idx = $(this).parents('div.value').find('button').index(this);
					$(this).parents('div.value').find('input:radio').eq(idx).click();

				});
			}

			// fooldal akcios mobilok
			if ($('body.indexpage div.mobile, body.mobilelist div.mobile').length > 0){
				$('body.indexpage div.mobile, body.mobilelist div.mobile').click(function(e){

					if (IE){
						window.location.href = '/'+$(this).find('a').attr('href');
					} else {
						window.location.href = $(this).find('a').attr('href');
					}

				});
			}


			// altalanos egykepes felugro
			if ($('a.zoomable').length > 0){
				$('a.zoomable').click(function(e){
					e.preventDefault();
					$('div#popupwrp a.next, div#popupwrp a.prev').css('visibility', 'hidden');
					$('div#popupwrp div.imageBox div.image img').attr({'src': $(this).attr('href'), 'title':'Kattints a bezáráshoz'}).click(function(e){
						setTimeout(function(){
							$('div#popupwrp a.prev, div#popupwrp a.next').show();
							$('div#popupwrp div.info').css('margin-left', 0);
						},500);
						$("div#popupwrp div.popup a.close").click();
					});
					var imgbox = $('#popupwrp .imageBox');
					$('span.title', imgbox).html($(this).attr('title'));
					$('span.description', imgbox).html($(this).find('img').attr('alt'));
					$('span.counter', imgbox).empty();

					$('<div id="fader"></div>').appendTo('body').fadeTo(500, 0.5, function()
					{
							if(IE)
								$('#popupwrp div.imageBox').show();
							else
								$('#popupwrp div.imageBox').fadeIn();
					});

				});
			}


			// galeria csukas
			$('#fader').live('click', function(e){
				setTimeout(function(){
					var pw = $('#popupwrp');
					$('a.prev, a.next', pw).show();
					$('div.info', pw).css('margin-left', 0);
				},500);
				$("#popupwrp .popup .close").click();
			});


			// android tips and tricks
			if ($('.android #tipstricks').length > 0){

				var tipstricks = $('.android #tipstricks');

				$('ul li', tipstricks).click(function(e){
					var th = $(this);
					th.addClass('open').siblings().find('p').slideUp(300, function(){
						th.find('p').slideDown(300,function(){
							th.siblings().removeClass('open');
						});
					 });

				});
				$('ul li h4 a', tipstricks).click(function(e){
					e.preventDefault();
					e.stopPropagation();
					var th = $(this).parents('li:eq(0)');
					th.find('p').slideUp(300, function(){
						th.removeClass('open');
					});
				});

				setTimeout(function(){
					$('.android #tipstricks ul li:eq(0)').trigger('click');
				},369);

			}

			// android apps
			if ($('.androidApp').length>0){

				$('.androidApp').appendTo('body');

				$('.android a.install').click(function(e){
					e.preventDefault();
					//var index = $(".android a.install").index(this);
					//var index = $(this).closest('.item').index();
					var index = $(this).parent().parent().index();
					site.showAndroidApp(index);
					if (IE6){
						$(window).scrollTop(0);
					}


				});

				$('.androidApp a.close').click(function(e){
					e.preventDefault();
					$(this).parents('.androidApp').fadeOut(500);
					$("#popupwrp .popup .close").click();

				});
			}

			$('div.cont div.phone_listing div.result-list h3').each(function() {
				if ($(this).height() > 52) {
					$(this).find('span.rating').addClass('inline');
				}
			});

			$('div.cont div.phone_listing ul.order-type li.list a, div.cont div.phone_listing ul.order-type li.grid a').each(function() {
				$(this).click(function(e) {
					e.preventDefault();
					Cufon.refresh();
					$('div.cont div.phone_listing ul.order-type li.list, div.cont div.phone_listing ul.order-type li.grid').removeClass('active');
					$(this).parent().addClass('active');
					$('div.cont div.phone_listing div.result-list h3').each(function() {
						if ($(this).height() > 44) {
							$(this).find('span.rating').addClass('inline');
						}
					});
				});
			});

			$('div.phone_listing div.left ul.manufacturers').each(function() {
				$(this).buttonset();
			});

			$('div.phone_listing div.left ul.style').each(function() {
				$(this).buttonset();
			});

			$('div.phone_listing div.left div.settings-box.price div.tariff').each(function() {
				$(this).buttonset();
			});

			$('div.phone_listing div.left div.settings-box.properties').each(function() {
				$(this).buttonset();
			});

			$('div.cont div.phone_listing select#order-select').each(function() {
				$(this).selectmenu({
					select: function(event){
						$('#order').val($('select#order-select').val());
						$('#search-form').submit();
					}
				});
			});

			$('ul#order-select-menu li').each(function() {
			});

			site.selMainPage();

			scroller();

			site.IEfix();
			site.IE6fix();
			site.IE7fix();

			site.cufon();
			site.fancyHeading();

			// phone listings functions

			setTimeout(function() {
				$('div.cont div.phone_listing div.result-list h3').each(function() {
					if ($(this).height() > 44) {
						$(this).find('span.rating').addClass('inline');
					}
				})}, 500);

			site.pageTracker();

			// overlay handling
			Overlay.initialize();
			// /overlay handling

			/* TEST *
			$('div.cont div.side div.menu a').click(function() {
				this.blur();
				$('div.cont div.side div.menu li:has(ul):has(a.active)').removeClass('open');
				$('div.cont div.side div.menu a').removeClass('active');
				$(this).addClass('active');
				$('div.cont div.side div.menu li:has(ul):has(a.active)').addClass('open');
				return false;
			});
			/* /TEST */

			Basket.init();

		}, // /initialize

		// GA tracker
		pageTracker: function(){

			// megadropdown promo
			$('.head .menu .submenu .promo a').click(function(){
				_gaq.push(['_trackEvent', 'Mega-drop-down', $('.head .smallmenu li.active').text() + ' / ' + $(this).parents('li').eq(0).find('a').eq(0).text(), $(this).find('.title').text()]);
			});

			// megadropdown kulcsszo
			$('.head .menu .submenu .keywords a').click(function(){
				_gaq.push(['_trackEvent', 'Mega-drop-down', $('.head .smallmenu li.active').text() + ' / ' + $(this).parents('li').eq(0).find('a').eq(0).text(), $(this).text()]);
			});

			// Tarifakereso
			$('#tariff-search li a').click(function(e){
				_gaq.push(['_trackEvent', 'Tarifakereső ', $('.head .smallmenu li.active').text() +' nyitó', $(this).text()]);
			});

			// keszulek kereso
			$('.mobile-holder + .button button').click(function(e){
				_gaq.push(['_trackEvent', 'Készülékkereső ', $('.head .smallmenu li.active').text() +' nyitó']);
			});

			// het kerdese
			$('.questionlist > p > a').click(function(e){
				_gaq.push(['_trackEvent', $('.head .smallmenu li.active').text() +' nyitó', 'Link', 'Hét kérdése']);
			});

			// nyito/linkek
			$('.questionlist > ul > li > a').click(function(e){
				_gaq.push(['_trackEvent', $('.head .smallmenu li.active').text() +' nyitó', 'Link', $(this).text()]);
			});

			// tudakozo
			$('.tudakozo form > div > button').click(function(e){
				_gaq.push(['_trackEvent', $('.head .smallmenu li.active').text() +' nyitó', 'Tudakozó', 'Keres']);
			});

			// tudakozo/reszletes kereses
			$('.tudakozo form > div > a[target=_blank]').click(function(e){
				_gaq.push(['_trackEvent', $('.head .smallmenu li.active').text() +' nyitó', 'Tudakozó', 'Részletes']);
			});

			// ujdonsagok
			$('#news-scroll .items a').click(function(e){
				_gaq.push(['_trackEvent', $('.head .smallmenu li.active').text() +' nyitó', 'Újdonságok', $(this).find('span:eq(1) strong').text()]);
			});

			// ajanlatkeres
			$('#offer_request > div > button').click(function(e){
				_gaq.push(['_trackEvent', 'Vállalatok nyitó', 'Ajánlat kérés']);
			});

			// esettanulmanyok, lefedettseg
			$('.coverage a').click(function(e){
				_gaq.push(['_trackEvent', $('.head .smallmenu li.active').text() +' nyitó', $('.coverage > h2').text(), $(this).find('span').text()]);
			});

			// mobil/keszulekkereso
			$('.keszulekkereso form .button button').click(function(e){
				var _type;
				if($('.smallmenu ul li:eq0').hasClass('active')){
					_type = 'Lakossági';
				} else {
					_type = 'Üzleti';
				}
				_gaq.push(['_trackEvent', 'Készülékkereső', _type + ' - Készülékek']);
			});

			// gyartolista
			$('.manufacturers ul li a').click(function(e){
				var _type;
				if($('.smallmenu ul li:eq0').hasClass('active')){
					_type = 'Lakossági';
				} else {
					_type = 'Üzleti';
				}
				_gaq.push(['_trackEvent', 'Készülék', _type + ' - ' + $(this).text()]);
			});

			// keszulek kereso oldal
			$('.mobilelist #search-form .button button').click(function(e){
				var _type;
				if($('.smallmenu ul li:eq0').hasClass('active')){
					_type = 'Lakossági';
				} else {
					_type = 'Üzleti';
				}
				_gaq.push(['_trackEvent', 'Készülékkereső', _type + ' - Kereső']);
			});


			// klk vegoldal / megrendelem
			$('.submit_netshop').click(function(e){
				var _type;
				if($('.smallmenu ul li:eq0').hasClass('active')){
					_type = 'Lakossági';
				} else {
					_type = 'Üzleti';
				}
				_gaq.push(['_trackEvent', 'Készülék - Netshop', _type, $('div.package.selected .inside input[name=offer_name]').val()]);
			});

		},
		// /GA tracker

		// cufon
		cufon: function() {

			if ($('body').not('.mobile').length > 0){

				var toCufon = $('div.head > div.smallmenu > ul > li > a > b')
				.add('div.head > div.menu > ul > li > a > b')
				.add('div.head > div.lang > ul > li > a > b')
				.add('div.head div.menu div.submenu span.title')
				.add('div.head div.menu div.submenu big')
				.add('div.cont div.box h6, div.cont div.related h6, div.cont div.box_link a')
				.add('div.cont h1, div.cont h2:not(div.cont div.phone_pack div.pack div.yourchoice div.recommend h2), div.cont h3:not(div.cont div.phone_listing div.result-list div.device h3), div.cont h4, div.content div.highlight em')
//				.add('div#phoneAttr div.attr h6, div#phonePack h6, div#phonePack h5, div#phonePack h4, div#phonePack h3, div#phonePack a.button b')
				.add('div.cont div.phone_pack div.properties h6, div.cont div.phone_pack div.yourchoice h5, div.cont div.phone_pack div.pack div.yourchoice div.result h6, div.cont div.phone_attr h5, div.cont div.phone_attr h6')
				.add('div.cont div.phone_pack div.yourchoice .big_orange')
				.add('div.cont div.phone_attr div.content div.table table .th1, div.cont div.phone_attr div.content div.table table .th3')
				.add('div.content div.more a')
				.add('div.item span.date')
				.add('div.more a')
				.add('div.tudakozo form a')
				.add('#tariff-search li a')
				.add('form button')
				.add('div.coverage ul li')
				.add('div.tabs')
				.add('body.indexpage div.tariff-accent.phonePack a.more')
				.add('.android a.more')
				.add('.android .recommended ul li a')
				.add('div.moreNews a')
				.add('div.cont div.content div.sider h5')
				.add('div.cont div.selected-tariff div')
				.add('.androidApp h2')
				.add('.android a.morenews')
				.add('div.footer div.foot div.contentTop h3')
				.add('.spring-block li')
				.add('div.phoneRotator ul.products li div.price')
				.add('body.indexpage div.cont div.productFinder a.btnSearch')
				.add('body.indexpage div.cont div.aboutUs div.itemList div.item div.data h6')
				.add('body.indexpage div.tariff-chooser ul li a span')
				.add('body.indexpage div.tariff-chooser-2 ul li a span')
				.add('div.phone_listing ul.order-type li a span')
				.add('div.phone_listing div.result-list div.device h3 a')
				.add('div.phone_listing ul.device-type li a')
				.add('div.phone_listing div.right div.settings div.settings-box h2')
				.add('div.content.basket div.basket div.data span:not(.nocufon)')
				.add('div.content.basket div.basket div.data ins')
				.add('div.cont div.content.hipernet-samsung-netbook div.detail-box div.price-box p')
				.add('div.cont div.content.hipernet-samsung-netbook div.detail-box h5')
				.add('div.cont div.content.hipernet-samsung-netbook div.detail-box ul li')
				.add('div.cont div.textbox_blue, div.cont div.textbox_gray')
				.add('div.android div.apps-scroll ul.items li span.price')
				.add('div.cont div.content *.cufont')
				.add('div.epitse-vallalkozasat h2 a,div.epitse-vallalkozasat p.top4,div.epitse-vallalkozasat span.price')
				.add('div.okostelefonok h1,div.okostelefonok h2,div.okostelefonok h3,div.okostelefonok .device-details *,div.okostelefonok .device-details-more *')
				.add('div.lumia-landing h1,.lumia-landing p.smalltext,.lumia-landing .device-details *')
				.add('div.dell-laptop-akcio .head-promo .head-box.box1 p, div.dell-laptop-akcio .head-promo .head-box.box2 ul, div.dell-laptop-akcio .head-promo .head-box.box3 a strong, div.dell-laptop-akcio .middle-promo ul, div.dell-laptop-akcio .middle-promo a.more, div.dell-laptop-akcio .full-table table thead tr td, div.dell-laptop-akcio .full-table table tbody tr td.title strong, div.dell-laptop-akcio .full-table small, div.dell-laptop-akcio .full-table table tbody tr:first-child td p, div.dell-laptop-akcio .full-table table tbody tr td')
				.add('div.mbi-landing .cfntxt,div.mbi-landing ul.cfntxt li')
				;

				if ($.browser.opera) {
					Cufon.replace(toCufon);
				} else {
					Cufon.replace(toCufon, {autoDetect: true, hover: true});
				}

				$('div.head > div.menu > ul > li').hover(
					function() {
						var that = this;
						setTimeout(function() {
							Cufon.replace($(that).find('b').eq(0));
						}, 10);
					},
					function() {
						var that = this;
						setTimeout(function() {
							Cufon.replace($(that).find('b').eq(0));
						}, 10);
					}
				);

	/*			if ($.browser.opera){
						Cufon.replace($('h1, h2'));
						Cufon.replace($('span, a, b, h3, h4, h5, h6'), {hover: true});
						Cufon.replace($('div.head div.menu > ul > li > a > b'), {hover: true});
					} else {
						Cufon.replace($('h1, h2'), {autoDetect: true});
						Cufon.replace($('span, a, b, h3, h4, h5, h6'), {hover: true, autoDetect: true});
						Cufon.replace($('div.head div.menu > ul > li > a > b'), {hover: true, autoDetect: true});
					}*/

				Cufon.replace('div.cont div.content > h1, div.content div.inner > h1, div.phone_listing h1', {
					color: '-linear-gradient(#0a416c, #0e7cb3, #0a416c)'
				});

				Cufon.replace('div.footer div.foot div.contentTop div.rightBlock span.phone', {
					color: '-linear-gradient(#ff7300, #ff5100)'
				});

				Cufon.replace('body.indexpage div.cont div.itemList h2', {
					color: '-linear-gradient(#0a416c, #0e7cb3, #0a416c)'
				});

				Cufon.replace('body.indexpage div.cont div.contacts h2', {
					color: '-linear-gradient(#0a416c, #0e7cb3, #0a416c)'
				});

			}

		},
		// /cufon

		fancyHeading: function(){
			$('div.content div.inner > h1, div.phone_listing h1').append('<span class="texture"></span>');
		}

	}
	// /return

}();
// /site


/* phonepage from 2011.03.10. */
var phonepage = new function() {

	this.toInteger = function(s) {
		var tmp = '';
		for (var i=0; i<s.length; i++) {
			if ((s.charCodeAt(i) >= 48 && s.charCodeAt(i) <= 57) || s.charAt(i) == ',') {
				tmp += s.charAt(i);
			}
		}
		return tmp; //parseInt('0' + tmp, 10);
	},

	this.serviceIndex = function() {
		return (($('input#cb_service:checked').length > 0) ? 1 : 0);
	},

	this.isNetshop = function(tariffval) {
		return (($('#price option:selected').parent().hasClass('netshop')) && tariffval && phonepackage[tariffval]['netshop_allowed'] ? true : false);
	},



	this.showResult = function() {
		var price = $('#price');
		var tariff = $('#tariff');
		var loyality = $('#loyality');
		var service = $('#cb_service');

		var priceval = price.val();
		var tariffval = tariff.val();
		var loyalityval = loyality.val();
		var serviceval = phonepage.serviceIndex();
		var tmp = null;

		if (phonepage.isNetshop(tariffval)) {
			$('div#phone_discount').html('<p>'
										+ ((parseInt(String(phonepackage[tariffval]['loyality'][loyalityval]['netshop'][serviceval]['discount']['amount']).split('(')[1].split('%')[0], 10) > 5) ? '<b class="emphasize4">Extra kedvezménnyel!</b><br />' : '')
										+ 'online kedvezmény: '
										+ phonepackage[tariffval]['loyality'][loyalityval]['netshop'][serviceval]['discount']['amount']
										+ (phonepackage[tariffval]['loyality'][loyalityval]['netshop'][serviceval]['discount']['shopprice'] ? '<br /> bolti ár: ' + phonepackage[tariffval]['loyality'][loyalityval]['netshop'][serviceval]['discount']['shopprice'] + ' Ft' : '')
										+ '</p>');
			$('a#phone_netshop').attr('href', phonepackage[tariffval]['loyality'][loyalityval]['netshop'][serviceval]['netshoplink']);
		} else {
			$('div#phone_discount').html('');
		}
		$('div#phone_result').html('<h6><small>Havidíj:</small> ' + (phonepackage[tariffval]['fee'][serviceval] == '' || phonepackage[tariffval]['fee'][serviceval] == null ? 'nincs' : phonepackage[tariffval]['fee'][serviceval] + ' Ft') + '</h6>' + phonepackage[tariffval]['description']);
		$('#tariffName, #tariffName_sel').attr('value', tariff.find('option:selected').html());
		$('#commitmentName, #commitmentName_sel').attr('value', loyality.find('option:selected').html());
	},



	this.packHandler = function() {
		var price = $('#price');
		var tariff = $('#tariff');
		var tariff_full = $('#tariff_full');
		var loyality = $('#loyality');
		var loyality_full = $('#loyality_full');
		var service = $('#cb_service');
		var pricevars;

		price.data('changed', false);
		tariff.data('changed', false);
		loyality.data('changed', false);
		service.data('changed', false);



		// selecting a price
		price.change(function(e, triggered) {
			var priceval = price.val();;
			var tariffval = tariff.val();
			var tmp = null;

			// tariff select building
			eval('pricevars = {' + $(this).find('option:selected').attr('class') + '}');
			tariff.find('option').remove();
			tariff_full.find('option').clone(true).appendTo(tariff.find('optgroup#tariff_no'));
			for (var i in pricevars.tariff) {
				tariff.find('optgroup#tariff_no option[value=' + pricevars.tariff[i] + ']').appendTo(tariff.find('optgroup#tariff_yes'));
			}

			if (!$('optgroup#tariff_no option').length) {
				$('optgroup#tariff_no, optgroup#tariff_sep').hide();
			} else {
				$('optgroup#tariff_no, optgroup#tariff_sep').show();
			}

			// tariff change
			if (!triggered) {
				tariff.find('option[value=' + pricevars.selected + ']').attr('selected', 'selected');
				tariff.trigger('change', true);
			} else {
				tariff.find('option[value=' + tariffval + ']').attr('selected', 'selected');
				phonepage.showResult();
			}

			// netshop or shop
			tariffval = tariff.val();
			if (phonepage.isNetshop(tariffval)) {
				$('div#buttons_shop').addClass('hidden');
				$('div#buttons_netshop').removeClass('hidden');
			} else {
				$('div#buttons_netshop').addClass('hidden');
				$('div#buttons_shop').removeClass('hidden');
			}

		});



		// selecting tariff
		tariff.change(function(e, triggered) {
			var priceval = price.val();
			var tariffval = tariff.val();
			var tmp = false;

			// tariff has service?
			if (phonepackage[tariffval]['service'].length > 0) {
				$('div#service').removeClass('hidden');
				$('div#service label').text(phonepackage[tariffval]['service']);
				$('div#service_advert').removeClass('hidden').html(phonepackage[tariffval]['advert']);
			} else {
				$('div#service').addClass('hidden');
				$('div#service_advert').addClass('hidden');
			}

			// loyality select building
			loyality.find('option').remove();
			for (var i in phonepackage[tariffval]['loyality']) {
				loyality_full.find('option[value=' + i + ']').clone(true).appendTo(loyality).text(phonepackage[tariffval]['loyality'][i]['text']);
			}

			service.removeAttr('checked');
			if (!triggered) {
				for (var i in phonepackage[tariffval]['loyality']) {
					if (tmp) {
						break;
					}
					for (var j in {'netshop': 'netshop', 'shop': 'shop'}) {
						if (tmp) {
							break;
						}
						for (var k=0; k<2; k++) {
							if ((phonepackage[tariffval]['loyality'][i][j][k] != null) && (price.find('option[value=' + phonepackage[tariffval]['loyality'][i][j][k]['value'] + ']').length > 0)) {
								loyality.find('option[value=' + i + ']').attr('selected', 'selected');
								price.find('option[value=' + phonepackage[tariffval]['loyality'][i][j][k]['value'] + ']').attr('selected', 'selected');
								if (k == 1) {
									service.attr('checked','checked');
								}
								tmp = true;
								break;
							}
						}
					}
				}
				loyality.trigger('change', true);
				price.trigger('change', true);
			} else {
				for (var i in phonepackage[tariffval]['loyality']) {
					if (tmp) {
						break;
					}
					for (var k=0; k<2; k++) {
						if ( (priceval == (phonepackage[tariffval]['loyality'][i]['shop'][k] || {value: ''})['value']) || (priceval == (phonepackage[tariffval]['loyality'][i]['netshop'][k] || {value: ''})['value']) ) {
							loyality.find('option[value=' + i + ']').attr('selected', 'selected');
							service.removeAttr('checked');
							if (k == 1) {
								service.attr('checked','checked');
							}
							tmp = true;
							break;
						}
					}
				}
				loyality.trigger('change', true);
				phonepage.showResult();
			}

		});



		// here comes the package info showing
		loyality.change(function(e, triggered) {

			var priceval = price.val();
			var tariffval = tariff.val();
			var loyalityval = loyality.val();
			var tmp = false;

			if (!triggered) {
				service.removeAttr('checked');
				for (var j in {'netshop': 'netshop', 'shop': 'shop'}) {
					if (tmp) {
						break;
					}
					for (var k=0; k<2; k++) {
						if ((phonepackage[tariffval]['loyality'][loyalityval][j][k] != null) && (price.find('option[value=' + phonepackage[tariffval]['loyality'][loyalityval][j][k]['value'] + ']').length > 0)) {
							price.find('option[value=' + phonepackage[tariffval]['loyality'][loyalityval][j][k]['value'] + ']').attr('selected', 'selected');
							if (k == 1) {
								service.attr('checked','checked');
							}
							tmp = true;
							break;
						}
					}
				}
				price.trigger('change', true);
			} else {
			}

		});

		service.change(function() {
			this.blur();

			var priceval = price.val();;
			var tariffval = tariff.val();
			var loyalityval = loyality.val();
			var serviceval = phonepage.serviceIndex();
			var netshopval = phonepage.isNetshop(tariffval);
			var tmp = false;

			for (var j in (netshopval ? {'netshop': 'netshop', 'shop': 'shop'} : {'shop': 'shop', 'netshop': 'netshop'})) {
				if (tmp) {
					break;
				}
				if (phonepackage[tariffval]['loyality'][loyalityval][j][serviceval] != null) {
					price.find('option[value=' + phonepackage[tariffval]['loyality'][loyalityval][j][serviceval]['value'] + ']:eq(0)').attr('selected', 'selected');
					tmp = true;
					break;
				} else {
					for (var i in phonepackage[tariffval]['loyality']) {
						if (phonepackage[tariffval]['loyality'][i][j][serviceval] != null) {
							loyality.find('option[value=' + i + ']').attr('selected', 'selected');
							price.find('option[value=' + phonepackage[tariffval]['loyality'][i][j][serviceval]['value'] + ']:eq(0)').attr('selected', 'selected');
							tmp = true;
							break;
						}
					}
				}
			}
			loyality.trigger('change', true);
			price.trigger('change', true);

		});

		// phonepack integer values correction
		var tmp = '';
		for (var i in phonepackage) {
			for (j=0; j<2; j++) {
				if (phonepackage[i]['fee'][j] && typeof(phonepackage[i]['fee'][j]) != 'number') {
					phonepackage[i]['fee'][j] = phonepage.toInteger(phonepackage[i]['fee'][j]);
				}
			}
		}

		// select the price
		price.trigger('change', false);

	};




	this.initialize = function() {

		if ($('div#phonepage').length > 0) {

			var a = Array();
			var tmp = null;

			//$('div.cont div.phone_pack div.product div.rater').hover(function() {$(this).find('div.summa').removeClass('hidden');}, function() {$(this).find('div.summa').addClass('hidden');});



			/* suggestion form */
			$('div#phonepage div#em').click(function() {
				$('div#phonepage div#suggestform').removeClass('hidden');
				return false;
			});
			$('div#phonepage div#suggestform').find('div.close').click(function() {
				$('div#phonepage div#suggestform').addClass('hidden');
				return false;
			});
			/* /suggestion form */

			/* ask offer form */
			$('div#phonepage a#askoffer').click(function() {
				$('div#phonepage div#offerform form').ajaxForm({
					dataType: 'json',
					success: function(data) {
						$("div#phonepage div#offerform form div.field").removeClass("error");
						if (data.ok) {
							$("div#phonepage div#offerform form").clearForm();
							$("div#phonepage div#offerform form fieldset.thankyou").removeClass("hidden");
						} else {
							for (var i in data.fields) {
								$("div#phonepage div#offerform form input[name="+data.fields[i]+"]").parents("div.field").addClass("error");
							}
						}
					}
				});
				$('div#phonepage div#offerform').removeClass('hidden');
				return false;
			});
			$('div#phonepage div#offerform').find('div.close').click(function() {
				$('div#phonepage div#offerform').addClass('hidden');
				return false;
			});
			/* /ask offer form */

			/* ask offer form tel */
			$('div#phonepage a#askoffer_tel, div#phonepage a#askoffer_tel2').click(function() {
				$('div#phonepage div#offerform_tel form').ajaxForm({
					dataType: 'json',
					success: function(data) {
						$("div#phonepage div#offerform_tel form div.field").removeClass("error");
						if (data.ok) {
							$("div#phonepage div#offerform_tel form").clearForm();
							$("div#phonepage div#offerform_tel form fieldset.input").addClass("hidden");
							$("div#phonepage div#offerform_tel form fieldset.thankyou").removeClass("hidden");
						} else {
							for (var i in data.fields) {
								$("div#phonepage div#offerform_tel form input[name="+data.fields[i]+"], div#phonepage div#offerform_tel form textarea[name="+data.fields[i]+"]").parents("div.field").addClass("error");
							}
						}
					}
				});
				$('div#phonepage div#offerform_tel').removeClass('hidden');
				return false;
			});
			$('div#phonepage div#offerform_tel').find('div.close').click(function() {
				$('div#phonepage div#offerform_tel').addClass('hidden');
				return false;
			});
			/* /ask offer form tel */

			/* zoom */
			$('div#zoom').click(function() {
				$('div#items div.item:eq(' + $('div#thumbs div.thumb.active').index() + ') a').trigger('click');
			});
			/* /zoom */

			/* gallery colors */
			if ($('div#cols a').length > 0) {
				$('div#zoomcolors').addClass('colors');
				$('div#cols').width($('div#cols a').length * 24 - 8);
				if ($('div#colors').width() < $('div#cols').width()) {
					$('div#cols').mousemove(function(e) {
						var ow = $(this).parent().width();
						var iw = $(this).width();
						var x = e.pageX - $(this).parent().offset().left;
						var l = (ow < iw) ? Math.round((Math.sin((x/ow-1/2)*Math.PI)+1)/2 * (ow-iw)) : 0;
						$(this).css({left: l + 'px'});
					});
				}
			}
			/* /gallery colors */

			/* gallery images, thumbnails */
			$('div#items').width($('div#items div.item').length * 300);
			$('div#thumbs').width($('div#thumbs div.thumb').length * 60);
			if ($('div#thumbnails').width() < $('div#thumbs').width()) {
				$('div#thumbs').mousemove(function(e) {
					var ow = $(this).parent().width();
					var iw = $(this).width();
					var x = e.pageX - $(this).parent().offset().left;
					var l = (ow < iw) ? Math.round((Math.sin((x/ow-1/2)*Math.PI)+1)/2 * (ow-iw)) : 0;
//					var l = (ow < iw) ? Math.round((x/ow) * (ow-iw)) : 0;
					$(this).css({left: l + 'px'});
				});
			}
			$('div#thumbs div.thumb').each(function(i) {
				$(this).find('a').data('index', i);
				$(this).find('a').click(function() {
					$('div#items').animate({left: String(0-$(this).data('index')*300) + 'px'}, 'fast' );
					$('div#thumbs div.thumb').removeClass('active');
					$(this).parent().addClass('active');
					return false;
				});
			});
			if ($('div#thumbs div.thumb').length > 1) {
				$('div#phonepage div.gallery div.prev').click(function() {
					var tmp = $('div#thumbs div.thumb.active');
					tmp = (tmp.prev().length != 1) ? tmp.parent().find('div.thumb:last') : tmp.prev();
					$('div#thumbs').animate({left: Math.round(Math.min(0, Math.max($('div#thumbnails').width() - $('div#thumbs').width(), $('div#thumbnails').offset().left - (tmp.index()-1/2)*tmp.width()))) + 'px' }, 'fast');
					tmp.find('a').trigger('click');
				});
				$('div#phonepage div.gallery div.next').click(function() {
					var tmp = $('div#thumbs div.thumb.active');
					tmp = (tmp.next().length != 1) ? tmp.parent().find('div.thumb:first') : tmp.next();
					$('div#thumbs').animate({left: Math.round(Math.min(0, Math.max($('div#thumbnails').width() - $('div#thumbs').width(), $('div#thumbnails').offset().left - (tmp.index()-1/2)*tmp.width()))) + 'px' }, 'fast');
					tmp.find('a').trigger('click');
				});
			} else {
				$('div#phonepage div.gallery div.prev, div#phonepage div.gallery div.next').addClass('hidden');
			}
			$('div#thumbs div.thumb a:eq(0)').trigger('click');
			/* /gallery images, thumbnails */

			/* features */
			$('div#phonepage div.features div.items').width($('div#phonepage div.features div.items div.item').length * 47 - 11);
			if ($('div#phonepage div.features').width() < $('div#phonepage div.features div.items').width()) {
				$('div#phonepage div.features div.items').mousemove(function(e) {
					var ow = $(this).parent().width();
					var iw = $(this).width();
					var x = e.pageX - $(this).parent().offset().left;
					var l = (ow < iw) ? Math.round((Math.sin((x/ow-1/2)*Math.PI)+1)/2 * (ow-iw)) : 0;
					$(this).css({left: l + 'px'});
				});
			}
			$('div#phonepage div.features div.items div.item').mouseover(function() {
				$('div#phonepage div.features div.items div.item').removeClass('active');
				$(this).addClass('active');
				$('div#phonepage div.features div.description div.inner').html($(this).find('div.desc').html());
			});
			/* /features */

			/* feture list condensation */
			$('div#phonepage div.feature').find('div.item').each(function(i) {
				if (a['item'+String($(this).offset().left)]) {
					tmp = a['item'+String($(this).offset().left)];
					$(this).css({'marginTop': - ($(this).offset().top - (tmp.offset().top + tmp.outerHeight())) + 'px'});
				}
				a['item'+String($(this).offset().left)] = $(this);
			});
			/* /feture list condensation */

			phonepage.packHandler();

		}

	};

}(); // /phonepage





$.fn.embedVideoPlayer = function(videoData, thumbData, titleData) {
	swfobject.embedSWF("swf/telenor_player.swf", "flashcontent", "390", "220", "9.0.0","swf/expressInstall.swf", {video: videoData, thumb: thumbData, title: titleData, colors: "0B9CD5,FFFFFF", autoplay: true}, {allowfullscreen: true, wmode: "transparent", bgcolor: "#FFFFFF", menu: true}, {id: "telenor"});
	return $(this);
};

$(function() {

	// terkep
	$('#mapoverlay').click(function(e){
		site.showMap();
	});


	// toolbar archivum dropdown select
	$("div.cont div.content div.toolbar div.archive div.archiveList div.drop").click(function(){
		$(this).toggleClass('on');
	});

	// altalanos popup bezaro
	$("#popupwrp .popup a.close").each(function(){
		$(this).click(function(e){
			e.preventDefault();
			if(IE)
			{
				$('#popupwrp .popup, .androidApp').hide(0,function(){
					$('#fader').fadeOut(function(){
						$(this).remove();
					})
				});
			}
			else
			{
				$('#popupwrp .popup, .androidApp').fadeOut(function(){
					$('#fader').fadeOut(function(){
						$(this).remove();
					})
				});
			}
		});
	});

	// sajtoszoba login popup
	$(".cont .content .pressBox a.login").each(function(){
		$(this).click(function(e){
			e.preventDefault();
			$('<div id="fader"></div>').appendTo('body').fadeTo(500, 0.5, function(){
					if(IE)
						$('#popupwrp .pressForm').show();
					else
						$('#popupwrp .pressForm').fadeIn();
			});
		});
	});

	// galeria kep popup
	if($(".cont .content .imageList").length > 0)
	{
		var _gallery = Array();
		var _selected = 0;
		$(".cont .content .imageList img").each(function()
		{
			_selected = 0;
			var _index = _gallery.length;
			var _name = ($(this).attr('src')).replace("164x112", "471x322");
			$(this).attr('index', _index);
			$(this).attr('view', _name);
			_gallery[_index] = $(this);
			_gallery[_index].click(function(e)
			{
				e.preventDefault();
				_selected = parseInt($(this).attr('index'));
				if(_selected == 0)
					$('#popupwrp .imageBox a.prev').addClass('first');
				else
					$('#popupwrp .imageBox a.prev').removeClass('first');
				if(_selected == (_gallery.length - 1))
					$('#popupwrp .imageBox a.next').addClass('last');
				else
					$('#popupwrp .imageBox a.next').removeClass('last');

				$('#popupwrp .imageBox .image img').attr({'src': $(this).attr('view'), 'title': 'Kattints a bezáráshoz'}).click(function(e){
					setTimeout(function(){
						$('#popupwrp a.prev, #popupwrp a.next').show();
						$('#popupwrp .info').css('margin-left', 0);
					},500);
					$("#popupwrp .popup a.close").click();
				});
				$('#popupwrp .imageBox span.title').html($(this).attr('title'));
				$('#popupwrp .imageBox span.description').html($(this).attr('alt'));
				$('#popupwrp .imageBox span.counter').html((_selected + 1) + '/' + (_gallery.length));

				$('<div id="fader"></div>').appendTo('body').fadeTo(500, 0.5, function()
				{
						if(IE)
							$('#popupwrp .imageBox').show();
						else
							$('#popupwrp .imageBox').fadeIn();
				});
			});
		});

		// previous image
		$('#popupwrp .imageBox a.prev').click(function(e)
		{
			e.preventDefault();
			if(!$(this).hasClass('first'))
			{
				_selected -= 1;

				// disable multiple clicks on both direction
				$('#popupwrp .imageBox a.prev').addClass('first');
				if(!$('#popupwrp .imageBox a.next').hasClass('last')) $('#popupwrp .imageBox a.next').addClass('last');

				$('#popupwrp .imageBox .info').fadeOut(function(){
					$('#popupwrp .imageBox span.title').html(_gallery[_selected].attr('title'));
					$('#popupwrp .imageBox span.description').html(_gallery[_selected].attr('alt'));
					$('#popupwrp .imageBox .image img').attr({'src': _gallery[_selected].attr('view'), 'title': 'Kattints a bezáráshoz'}).click(function(e){
						setTimeout(function(){
							$('#popupwrp a.prev, #popupwrp a.next').show();
							$('#popupwrp .info').css('margin-left', 0);
						},500);
						$("#popupwrp .popup a.close").click();
					});
					$('#popupwrp .imageBox span.counter').html((_selected + 1) + '/' + (_gallery.length));

					$('#popupwrp .imageBox .info').fadeIn(function(){
						if(_gallery.length != 1) $('#popupwrp .imageBox a.next').removeClass('last');
						if(_selected > 0) $('#popupwrp .imageBox a.prev').removeClass('first');
					});
				});
			}
		});

		// next image
		$('#popupwrp .imageBox a.next').click(function(e)
		{
			e.preventDefault();
			if(!$(this).hasClass('last'))
			{
				_selected += 1;

				// disable multiple clicks on both direction
				if(!$('#popupwrp .imageBox a.prev').hasClass('first')) $('#popupwrp .imageBox a.prev').addClass('first');
				$('#popupwrp .imageBox a.next').addClass('last');

				$('#popupwrp .imageBox .info').fadeOut(function(){
					$('#popupwrp .imageBox span.title').html(_gallery[_selected].attr('title'));
					$('#popupwrp .imageBox span.description').html(_gallery[_selected].attr('alt'));
					$('#popupwrp .imageBox .image img').attr({'src':_gallery[_selected].attr('view'), 'title':'Kattints a bezáráshoz'}).click(function(e){
						setTimeout(function(){
							$('#popupwrp a.prev, #popupwrp a.next').show();
							$('#popupwrp .info').css('margin-left', 0);
						},500);
						$("#popupwrp .popup a.close").click();
					});
					$('#popupwrp .imageBox span.counter').html((_selected + 1) + '/' + (_gallery.length));

					$('#popupwrp .imageBox .info').fadeIn(function(){
						if(_selected < (_gallery.length-1)) $('#popupwrp .imageBox a.next').removeClass('last');
						if(_gallery.length != 1) $('#popupwrp .imageBox a.prev').removeClass('first');
					});
				});
			}
		});
	}

	// galeria video popup
	if($(".cont .videoList").length > 0)
	{
		var _videoGallery = Array();
		var _selected = 0;
		$(".cont .videoList .item").each(function()
		{
			_selected = 0;
			var _index = _videoGallery.length;
			var _title = $(this).find('img').attr('title');
			var _name = ($(this).find('img').attr('src')).replace("164x112", "300x240");
			var _video = $(this).find('img').attr('longdesc');

			$(this).attr('index', _index);
			$(this).attr('title', _title);
			$(this).attr('thumb', _name);
			$(this).attr('video', _video);

			_videoGallery[_index] = $(this);

			_videoGallery[_index].click(function(e)
			{
				e.preventDefault();
				_selected = parseInt($(this).attr('index'));
				if(_selected == 0)
					$('#popupwrp .videoBox a.prev').addClass('first');
				else
					$('#popupwrp .videoBox a.prev').removeClass('first');
				if(_selected == (_videoGallery.length - 1))
					$('#popupwrp .videoBox a.next').addClass('last');
				else
					$('#popupwrp .videoBox a.next').removeClass('last');

				var vb = $('#popupwrp .videoBox');
				$('span.title', vb).html($(this).attr('title'));
				$('.video', vb).html('<div id="flashcontent"></div>');
				$('.video', vb).embedVideoPlayer(($(this).attr('video')),($(this).attr('thumb')),($(this).attr('title')));

				$('<div id="fader"></div>').appendTo('body').fadeTo(500, 0.5, function()
				{
						if(IE)
							$('#popupwrp .videoBox').show();
						else
							$('#popupwrp .videoBox').fadeIn();
				});
			});
		});

		// previous image
		$('#popupwrp .videoBox a.prev').click(function(e)
		{
			e.preventDefault();
			if(!$(this).hasClass('first'))
			{
				_selected -= 1;

				// disable multiple clicks on both direction
				$('#popupwrp .videoBox a.prev').addClass('first');
				if(!$('#popupwrp .videoBox a.next').hasClass('last')) $('#popupwrp .videoBox a.next').addClass('last');

				$('#popupwrp .videoBox .info').fadeOut(function(){
					$('#popupwrp .videoBox span.title').html(_videoGallery[_selected].attr('title'));
					$('#popupwrp .videoBox .video').html('<div id="flashcontent"></div>');
					$('#popupwrp .videoBox .video').embedVideoPlayer((_videoGallery[_selected].attr('video')),(_videoGallery[_selected].attr('thumb')), _videoGallery[_selected].attr('title'));

					$('#popupwrp .videoBox .info').fadeIn(function(){
						if(_videoGallery.length != 1) $('#popupwrp .videoBox a.next').removeClass('last');
						if(_selected > 0) $('#popupwrp .videoBox a.prev').removeClass('first');
					});
				});
			}
		});

		// next image
		$('#popupwrp .videoBox a.next').click(function(e)
		{
			e.preventDefault();
			if(!$(this).hasClass('last'))
			{
				_selected += 1;

				// disable multiple clicks on both direction
				if(!$('#popupwrp .videoBox a.prev').hasClass('first')) $('#popupwrp .videoBox a.prev').addClass('first');
				$('#popupwrp .videoBox a.next').addClass('last');

				$('#popupwrp .videoBox .info').fadeOut(function(){
					$('#popupwrp .videoBox span.title').html(_videoGallery[_selected].attr('title'));
					$('#popupwrp .videoBox .video').html('<div id="flashcontent"></div>');
					$('#popupwrp .videoBox .video').embedVideoPlayer((_videoGallery[_selected].attr('video')),(_videoGallery[_selected].attr('thumb')), _videoGallery[_selected].attr('title'));

					$('#popupwrp .videoBox .info').fadeIn(function(){
						if(_selected < (_videoGallery.length-1)) $('#popupwrp .videoBox a.next').removeClass('last');
						if(_videoGallery.length != 1) $('#popupwrp .videoBox a.prev').removeClass('first');
					});
				});
			}
		});
	}

//  tesztel�shez
//	$(".order").click(function(){$(this).toggleClass('on');});

});

$(document).ready(function(){

	if(IE6 && $('#browser').length > 0){
		var browser = $('#browser');
		var txt = '<p>A Telenor.hu nem támogatja az Internet Explorer Ön által használt verzióját.</p>'
				+ '<p><b>Töltsön le innen egy újabb böngészőt!</b></p>'
				+ '<p><b>Your browser is no longer supported. Please upgrade a modern browser.</b></p>'
				+ '<a target="_blank" class="ie8" href="http://www.microsoft.com/hun/windows/internet-explorer/" title="Internet Explorer 8">Internet Explorer 8</a>'
				+ '<a target="_blank" class="ff" href="http://www.mozilla-europe.org/hu/firefox/" title="Mozilla Firefox">Mozilla Firefox</a>'
				+ '<a target="_blank" class="google" href="http://www.google.com/chrome/?hl=hu" title="Google Chrome">Google Chrome</a>'
				+ '<a target="_blank" class="opera" href="http://www.opera.com/" title="Opera Browser">Opera Browser</a>'
				+ '<a target="_blank" class="safari" href="http://www.apple.com/hu/safari/download/" title="Safari">Safari</a>'
				+ '<a class="close" href="#" title="Bezár">Bezár</a>';
		browser.html(txt);
		$('a.close', browser).click(function(e){
			e.preventDefault();
			browser.animate({opacity:0, marginTop:-130},250);
			$.cookie("TelenorIE6", 'closed');
		});
		browser.animate({marginTop:0},250,"linear");
	}
});


function scroller() {

	// scrollozhato tartalmak
	var scroll = $('#news-scroll, #apps-scroll');

	scroll.each(function(){

		var el = $(this);

		var elWidth = el.find('ul.items li:eq(0)').width();
		var pagePositions = new Array();
		pagePositions[0] = 0;
		var currentPage=0;
		var k = 1;
		var pager = '';
		var pagerwidth = 0;
		var itemPerPage = 5;

		// fel oldalszelesseg
		if(el.hasClass('narrow')) {
			itemPerPage = 3;
			elWidth = 174;
		}

		// kis blokk
		if(el.hasClass('mini')) {
			itemPerPage = 1;
			elWidth = 338;
		}

		// egy elem per lap
		if(el.hasClass('one')) {
			itemPerPage = 1;
		}

		// lapozo anim
		function gotoPage(page){
			$('ul.items', el).stop().animate({'margin-left': -1 * pagePositions[page] },300);
			$('.indicator ul li:eq('+page+')', el).addClass('sel').siblings().removeClass('sel');
		}


		// lap poziciok meghatarozasa
		$('ul.items li', el).each(function(j){

			if(j % itemPerPage == 0 &&  j > 0) {

				if ($(this).nextAll().length >= itemPerPage){

					pagePositions[k] = elWidth * k * itemPerPage;

				} else {

					pagePositions[k] = elWidth *  ((k-1) * itemPerPage + $(this).nextAll().length+1);

				}
				k++;

			}


		});

		// ha dupla magas
		// ket sorba torjuk a felenel
		if (el.hasClass('double')){
			$('ul.items li', el).eq(Math.ceil($('ul.items li', el).length/2)).css('clear', 'left');

			// levagjuk a pagePositions "maradekat"
			pagePositions = pagePositions.slice(0, Math.ceil($('ul.items li', el).length/2));
		}


		// lapszamok
		if (pagePositions.length>1){
			for (i = 0; i < pagePositions.length; i++){
				pager += '<li><a href="#">'+i+'. oldal</a></li>';
			}
		} else {
			$('a.pager', el).hide();
		}

		$('div.indicator ul', el).html(pager).find('li:eq(0)').addClass('sel');

		$('div.indicator ul li', el).each(function(){
			$(this).click(function(e){
				e.preventDefault();
				currentPage = $("div.indicator ul li", el).index(this);
				gotoPage(currentPage);

			});
			pagerwidth+=$(this).outerWidth();
		});


		// lapozo kozeprerendezes
		$('div.indicator ul', el).css({
			'width': pagerwidth,
			'margin-left': -1*pagerwidth/2
		});

		// lapozo gombok
		$('.prevPage',el).click(function(e){

			e.preventDefault();
			if (currentPage > 0){
				currentPage--;
				gotoPage(currentPage);
			}

		});

		$('.nextPage',el).click(function(e){

			e.preventDefault();
			if (currentPage < pagePositions.length-1){
				currentPage++;
				gotoPage(currentPage);
			}

		});
	});

}


function setCookie(c_name,value,expiredays,path,domain) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie = c_name + "=" +escape(value)
						+((expiredays==null) ? "" : ";expires="+exdate.toUTCString())
						+";path="+(typeof(path)=="undefined" ? "/" : path)
						+(typeof(domain) != 'undefined' ? ";domain="+domain : "");
}

function getCookie(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 "";
}




// overlay handling
Overlay = new function() {

	var _tmp = null;


	// overlay main elements
	var _overlayTpl = '<div class="overlay"><div class="cover"></div></div>';

	var _overlayDOM = null;
	var _contentDOM = null;

	this.overlayShow = function() {
		if (!_overlayDOM) {
			_overlayDOM = $(_overlayTpl);
			_overlayDOM.find('div.cover').click(function() {
				Overlay.overlayHide();
			});
			$('body').append(_overlayDOM);
		}
		_overlayDOM.width($('body').width()).height($(document).height());
		_overlayDOM.addClass('show');
		if (IE6) {$('select').css({visibility: 'hidden'});}
	};

	this.overlayHide = function() {
		Overlay.contentHide();
		_overlayDOM.removeClass('show');
		if (IE6) {$('select').css({visibility: 'visible'});}
	};

	this.contentShow = function() {
		if (_contentDOM != null) {
			Overlay.overlayShow();
			_overlayDOM.append(_contentDOM);
			//_contentDOM.css({top: Math.round(Math.max($(document).scrollTop() + $(window).height() / 2 - _contentDOM.outerHeight() / 2 - 8, 32)) + 'px'});
			site.IEfix();
		}
	};

	this.contentHide = function() {
		if (_contentDOM != null) {_contentDOM.remove();}
		_contentDOM = null;
	};



	// direct
	var _directItems = Array();
	var _directTpl = ''+
		'<div class="content media direct">'+
		' <div class="top"></div>'+
		' <div class="inner cont">'+
		'  <div class="media">##media##</div>'+
		'  <div class="title">##title##</div>'+
		'  <div class="paging">##paging##<div class="prev"></div><div class="next"></div></div>'+
		'  <div class="close"></div>'+
		' </div>'+
		' <div class="bot"></div>'+
		((IE) ? ' <div class="bg"></div>' : '' ) +
		'</div>';

	this.directShow = function(objIndex, items) {

/*		if (typeof items == 'string') {
			alert(items);
		} else {
			alert(items[0].href);
		}*/

		// remove visible overlay content
		Overlay.contentHide();

		// build overlay html code
		var directHtml = _directTpl;

		if (!items || (items.length == 0)) {
			if (!_directItems || (_directItems.length == 0)) {
				return false;
			}
		} else {
			if (typeof items == 'string') {
				eval('_directItems = ' + items + ';');
			} else {
				_directItems = items;
			}
		}
		objIndex = Math.max(0, Math.min(_directItems.length, objIndex));
		var directObj = _directItems[objIndex].href;
		var objType = String(directObj).split('&')[0].split('?')[0].split('.').pop().substr(0,3);
		var objVars = {title: _directItems[objIndex].title || ''};
		if (_directItems.length > 1) {
			directHtml = directHtml.split('class="content media direct"').join('class="content media"');
		}
		directHtml = directHtml.split('##title##').join(objVars.title);
		directHtml = (_directItems.length > 1) ? directHtml.split('##paging##').join((objIndex+1) + ' / ' + _directItems.length) : directHtml.split('<div class="paging">##paging##<div class="prev"></div><div class="next"></div></div>').join('');
		switch (objType) {
			case 'jpg' :
			case 'gif' :
			case 'png' :
			case 'bmp' :
				directHtml = directHtml.split('##media##').join('<img src="' + directObj + '" alt="" />');
				break;
			case 'flv' :
				directHtml = directHtml.split('##media##').join('<embed src="swf/player-licensed.swf" width="480" height="320" flashvars="file=' + directObj + '&amp;backcolor=87A520&amp;frontcolor=000000&amp;lightcolor=ffffff&amp;screencolor=000000&amp;autostart=true" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" quality="high" name="overlayvideo" id="overlayvideo" type="application/x-shockwave-flash">');
				break;
			default :
				directHtml = directHtml.split('##media##').join('not supported media format');
				break;
		}

		// create DOM object
		_contentDOM = $(directHtml);

		// setting interactive elements and events
		_contentDOM.find('div.prev').addClass((objIndex == 0) ? 'hidden' : '').click(function() {
			Overlay.directShow((_directItems.length + objIndex - 1) % _directItems.length);
		});
		_contentDOM.find('div.next').addClass((objIndex == _directItems.length-1) ? 'hidden' : '').click(function() {
			Overlay.directShow((objIndex + 1) % _directItems.length);
		});
		_contentDOM.find('div.close').click(function() {
			Overlay.overlayHide();
		});

		// show overlay content
		Overlay.contentShow();

	}
	// /direct



	// media
	var _mediaItems = Array();
	var _mediaTpl = '' +
		'<div class="overlaycontent">' +
		' <div class="media">' +
		'  <div class="inner">' +
		'   <div class="image">##media##</div>' +
		'   <div class="zoom hidden"></div><div class="prev"></div><div class="next"></div><div class="close"></div>' +
		'  </div>' +
		((IE) ? '  <div class="shadow"></div>' : '' ) +
		' </div>' +
		' <div class="medialarge hidden">' +
		'  <div class="inner">' +
		'   <div class="image">##media##</div>' +
		'   <div class="close"></div>' +
		'  </div>' +
		' </div>' +
		'</div>';

	this.mediaAdd = function(obj) {
		_mediaItems.push(obj);
	};

	this.mediaShow = function(objIndex) {
		// remove visible overlay content
		Overlay.contentHide();

		// build overlay html code
		var mediaHtml = _mediaTpl;
		var mediaObj = _mediaItems[objIndex];
		var objType = String(mediaObj.attr('href')).split('&')[0].split('?')[0].split('.').pop().substr(0,3);
		try{
			eval('var objVars = {' + String(mediaObj.attr('rel')) + '}');
		}catch(e){
			objVars = {};
		}

		objVars.title = objVars.title || '';
		objVars.info = objVars.info || '';
		objVars.lead = objVars.lead || '';

		switch (objType) {
			case 'jpg' :
			case 'jpe' :
			case 'gif' :
			case 'png' :
			case 'bmp' :
				mediaHtml = mediaHtml.split('##media##').join('<img src="' + mediaObj.attr('href') + '" alt="" />');
				break;
			case 'flv' :
				mediaHtml = mediaHtml.split('##media##').join('<embed src="swf/player-licensed.swf" width="480" height="320" flashvars="file=' + mediaObj.attr('href') + '&amp;backcolor=5DA2CE&amp;frontcolor=000000&amp;lightcolor=ffffff&amp;screencolor=000000&amp;autostart=true" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" quality="high" name="overlayvideo" id="overlayvideo" type="application/x-shockwave-flash">');
				break;
			default :
				mediaHtml = mediaHtml.split('##media##').join('not supported media format');
				break;
		}

		// create DOM object
		_contentDOM = $(mediaHtml);

		// setting interactive elements and events
		_contentDOM.find('div.prev').addClass((objIndex == 0) ? 'hidden' : '').click(function() {
			Overlay.mediaShow((_mediaItems.length + objIndex - 1) % _mediaItems.length);
		});
		_contentDOM.find('div.next').addClass((objIndex == _mediaItems.length-1) ? 'hidden' : '').click(function() {
			Overlay.mediaShow((objIndex + 1) % _mediaItems.length);
		});
		_contentDOM.find('div.media div.close').click(function() {
			Overlay.overlayHide();
		});

		if (!mediaObj.hasClass('nolarge')) {
			_contentDOM.find('div.media div.inner').mousemove(function(e) {
				Overlay.mediazoomPositioning(e);
			});
			_contentDOM.find('div.media div.image, div.media div.zoom').click(function(e) {
				_contentDOM.find('div.medialarge').removeClass('hidden');
				_contentDOM.find('div.media').addClass('hidden');
				Overlay.medialargePositioning(e);
			});
		} else {
			_contentDOM.find('div.media div.image').addClass('nolarge');
		}

		_contentDOM.find('div.medialarge div.inner').mousemove(function(e) {
			Overlay.medialargePositioning(e);
		});
		_contentDOM.find('div.medialarge div.image, div.medialarge div.close').click(function() {
			_contentDOM.find('div.medialarge').addClass('hidden');
			_contentDOM.find('div.media').removeClass('hidden');
		});

		// positioning
		Overlay.mediaPositioning();
		$(window).resize(function() {
			Overlay.mediaPositioning();
		});

		// show overlay content
		Overlay.contentShow();
	};

	this.mediaPositioning = function() {
		var ww = $(window).width();
		var wh = $(window).height();
		_contentDOM.find('div.media').css({left: Math.round(ww/2 - wh/3) + 'px', top: '0px', width: Math.round(wh/3*2) + 'px', height: wh + 'px'});
	};

	this.mediazoomPositioning = function(e) {
		var image = _contentDOM.find('div.media div.image');
		var mx = e.pageX;
		var my = e.pageY;
		var x = mx - _contentDOM.find('div.media div.inner').offset().left;
		var y = my - _contentDOM.find('div.media div.inner').offset().top;
		var ix0 = image.offset().left;
		var iy0 = image.offset().top;
		var ix1 = ix0 + image.find('img').width();
		var iy1 = iy0 + image.find('img').height();
		if ((ix0 <= mx) && (mx <= ix1) && (iy0 <= my) && (my <= iy1)) {
			_contentDOM.find('div.zoom').removeClass('hidden');
		} else {
			_contentDOM.find('div.zoom').addClass('hidden');
		}
		_contentDOM.find('div.media div.inner div.zoom').css({left: Math.min(Math.max(x, 75), image.find('img').width()-75)  + 'px', top: y + 'px'});
	};

	this.medialargePositioning = function(e) {
		var ww = $(window).width();
		var wh = $(window).height();
		var ow = ww; //_contentDOM.find('div.medialarge div.inner').width();
		var oh = wh; //_contentDOM.find('div.medialarge div.inner').height();
		var iw = 1200;
		var ih = 1800;
		var x = e.pageX - _contentDOM.find('div.medialarge div.inner').offset().left;
		var y = e.pageY - _contentDOM.find('div.medialarge div.inner').offset().top;
		var l = (ow>iw) ? Math.round((ow-iw)/2) : Math.round((x/ow) * (ow-iw));
		var t = (oh>ih) ? Math.round((oh-ih)/2) : Math.round((y/oh) * (oh-ih));
		_contentDOM.find('div.medialarge').css({width: ww + 'px', height: wh + 'px'});
		_contentDOM.find('div.medialarge div.inner div.image').css({left: l + 'px', top: t + 'px'});
		_contentDOM.find('div.medialarge div.inner div.close').css({left: x + 'px', top: y + 'px'});
	};
	// /media



	// initialize
	this.initialize = function() {
		_tmp = 0;

		// media
		$('div.gallery div.item').each(function() {
//			var _a = $(this).find('a img').parents('a').eq(0);
			var _a = $(this).find('a').eq(0);
			Overlay.mediaAdd(_a);
			$(this).find('a').each(function() {
				if (_a.attr('href') == $(this).attr('href')) {
					this.index = _tmp;
					$(this).click(function() {
						this.blur();
						Overlay.mediaShow(this.index);
						return false;
					});
				}
			});
			_tmp++;
		});

		// direct
		$('div.cont a.directshow').each(function() {
			$(this).click(function() {
				this.blur();
				Overlay.directShow(0, [{href: this.href, title: this.title}]);
				return false;
			});
		});

	};
	// initialize

}();
// /overlay handling


/* campaigns */
$(document).ready(function() {
	$('.popeye2 .details').click(function(e){
		this.blur();
		e.preventDefault();
		$.scrollTo($(this).attr('href'),400);
		return false;
	});
});
/* /campaigns */


/* removable lines */

var phone = new function() {

	this.pContainer;
	this.p0; // package
	this.p1; // makeups
	this.p2; // buying


	this.phase0Handler = function() {

		// package selection handler
		phone.p0.find('div.packsel a').click(function() {
			this.blur();
			$(this).parents('ul:eq(0)').find('li').removeClass('active');
			$(this).parents('div:eq(0)').find('ul.sheet:not(.s0) li').removeClass('active');
			$(this).parent('li').addClass('active');
			eval('var packsel = {' + this.rel + '}');
			phone.p0.find('div.package.sheet').removeClass('s0');
			for (var i=0; i<packsel.packageIds.length; i++) {
				phone.p0.find('div.package.sheet.id' + packsel.packageIds[i]).eq(0).addClass('s0');
			}
			return false;
		});

		// package events and settings
		// jump to phase1 when selected a package
		phone.p0.find('div.package div.inside p.btn a.btn, div.package div.inside div.prices a.basket').click(function() {
			this.blur();

			if ($(this).hasClass('gotoNetshop')) {
				return true;
			} else {
				phone.phase1Handler(this.rel);
				return false;
			}
		});

		// url hash check for auto trigger
		var urlHash = parseInt(String(location.hash).split('tariffId=')[1], 10);
		if (urlHash > 0) {
			phone.p0.find('div.package.id'+urlHash+' div.inside p.btn a.btn, div.package.id'+urlHash+' div.inside div.prices a.basket').eq(0).trigger('click');
		}

		// jump back here from phase1 or phase2 when selecting a new package
		phone.p0.find('div.package div.inside a.btn.del').click(function() {
			this.blur();
			phone.pContainer.removeClass('ts0 ts1 ts2 ts3').addClass('ts0');
			return false;
		});

		// insert selectable packages to select
		phone.p0.find('div.package.packages select option').remove();
		phone.p0.find('div.package.selectable.sheet h2').each(function(i) {
			phone.p0.find('div.package.packages select').append('<option value=' + i + '>' + this.title + '</option>');
		});

		// show selected package
		phone.p0.find('div.package.packages select').change(function() {
			phone.p0.find('div.package.packages div.inside').remove();
			phone.p0.find('div.package.selectable.sheet div.inside').eq(this.value).clone(true).appendTo(phone.p0.find('div.package.packages'));
		});
		phone.p0.find('div.package.packages select').trigger('change');

		if (phone.p0.find('div.package.selectable.sheet.s0 div.inside').length == phone.p0.find('div.package.selectable.sheet div.inside').length) {
			phone.p0.find('div.package.packages').hide();
		}


		// makeup events and settings
		// makeup append to selected
		phone.p1.find('div.package.sheet div.inside p.btn a.btn.add').click(function(e) {

			e.preventDefault();

			this.blur();
			var makeupIndex = 'makeupIndex' + parseInt($(this).parents('div.inside:eq(0)').attr('class').split('makeupIndex')[1], 10);
			if (!phone.p1.find('div.package div.inside.' + makeupIndex).hasClass('added')) {
				$(this).parents('div.inside:eq(0)').addClass('added').clone(true).appendTo(phone.p1.find('div.package.selected'));
				$(this).parents('div.inside:eq(0)').parent().addClass('added');
			}
			return false;
		});

		// makeup remove from selected
		phone.p1.find('div.package.sheet div.inside a.btn.del').click(function() {
			this.blur();
			var makeupIndex = 'makeupIndex' + parseInt($(this).parents('div.inside:eq(0)').attr('class').split('makeupIndex')[1], 10);
			phone.p1.find('div.package div.inside.added.' + makeupIndex).parent().removeClass('added');
			phone.p1.find('div.package div.inside.added.' + makeupIndex).removeClass('added');
			$(this).parents('div.inside:eq(0)').remove();
			return false;
		});

		// add makeupIndex
		phone.p1.find('div.package.sheet h2').each(function(i) {
			$(this).parent().find('p.btn a.btn').attr('rel', function() {return this.rel + ', makeupIndex: ' + i;});
			$(this).parent().addClass('makeupIndex' + i);
		});

		// select default package
//		if (phone.p0.find('div.package.iamtheone').length > 0) {
//			phone.p0.find('div.package.iamtheone p.btn a.btn').trigger('click');
//		}
		// select default package/offer
		phone.p0.find('div.package.selectable a.iamtheone:eq(0)').trigger('click');

		// buying events and settings
		phone.p1.find('div.insert a.button').click(function() {
			this.blur();
			phone.pContainer.removeClass('ts0 ts1 ts2 ts3').addClass('ts1 ts2');
			phone.phase2Handler(true);
			return false;
		});

		phone.p2.find('div.form a.button').click(function() {
			this.blur();

			var submitable = false;
			var selected = phone.p1.find('div.package.selected').eq(0);

			$('#packageID').val('');
			$('#makeupIDs').val('');
			$('#phoneOwnerName').val('');
			$('#phoneNumber').val('');
			$('#emailAddress').val('');
			$('#submitType').val('');
			$('#OfferID').val('');

			selected.find('div.inside p.btn a.btn').each(function(i) {
				eval('var pitem = {' + this.rel + '}');
				if (i == 0) {
					$('#packageID').val((pitem.packageId) ? pitem.packageId : 'null');
					$('#OfferID').val((pitem.OfferID) ? pitem.OfferID : 'null');
				} else {
					$('#makeupIDs').val((pitem.makeupId) ? $('#makeupIDs').val() + (($('#makeupIDs').val().length > 0) ? ',' : '') + pitem.makeupId : 'null');
				}
			});

//			$('#phoneNumber').val( phone.p2.find('div.form0 div.select select').val() + String(parseInt('0' + phone.p2.find('div.form0 div.input input').val(), 10)) );
			$('#phoneOwnerName').val( phone.p2.find('div.form0 div.input input').eq(0).val() );
			$('#phoneNumber').val( phone.p2.find('div.form0 div.input input').eq(1).val() );
			$('#emailAddress').val( phone.p2.find('div.form2 div.input input').val() );

			if ($(this).hasClass('submit_phone')) {
				$('#submitType').val('P');
				if ($('#phoneNumber').val().length < 11) {
					phone.p2.find('div.form0').addClass('error');
				} else {
					phone.p2.find('div.form0').removeClass('error');
					submitable = true;
					$(this).parents('div.submit:eq(0)').find('div.form0.thx0').addClass('s0');
					$(this).parents('div.form0:eq(0)').removeClass('s0');
					$(this).parents('div.submit:eq(0)').find('div.form1').removeClass('s0');
				}
			}

			if ($(this).hasClass('submit_netshop')) {
				$('#submitType').val('I');
				submitable = true;
			}

			if ($(this).hasClass('submit_email')) {
				$('#submitType').val('E');
				if (($('#emailAddress').val().length < 6) || ($('#emailAddress').val().indexOf('@') < 0) || ($('#emailAddress').val().indexOf('.') < 0) ) {
					phone.p2.find('div.form2').addClass('error');
				} else {
					phone.p2.find('div.form2').removeClass('error');
					submitable = true;
					$(this).parents('div.submit:eq(0)').find('div.form2.thx2').addClass('s0');
					$(this).parents('div.form2:eq(0)').removeClass('s0');
				}
			}

			if (submitable) {
				$('form#packageForm').submit();
			}

			return false;
		});

		if ($('form#packageForm').length > 0) {
			$('form#packageForm').ajaxForm({
				success: function(data) {
					if (data != '') {
						if (data.match(/^http/)) {
							document.location = data;
						} else {
							$('#purchase').val(data);
						}
					}
				}
			});
		}
	};



	this.phase1Handler = function(packageSelected) {

		scroll(0,0);

		eval('var package = {' + packageSelected + '}');

		if (package.makeupIds != null) {

			if (package.makeupIds.length > 0) {

				// show the selected package
				phone.p1.find('div.package.selected div.inside').remove();
				phone.p0.find('div#OfferID_' + package.OfferID + '.package.sheet div.inside').clone(true).appendTo(phone.p1.find('div.package.selected'));

				// show suggested makeups for the selected packege
				phone.p1.find('div.package.sheet').removeClass('s0');
				for (var i=0; i<package.makeupIds.length; i++) {
					phone.p1.find('div.package.sheet.id' + package.makeupIds[i]).eq(0).addClass('s0');
				}

				// insert all makeups to select
				phone.p1.find('div.package.packages select option').remove();
				phone.p1.find('div.package.sheet h2').each(function(i) {
					phone.p1.find('div.package.packages select').append('<option value=' + i + '>' + this.title + '</option>');
				});

				// show selected makeup
				phone.p1.find('div.package.packages select').change(function() {
					phone.p1.find('div.package.packages div.inside').remove();
					phone.p1.find('div.package.sheet div.inside').eq(this.value).clone(true).appendTo(phone.p1.find('div.package.packages'));
				});
				phone.p1.find('div.package.packages select').trigger('change');

				if (phone.p1.find('div.package.sheet.s0 div.inside').length == phone.p1.find('div.package.sheet div.inside').length) {
					phone.p1.find('div.package.packages').hide();
				}
				if (phone.p1.find('div.package.sheet div.inside').length == 0) {
					phone.p1.find('div.makeups').hide();
				}

				// set visible phase1
				phone.pContainer.removeClass('ts0 ts1 ts2 ts3').addClass('ts1');


			} else {

				// show the selected package
				phone.p1.find('div.package.selected div.inside').remove();
				phone.p0.find('div#OfferID_' + package.OfferID + '.package.sheet div.inside').clone(true).appendTo(phone.p1.find('div.package.selected'));

				// set visible phase1
				phone.pContainer.removeClass('ts0 ts1 ts2 ts3').addClass('ts1 ts2');
				phone.p1.find('div.makeups').hide();
				phone.phase2Handler(false);

			}

		} else {

			phone.p1.find('div.package.selected div.inside').remove();
			phone.p0.find('div.package div.inside.onlydevice').eq(0).clone(true).appendTo(phone.p1.find('div.package.selected'));

			phone.pContainer.removeClass('ts0 ts1 ts2 ts3').addClass('ts1 ts2 ts3');
			phone.phase2Handler(false);

		}

	};

	this.phase2Handler = function(ispackage) {

		if (ispackage) {

			phone.p1.find('div.makeups.open').removeClass('open');

		} else {

//			phone.p1.find('').

		}

	}



	this.initialize = function() {

		if (($('div#phoneAttr').length > 0) && ($('div#phonePack').length > 0)) {

			phone.pContainer = $('div#phonePack'); // form container
			phone.p0 = $('div#phonePackPhase0'); // package
			phone.p1 = $('div#phonePackPhase1'); // makeups
			phone.p2 = $('div#phonePackPhase2'); // buying

			var feature = $('div#phoneAttr div.feature');
			var a = Array();
			var tmp = null;
			feature.find('div.item').each(function(i) {
				if (a[$(this).offset().left]) {
					tmp = a[$(this).offset().left];
					$(this).css({'marginTop': - ($(this).offset().top - (tmp.offset().top + tmp.outerHeight())) + 'px'});
				}
				a[$(this).offset().left] = $(this);
			});

			$('div#phonePack div.packages h3').click(function() {$(this).parent().toggleClass('open');});
			$('div#phonePack div.makeups h5').click(function() {$(this).parent().toggleClass('open');});

			phone.phase0Handler();

		}

	};



}(); // /phone
/* /removable lines */

function initRotator(xml)
{
	$tpl = $('.rotator-holder #rotator .item').remove()

	$(xml).find('phone').each(function(){
		var t = $tpl.clone();
		$('h3',t).html('<a href="' + $('url', $(this)).text() + '">' + $('manufacturer', $(this)).text() + ' <strong>' + $('type', $(this)).text() + '</strong></a>');
		$('.price',t).html($('price', $(this)).text());
		$('img',t).attr('src', $('image', $(this)).text());
		$('.btn a',t).attr('href', $('url', $(this)).text());
		$('.tariff',t).html('<a href="' + $('tariff_url', $(this)).text() + '">' + $('tariff', $(this)).text() + '</a>');
		$('.commitment',t).html($('commitment', $(this)).text().split(' és 2').join(' és<br /> 2'));


		if($('android', $(this)).text() == 'false')
		{
			$('.android',t).hide()
		}

		if($('new', $(this)).text() == 'false')
		{
			$('.new',t).hide()
		}

/*		var features = $('features', $(this)).text().split(' | ');

		for(f in features){
			$('ul.features',t).append('<li>'+features[f]+'</li>')
		}*/

		$('.rotator-holder #rotator').append(t)
	})

	Cufon.replace($('.rotator-holder h3, .rotator-holder .price, .rotator-holder .btn, .rotator-holder .locator'));

	$('#rotator').cycle({
	    fx:     'scrollHorz',
	    speed:  'fast',
	    timeout: 8000,
	    next:   '.cycle_next',
	    prev:   '.cycle_prev'
	});
}

var Basket = {
	init: function() {
		$("a.kosar").click(function() {
			var matches = /\?(.*)$/.exec($(this).attr("href"));
			return Basket.add(matches[1]);
		});
	},

	add: function(OfferID) {
		/*
		var cookie;
		if ((cookie = getCookie("basket"))) {
			var match = /SegmentID=(\w+)/.exec(OfferID);
			if (!confirm(match.length && match[1] == "LAKO" ? "Ha folytatod, a kosár korábbi tartalma törlődik.\n\nFolytatod?" : "Ha folytatja, a kosár korábbi tartalma törlődik.\n\nFolytatja?")) {
				return false;
			}
		}
		setCookie("basket", OfferID, 30, "/", document.location.hostname.replace(/www/, ''));
		*/
		return true;
	},

	remove: function() {
		setCookie("basket", null, -1);
	},

	isEmpty: function() {
		return getCookie("basket") == "";
	}

};




/* main promo rotator */
(function($){

	$.fn.mainPromoRotator = function(options){

		return this.each(function(index, element){
			var currentPromoIndex = 0;
			var prevPromoIndex = 0;
			var animated = false;
			var $element = $(element);
			var $promos = $element.find('div.promos ul li');
			var numPromos = $promos.size();
			var timer;
			var numLoadedImages = 0;

			var onMenuItemClick = function(event){
				changePromo($(this).parent().index());

				event.stopPropagation();
				event.preventDefault();
			};

			var getDelayValue = function($promo){
				return Number($promo.attr('data-delay')) == 0 ? 5000 : Number($promo.attr('data-delay')) * 1000;
			};

			var changePromo = function(promoIndex){
				var $currentPromo, $prevPromo, delay;

				if(currentPromoIndex == promoIndex){
					return;
				}

				currentPromoIndex = promoIndex;
				$prevPromo = $element.find('div.promos ul li').eq(prevPromoIndex);
				$currentPromo = $element.find('div.promos ul li').eq(promoIndex);
				$element.removeClass('dark-theme light-theme').addClass($currentPromo.attr('class'));

				$promos.each(function(i, promo){
					var $this = $(this);
					$this.stop();

					if(i == prevPromoIndex){
						$this.css('z-index', numPromos + 1);
					}else if(i == currentPromoIndex){
						$this.css({
							'z-index' : numPromos + 2,
							'opacity' : 0
						});
					}else{
						$this.css('z-index', i);
					}
				});

				$currentPromo.animate({
					'opacity' : 1
				}, 700, function(){
					animated = false;
				});

				prevPromoIndex = currentPromoIndex;

				$element.find('ul.menuItems li.active').removeClass('active');
				$element.find('ul.menuItems li').eq(currentPromoIndex).addClass('active');
				Cufon.replace($element.find('ul.menuItems li a'));
				nextItemTiming(getDelayValue($currentPromo));
			};

			var nextItemTiming = function(delay){
				clearTimeout(timer);
				timer = setTimeout(function(){
					if(currentPromoIndex < numPromos - 1){
						changePromo(currentPromoIndex + 1);
					}else{
						changePromo(0);
					}
				}, delay);
			};

			var setMenuItemsScrollable = function(){
				var scrollable;

				Cufon.replace($element.find('ul.menuItems li a'));

				//csak a cufon rendereles utan szabad rarakni a carouselt,
				//kulonben rosszul szamitja ki a szelesseg ertekeket
				//1.10-es cufontol mar van onAfterReplace callback, de itt meg nem azt hasznaljuk
				setTimeout(function(){
					$element.find('ul.menuItems').jcarousel({
						animation: 700,
						easing: 'easeOutExpo'
					});

					scrollable = !($element.find('div.menuItemsContainer div.jcarousel-prev-disabled').size() > 0 &&
								   $element.find('div.menuItemsContainer div.jcarousel-next-disabled').size() > 0);

					if(scrollable){
						$element.addClass('menuitems-scrollable');
					}else{
						$element.addClass('menuitems-no-scrollable');
						$element.find('ul.menuItems')
							.append('<li class="placeholder" style="width:720px;"></li>')
							.css('width', '+=720');
					}

				}, 400);

			};

			setMenuItemsScrollable();
			$element.find('ul.menuItems a').click(onMenuItemClick);
			$element.find('ul.menuItems li:first-child').addClass('active');
			$element.find('div.promos ul li:first-child').show().css('z-index', numPromos);
			nextItemTiming(getDelayValue($element.find('div.promos ul li:first-child')));
		});

	};

})(jQuery);
/* /main promo rotator */


/* hipernet tables */

$(document).ready(function(){
	$('table.hipernet-table-1-slider1')
	$('table.hipernet-table-1-lime-slider1')
	.add('table.hipernet-table-2-slider1')
	.add('table.hipernet-table-3-slider1')
	.add('table.hipernet-table-1-fullwide')
	.add('table.hipernet-table-1-lime-fullwide')
	.add('table.hipernet-table-2-fullwide')
	.add('table.hipernet-table-3-fullwide')
	.add('table.hipernet-table-3-private-fullwide')
		.each(function(){
			var $this = $(this);
			var caption = $this.children('caption').html();
			var $wrapper = $('<div class="' + $this.attr('class') + '"><div class="table-wrapper"></div></div>');

			$wrapper.addClass('hipernet-table');
			$this.wrap($wrapper);

			if(caption){
				$this.parent().prepend('<div class="caption">' + caption + '</div>');
			}

			$this.children('caption').remove();

			$this.find('tr:nth-child(odd)').addClass('odd');
			$this.find('tr:nth-child(even)').addClass('even');
			$this.find('tr td:last-child, tr:last-child').addClass('last');

			$this.find('td.icon-true, td.icon-false').empty().append('<span class="icon"></span>');

			if($this.find('tr:last-child').hasClass('odd')){
				$this.addClass('last-odd');
			}else{
				$this.addClass('last-even');
			}
		});

	Cufon.replace($('div.hipernet-table div.caption'));
});

/* /hipernet tables */






$(document).ready(function() {
	$('div.double110920 div.cpromo div.items').cycle({
		speed: 400,
		timeout: 10000,
		pause: 1,
		pager: '#nav',
		onPagerEvent:function(i){location.hash=i;},
		after:function(c,n,o){location.hash=o.currSlide;},
		startingSlide:location.hash?location.hash.replace('#','')*1:0
	});
});


/* apple landing */

$(document).ready(function() {
	var names={nev:'Név',email:'E-mail cím',tel_szam:'Telefonszám',iranyitoszam:'Irányítószám',telepules:'Település'};
	
	$(".hipernet form a.button").click(function(e){
		var success=true;
		frm=$(".hipernet form")[0];
		$(".hipernet form").find('.error').remove();
		for (var i=0;i<frm.elements.length;i++) {
			var err='';
			var o=frm.elements[i];
			if (o.name) {
				if (!o.value) err=names[o.name]+' kitöltése kötelező!';
				else if (o.name=='email'&&!/^[0-9a-zA-Z\._\-]{2,}@([0-9a-zA-Z_\-]{2,}\.){1,7}[a-zA-Z]{2,3}$/.test(o.value)) err=names[o.name]+' formátuma helytelen!';
				else if (o.name=='tel_szam'&&!/^[0-9]{7}$/.test(o.value)) err=names[o.name]+' helytelen!<br />Helyesen: 1234567';
				
				if (err) {
					$('<div>').html(err).addClass('error').appendTo($(o).parent().parent());
					success=false;
				}
			}
		}

		if (success) frm.submit();
		
		return false;
	});
});

/* hipernet form */

$(document).ready(function(){
	$("form#hipernet-form input[name='rel_attribute[Cím]']").keyup(function(){
		var o=$(this).parent().parent();
		
		$(o).children('.message').remove();
		
		$.post('/check_hipernet.php?zip='+$(this).val(),function(r){
			if (r=='true') {
				$('<div>').html("Jó hírünk van, itt már elérhető a Hipernet! <a href='http://www.telenor.hu/hipernet-csomagok/'>További információk</a>").addClass('message').appendTo(o);
			}
		});
	});
});


/* shop és ügyfél kérdőív ellenőrzés */

$(document).ready(function(){
	$("#ugyfel_kerdoiv input[name^='q']").bind("click",function(){
		/q\[([0-9]+)\]/.exec($(this).attr('name'));
		$("span#q"+RegExp.$1+"answer").html($(this).parent().find('span').text());
	});
															  
	$("#shop_kerdoiv,#ugyfel_kerdoiv").bind("submit",function(){
		var requireds=['outlet','salesman'];
		var r=true;
		
		for (var i=0;i<requireds.length;i++) {
			var field=$(this).find("input[name='"+requireds[i]+"']");

			if (!field.val()) {
				field.parents('.section').addClass('error');
				r=false;
			}
			else {
				field.parents('.section').removeClass('error');
			}
		}
		
		if (!r) $("html,body").animate({scrollTop:$(".quiz-area").offset().top})
		
		return r;
	});
});
