jQuery(document).ready(function() {



	$("ul#menu li a").each(function () {
		if( $('ul:first',jQuery(this).parent()).length > 0 ) {
			jQuery(this).attr("href", "javascript:void(null)").click(function() {
				$('ul:first', jQuery(this).parent()).slideToggle();
			});
		}
	})


	jQuery("#menu a")
	.attr("href", "javascript:void(null)")
	.not(":contains('Tudományos ismeretek')")
	.click(function () {
		
		var id = jQuery(this).attr("id");

		var pos = jQuery("#"+id.replace(/_btn2|_btn/g, "")).offset();
		if (typeof pos.top != 'undefined') {
			jQuery.scrollTo((pos.top-10) + "px", 700);
		}
			
	})
	

	//
	//	jQuery("#kezdolap_btn, #rendeles_btn, #lkarnitin_btn, #lkarnitin05_btn,"+
	//			"#shot_btn, #energydrink_btn, #mandala_lime_btn, #izotopiasitalok_btn,"+
	//			".lkarnitin_btn, .lkarnitin05_btn, .aloevera_btn,"+
	//			".shot_btn, .energydrink_btn, .mandala_lime_btn, .izotopiasitalok_btn,"+
	//			"#tudomanyosismeretek_btn, #kapcsolat_btn, #mandala_line_btn, #egyebtermekek_btn, #az_optimalis_sportital_jellemzoi_btn, #az_izotonias_italok_btn, #L_karnitin_btn, #krom_btn, #koffein_btn, #taurin_btn, #aloe_vera_btn, #gingko_btn,"+
	//			".tudomanyosismeretek_btn")
	//	.attr("href", "javascript:void(null)")
	//	.click(function () {
	//		var id = jQuery(this).attr("id")?jQuery(this).attr("id"):jQuery(this).attr("class");
	//
	//		var pos = jQuery("#"+id.replace(/_btn2|_btn/g, "")).offset();
	//		jQuery.scrollTo((pos.top-10) + "px", 700);
	////		$("html").animate({
	////			scrollTop: (pos.top-10) + "px"
	////		}, {
	////			duration: 700
	////		});
	//	});


	var screenHeight = jQuery(window).height();
	jQuery(".page, .page-full").each(function () {
		if( jQuery(this).height() < screenHeight ) {
			jQuery(this).height( screenHeight +"px" );
		}
	})









	var currentPos = 0;
	var scrollStep = 221;
	var obj = jQuery(".termek_scroller");

	jQuery(".termek_scroller_prev").click(function () {
		currentPos--;
		if( currentPos < 0 ) {
			currentPos = jQuery(".item", obj).length-1;
		}
		obj.animate({
			left: (-1 * currentPos * scrollStep) + "px"
		}, 500);
	})

	jQuery(".termek_scroller_next").click(function () {

		currentPos++;
		var length = jQuery(".item", obj).length;
		if( currentPos >= length ) {
			currentPos = 0;
		}

		obj.animate({
			left: (-1 * currentPos * scrollStep) + "px"
		}, 500);
	})


	FloatMenu();
	setTimeout("headerScroll()", 5000);



});

$(window).scroll(function () {
	FloatMenu();
});

function FloatMenu(){
	var menuObj = jQuery("#left");
	var menuOffset = menuObj.offset();
	var scrollAmount=$(document).scrollTop();


	//	if(scrollAmount<125){
	//		menuObj.css({
	//			left: '0px',
	//			top: "125px",
	//			position: "absolute"
	//		});
	//	} else {
	menuObj.stop().css({
		position: "fixed",
		left: menuOffset.left + "px",
		top: "0px"
	});
//	}
}



var headerI = 0;
function headerScroll() {
	var length = jQuery("#header_scroller img").length;
	headerI++;
	if( headerI > length ) headerI = 0;

	jQuery("#header_scroller").animate({
		top: -headerI * 227 + "px"
	}, 1000);

	setTimeout("headerScroll()", 5000);
}


