/**
 * © GOELDI, Zürich
 * goeldi.eu
 * author: Peter Göldi | goeldi.eu
 */

window.addEvent('domready', function() {
	
	var now = Math.round(+new Date()/1000),
		last = Cookie.read('lastHit') ? Cookie.read('lastHit').toInt() : now,
		showIntro = false;
	if ((now - last) > 100 || (now == last)) {
		showIntro = true;
		last = now;
		Cookie.write('lastHit',now);
	}
	var po = $('project-overview');
	if (!po) return;
	$('project-overview').getChildren('li').each(function(item, index){
		var anchor = item.getElement('a'),
			image = item.getElement('img');
		if (showIntro) {
			item.setStyle('opacity',0);
			(function(){ item.fade(1) }).delay(200 + index*350);
		};
		item.addEvents({	
			'click': function() {
					window.location=anchor.get('href');
				},
			'mouseenter': function() {
					image.fade(0.5);
				},
			'mouseleave': function() {
					image.fade(1);
				}
		}).setStyle('cursor','pointer');
		
		anchor.addEvent('click',function(event){
			event.preventDefault();
		});
	});
});
