// Headeranimation
var items;
var cItem = 0;
var pauseTime = 5000;
var fadeTime = 500;
// var easing = 'easeInSine';
var easing = 'easeOutQuad';


$(function(){
	if(typeof get_slides_url != 'undefined' && get_slides_url != '')
		$.getJSON(get_slides_url, function(data){
		// $.getJSON('get_slides.php?f_categoryId=270', function(data){
		// static: $.getJSON('js/data.js', function(data){
			items = data.items;
			
			$.each(items, function(i, item){
				if(i != 0)
					$('<div>').appendTo('#ani').addClass('image').attr('id','image' + i).css({'background-image':'url(' + item.image + ')'});
			})
			
			setInterval(function(){
				aItem = cItem;
				cItem = (cItem + 1 >= items.length) ? 0 : cItem + 1;
				var item = items[cItem];
				
				$('#teaser').animate({'opacity':'0'}, (fadeTime/2), 'swing', function(){
					$('#teaser .name').text(item.name);
					$('#teaser .time').text(item.time);
					$('#teaser .project').text(item.project);
					$('#teaser .copyright').html(item.copy);
					$('#teaser').animate({'opacity':'1'}, (fadeTime/2), 'swing');
				});
				$('#ani #image' + aItem).animate({'right':'640px'}, fadeTime, easing, function(){ $(this).css({'right':'-640px'}); });
				$('#ani #image' + cItem).animate({'right':'0px'}, fadeTime, easing);
			}, pauseTime);
		});
	
	$('#nav li').hover(function(){
		$(this).addClass('hover');		
	},
	function(){
		$(this).removeClass('hover');
	});
	
	
	$('a.plus_info_trigger').click(function(){
		$(this).next('.plus_info').fadeIn('fast');
		$(this).fadeOut('fast');
		
	})
	$('a.plus_info_trigger_close').click(function(){
		$(this).parent().fadeOut('fast');
		$('a.plus_info_trigger').fadeIn('fast');
	})


})
