//	delicious liens invisibles
//	some javascript rules

var titles = new Array();
var ind=0;

function putTheLinkInTheMiddleOfThePage() {
	if ($('linkingTheInvisible')) {
		$('linkingTheInvisible')
		.morph({
			'top':(window.getSize().y.toInt()-130)/2
		});
	}
}

function fadeIn() {
	titles[ind].morph({'opacity':1})

}

function fadeOut() {
	titles[ind].morph({'opacity':0})
	ind = (ind<titles.length-1) ? ind+1 : 0;
	
}
window.addEvent('resize', putTheLinkInTheMiddleOfThePage);
window.addEvent('domready',function() {
	
	if (document.getElement('h3 a')) {
		document.getElement('h3 a').set('morph',{duration:300})
		.set('events', {
			'mouseover':function() { this.morph({'color':'#000'}); },
			'mouseout':function() { this.morph({'color':'#999'}); }
		});
	}
	
	document.getElements('#dida h1, #dida h2, #dida h2 strong').set('morph',{duration:400});

	document.getElement('#dida')
	.set('events', {
		'mouseover':function() { 
			document.getElement('#dida h1').morph({'color':'#ddd'}); 
			document.getElement('#dida h2').morph({'color':'#3274D0'}); 
			document.getElements('#dida h2 strong').morph({'color':'#565656'}); 
		},
		'mouseout':function() { 
			document.getElement('#dida h1').morph({'color':'#eee'}); 
			document.getElement('#dida h2').morph({'color':'#ddd'}); 			
			document.getElements('#dida h2 strong').morph({'color':'#ccc'}); 				
		}
	});

	
	if ($('linkingTheInvisible')) {
		$('linkingTheInvisible')
		.set('morph',{duration:250})
		.set('styles',{
			'top':(window.getSize().y.toInt()-130)/2,
			'opacity':.8
		});
	}


	$$('#linkingTheInvisible>li').each(function(title,index) {
		
		title
		.set('styles',{
			'display':'block',
			'opacity':0
		})
		.set('morph',
			{
				duration:1500, 
				link:'chain', 
				onComplete:function() {
					if (titles[ind].getStyle('opacity')==0) fadeIn.delay(500);
					else fadeOut.delay(5000);
				}
			});
		
		titles[index] = title;
	});
	if ($$('#linkingTheInvisible>li').length>0) titles[0].morph({'opacity':1});
	
	$$('#linkingTheInvisible>li>a','._blank').addEvent('click', function() {
		window.open(this.href,'an-invisible-link','');
		return false;
	});
	
	

})
