
//         d8888                  
//        d88888                  
//       d88P888                  
//      d88P 888   888     888    
//     d88P  888 8888888 8888888  
//    d88P   888   888     888    
//   d8888888888                  
//  d88P     888                  
// 
//  © Uli Schöberl, aplusplus.org 





$(function(){
	
	
	
	// $('body').css({opacity:.99});
	$("a[href^='/'],a[href*='"+location.hostname+"']").click(function(){
		$.cookie('clickedinternal', 'true'); //, { expires: 7}
		$('#loader').show();
		$('#allcontent,.backlink').hide();
		self.location.href = $(this).attr('href');
		return false;
	});
	
	$('.folderimages img,.thumbwrap,#contact li,#footer,.backlink,.foldertitle a').css({opacity:0,visibility:'visible'});
	
	if($('#index').length){
		initIndex();
	}
	

	
	// if(!$.cookie('clickedinternal')){
	// 	$('#header h1 a, #header a').css({opacity:0,paddingLeft:'0'});
	// }

});


$(window).load(function(){
	$('#loader').hide();
	// console.log($.cookie('clickedinternal'));
	if($.cookie('clickedinternal')){
		fadeInContent();
	} else {
		
		// $('#header h1 a').animate({opacity:1,paddingLeft:0},800,'easeInOutSine',function(){
		// 	$('#header a').animate({opacity:1,paddingLeft:0},400);
		// 	fadeInContent();
		// });
		
		fadeInContent();
	}
	
	$.cookie('clickedinternal',null);
	
})

function initIndex(){
	$('.folder').hover(function(){
		$('img',this).stop().css({opacity:.07}); //,100,'easeInOutSine'
		$('.foldertitle a',this).stop().css({opacity:1});
	},function(){
		$('img',this).stop().animate({opacity:1},200,'easeInOutSine');
		$('.foldertitle a',this).stop().animate({opacity:0},150,'easeInOutSine');
	});
	
	$('.folder').click(function(){
		$('a',this).trigger('click');
	}).css({cursor:'pointer'});
}

function fadeInContent(){
	a = $('.folderimages img,.thumbwrap,#contact li')
	a.each(function(i,e){
		$(e).animate({opacity:0},10+i*40,function(){
			$(this).animate({opacity:1},300,'easeInOutSine');
		})
	});
	
	$('#footer,.backlink').animate({opacity:0},100+2*40,function(){
		$(this).animate({opacity:1},1000,'easeInOutSine');
	})
}

