var slconf={
	sajat_link_loader_url: 'http://www.startlap.hu/sajat_linkek/ajax/startlap_box.php',
	logger_sales_url: 'http://admin.startlap.hu/apps/log/slog.php?id=',
	logger_url: 'http://admin.startlap.hu/apps/log/log.php?21012945&',
	logger_sales_sessiontime: 5};

var ie6 = (jQuery.browser.msie && jQuery.browser.version < 7);

var sl = {
	boot:function(o) {
		var options = $.extend({
			stat: true,
			providers: false,
			gaTrackerId: null,
			bottomSearch: false,
			targetBlankItems: ["a.lk", ".lk a", ".kt a", ".box[class!='box k'] a[href^='h' ][target!='_self']"],
			inputItems: ["input[type=text].imput"],
			buttonItems: [".btn"],
			selectItems: ["select.radio", "div.std select"],
			radioItems: [".radioHolder input[type=radio]"],
			focusItems: ["#addLink div.inpt input", "div.std form input[name=word]"],
			localLinks: false
		}, o);
		this.setTargetBlank(options.targetBlankItems);
		$(function(){
			sl.search.init();
			if (options.stat) sl.stat.init();
			if (options.providers) sl.providers.init();
			if (options.bottomSearch) sl.bottomSearch.init();
			if (options.localLinks) sl.localLinks.init(options.localLinks);
			sl.inputs.init(options.inputItems);
			sl.selects.init(options.selectItems);
			sl.radios.init(options.radioItems);
			sl.buttons.init(options.buttonItems);
			$(options.focusItems.toString()).setFBEvents();
			$('#loginlink').click(function(e) {
				if ($.cookie('SL_HASH')) {
					document.location.reload();
					e.preventDefault();
					return false;
				} else {
					return true;
				}
			});
			if (options.gaTrackerId) sl.gaTracker.init(options.gaTrackerId);
		});
	},

	setTargetBlank: function(items){
		$(items.toString()).live("click", function(){
			$(this).attr("target", "_blank");
		});
	}
};

sl.toc = {
	selectedClass: "toci",

	toggle: function(){
		$("#toc-c").toggle();
		$("#toc-h a.opnr").toggleClass("clsr");
		var rel = $("#toc-h a.opnr").attr("rel");
		$("#toc-h a.opnr").attr("rel", $("#toc-h a.opnr").text()).text(rel);
		if ($("#toc-c:visible").size()){
			var date = new Date();
			date.setTime(date.getTime() + 1000*60*60*24*365);//egy év
			$.cookie('SL_TOC', 1, {expires: date});
		}
		else
			$.cookie('SL_TOC', null);
	},

	selectItem: function(ids){
		ids = ids.split(" ");
		if (ids.length){
			var toScroll = $(document).height();
			$(".box."+ this.selectedClass).removeClass(this.selectedClass);
			for(var i=0; i<ids.length; i++){
				var boxO = $("h1#h"+ ids[i]).parent().offset();
				if (boxO.top){
					if (toScroll > boxO.top)
						toScroll = boxO.top;
					$("h1#h"+ ids[i]).parent().addClass(this.selectedClass);
				}
			}
			$(document).scrollTo(toScroll);
		}
	}
};

sl.weather = {
	actIdx: 1,
	
	updateDay: function(idx, datas){
		if (this.actIdx != idx){
			this.actIdx = idx;
			var c = $(".bg.weather");
			$(".rd", c).removeClass("slctd").eq(this.actIdx-1).addClass("slctd");
			$("span.l", c).text("Napkelte: "+ datas.napkelte);
			$("span.r", c).text("Napnyugta: "+ datas.napnyugta);
			for(var i=1; i<6; i++)
				$("#wt_"+ i, c).attr("title", datas["ter"+ i].title).html("<div class=\"wicon "+ datas["ter"+ i].ikon +"\">&nbsp;</div>"+ datas["ter"+ i].fok +" °C");
		}
	}
};

sl.bannerSky = {

	init: function(){
		$(function() {
			if ($(".h120600").size()){
				var bannerWidth = 120;
				setPosition2SkyBanners = function(){
					var d = $("#body").offset();
					$("#banner-sky-left").css("left", (d.left-bannerWidth-15) +"px");
					$("#banner-sky-right").css("left", (d.left+995) +"px");
				}
				$(window).bind("resize", function(){
					var ww = $(window).width();
					setPosition2SkyBanners();
					if(ww >= 1260){
						$(".h120600").show();
					}else {
						$(".h120600").hide();
					}
				}).trigger("resize");
			}
		});
	}
};

sl.buttons = {
	iSelector: '',
	
	init: function(items){
		this.iSelector = items.toString();
		this.initHover();
	},
	
	initHover: function(){
		$(this.iSelector).hover(
			function(){
				if (!ie6) $(this).addClass("hvr");
			}, function(){
				if (!ie6) $(this).removeClass("hvr");
			}
		);
	}
};

sl.inputs = {
	iSelector: '',

	init: function(items){
		this.iSelector = items.toString();
		this.convert();
	},

	convert: function(){
		$(this.iSelector).wrap("<div class=\"inpt\"></div>").parent().after("<b class=\"inpt inptend\">&nbsp;</b>");
	}
};

sl.radios = {
	iSelector: '',

	init: function(items){
		this.iSelector = items.toString();
		$(".radioHolder tr").find("td:last label").addClass("rlb");
		this.transformRadios();
	},

	transformRadios: function(){
		$(this.iSelector).hide();
		$.each($(this.iSelector), function(idx){
			var group = $(this).attr("name");
			var label = $(this).siblings("label[for="+ $(this).attr("id") +"]");
			label.addClass("rd").click(function(){
				sl.radios.selectOne(this, group);
			})
		});
	},

	selectOne: function(t, group){
		$("input[type=radio][name="+ group +"]").siblings("label").removeClass("slctd");
		$(t).addClass("slctd");
	}
};

sl.selects = {
	iSelector: '',
	array: {},
	maxPageSize: 15,

	init: function(items){
		this.iSelector = items.toString();
		$.each($(this.iSelector), function(idx){
			var select = new sl.select(this, idx);
			if (select.id)
				sl.selects.array[select.id] = select;
		});
	}
};

sl.select = function(obj, idx){
	this.id = 0;
	this.label = '';
	this.options = [];
	this.obj = null;
	this.timer = 0;
	this.callback = false;
	this.pageLimit = 0;
	this.width = 0;
	this.optGroups = [];

	this.init = function(obj, idx){
		if ($(obj).attr("type").toLowerCase() != "select-one") return false;
		this.obj = $(obj);
		this.options = this.obj[0].options;
		this.id = this.obj.attr("id") ? this.obj.attr("id") : "slSelect"+ idx;                
		if (sl.selects.array[this.id]){
			if (sl.selects.array[this.id].options[0] == this.options[0])
				return false;
			else
				this.id += $(".box").size() + idx;
		}
		this.label = this.obj.siblings("label").text();
		if (this.label == '' && this.options.length)
			this.label = this.options[this.obj[0].selectedIndex].text;
		this.setPageLimit();
		this.callback = this.obj.attr("title").indexOf("document.") == 0 ? false : this.obj.attr("title").replace('();', '');

		this.width = parseInt(this.obj.css("width"));
		if (!this.width || this.width == 0) this.width = this.obj.width();

		if (
			this.obj.siblings('div.inpt.pntr').size() ||
			this.obj.hide()
				.after("<div class=\"inpt pntr\" style=\"width:"+ (this.width-23) +"px;\"><b></b></div><div class=\"btn lenyil\">&nbsp;</div>")
		){
			this.setLabel(this.label);
			this.setOptions();
			if (!ie6){
				this.obj.siblings("div.inpt.pntr").hover(function(){
					$(this).siblings(".lenyil, .felnyil").addClass("hvr");
				},function(){
					$(this).siblings(".lenyil, .felnyil").removeClass("hvr");
				});
			}
			return this;
		}
		else return false;
	};

	this.setLabel = function(text){
		var el = this.obj.siblings(".inpt.pntr").find('b').eq(0);
		el.text(text);
	};

	this.setPageLimit = function(){
		var checkFirst = this.options[0].text;
		var hideFirst = checkFirst.toLowerCase().indexOf("válassz") > -1;
		var l = this.options.length - (hideFirst ? 1 : 0);
		if (!l || l == 0){
			this.pageLimit = 0;
		}
		else {
			if (l < sl.selects.maxPageSize)
				this.pageLimit = l;
			else {
				this.pageLimit = Math.ceil(l / (parseInt(l.toString().substr(0, (l.toString().length-1)))+1));
			}
		}
	};

	this.clearInt = function() {
		clearInterval(this.timer);
	};

	this.setInt = function(){
		var me = this;
		this.timer = setInterval(function() {
			me.closeSelecter(false);
			me.clearInt();
		}, 1000);
	};

	this.closeSelecter = function(justClose){
		var visible = this.obj.siblings(".selecter").css("display") == "block";
		if (!justClose){
			if (visible)
				this.toggleSelecter(visible);
		}
		else
			this.toggleSelecter(visible);
	};

	this.setValue = function(value, text){
		this.setLabel(text != '' ? text : value);
		var obj = $(this.obj).get(0);
		obj.value = value;
		if (obj.onchange) obj.onchange();
	};

	this.getValue = function(){
		var obj = $(this.obj).get(0);
		return obj.options[obj.selectedIndex].value;
	};

	this.setDatas = function(datas){
	    this.options = [];
		this.optGroups = [];
	    if(parseInt(datas[0])){
                for(var i=0;i<datas.length;i++){
				if (parseInt(i) >= 0)
				this.options.push({text: datas[i+1], value: datas[i]});
                            i++;
			}
            }
            else if (typeof datas[0] == "string"){//ha nincs külön érték megadva
			for(var i in datas){
				if (parseInt(i) >= 0)
				this.options.push({text: datas[i], value: datas[i]});
			}
	    }
	    else {
			for(var i in datas){
				if (parseInt(i) >= 0)
				this.options.push(datas[i]);
			}
	    }
	    if (this.options.length){//csak ha valóban vannak elemek
			this.clearOptions();
			this.setPageLimit();
			this.setOptions();
	    }
	};

	this.clearOptions = function(){
		this.obj.siblings(".selecter").remove();
	};

	this.setOptions = function(){
		var opts = "<div class=\"selecter\"><div class=\"top\"><b>&nbsp;</b><i>&nbsp;</i></div><div class=\"c\">";
		var me = this;
		if (this.options.length){
			var checkFirst = this.options[0].text;
			var hideFirst = checkFirst.toLowerCase().indexOf("válassz") > -1;
			//ha van optgroup, akkor a nem kell limit, minden lap a group elemeit tartalmazza
			//csak 2 optgroupra tesztelve
			if (this.obj.children("optgroup").size()){
				var pageCount = this.obj.children("optgroup").size();
				var m;
				var last;
				for (var p=0;p<pageCount;p++){
					if (p>0){
						opts += this.getSelectPager(p, pageCount, this.width, {right: $(this.obj.children("optgroup").get(p)).attr("label")});
						opts += "</div><div id=\""+ this.id +"_"+ (p+1) +"\" style=\"display:none;\">";
					}
					else {
						var $this = this;
						opts += "<div id=\""+ this.id +"_"+ (p+1) +"\">";
						this.obj.children("option").each(function(){
							opts += $this.getSelectRow($(this).get(0), false);
						});
					}
					for (var j=0;j<$(this.obj.children("optgroup").get(p)).children("option").size();j++){
						last = j == $(this.obj.children("optgroup").get(p)).children("option").size()-1;
						var item = $(this.obj.children("optgroup").get(p)).children("option").get(j);
						if (item){
							var pl = $(this.obj.children("optgroup").get(p)).attr("label");
							if (pl && $.inArray(pl, this.optGroups) == -1){
								this.optGroups.push(pl);
							}
							opts += this.getSelectRow(item, last);
						}
					}
				}
				opts += this.getSelectPager(p, pageCount, this.width, {left: $(this.obj.children("optgroup").get(0)).attr("label")}) +"</div>";
			}
			else if (this.options.length - (hideFirst ? 1 : 0) > this.pageLimit){
				var c = this.options.length - (hideFirst ? 1 : 0);
				var pageCount = Math.ceil(c/this.pageLimit);
				var p = 1;
				var m, ii;
				var last;
				opts += "<div id=\""+ this.id +"_"+ p +"\">";
				for (var i = 0; i < pageCount*this.pageLimit; i++){
					ii = (hideFirst ? i+1 : i);
					m = i != 0 && i % this.pageLimit == 0;
					if (m){
						opts += this.getSelectPager(p, pageCount, this.width);
						opts += "</div><div id=\""+ this.id +"_"+ (p+1) +"\" style=\"display:none;\">";
						p++;
					}
					last = ((i+1) % this.pageLimit == 0) || (ii == this.options.length-1);
					if (this.options[ii]){
						opts += this.getSelectRow(this.options[ii], last);
					}
					else
						opts += "<b class=\"sep\">&nbsp;</b>";
				}
				opts += this.getSelectPager(p, pageCount, this.width) +"</div>";
			}
			else
				$.each(this.options, function(idx){
					if (!(hideFirst && idx == 0))
						opts += me.getSelectRow(this, idx == (me.options.length-1));
				});
		}
		else {
			opts += "<b>Nincs megjeleníthető elem!</b>";
		}
		opts += "</div><div class=\"bottom\"><b>&nbsp;</b><i>&nbsp;</i></div></div>";
		this.obj
		.siblings(".btn").eq(0)
		.after(opts);
		this.obj
		.siblings(".inpt.pntr, .btn:first")
		.unbind("click")
		.click(function(){
			me.closeSelecter(true);
		});

		this.obj
		.siblings(".selecter")
		.find("div.c > a, div.c > div > a").unbind("click").click(function(){
			if ($(this).attr("rel")){
				me.setValue($(this).attr("rel"), $(this).text());
			}
			me.toggleSelecter(me.obj.siblings(".selecter").css("display") == "block");
		});
		this.obj
		.siblings(".inpt.pntr, .btn:first")
		.unbind("mouseover mouseout")
		.mouseover(function(){
			me.clearInt();
		})
		.mouseout(function(){
			me.setInt();
		});
		this.obj
		.siblings(".selecter")
		.width(this.width)
		.mouseover(function(){
			me.clearInt();
		})
		.mouseout(function(){
			me.setInt();
		});
	};

	this.toggleSelecter = function(visible){
		var dH = $(document).height();
		var sib = this.obj.siblings(".selecter");
		var offSet = this.obj.siblings(".inpt.pntr").offset();
		var height = sib.height();
		var topPos = offSet.top + 23;
		if ((offSet.top + height) > (dH - 40)){
			sib.find(".top").attr("class", "ctop").end()
			.find(".bottom").attr("class", "cbottom").end()
			.height(height).css({"top": -(height-offSet.top) +"px", "left": offSet.left});
			var altNyil = true;
		}
		else {
			sib.find(".ctop").attr("class", "top").end()
			.find(".cbottom").attr("class", "bottom").end()
			.height(height).css({"top": topPos +"px", "left": offSet.left});
		}
		sib.width(this.width).find(".bottom b, .ctop b").width(this.width-3).end()
		.find(".cbottom b, .top b").width(this.width-23);
		if (jQuery.browser.msie && jQuery.browser.version < 8) {
			sib.find("div.c > a, div.c > div > a").width(this.width - 22).end().css("left", offSet.left +"px");
		}
		if (ie6 && this.obj.siblings(".btn.mehet").size()){
			if (!this.obj.siblings(".btn.mehet").hasClass("fix")){
				this.obj.siblings(".btn.mehet").addClass("fix");
			}
		}
		var nyil = this.obj.siblings(".btn").eq(0);
		if (visible){
			if (nyil.hasClass("felnyil"))
				nyil.removeClass("felnyil").addClass("lenyil");
			else
				nyil.removeClass("felnyil2").addClass("lenyil");
			sib.hide().css({
				zoom: 0,
				zIndex: 1
			});
			sib.parent().parent().css({
				zoom: 0,
				zIndex: 1
			});
		}
		else {
			if (altNyil)
				nyil.removeClass("lenyil").addClass("felnyil2");
			else
				nyil.removeClass("lenyil").addClass("felnyil");
			for (var i in sl.selects.array){
				sl.selects.array[i].closeSelecter();
			}
			//odalapozunk, ahol a kiválasztás van
			var value = $.trim(this.obj.siblings(".inpt.pntr").find('b').eq(0).text());
			if (value != ''){
				var valueinpage = 0;
				sib.find(".c > div > a").each(function(){
					if ($(this).text() == value){
						valueinpage = $(this).parent().attr("id").split("_").pop();
						return false;
					}
				});
				this.setPage(valueinpage);
			}
			sib.show().css({
				zoom: 1,
				zIndex: 10000,
				"float": "left"
			});
			sib.parent().parent().css({
				zoom: 1,
				zIndex: 10000
			});
		}
	};

	this.getSelectPager = function(page, pageCount, width, labels){
		var html = '';
		var getNextText = function(){
			return (labels && labels.right?labels.right:(width>140?"Következő":"<span title=\"Következő\">K</span>"));
		};
		var getBackText = function(){
			return (labels && labels.left?labels.left:(width>140?"Előző":"<span title=\"Előző\">E</span>"));
		};
		switch(page){
			case 1:
				html = "<div class=\"la\" style=\"border-bottom:0;\">" +
					"<strong class=\"l\">"+ getBackText() +"</strong>"+
					"<a class=\"r\" href=\"javascript:sl.selects.array['"+ this.id +"'].setPage("+ (page+1) +")\">"+ getNextText() +"</a>"+
					"</div>";
				break;
			case pageCount:
				html = "<div class=\"la\" style=\"border-bottom:0;\">" +
					"<a class=\"l\" href=\"javascript:sl.selects.array['"+ this.id +"'].setPage("+ (page-1) +")\">"+ getBackText() +"</a>"+
					"<strong class=\"r\">"+ getNextText() +"</strong>"+
					"</div>";
				break;
			default:
				html = "<div class=\"la\" style=\"border-bottom:0;\">" +
					"<a class=\"l\" href=\"javascript:sl.selects.array['"+ this.id +"'].setPage("+ (page-1) +")\">"+ getBackText() +"</a>"+
					"<a class=\"r\" href=\"javascript:sl.selects.array['"+ this.id +"'].setPage("+ (page+1) +")\">"+ getNextText() +"</a>"+
					"</div>";
		}
		return html;
	};

	this.getSelectRow = function(option, last){
		var html = '<a href="#" onclick="return false;"'+ (last ? ' class="nom"' : '') +' rel="'+ option.value +'">'+ option.text +'</a>';
		return html;
	};

	this.setPage = function(page){
		$("#"+ this.id +"_"+ page)
		.show()
		.siblings("div")
		.hide();
	};

	return this.init(obj, idx);
};

sl.stat = {
	init: function() {
		$("body").append('<img alt="logimage" src="i/transparent.gif" id="logimage" />');
		$("div.box a").each(function() {
			var id = this.id;
			if(id) {
				if (id.substr(0, 1) == 'l')
					id = id.substr(1, id.length);
				$(this).click(function(){
					sl.stat.l(id);
				});
			}
		});
		$("div.box div[id^=script_]").each(function() {
			var id = this.id.split('_').pop();
			$(this).find('a').click(function(){
					sl.stat.l(id);
			});
		});
	},

	l: function(id) {
		var src = '';
		var plink;
		var a = id.split('_');
		if (a[0] != 'k') {
			if (a[0] != 'o')
				src = slconf.logger_url+id; //sima link
		}
		else {
			plink = id.split(';');
			if (plink[1]) src = slconf.logger_url+plink[1];//puffer link
			else {//sales link
				if (!$.cookie('slstat')) {
					var date = new Date();
					date.setTime(date.getTime() + slconf.logger_sales_sessiontime*60*1000);
					$.cookie('slstat', Math.round(Math.random()*10000000000), {expires: date});
				}
				src = slconf.logger_sales_url+a[1] +'&cookie='+ $.cookie('slstat');
			}
		}
		if ($.trim(src) != '')
			$('#logimage').attr('src', src+'&'+Math.round(Math.random()*10000000000) );
	}
};

sl.check = function(e){
	if (e.keyCode == 40 || e.keyCode == 38 || e.keyCode == 9){
		e.stopPropagation();
        e.cancelBubble = true;
		e.preventDefault();
		return false;
	}
	return true;
};

sl.search = {
	timer: 0,
	timeout: 0,
	banner2hideSelector: "div#hdbnnr",
	links: [],
	topLink: 1,
	hasContainer: false,
	query: '',
	minChar: 2,
	delay: 100,
	searchClass: "search",
	suggestionClass: "startlapSuggestionResults",
	
	clearTimer: function() {
		clearInterval(this.timer);
	},

	setTimer: function(){
		var me = this;
		this.timer = setInterval(function() {
			me.closeSuggestDiv();
		}, 2000);
	},

	suggest: function(input){
		var form = $(input).parent();
		this.query = encodeURIComponent($.trim($(input).val()));
		if (!form.siblings("div."+ this.suggestionClass).size())
			$('<div />').addClass(this.suggestionClass).insertAfter(form);
		clearTimeout(this.timeout);
		if (this.query.length >= this.minChar){
			this.timeout = setTimeout(this.queryChanged, this.delay);
		}
	},

	queryChanged: function(){
		var $this = sl.search;
		$this.showBusy();
		$.getJSON(
			"http://www.startlapkereso.hu/suggest?q="+ $this.query +"&uid=165&cid=833&callback=?",
			$this.suggestionCallback
		);
	},

	showBusy: function(){
		if (!$("div."+ this.suggestionClass).siblings("form").children(".indicator").size())
			$('<div />').addClass('indicator').appendTo($("div."+ this.suggestionClass).siblings("form"));
		$("div."+ this.suggestionClass).siblings("form").children(".indicator").show();
	},

	hideBusy: function(){
		$("div."+ this.suggestionClass).siblings("form").children(".indicator").hide();
	},

	closeSuggestDiv: function(){
		this.clearTimer();
		$("div."+ this.suggestionClass).hide();
		if (!$("#container").hasClass("alt"))
			$(this.banner2hideSelector).css("visibility", "visible");
	},

	showSuggestDiv: function(){
		if ($("div."+ this.suggestionClass +" li").size()) {
			$("div."+ this.suggestionClass).show();
			if (!$("#container").hasClass("alt"))
				$(this.banner2hideSelector).css("visibility", "hidden");
		}
	},

	strongEnough: function(str){
		return "<b>"+ str +"</b>";
	},

	suggestionCallback: function(links){
		var $this = sl.search;
		$("div."+ $this.suggestionClass +" ul").empty();
		$this.hideBusy();
		$this.links = links;
		$this.topLink = 0;
		if ($this.links.length) {
			$this.topLink = 1;
			var aContent = '';
			var linksHTML = '';
			var regexp = new RegExp($this.query, "ig");
			for (var i = 0; i < $this.links.length; i++) {
				aContent = $this.links[i].replace($($this.links[i]).text(), $($this.links[i]).text().replace(regexp, $this.strongEnough));
				linksHTML += "<li>"+ aContent +"</li>";
			}
			if (!$this.hasContainer){
				linksHTML = "<div id=\"controll\"><div id=\"upa\"><a tabindex=\"100\" href=\"#\">&nbsp;</a></div><div id=\"downa\"><a tabindex=\"100\" href=\"#\">&nbsp;</a></div><ul>"+
							linksHTML +
							"</ul></div>";
				$("div."+ $this.suggestionClass).append(linksHTML);
				$this.hasContainer = true;
				$(".search input#q, div."+ $this.suggestionClass)
				.mouseover(function(){
					$this.clearTimer();
				})
				.mouseout(function(){
					$this.setTimer();
				});
				$(".search input#q")
				.click(function(){
					$this.showSuggestDiv();
				});
			}
			else {
				$("div."+ $this.suggestionClass +" ul").html(linksHTML);
			}
			$("div."+ $this.suggestionClass +" ul a").attr("tabindex", 100);
			$this.showSuggestDiv();
		}
		else {
			$this.closeSuggestDiv();
		}
		$("div."+ $this.suggestionClass +" ul").css({"marginTop" : "0px"});
		$this.refreshArrows();
	},

	refreshArrows: function(){
		var vars = {
			up : $("#upa").children('a'),
			down : $("#downa").children('a')
		};
		if (this.links.length <= 4) {//leszedjük a nyilakat
			vars.up.css("visibility", "hidden");
			vars.down.css("visibility", "hidden");
		}
		else {
			var me = this;
			vars.lh = 23;
			vars.ul = $("div."+ this.suggestionClass +" ul");
			vars.mTop = parseInt($("div."+ this.suggestionClass +" ul").css("marginTop"));
			vars.scrollCount = 4;
			var stepOneLine = function(up){
				var marginTop = 0;
				if (up){
					if (me.topLink > 1){
						if (me.topLink <= 5){
							marginTop = 0;
							me.topLink = 1;
						}
						else {
							marginTop = vars.mTop + vars.scrollCount * vars.lh;
							me.topLink -= vars.scrollCount;
						}
					}
				}
				else {
					if (me.topLink < me.links.length){
						if ((me.links.length - (me.topLink + 4)) <= 4){
							marginTop = -(me.links.length - 4) * vars.lh;
							me.topLink = me.links.length - 3;
						}
						else {
							marginTop = vars.mTop - vars.scrollCount * vars.lh;
							me.topLink += vars.scrollCount;
						}
					}
				}
				vars.up.unbind("click");
				vars.down.unbind("click");
				vars.ul.animate({"marginTop" : marginTop +"px"}, 200, "linear", function(){
					me.refreshArrows();
				});
			};
			if (me.topLink > 1)
				vars.up
				.css("visibility", "visible")
				.unbind("click")
				.click(function(e){
					e.preventDefault();
					stepOneLine(true);
				});
			else
				vars.up.css("visibility", "hidden");

			if ((me.links.length - me.topLink) >= 4)
				vars.down
				.css("visibility", "visible")
				.unbind("click")
				.click(function(e){
					e.preventDefault();
					stepOneLine();
				});
			else
				vars.down.css("visibility", "hidden");
		}
	},
	
	init: function(iframeId){
		var doc = document;
		if (iframeId){
			var f = $("#"+ iframeId)[0];
			doc = f.contentWindow ? f.contentWindow.document : f.contentDocument ? f.contentDocument : f.document;
		}

		$("div."+ this.suggestionClass +" a", doc)
		.live("keydown", sl.check)
		.live("keypress", sl.check)
		.live("keyup", sl.check);

		$("div.search a.c, div.bottomSearch a.c", doc).click(function(){
			$(this).siblings("a.c").removeClass("selected").children("input").check("off");
			$(this).addClass("selected").children("input").check();
			return false;
		});

		var form = $("div.search form, div.bottomSearch form", doc);
		var input = $("input#q", form);

		$("a.r", form).click(function(){
			sl.startSearch(form.get(0));return false;
		});

		if ($("a[href=#google]", doc).hasClass("selected")){//ha a google az alap
			$("img", form).show();
			input.css("background", "none").focus(function(){
				$(this).css("background", "#fff").siblings("img").hide();
				if (typeof delRefresh == "function")
					delRefresh(ref);
			}).blur(function(){
				if ($(this).val() == '')
					$(this).css("background", "none").siblings("img").show();
			});
		}
		else {//ha a startlap az alap
			input.css("background", "#fff").keyup(function(e){
				if (iframeId)
					sl.bottomSearch.suggest(this);
				else
					sl.search.suggest(this);
				sl.check(e);
			})
			.click(function(){
				if (iframeId)
					sl.bottomSearch.showSuggestDiv();
				else
					sl.search.showSuggestDiv();
				if (typeof delRefresh == "function")
					delRefresh(ref);
			});
		}

		$("a[href=#google]", doc).click(function(){
			input
			.unbind("keyup focus click blur")
			.focus(function(){
				$(this).css("background", "#fff").siblings("img").hide();
				clearTimeout(sl.search.timeout);
				if (iframeId)
					sl.bottomSearch.closeSuggestDiv();
				else
					sl.search.closeSuggestDiv();
				if (typeof delRefresh == "function")
					delRefresh(ref);
			})
			.blur(function(){
				if ($(this).val() == '')
				$(this).css("background", "none").siblings("img").show();
			});
			input.focus();
		});
		//villogás ellen
		$("a[href=#startlap]", doc).hover(
			function(){
				input.unbind("blur");
			}, function(){
				if ($("a[href=#google]", doc).hasClass("selected"))
				input.blur(function(){
					if ($(this).val() == '')
					$(this).css("background", "none").siblings("img").show();
				});
		});
		$("a[href=#startlap]", doc).click(function(){
			$("img", form).hide();
			input
			.css("background", "#fff")
			.unbind("blur")
			.keyup(function(e){
				if (iframeId)
					sl.bottomSearch.suggest(this);
				else
					sl.search.suggest(this);
				sl.check(e);
			})
			.click(function(){
				if (iframeId)
					sl.bottomSearch.showSuggestDiv();
				else
					sl.search.showSuggestDiv();
				if (typeof delRefresh == "function")
					delRefresh(ref);
			});
			input.focus();
		});
	}
};

sl.bottomSearch = {
	opened: $.cookie('SL_BS_OPENED') == 2 ? false : true,
	template: "<head><link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" /></head><body class=\"tr\">#BODY</body>",
	content: {
		bs_closed: "<a href=\"javascript:parent.sl.bottomSearch.open();\" class=\"bs_closed\">Keresősáv be</a>",
		bs_opened: "<div class=\"bottomSearch\">"+
						"<div class=\"w750\">"+
						"<b class=\"l\">"+
							"<a class=\"c selected\" tabindex=\"2\" href=\"#google\"><input type=\"radio\" name=\"search\" value=\"google\" id=\"s_g\" checked=\"checked\" />Google</a>"+
							"<span>&nbsp;</span>"+
							"<a class=\"c\" tabindex=\"3\" href=\"#startlap\"><input type=\"radio\" name=\"search\" value=\"startlap\" id=\"s_s\" />Startlap</a>"+
						"</b>"+
						"<div class=\"l\">"+
							"<form target=\"sl_search\" onsubmit=\"return parent.sl.startSearch(this);\" method=\"get\">"+
								"<input type=\"hidden\" name=\"page\" value=\"1\" />"+
								"<a tabindex=\"1\" class=\"r\" href=\"#keresés\">Keresés</a>"+
								"<input type=\"text\" id=\"q\" name=\"q\" autocomplete=\"off\" />"+
								"<img src=\"i/s_google_alt.gif\" alt=\"Fejlesztette a Google\" />"+
								"<input type=\"submit\" class=\"nv\" />"+
								"<div class=\"indicator\"></div>"+
							"</form>"+
						"</div>"+
						"<a href=\"javascript:parent.sl.bottomSearch.scroll2Top();\" class=\"l bs_top\">Oldal tetejére</a>"+
						"</div>"+
						"<a href=\"javascript:parent.sl.bottomSearch.close();\" class=\"bs_closer\">&nbsp;</a>"+
					"</div>",
		bs_startlapSuggestionsResults: "<div class=\"startlapSuggestionResults\"></div>"
	},
	timer: 0,
	timeout: 0,
	links: [],
	topLink: 1,
	hasContainer: false,
	query: '',
	minChar: 2,
	delay: 100,

	clearTimer: function() {
		clearInterval(this.timer);
	},

	setTimer: function(){
		var me = this;
		this.timer = setTimeout(function() {
			me.closeSuggestDiv();
		}, 2000);
	},

	suggest: function(input){
		this.query = encodeURIComponent($.trim($(input).val()));
		clearTimeout(this.timeout);
		if (this.query.length >= this.minChar){
			this.timeout = setTimeout(this.queryChanged, this.delay);
		}
	},

	queryChanged: function(){
		var $this = sl.bottomSearch;
		$this.showBusy();
		$.getJSON(
			"http://www.startlapkereso.hu/suggest?q="+ $this.query +"&uid=165&cid=833&callback=?",
			$this.suggestionCallback
		);
	},

	showBusy: function(){
		$(".indicator", frames["bs_opened"].document).show();
	},

	hideBusy: function(){
		$(".indicator", frames["bs_opened"].document).hide();
	},

	closeSuggestDiv: function(){
		this.clearTimer();
		$("#bs_startlapSuggestionsResults").hide();
	},

	showSuggestDiv: function(){
		if ($("div.startlapSuggestionResults li", frames["bs_startlapSuggestionsResults"].document).size()) {
			$("#bs_startlapSuggestionsResults").show();
		}
	},

	suggestionCallback: function(links){
		var $this = sl.bottomSearch;
		$("div.startlapSuggestionResults ul", frames["bs_startlapSuggestionsResults"].document).empty();
		$this.hideBusy();
		$this.links = links;
		$this.topLink = 0;
		if ($this.links.length) {
			$this.topLink = 1;
			var aContent = '';
			var linksHTML = '';
			var regexp = new RegExp($this.query, "ig");
			for (var i = 0; i < $this.links.length; i++) {
				aContent = $this.links[i].replace($($this.links[i]).text(), $($this.links[i]).text().replace(regexp, sl.search.strongEnough));
				linksHTML += "<li>"+ aContent +"</li>";
			}
			if (!$this.hasContainer){
				linksHTML = "<div id=\"controll\"><div id=\"upa\"><a tabindex=\"100\" href=\"#\"></a></div><div id=\"downa\"><a tabindex=\"100\" href=\"#\"></a></div><ul>"+
							linksHTML +
							"</ul></div>";
				$("div.startlapSuggestionResults", frames["bs_startlapSuggestionsResults"].document).append(linksHTML);
				$this.hasContainer = true;
				$("#bs_startlapSuggestionsResults")
				.mouseover(function(){
					$this.clearTimer();
				})
				.mouseout(function(){
					$this.setTimer();
				});
				$("input#q", frames["bs_opened"].document)
				.click(function(){
					$this.showSuggestDiv();
				})
				.mouseover(function(){
					$this.clearTimer();
				})
				.mouseout(function(){
					$this.setTimer();
				});
			}
			else {
				$("div.startlapSuggestionResults ul", frames["bs_startlapSuggestionsResults"].document).html(linksHTML);
			}
			$("div.startlapSuggestionResults ul a", frames["bs_startlapSuggestionsResults"].document).attr({tabindex: 100, target: "_blank"});
			$this.showSuggestDiv();
		}
		else {
			$this.closeSuggestDiv();
		}
		$("div.startlapSuggestionResults ul", frames["bs_startlapSuggestionsResults"].document).css({"marginTop" : "0px"});
		$this.refreshArrows();
	},

	refreshArrows: function(){
		var vars = {
			up : $("#upa a", frames["bs_startlapSuggestionsResults"].document),
			down : $("#downa a", frames["bs_startlapSuggestionsResults"].document)
		};
		if (this.links.length <= 4) {//leszedjük a nyilakat
			vars.up.css("visibility", "hidden");
			vars.down.css("visibility", "hidden");
		}
		else {
			var me = this;
			vars.lh = 23;
			vars.ul = $("div.startlapSuggestionResults ul", frames["bs_startlapSuggestionsResults"].document);
			vars.mTop = parseInt($("div.startlapSuggestionResults ul", frames["bs_startlapSuggestionsResults"].document).css("marginTop"));
			vars.scrollCount = 4;
			var stepOneLine = function(up){
				var marginTop = 0;
				if (up){
					if (me.topLink > 1){
						if (me.topLink <= 5){
							marginTop = 0;
							me.topLink = 1;
						}
						else {
							marginTop = vars.mTop + vars.scrollCount * vars.lh;
							me.topLink -= vars.scrollCount;
						}
					}
				}
				else {
					if (me.topLink < me.links.length){
						if ((me.links.length - (me.topLink + 4)) <= 4){
							marginTop = -(me.links.length - 4) * vars.lh;
							me.topLink = me.links.length - 3;
						}
						else {
							marginTop = vars.mTop - vars.scrollCount * vars.lh;
							me.topLink += vars.scrollCount;
						}
					}
				}
				vars.up.unbind("click");
				vars.down.unbind("click");
				vars.ul.animate({"marginTop" : marginTop +"px"}, 200, "linear", function(){
					me.refreshArrows();
				});
			};
			if (me.topLink > 1)
				vars.up
				.css("visibility", "visible")
				.unbind("click")
				.click(function(e){
					e.preventDefault();
					stepOneLine(true);
				});
			else
				vars.up.css("visibility", "hidden");

			if ((me.links.length - me.topLink) >= 4)
				vars.down
				.css("visibility", "visible")
				.unbind("click")
				.click(function(e){
					e.preventDefault();
					stepOneLine();
				});
			else
				vars.down.css("visibility", "hidden");
		}
	},

	init: function(){
		function onIframeLoad(){
			sl.search.init("bs_opened");
			sl.bottomSearch.hideBusy();
			$(window).bind("scroll", bottomSearchSticky);
			$(window).bind("resize", function(){ bottomSearchSticky(); $("#bs_opened").width($(window).width()); }).trigger("resize");
		}
		function bottomSearchSticky() {
			var stickyJQElm			= sl.bottomSearch.opened?$("#bs_opened"):$("#bs_closed");
			var suggest				= $("#bs_startlapSuggestionsResults");
			var scrollPos			= $(window).scrollTop();
			var headerHeight		= 763 - $(window).height();
			if (headerHeight < 80)
				headerHeight = 80;//ekkor már nem látszik a fenti kereső
			sl.bottomSearch.closeSuggestDiv();
			if (scrollPos > headerHeight){
				stickyJQElm.show();
				//hogy látszódjon a footer
				if (sl.bottomSearch.opened) $("#bs_opened_spacer").show();
				else $("#bs_opened_spacer").hide();
				if (ie6){
					stickyJQElm.css({top: $(window).height() + scrollPos - stickyJQElm.height()});
					suggest.css({top: ($(window).height() + scrollPos - 134) +"px"});
				}
				else {
					stickyJQElm.css({top: $(window).height() - stickyJQElm.height()});
					suggest.css({top: ($(window).height() - 134) +"px"});
				}
				try {
					//var doc = f.contentWindow ? f.contentWindow.document : f.contentDocument ? f.contentDocument : f.document;
					var doc = frames["bs_opened"].document;
					var formO = $("form", doc).offset();
					suggest.css({left: formO.left +"px"});
				}catch(e){}
			}
			else {
				stickyJQElm.hide();
				$("#bs_opened_spacer").hide();
			}
			if ($.browser.msie && parseInt($.browser.version) == 7 && sl.bottomSearch.opened) $("a.bs_top", frames["bs_opened"].document).focus();
			return false;
		}
		this.initIframes();
		var f = $("#bs_opened")[0];
		if (!ie6)
			f.attachEvent ? f.attachEvent('onload', onIframeLoad) : f.addEventListener('load', onIframeLoad, false);
		else
			onIframeLoad();
		if ($.browser.msie)
			$("#body iframe").attr({"allowTransparency": "true"});
	},

	initIframes: function(){
		for (var iframeId in this.content)
			this.setInnerHTML(iframeId);
		if (!ie6) $("#bs_closed, #bs_opened, #bs_startlapSuggestionsResults").css({position: "fixed"});
		else $(".bottomSearch b.l", frames["bs_opened"].document).css({"marginTop": "5px"});
	},

	setInnerHTML: function(id, content){
		if (frames[id].document){
			var c = content?content:this.content[id];
			var d = frames[id].document;
			d.open();
			d.write(
				'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional //EN" "http://www.w3.org/TR/html4/loose.dtd">'+
				'<html>'+ this.template.replace("#BODY", c) +'</html>'
			);
			d.close();
		}
	},

	open: function(){
		this.opened = true;
		var date = new Date();
		date.setTime(date.getTime() + 1000*60*60*24*365);//egy év
		$.cookie('SL_BS_OPENED', 1, {expires: date});
		$("#bs_closed").css("bottom", 0).hide();
		$("#bs_startlapSuggestionsResults").hide();
		$("#bs_opened").show();
		$(window).trigger("resize");
	},
	
	close: function(){
		this.opened = false;
		var date = new Date();
		date.setTime(date.getTime() + 1000*60*60*24*365);//egy év
		$.cookie('SL_BS_OPENED', 2, {expires: date});
		$("#bs_opened").css("bottom", 0).hide();
		$("#bs_startlapSuggestionsResults").hide();
		$("#bs_closed").show();
		$(window).trigger("resize");
	},

	scroll2Top: function(){
		$(window).scrollTo(0);
	}
};

sl.startSearch = function(form){
	var searchModule = $(form).parent().siblings("b.l").children("a.c.selected").attr("href");
	var url;
	switch(searchModule){
		case "#google":
			url = "http://www.startlap.hu/web/";
			break;
		case "#startlap":
			url = "http://www.startlapkereso.hu/searchresult.jsp";
			break;
	}
	form.action = url;
	form.submit();
}

var pTimer = 0;
sl.providers = {

	init: function(){
		$("div.box div.p a").live("mouseover", function(){
			$(this).parent().parent().find("a:not(.selected) b").show();
			$(this).children("b").hide();
			clearTimeout(pTimer);
		}).live("mouseout", function(){
			var $parent = $(this).parent().parent();
			pTimer = setTimeout(function(){
				if ($("a.selected", $parent).size())
					$parent.find("a:not(.selected) b").show();
				else
					$parent.find("a b").hide();
			}, 100);
		});
		$("div.box div.p a[rel]").live("click", function(){
			if ($(this).hasClass("selected")){
				$(this).removeClass("selected");
				$("#pform").hide();
			}
			else {
				$(this).parent().parent().find("a").removeClass("selected").children("b").show();
				$(this).addClass("selected").children("b").hide();
				$("#pform form#"+ $(this).attr("rel")).show().siblings().hide();
				$("#pform:hidden").show();
			}
			$("#pform input#plogin_"+ $(this).attr("rel")).focus();
			return false;
		});
		if ($.browser.msie){
			$("#pform form div.inpt input").live("keypress", function(e){
				if (e.keyCode == 13) {
					e.preventDefault();
					var f = $(this).parents("form").get(0);
					f.onsubmit();
					f.submit();
					return false;
				}
			});
		}
		$("#pform form")
		.find(".figyelem").children("span.boxer").click(function(){ $(this).parent().toggleClass("checked"); })
		.siblings("span.blue").click(function(){ $(this).parents("form").toggleClass("figy"); }).hover(function(){ $(this).addClass("hover"); }, function(){ $(this).removeClass("hover"); });
	},

	onSubmit: function(f, func){
		eval(func);
		var premeberData = {};
		if ($(".figyelem.checked", f).size()) {
			var pData = {
				login: $('#plogin_'+f.id).val(),
				password: $('#ppassword_'+f.id).val()
			};
			if ($.cookie(sl.providersCookieName)){
				premeberData = $.evalJSON($.cookie(sl.providersCookieName));
			}
			premeberData[f.id.split("_").shift()] = {id: f.id, data: pData};
			var date = new Date();
			date.setTime(date.getTime() + 1000*60*60*24*365);//egy év
			$.cookie(sl.providersCookieName, $.toJSON(premeberData), {expires: date});
		} else {
			if ($.cookie(sl.providersCookieName)){
				premeberData = $.evalJSON($.cookie(sl.providersCookieName));
				if (premeberData[f.id.split("_").shift()]){
					delete(premeberData[f.id.split("_").shift()]);
					var date = new Date();
					date.setTime(date.getTime() + 1000*60*60*24*365);//egy év
					$.cookie(sl.providersCookieName, $.toJSON(premeberData), {expires: date});
				}
			}
			setTimeout(function () {$('#ppassword_'+f.id).val('')},500);
		}
	}
	
};

sl.sajat_linkek = {
	ontTagSelect: function(el) {
		var tagId=$(el).val();
		$.getJSON(slconf.sajat_link_loader_url, {tag_id:tagId}, sl.sajat_linkek.render);
	},

	render: function(links) {
		var container = $('#box_kedvenc_linkek div.bg.kl').empty();
		$.each(links, function() {
			$('<a>').attr('href', this.url).text(this.title).appendTo(container);
		});
		container[links.length ? 'show':'hide']();
	}
};

sl.lapkatMenu = {
	init: function(){
		function stickyHandle(oldScrollHeight) {
			var stickyJQElm			= $("#katalogus");
			stickyJQElm.css("position", "absolute").parent().css("position", "relative");
			var off = stickyJQElm.parent().offset();
			var headerHeight		= off.top;
			var currScrollHeight	= document.getElementsByTagName("html")[0].scrollHeight;
			var docHeight			= oldScrollHeight && oldScrollHeight < currScrollHeight ? oldScrollHeight : currScrollHeight;
			var scrollPos			= $(window).scrollTop();
			var maxScrollTo			= docHeight - stickyJQElm.height() - headerHeight - 45;
			var scrollItTo;
			if (stickyJQElm.height() >= $(window).height()){
				var stop = isNaN(parseInt(stickyJQElm.css("top")))?0:parseInt(stickyJQElm.css("top"));
				var stickyFootPos = headerHeight + stop + stickyJQElm.height() - 10;
				if (scrollPos > stickyFootPos){
					scrollItTo = scrollPos - headerHeight > maxScrollTo ? maxScrollTo : scrollPos - headerHeight;
				}
				else if(scrollPos < headerHeight + stop){
					var i = scrollPos - headerHeight;
					scrollItTo = i > maxScrollTo ? maxScrollTo : (i < 0 ? 0 : i);
				}
				else
					return false;
			}
			else {
				if (scrollPos > headerHeight){
					scrollItTo = scrollPos - headerHeight > maxScrollTo ? maxScrollTo : scrollPos - headerHeight;
				}
				else if (parseInt(stickyJQElm.css('top')) > 0){
					scrollItTo = 0;
				}
				else
					return false
			}
			stickyJQElm.stop().animate({top: scrollItTo}, 'slow');
			return false
		}
		$(function(){
			if ($(".w220 div.box.k").size()){
				$(window).bind('scroll', stickyHandle).trigger('scroll');
			}
		});
	}
};

sl.gaTracker = {
	uid: '',

	init: function(gaTrackerId){
		this.uid = gaTrackerId;
		try {
			var mainTracker = _gat._getTracker(this.uid);//footerban már van
			//logo kattintás
			$("#header .logo a").live("click", function(){
				mainTracker._trackPageview('/aktivitas/logo kattintas');
			});
			//link kattintás
			$("div.box a").live("click", function(){
				if (this.id && !$(this).parents(".box.act, .box.kt").size()) {
					var $this = $(this);
					var boxtitle = $this.parents('div.box').find('h1').text();
					boxtitle = boxtitle.replace('/', '-');
					//sales linkek
					if ($(this).hasClass("y")){
						mainTracker._trackPageview('/aktivitas/kattintas/'+boxtitle+'/sales/'+ $this.text()+'/'+this.id);
					}
					else {//szerkesztőségi linkek
						mainTracker._trackPageview('/aktivitas/kattintas/'+boxtitle+'/szerkesztosegi/'+ $this.text()+'/'+this.id);
					}
				}
			});
			//kereső rádiógomb kattintás
			$(".search a.c").live("click", function(){
				mainTracker._trackPageview('/aktivitas/kereses/radiogomb kattintas');
			});
			//hányan keresnek bizonyos keresőkkel
			$(".search form").submit(function() {
				mainTracker._trackPageview('/aktivitas/kereses/'+ $(".search a.c.selected").attr("href").replace("#", ''));
				return true;
			});
			$(".search form a.r").click(function() {
				mainTracker._trackPageview('/aktivitas/kereses/'+ $(".search a.c.selected").attr("href").replace("#", ''));
				return true;
			});
			//alsó kereső
			if ($("#bs_opened").size()){
				function onOpenedIframeLoad(){
					//keresés
					$(".bottomSearch form", doc).submit(function() {
						mainTracker._trackPageview('/aktivitas/kereses/also kereso/'+ $(".bottomSearch a.c.selected", doc).attr("href").replace("#", ''));
						return true;
					});
					$(".bottomSearch form a.r", doc).click(function() {
						mainTracker._trackPageview('/aktivitas/kereses/also kereso/'+ $(".bottomSearch a.c.selected", doc).attr("href").replace("#", ''));
						return true;
					});
					//checkbox
					$(".bottomSearch a.c", doc).click(function(){
						mainTracker._trackPageview('/aktivitas/kereses/also kereso/radiogomb kattintas');
					});
					//becsuk
					$("a.bs_closer", doc).click(function(){
						mainTracker._trackPageview('/aktivitas/kereses/also kereso/becsuk');
					});
					//oldal tetejére
					$("a.bs_top", doc).click(function(){
						mainTracker._trackPageview('/aktivitas/kereses/also kereso/oldal tetejere');
					});
				}
				function onClosedIframeLoad(){
					//kinyit
					$("a", doc2).click(function(){
						mainTracker._trackPageview('/aktivitas/kereses/also kereso/kinyit');
					});
				}
				var f = $("#bs_opened")[0];
				var doc = f.contentWindow ? f.contentWindow.document : f.contentDocument ? f.contentDocument : f.document;
				if (!ie6)
					f.attachEvent ? f.attachEvent('onload', onOpenedIframeLoad) : f.addEventListener('load', onOpenedIframeLoad, false);
				else
					onOpenedIframeLoad();
				var f2 = $("#bs_closed")[0];
				var doc2 = f2.contentWindow ? f2.contentWindow.document : f2.contentDocument ? f2.contentDocument : f2.document;
				if (!ie6)
					f2.attachEvent ? f2.attachEvent('onload', onClosedIframeLoad) : f2.addEventListener('load', onClosedIframeLoad, false);
				else
					onClosedIframeLoad();
			}
			//belépés, regisztráció, beállítások gombra kattintás
			$("#header .loginLinks a").live("click", function(){
				var val;
				switch($(this).text()){
					case "Belépés":
						val = "belepes";
						break;
					case "Regisztráció":
						val = "regisztracio";
						break;
					case "Beállítások":
						val = "beallitasok";
						break
				}
				mainTracker._trackPageview('/aktivitas/'+ val +' gomb kattintas');
			});
			//állítsd be nyitóoldalnak
			$(".loginLinks a.login-nyito").live("click", function(){
				mainTracker._trackPageview('/aktivitas/nyito oldalnak beallitas');
			});
			//tartalomjegyzék kiemelt linkek
			$("#toc-h div.r a").live("click", function(){
				mainTracker._trackPageview('/aktivitas/tartalomjegyzek/kiemelt elem/'+ $(this).text());
			});
			//tartalomjegyzék sima linkek
			$("#toc-c td a").live("click", function(){
				mainTracker._trackPageview('/aktivitas/tartalomjegyzek/sima elem/'+ $(this).text());
			});
			//tartalomjegyzék nyit
			$("#toc-h a[class='opnr l']").live("click", function(){
				mainTracker._trackPageview('/aktivitas/tartalomjegyzek/nyit');
			});
			//tartalomjegyzék zár
			$("#toc-h a[class='opnr l clsr']").live("click", function(){
				mainTracker._trackPageview('/aktivitas/tartalomjegyzek/zar');
			});
			//belépés doboz testreszabás gomb
			$("#pform").siblings(".ll").children("a").live("click", function(){
				mainTracker._trackPageview('/aktivitas/belepes doboz/doboz testreszabasa');
			});
			//belépés doboz regisztráció
			$("#pform form a.lk").live("click", function(){
				mainTracker._trackPageview('/aktivitas/belepes doboz/regisztracio');
			});
			//belépés doboz felhasználónév jelszó megjegyzés
			$("#pform .figyelem span.boxer").live("click", function(){
				if ($(this).parent().hasClass("checked"))
					mainTracker._trackPageview('/aktivitas/belepes doboz/felhasznalonev megjegyzes');
			});
			//belépés doboz termékek
			$(".k3 .p a").click(function(){
				mainTracker._trackPageview('/aktivitas/belepes doboz/termek/'+ $(this).text());
			});
			//szótár doboz
			$("form[target=DicFor]").submit(function() {
				mainTracker._trackPageview('/aktivitas/szotar doboz/kereses');
				return true;
			});
			//időjárás doboz napváltás
			$(".weather .rd").live("click", function(){
				mainTracker._trackPageview('/aktivitas/idojaras doboz/napvaltas');
			});
			//aktuális minden sora, a lábléc is
			$(".box.act a, .box.act div.wicon").live("click", function(){
				var text, s;
				if ($(this).hasClass("wicon")){//időjárás
					text = "idojaras ikonok";
					s = '';
				}
				else{
					text = $(this).text();
					s = $(this).hasClass("y") ? 'sales/' : 'szerkesztosegi/';
				}
				//két felére lebontva
				if ($(this).parents(".col.w240.f").size()){
					mainTracker._trackPageview('/aktivitas/aktualis/bal/'+ s + text);
				}
				else {
					mainTracker._trackPageview('/aktivitas/aktualis/jobb/'+ s + text);
				}
			});
			//kiemelt témák CT
			$(".box.kt a").live("click", function(){
				var text = $(this).text();
				if (text == '')
					text = "logo/"+ $(this).attr("href");
				mainTracker._trackPageview('/aktivitas/kiemelt temak/'+ text);
			});
		} catch(err) {
			try {console.log(err);}catch(e){}
		}
	}
};

sl.localLinks = {
	init: function(items){
		$(items.toString()).each(function(){
			var matchedId = this.href.match(/#b(\d+)/);
			if (matchedId && matchedId[1]){
				var id = matchedId[1];
				$(this).bind("click", function(){
					sl.toc.selectItem(id);
					return false;
				});		
			}
		});	
	}	
}; 
