/*
Script: ork.js
	Use MooTools

License:
	MIT-style license.

Copyright:
	Copyright (c) OrK web team.

*/

window.addEvent('domready', function()
{

	// Add effect on all the menu boxes, and the ajax request
	$$('#menu a').each( function(el)
	{
		el.addEvents(
		{
			'mouseover': function()
			{
				el.morph({ 'border-color': '#fff','color':'#fff' });
			},
		
			'mouseout': function()
			{
				el.morph({ 'border-color': '#aaa','color':'#aaa' });
			},
			
			'click': function(event)
			{
				//prevent the page from changing (i.e. following the link)
				event.stop();
	
				var content = $('body');
				var myFx = new Fx( content );

				myFx.start(1,0).chain
				( // in this context this. refer to myFx
					function() { content.fade(0); this.start(); },
					function() { $('content').load( 'pages/' + el.get('href') + '.html' ); this.start(); },
					function() { content.fade(1); this.start(); }
				);
			}
		});
	});
	
	// Remove hard link
// 	$$('#header a').erase('href') ;
	$$('#menu a').erase('href') ;

	// Replace hard link in header by ajax request
	$('header h1').addEvents(
	{
		'click': function()
		{
			$('content').load( 'pages/accueil.html' );
		}
	});

});
