﻿$(document).ready(function(){

var teksty = new Array(6);
teksty[0] = new Array(3);
teksty[0][0] = "Umiejętności doprowadza Cię na szczyt.";
teksty[0][1] = "Potrzebujesz jednak  charakteru, by na nim pozostać.";
teksty[0][2] = "- Zig Ziglar";

teksty[1] = new Array(3);
teksty[1][0] = "Nie mogę nikogo nauczyć czegokolwiek.";
teksty[1][1] = "Mogę jedynie sprowokować do myślenia.";
teksty[1][2] = "- Sokrates";

teksty[2] = new Array(3);
teksty[2][0] = "Wielkie rzeczy nie powstają w wyniku impulsu,";
teksty[2][1] = "a w wyniku poskładania małych rzeczy w jedną całość.";
teksty[2][2] = "- Vincent Van Gogh";

teksty[3] = new Array(3);
teksty[3][0] = "Zacznij tam gdzie jesteś, użyj tego co masz,";
teksty[3][1] = "zrób co możesz.";
teksty[3][2] = "- Arthur Ashe";

teksty[4] = new Array(3);
teksty[4][0] = "Jeśli to, co robisz nie zbliża Cię do Twoich celów,";
teksty[4][1] = "oznacza to, że Cię od nich oddala.";
teksty[4][2] = "- Brian Tracy";

teksty[5] = new Array(3);
teksty[5][0] = "Duże cele dają duże rezultaty. Brak";
teksty[5][1] = "celu to żaden rezultat, albo osiągnięcie kogoś innego.";
teksty[5][2] = "- Mark Victor Hansen";

var licznik = 1;
var txt = 0;

	$("#txt1").html(teksty[txt][0]);
	$("#txt2").html(teksty[txt][1]);
	$("#txt3").html(teksty[txt][2]);
	
	$('.container .flying-text').css({opacity:0});
	$('.container .active-text').animate({opacity:1}, 4000);

	var int = setInterval(changeText, 1700);	

function changeText(){
	if(licznik > 2)
	{
	
		$('.container .flying-text').css({opacity:0});
		//$('.container .flying-text').animate({opacity:0}, 500);
		txt += 1;
		licznik = 0;	
		if(txt > 5)
			txt = 0;
			
	}
	$("#txt1").html(teksty[txt][0]);
	$("#txt2").html(teksty[txt][1]);
	$("#txt3").html(teksty[txt][2]);
	var $activeText = $(".container .active-text");	
	
	var $nextText = $activeText.next(); 
	if($activeText.next().length == 0) $nextText = $('.container .flying-text:first');
	
	//$activeText.animate({opacity:0}, 1000);
	//$activeText.animate({marginLeft: "-100px"});
		
	$nextText.css({opacity: 0}).addClass('active-text').animate({opacity:1}, 700, function(){
		licznik+=1;
		$activeText.removeClass('active-text');		
	});
} 
});

