window.addEvent('domready', function(){
	
	// ============================
	// = fade in and out keyfacts =
	// ============================
	
	// flash/pulsate implementation by davidwalsh.name
	Element.implement({
		flash: function(to,from,reps,prop,dur) {

			//defaults
			if(!reps) { reps = 1; }
			if(!prop) { prop = 'background-color'; }
			if(!dur) { dur = 250; }

			//create effect
			var effect = new Fx.Tween(this, {
					duration: dur,
					link: 'chain'
				})

			//do it!
			for(x = 1; x <= reps; x++)
			{
				effect.start(prop,from,to).start(prop,to,from);
			}
		}
	});

	$$('#keyfacts a img').each(function(el, index){
		el.flash('1','0.2',500,'opacity',$random(3000, 8000));
		el.addEvents({
			'mouseover':function(){
				$('desc').set('text',el.getParent('div').getElements('div')[index].get('text').clean());
				$('desc').fade('in');
			},
			'mouseout':function(){
				$('desc').fade('out');
			},
		});		
	})	

	// =================================
	// = fade in and out for home page =
	// =================================
	if($chk($('home'))) {	
		$('subnavigationlist').fade('hide');
	
		$('verity').addEvent('mouseover', function(e) {
			$('subnavigationlist').fade('in');
		})
		$('homepage').addEvent('mouseover', function(e) {
			$('subnavigationlist').fade('out');
		})
		$('shop').addEvent('mouseover', function(e) {
			$('subnavigationlist').fade('out');
		})
		// $('blog').addEvent('mouseover', function() {
		// 	$('subnavigationlist').fade('out');
		// })
	}
});