/**
 * Navigation Ajax - http://www.webinventif.fr/navigation-sans-rechargement-de-page-via-javascript-jquery/
 * 
 * Copyright (c) 2008 Julien Chauvin (webinventif.fr)
 * Licensed under the Creative Commons License:
 * http://creativecommons.org/licenses/by/3.0/
 *
 * Date: 2008-03-13
 */

/* Fonction chargement ajax avec animation, 
 * vous pouvez modifier la vitesse (slow, fast, 1500, ...) 
 * et l'effet (slideUp, fadeOut, ...) */
function ajax_page_advanced(ele,msg,url){
	$(ele).slideUp("slow", function(){
		$(ele).html(msg).show("slow", function(){
			$(ele).load(url+" "+ele, null, function(){
				var tampon = $(ele).html();
				$(ele).html(msg).slideUp("slow",function(){
					$(ele).html(tampon);
					$(ele).slideDown("slow");
					$('html, body').animate({scrollTop:$(document).height()/2-75}, 'slow');
				});
			});
		});
	});
}
/* Fonction de chargement ajax simple */
function ajax_page(ele,msg,url){
	$(ele).html(msg).load(url+" "+ele);
}
/* Fonction de chargement ajax simple, mais avec un delai pour la demo */
function ajax_page_delayed(ele,msg,url){
	$(ele).html(msg);
	setTimeout(function(){
		$(ele).load(url+" "+ele);
	}, 1500)
}

/* Une fois la page chargée */
$(document).ready(function(){
	//Application du chargement ajax avec animation sur les liens ayant une classe "wajax"
	$("#test a.nav").click(function(){
		ajax_page_advanced('#load','<p style="text-align: center"><img src="slide/default/70.gif"><br/>Chargement...</p>',this.href);
		return false;
	});
	<!--SCROLL TOP-->
	$('#scroll').hide();
	$('#scroll').css({'margin-left':$(document).width()-70});
	$('#scroll img').animate({
				opacity: 0.5,
			  }, 100);
	$(function(){
		$(window).scroll(function(){
			if($(this).scrollTop() > 200){
				$('#scroll').fadeIn();
			}else{
				$('#scroll').fadeOut();
			}
		});
		$('#scroll img').click(function(){
			$('html, body').animate({
				scrollTop:0
				},300);
				return false;
		});
		
		$('#scroll img').mouseover(function(){
			$('#scroll img').animate({
				opacity: 1,
			  }, 100);
		});
		$('#scroll img').mouseout(function(){
			$('#scroll img').animate({
				opacity: 0.5,
			  }, 100);
		});
	});
});


