// JavaScript Document
//----------------------------------------------
//-------------------TIME LINE -----------------
//----------------------------------------------
			//BARRA DE ROLAGEM
			//$(function()
			//{
			//	$('#time-line-year').jScrollPane();

			//});
// SCROLL
$(function(){
    $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
				var targetOffset = targetOffset - 10;
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                return false;
            }
        }
    });
});
//<a href="#portfolio">Portfólio</a><div id="portfolio">
$(document).ready(function(){
	$('#time-line-year').css( "visibility", "hidden" )
	$('a.btn-time-line').click(function(e){
		$('#time-line').css( "height", "auto" )
		$('#time-line-year').css( "visibility", "visible" )
	})

//------------------
		$(window).scroll(function(){
		
			
			var windowScrollTop = $(window).scrollTop();
			var windowHeight = $(window).height();
			
			   el =  $('#time-line-year')   
					
			if(windowScrollTop < 350){
				el.slideUp();
			}else{
				el.slideDown();
			}
			
		});
//--------------------
		anim('#nuvem1',0.5);
	anim('#nuvem2',0.3);
	anim('#nuvem3',0.1);
	anim('#montanha1',0.5);
	anim('#montanha2',0.3);
	anim('#montanha3',0.1)
	anim('#arvore2',0.5);
	anim('#arvore1',0.6);
	anim('#arvore_frente',0.9);
	anim('#trilho',0.9);
	
	setInterval( trem, 200 )
//---------------------
//============= ACORDION Agenda ================//
	$(".agenda_old_title").click(function(e){
		e.preventDefault();
		$(this).next().slideToggle();
		return false;
	})
	
//============================================
//================= IMPRESSÃO ==================

	$('.print').click(function() {
		window.print();
		return false;
	});
})//fim jquery


//------------------------------------------------
// ------------------ PARALLAX--------------------
//------------------------------------------------
function anim(obj,velocity){
	var xAdd = 0;
	var scrollInterval = setInterval(function(){
		xAdd++;
		if(xAdd >= 5000){xAdd = 0;}
		$(obj).css('background-position',(xAdd * velocity) + 'px 100%');
	},10);
}
//----------------------------------------------
//----------------- ANIMA O TREM ---------------
//----------------------------------------------
var i = 0;
var left = 0;
var inv = false;

function trem(){
	if( left==566 ) inv = true;
	if( left==0 ) inv = false;
	if( inv ) left -= 283;
	else left += 283;
	$('#trem').css('background-position','-'+left+'px top');
}

