$(document).ready(function() {

	debug = false;
	
	function penjac(animate) {
		$('#penjac').stop();
		var top = $('.left li a.active').offset().top;
		top = 680 - top;
		top *= -1;
		(debug) ? console.log(top) : false;
		if(animate) {
			$('#penjac').animate({
		    top: top
		  	}, 600, function() {
		    // Animation complete.
		  	});
		} else {
			$('#penjac').css('top',top);
		}
	}
	
	penjac(false);
	
	$('.menu li').mouseover(function(){
		
		top = $(this).offset().top;
		top = 680 - top;
		top *= -1;
		(debug) ? console.log(top) : false;

		$('#penjac').stop();
		$('#penjac').animate({
	    top: top
	  	}, 300, function() {
	    // Animation complete.
	  	});

	});


	$('.menu li').mouseout(function(){
		penjac(true);
	});
	
	
	// footer
	
	$(".footer_ani1").everyTime(10, function (){
		$(this).animate({left:200},2500).animate({left:165},3000).animate({left:155},4000);
	});

	$(".footer_ani2").everyTime(10, function (){
		//$(this).animate({left:690},1500).animate({left:720},3000).animate({'rotate':30},1000);
	});

	$(".footer_ani3").everyTime(10, function (){
		$(this)	.animate({left:'-=10',top:'+=4'},1000)
				.animate({left:'-=0',top:'+=0'},2000)
				.animate({left:'-=10',top:'+=4'},500)
				.animate({left:'+=10',top:'-=4'},500)
				.animate({left:'+=10',top:'-=4'},1000)
				.animate({left:'-=0',top:'+=0'},2000)
	});


	// FancyBox
	$.each( $("area[rel^=galerija]"), function(){
		$(this).fancybox();
	});

});
