
/*   
var tekstyklient = new Array();
$("div.client_text p").each(function(i){
	tekstyklient.push(i);
});
*/

/*


var scrollingfunc = function movepointer (){
 $("#setoffset").html($(window).scrollTop());	
}
*/

var pozycje_top = new Array ();


$(document).ready(function() {
	
	
    hide_list();
	
	
	$(".showPanelHidden").hide();
 //funcja chowa zawartość diva po użyciu przycisku
	$(".togglebutton").click(function(){
		
	//parent().css('backround-color','red');
	$(this).parent().children(":nth-child(2)").toggle();
	test = $(this).parent().children(":nth-child(2)").is(":visible");
	//alert(test);
		if(test){
			$(this).attr({
			src: "images/mniej_przycisk.png"
		});
		} else {
			$(this).attr({
			src: "images/wiecej_przycisk.png"
		});
		}
		
		
		

	});
	
//funkcja pokazuje opis osoby animujący się nad jej zdjęciem

$.fn.showperson = function(){
	$(this).live('mouseenter mouseleave', function(event) {
	var panel = $('.person', $(this));
	  if (event.type == 'mouseenter') {
	    panel.animate({top: 15}, 400, 'swing')
	  } else {
	    panel.animate({top: '240px'}, 400, 'swing')
	  }
	});
	}
	
	
	//wywołanie funkcji
	$(".work li").showperson();	
	

		
	
	//$('#about_me_content h1').text('testowy wpis');


		
	// jquery Carousel dla sekcji Sukcesy	
		


// Button status functionality
	$(function () {
		//Select the buttons to be clicked, and appends appropriate class on click
	  	$('ul#main_nav li a').click(function () {
			$('ul#main_nav li a').removeClass('on');
	        $(this).addClass('on');	        
	    })	 
	
		$('.back_to_top').click(function () {
			$('ul#main_nav li a').removeClass('on');
	    })
		
	
	});
	

	

	// Smooth scroll code **http://blog.medianotions.de/en/articles/2009/smoothscroll-for-jquery**

	

	  // jQuery SmoothScroll | Version 10-04-30
	$('#main_nav a[href*=#]').click(function() {

	   // duration in ms
	   var duration=500;

	   // easing values: swing | linear
	   var easing='swing';

	   // get / set parameters
	
	   var newHash=this.hash;
	   var target=$(this.hash).offset().top;
	   
	   var oldLocation=window.location.href.replace(window.location.hash, '');
	   var newLocation=this;

	   // make sure it's the same location      
	   if(oldLocation+newHash==newLocation)
	   {
	      // animate to target and set the hash to the window.location after the animation
	      $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {

		    
			 
	         // add new hash to the browser location
	         window.location.href=newLocation;
			 		 
	      });
		   
		// moving menu pointer
//		  var move_pointer = Math.round($(this).parent().offset().top);
//		  var move_pointer_2 = move_pointer - Math.round($('#nav_wrap').offset().top) -5;
//		  
//		    $('#nav_pointer').animate({ top:move_pointer_2}, duration, easing);
		//  $('#nav_pointer').animate({ top:move_pointer_2}, duration, easing).css('left',$('#main_nav').width());
		   
		 //change pointer top value without animation effect 
		 //css("top",przesuniecie-przesuniecie2+'px');

	      // cancel default click action
	      return false;
	   }
	});
	
		 //$('#nav_pointer').animate({scrollTop: dlugosc }, duration, easing); 

/*mouse scroll function*/


// moving menu pointer
		 
		  
		    

	
	//wywołanie funkcji
	
	//funkcje do przewijania slajdow - strona platforma e-learningowa - plugin jquery cycle all
	
	function pagerFactory(idx, slide)
{
   return "<a href=\"#\"></a>";
};
	  
  var opisy_szkolenia = new Array();
  opisy_szkolenia['text1'] = 'Opowiadamy <span>historie,</span> <br /> które <span>uczestnicy  <br />zapamiętują</span>';
  opisy_szkolenia['text2'] = 'Tworzymy <br /> <span>odpowiedni kontekst</span>, <br /> aby uczestnicy mogli<span> natychmiast <br />użyć nowej wiedzy</span> ';
  opisy_szkolenia['text3'] = 'Zapewniamy <br/> <span>różnorodność</span><br /> środków przekazu i ich <br/> <span>interaktywność,</span> <br /> aby uczestnicy <br /> nigdy się nie nudzili';
  
  var opisy_platforma = new Array();
  opisy_platforma['text4'] = 'Dostęp do platformy <br /> może mieć <br /> <span>nieograniczona <br /> liczba <br /> pracowników</span>';
  opisy_platforma['text5'] = '<span>Ponad 30</span> <br /> zdefiniowanych <br /> <span>raportów</span> <br /> pozwalających <br /> generować <br /> <span>wiele informacji</span>';
  opisy_platforma['text6'] = 'Platforma może <br /> zostać <br /> <span>dostosowana <br /> graficznie do </span> <br />potrzeb każdego <br /> <span>Klienta</span>';  
   
   function onBefore() { 
    $('.text').html(opisy_platforma[this.title]); 
   
	} 
	function onAfter() { 
	    $('.text').html(opisy_platforma[this.title]); 
	     
	}
    
    function onBeforeCourses() { 
    $('.text_courses').html(opisy_szkolenia[this.title]); 
	} 
	function onAfterCourses() { 
	    $('.text_courses').html(opisy_szkolenia[this.title]); 
	}


  $("#elearning_platform_wrapper #navPics").cycle({
			fx: "scrollUp",
			speed:       500,
			timeout:     10000,
       	    pager:   "#elearning_platform_wrapper .navPicsPagination",
			pagerAnchorBuilder: pagerFactory,
			before:  onBefore, 
		    after:   onAfter
		}); 
				
	
  $("#elearning_courses_wrapper #navPics").cycle({
			fx: "scrollUp",
			speed:       500,
			timeout:     10000,
       	    pager:   "#elearning_courses_wrapper  .navPicsPagination",
			pagerAnchorBuilder: pagerFactory,
			before:  onBeforeCourses, 
		    after:   onAfterCourses
		}); 
					
				
				

					
		//$("div#makeMeScrollable").smoothDivScroll({autoScroll: "always", autoScrollDirection: "endlessloop", pauseAutoScroll: "mouseover"});
	//$.each( { name: "John", lang: "JS" }, function(k, v){
   //alert( "Key: " + k + ", Value: " + v );
 //});
	
	//	var pozycje = $("h1.page_title");				
		var pozycja_elementu = $(".page_title").each(function (e) {
			pozycje_top.push(parseInt($(this).offset().top));
		});
		

		


   var nav =  function(){
	 
		$nav  = $('#nav_pointer');
		var window_position = 0;
		
		aktualna_pozycja = $(window).scrollTop()-500;
		for(i=0; i<=pozycje_top.length-1; i++){
			//alert(pozycje_top[i]);
			if(aktualna_pozycja>=pozycje_top[i] && aktualna_pozycja < pozycje_top[i+1] ){
				window_position = i+1;
			} else
			if (aktualna_pozycja>=pozycje_top[i] && i==pozycje_top.length-1){
				window_position = i+1;
			}
		}
		
		
		//$('#setoffset').html(window_position);
		//var elempos = $('#main_nav :nth-child('+window_position+')').offset().top;	
		window_position++;
		var elempos = Math.round($('#main_nav :nth-child('+window_position+')').offset().top);
		var elempos = elempos - Math.round($('#nav_wrap').offset().top) -5;
		//alert(elempos);alert("wefd");
		$nav.stop().animate({"top": elempos + "px"}, "slow" );	
		//.animate({ top:move_pointer_2}, "slow");	
	   
};    
       
      
	
//	window.onscroll = scrollingfunc;
	window.onscroll = nav;
	
}); 


