

$(document).ready(function(){
	var href,page;

	$(this).hauteurPage();
	$('.ajax').click(function(nb){
		if ($("#animation_jvs").attr("value")==0){
			$("#animation_jvs").attr("value",1);
			$("a").css("cursor","wait");
			$("#conteneur").css("cursor","wait");
			var tmp=$(this).attr("href");
			var tmp2=$(this).html().toUpperCase();
			page=tmp.substr(0,tmp.indexOf(".html",0)-3);
			href="./index.php?page="+page;
			$('.selected').css("fontWeight","normal").removeClass("selected");
			$(this).css("fontWeight","bold").addClass("selected");
			$("#affichage").animate({opacity:'toggle',height:'toggle'},function(){
				$.get(href,{ajax: "1"},function(data) {
					$("#affichage").html(data).animate({opacity:'toggle',height: 'toggle'},function(){
						$(this).hauteurPage();
						$(".TogglePaneHeader").click(function(){
							$(this).hauteurPage();
							$('html,body').animate({ scrollTop: this.offsetTop }, 750);
							
						});
						$("a").css("cursor","pointer");
						$("#conteneur").css("cursor","default");
						$('.language a').each(function(nb){
							this.href=page+this.href.substr(this.href.indexOf(".html",0)-3);
						});
						$("#cadreMenu").toggleMenu(tmp2,function(){$("#animation_jvs").attr("value",0);});
					});
				});
			});
		}
		return false;
	});

	setTimeout(function(){ 
		$(".TogglePaneHeader").click(function(){
			$('html,body').animate({ scrollTop: this.offsetTop}, 750);
			$(this).hauteurPage();
		}); 

	},2500);


});

function togMenu() {
	$("#retour_menu").unbind("mouseenter", togMenu);
	$('#cadreMenu').toggleMenu();
}


$.fn.toggleMenu = function(titre_menu,callback) {
	var off=0,menu;
	if ($("#retour_menu").html()!='') {$("#retour_menu").empty();off=1; }
	$('#cadreMenu').animate({width: 'toggle'},function(){
		if (off==0){
			menu="<div id=\"titre_retour_menu\" onmouseover=\"\"><pre id=\"contenu_titre_retour_menu\"><br/></pre></div>";
			$("#retour_menu").html(menu);
			for (i=0;titre_menu!=null && i<titre_menu.length;i++) {
				menu=menu+titre_menu.charAt(i)+"<br/>";
				if (titre_menu.charAt(i)=='&') i=i+4;
			}
			menu=menu+"<br/>";
			$("#contenu_titre_retour_menu").append(menu);
			$("#retour_menu").bind("mouseenter", togMenu);
		} else hdp();
		if (callback!=null) callback();
	 });
	return this;
}

$.fn.togglePanneau = function(nb) {
	var i=0;
	$('.TogglePane').each(function(d) {
		i++;
		if (i<=nb) $(this).initTogglePane({headerClassClosed:'TogglePaneHeaderClosed',startOpened: true});
		else $(this).initTogglePane({headerClassClosed:'TogglePaneHeaderClosed',startOpened: false});
	});
	$(this).hauteurPage();
	return this;
}



$.fn.typewriter = function(opt,callback) {
	var i=0;
	var typeone = function(self, text, content) {
		if (text.length > 0) {
			i=i+1;
			var next = text.match(/(\s*(<[^>]*>)?)*(&.*?;|.?)/)[0];
			text = text.substr(next.length);
			$(self).html(content+next);
			setTimeout(function(){
				typeone(self, text, content+next);
			}, opt['delay']);
			if(text.length==0) if (callback!=null) callback();
		}
	}
	this.each(function() {
		opt = opt || { 'delay': 95 };
		typeone(this, $(this).html(), '');
	});
	return this;
}


$.fn.majStyle = function(couleur){
	$("a,.rouge").css({color: '#'+couleur});
	$.get("./css/couleur.css.php?couleur="+couleur,function(data) {
		if (navigator.appVersion.indexOf("MSIE")!=-1) location.reload(true);
		else $("#majStyle").html(data);
	});
}


function isIE() {
	if (navigator.appVersion.indexOf("MSIE")!=-1)return true;
	else return false;
}



$.fn.hauteurPage = function(){
	setTimeout(function(){
		var hauteurEcran=(document.documentElement.clientHeight !== undefined) ? document.documentElement.clientHeight : screen.height;
		var hauteurDoc=(document.height !== undefined) ? document.height : document.body.offsetHeight;
		if (hauteurDoc>hauteurEcran) $("#hdp").show();
		else $("#hdp").hide();
	},75);
}

function hdp(){
	$(document).ready(function(){
		$('html,body').animate({ scrollTop: 0 }, 1000);
	});
}