$(document).ready(function(){
	$("#Redirection").hide();
	$("#loadCreation").hide();
	$("#load").hide();
	
	$("#MENU a").click(function(){
		page = $(this).attr("href");
		//alert(page);
		page_extract = "";
		test=0;
		for(i=0;i<page.length;i++){
			if(test==1){
				page_extract += page[i];
			}
			if(page[i]=='='){
				test=1;
			}
		}
		
		//alert(page_extract);
		
		$.ajax({
			url:"Pages/"+page_extract+".php",
			beforeSend: function(){
				$("#CONTENEUR").fadeOut(500,function(){
					$("#load").show();
				});
			},
			/*complete: function(){
				affichage(html);
			},*/
			success:function(html){
				affichage(html);
			},
			error:function(XMLHttpRequest,textStatus,errorThrown){
				alert(textStatus);
			}
		})
		return false;
	});
	
	$("#FOOTER a").click(function(){
		page = $(this).attr("href");
		//alert(page);
		page_extract = "";
		test=0;
		for(i=0;i<page.length;i++){
			if(test==1){
				page_extract += page[i];
			}
			if(page[i]=='='){
				test=1;
			}
		}
		
		//alert(page_extract);
		
		$.ajax({
			url:"Pages/"+page_extract+".php",
			beforeSend: function(){
				$("#CONTENEUR").fadeOut(500,function(){
					$("#load").show();
				});
			},
			/*complete: function(){
				affichage(html);
			},*/
			success:function(html){
				affichage(html);
			},
			error:function(XMLHttpRequest,textStatus,errorThrown){
				alert(textStatus);
			}
		})
		return false;
	});
	
});

function affichage(data){
		$("#CORP").empty();
		$("#CORP").append(data);
		$("#CORP").ready(function(){
			$("img").ready(function(){
				$("#load").hide();
			});
			//$("#CONTENEUR").show();
		})
		$("#CONTENEUR").fadeIn(1000);
}
