$(function(){
	$.extend( $.easing, {
	    easeInOutCubic: function (x, t, b, c, d) {
			if ((t/=d/2) < 1) return c/2*t*t*t + b;
			return c/2*((t-=2)*t*t + 2) + b;
		},
		easeOutExpo: function (x, t, b, c, d) {
			return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
		}
	});
	$('#langs li:first').mouseenter(function(){
		$('#langs li').show();
	});
	$('#langs').mouseleave(function(){
		$('#langs li:not(.active)').hide();
	});
	$('#langs .active a').click(function(e){
		e.preventDefault();
	});
	$('#top .text, #quest textarea').focusin(function(){
		if ($(this).val() == $(this).attr('title'))
			$(this).val('');
	}).focusout(function(){
		if ($(this).val() == '')
			$(this).val($(this).attr('title'));
	});
	$(".photos a").fancybox({
			'titleShow':false,
			'transitionIn':'fade',
			'transitionOut':'fade',
			'overlayOpacity': 0.5,
			'centerOnScroll': true,
			'padding': 0
	});
	$('.gmap').fancybox({
		'titleShow':false,
		'type' : 'iframe',
		'autoScale' : false,
		'width' : '80%',
		'height' : '80%',
		'href' : $('.gmap').attr('href')+"&output=embed",
		'overlayOpacity': 0.5,
		'centerOnScroll': true,
		'padding': 0,
		'transitionIn':'fade',
		'transitionOut':'fade'
	});
	bannerAlign();
});

var isviso = 0;
var aktyvus = 0;

$(window).resize(function(){
	bannerAlign();
});
$(window).load(function(){
	isviso = $('#banners img').size();
	if (isviso > 5) {
		$('#banners img').each(function(index) {
			if (index < 5) {
				$(this).clone().appendTo('#banners .slider');
			}
		});
		setTimeout('bannerAnimation()',secs);
	}
});
function bannerAnimation() {
	var kitas = aktyvus + 1;
	if (aktyvus == isviso) {
		$('#banners .slider').css('left', 0);
		kitas = 1;
	}
	$('#banners .slider').animate({'left' : -220 * kitas }, greitis, 'easeInOutCubic');
	aktyvus = kitas;
	setTimeout('bannerAnimation()',secs+greitis);
}
function bannerAlign() {
	var w = $(window).width();
	if (w >= 1100) {
		$('#banners').css({
			'width': 1100,
			'left': -60
		});
		$('#banners .inner').css({'width': 1100});
	} else if (w >= 980) {
		$('#banners').css({
			'width': w,
			'left': (w-980) / -2
		});
		$('#banners .inner').css({'width': w});
	} else {
		$('#banners').css({
			'width': 980,
			'left': 0
		});
		$('#banners .inner').css({'width': 980});
	}
}
