jQuery(function(){
	$("a[rel=external]").live("click", function(){
		$(this).attr("target", "_blank");
		return true;
	});
	
	var scroll_opt = {
		keret: $("#hirek"),
		mozgo: $("#hirek_cont"),
		gombok_selector: ".scroll",
		le_class: "scroll_le",
		fel_class: "scroll_fel",
		scroll_event: "click",
		scroll_egyseg: $("#hirek").height()/2,
		scroll_duration: 400,
		scroll_easing: 'linear'
	};

	if(scroll_opt.mozgo.height()>scroll_opt.keret.height()) {$("."+scroll_opt.le_class).show();}

	$(scroll_opt.gombok_selector).bind(scroll_opt.scroll_event, function(){
		var ujPozicio = false;
		var pozicio = parseInt(scroll_opt.mozgo.css("margin-top"));
		var magassag = scroll_opt.mozgo.height();
		var le = $("."+scroll_opt.le_class);
		var fel = $("."+scroll_opt.fel_class);
		
		switch(true)
			{
			case ($(this).hasClass(scroll_opt.le_class)): ujPozicio=pozicio-scroll_opt.scroll_egyseg; break;
			case ($(this).hasClass(scroll_opt.fel_class)): ujPozicio=pozicio+scroll_opt.scroll_egyseg; break;
			default: return false;
			}
		
		scroll_opt.mozgo.animate({'margin-top': (ujPozicio>0?0:ujPozicio)},
								 {duration: scroll_opt.scroll_duration,
								  easing: scroll_opt.scroll_easing,
								  queue: false,
								  complete: function(){
										if(ujPozicio == 0) {fel.hide();}
										else {fel.show();}
										if(Math.abs(ujPozicio) >= (magassag-scroll_opt.keret.height())) {le.hide();}
										else {le.show();}
								  }
		});
	});
});
