/****************************************/
/*		FONCTIONS PARSING				*/
/****************************************/

	function goParse( e ) {
		isPageParse = true ;
		var tabParam	= e.split( "#/" ) ;
		
		if( tabParam[ 1 ] ) {
			var param		= tabParam[ 1 ]
			var urlTarget	= urlSite + "ajax/" + tabParam[ 1 ] ;
		
			var options		= { 
								asynchronous:true ,
								method: "get" ,
								onSuccess: function ( xhr ) {
									$( 'fullContent' ).update( xhr.responseText ) ;	
									new Effect.ScrollTo( "htmlContent", { duration: 0.5 } ) ;
									loadJsEnd() ;
									curHashVal = window.location.hash ;
									prepareParse() ;
									getParse() ;
									$( 'htmlContent' ).removeClassName( "loading" );
								}
							  } 		

			$( 'htmlContent' ).addClassName( "loading" );

			window.setTimeout( function() {
				var ajaxCall	= new Ajax.Request( urlTarget, options );
			}, 500 );
		}
		else {
			curHashVal = window.location.hash ;
			getParse() ;
		}
	}

	function detectChangeUrl() {		
		if( curHashVal != window.location.hash ) { 
			curHashVal = window.location.hash ;
			goParse( curHashVal ) ;
		}
		else getParse() ;
	}

	function getParse() {
		window.setTimeout ( detectChangeUrl, 10 );
	}

	function prepareParse() {
		var Liens = $$( 'a' ) ;
		for( var i = 0; i < Liens.length; i++ ) {
			if( Liens[i].hasClassName( "ajax" ) && ! Liens[i].hasClassName( "ajax_ready" ) )	{
				Liens[i].href = "#/" + Liens[i].href.replace( urlSite, '' ) ;
				Liens[i].addClassName( "ajax_ready" ) ;
			}
		}
	}

/****************************************/
/*		OBSERVATEURS D'ELEMENTS			*/
/****************************************/
	
	var curHashVal	= window.location.hash;

	Event.observe( window, 'load', getParse );
	Event.observe( window, 'load', prepareParse );
