﻿ $(document).ready(function(){ 
	/* ---------- TopMenu ---------- */
        $("ul.sf-menu").supersubs({ 
            minWidth:    12,   // minimum width of sub-menus in em units 
            maxWidth:    27,   // maximum width of sub-menus in em units 
            extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                               // due to slight rounding differences and font-family 
        }).superfish();  // call supersubs first, then superfish, so that subs are 
                         // not display:none when measuring. Call before initialising 
                         // containing tabs for same reason. 
		/* Kozepre igazitjuk a kesz menut */
		var $TopMenuWidth = $("ul.sf-menu").outerWidth(true);
		var $TopMenuBox = $("#TopMenu").width();
		if($TopMenuWidth>0 && $TopMenuWidth<$TopMenuBox){
			var $TopMenuBalMargo = ($TopMenuBox-$TopMenuWidth)/2;
			$("ul.sf-menu").css('margin-left',$TopMenuBalMargo);
		}
	/* ---------- TopMenu vége ---------- */
	
	/* ---------- AlsoPartnerekCarousel ---------- */
	var $AlsoPartnerekCarouselHeight = $("#AlsoPartnerekCarousel").height();
	jQuery('#AlsoPartnerekCarousel li').each(function() {
		var $Elem = $(this).find('img');
		var $ElemHeight = $($Elem).height();
		if($ElemHeight>0 && $ElemHeight<$AlsoPartnerekCarouselHeight){
			var $TopMargo = ($AlsoPartnerekCarouselHeight-$ElemHeight)/2;
			$Elem.css('margin-top',$TopMargo);
		}
	});
	
    jQuery('#AlsoPartnerekCarousel').jcarousel({
        visible: 4,
		auto: 4,
		wrap: 'last',
		easing: 'easeInOutBack',
		animation: 3000,
     // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null,		
		initCallback: BDTeam_Carousel_initCallback
    });
	
	function BDTeam_Carousel_initCallback(carousel){
		// Disable autoscrolling if the user clicks the prev or next button.
		jQuery('#AlsoPartnerekCarouselKovetkezo').bind('click', function() {
			carousel.startAuto(0);
			carousel.next();
			return false;
		});

		jQuery('#AlsoPartnerekCarouselElozo').bind('click', function() {
			carousel.startAuto(0);
			carousel.prev();
			return false;
		});
		
		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};
	
	/* ---------- AlsoPartnerekCarousel vége ---------- */
	
	/* ---------- Galéria egyenlő magasságú előnézeti képek ---------- */
		function CsoportElemekEqualHeight(group) {
			var tallest = 0;
			group.each(function() {
				var thisHeight = $(this).height();
				if(thisHeight > tallest) {
					tallest = thisHeight;
				}
			});
			group.height(tallest);
		}
		
	/* ---------- Galéria egyenlő magasságú előnézeti képek vége ---------- */
	
	/* ---------- Galéria megjelenés ---------- */
	/*hs.graphicsDir = '../highslide/graphics/';*/
	hs.graphicsDir = 'bdt_layout/Feketefarm/bdt_img/highslide/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.fadeInOut = true;
	hs.dimmingOpacity = 0.9;
	hs.outlineType = 'rounded-white';
	hs.captionEval = 'this.thumb.alt';
	/*hs.marginBottom = 105; // make room for the thumbstrip and the controls*/
	hs.marginBottom = 110; // make room for the thumbstrip and the controls
	hs.numberPosition = 'caption';

	// Add the slideshow providing the controlbar and the thumbstrip
	hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 4000,
		repeat: true,
		useControls: true,
		overlayOptions: {
			className: 'text-controls',
			position: 'bottom center',
			relativeTo: 'viewport',
			offsetY: -60
		},
		thumbstrip: {
			position: 'bottom center',
			mode: 'horizontal',
			relativeTo: 'viewport'
		}
	});	
	/* ---------- Galéria megjelenés vége ---------- */
	
	/* Galeria Accordion */
	function InitGaleriaAccordion() {
	
			$('ul.CsoportLista > li:not(.CsoportListaGaleriai)').each(function(){
				var CsoportListaElem = $(this).next();
				if($(this).hasClass('Aktiv')){
					
				}else{
					if( (CsoportListaElem.is('li')) && (CsoportListaElem.hasClass('CsoportListaGaleriai')) ){
						$(CsoportListaElem).hide();						
					}
				}
			});

		/*$('ul.CsoportLista > li.Aktiv:').show();*/
		/*$('ul.CsoportLista > li.AccordionFunkcLiBox > a.AccordionFunkc').append("<strong>Hello</strong>");*/
		

			$('ul.CsoportLista > li.AccordionFunkcLiBox > a.AccordionFunkc').click(
				function() {
				
					var checkElement = $(this).parent().next();
					
					if((checkElement.is('li')) && (checkElement.hasClass('CsoportListaGaleriai')) && (checkElement.is(':visible')) ) {
						$('ul.CsoportLista > li.AccordionFunkcLiBox > a.AccordionFunkc').removeClass('AccordionFunkcClose');
						$('ul.CsoportLista > li.AccordionFunkcLiBox > a.AccordionFunkc').addClass('AccordionFunkcOpen');
						
						$('ul.CsoportLista > li.CsoportListaGaleriai:visible').slideUp('slow');
						$(this).removeClass('AccordionFunkcClose');
						$(this).addClass('AccordionFunkcOpen');
						//return false;
					}
				
					if((checkElement.is('li')) && (checkElement.hasClass('CsoportListaGaleriai')) && (!checkElement.is(':visible')) ) {
						/*$('#menu ul:visible').slideUp('slow');*/
						$('ul.CsoportLista > li.AccordionFunkcLiBox > a.AccordionFunkc').removeClass('AccordionFunkcClose');
						$('ul.CsoportLista > li.AccordionFunkcLiBox > a.AccordionFunkc').addClass('AccordionFunkcOpen');
						
						$('ul.CsoportLista > li.CsoportListaGaleriai:visible').slideUp('slow');
						checkElement.slideDown('slow');
						/*$('html, body').animate({scrollTop:0}, 'slow')*/
						var ThisOffset = checkElement.offset();
						/*$('html, body').scrollTop(ThisOffset.top-50);*/
						/*alert(ThisOffset.top);
						alert($(this).parent().outerHeight(true));*/
						$('html, body').animate({scrollTop:ThisOffset.top-($(this).parent().outerHeight(true)*3)}, 'slow')
						/*checkElement.addClass('Nyitva');*/
						$(this).removeClass('AccordionFunkcOpen');
						$(this).addClass('AccordionFunkcClose');
						//return false;
					}
					
			});
			/*
			$('ul.CsoportLista > li.AccordionFunkcLiBox > a.AccordionFunkcClose').click(
				function() {
				
					var checkElement = $(this).parent().next();
					
					if((checkElement.is('li')) && (checkElement.hasClass('CsoportListaGaleriai')) && (checkElement.is(':visible')) ) {
						$('ul.CsoportLista > li.CsoportListaGaleriai:visible').slideUp('slow');
						//return false;
					}
				
					
			});			
			*/
	}
	InitGaleriaAccordion();
	/* Galeria Accordion vége */
	
		
}); 
