$(document).ready(function()
{
	// ----------------------------------------------
	// TOGGLE VALUE formulaire
	// ----------------------------------------------
    $("input:text, textarea, input:password").each(function(){
        if(this.value == '')
            this.value = this.title;
    });
    $("input:text, textarea, input:password").focus(function(){
        if(this.value == this.title)
            this.value = '';
    });
    $("input:text, textarea, input:password").blur(function(){
        if(this.value == '')
            this.value = this.title;
    });
    $("input:image, input:button, input:submit").click(function(){
        $(this.form.elements).each(function(){
            if(this.type =='text' || this.type =='textarea' || this.type =='password' ){
                if(this.value == this.title && this.title != ''){
                    this.value='';
                }
            }
        });
    });

	// logo flash
	/*
	$('#logo').flash(
            { src: './images/logo.swf',
              width: 434,
              height: 84,
              wmode:'transparent'},
            { version: 9 }
        );
	*/
    
	// scroll to window top 
	$('#scrollToBottom').click(function() {
		$.scrollTo ($('#bottom'), {speed:300});
		return false;
	});
	$('#scrollToTop').click(function() {
		$.scrollTo ($('#top'), {speed:300});
		return false;
	});

	$("ul#navigationHaut li a").live('click',function(){
		var variable=$(this).attr('href').substr(6);
		$('#piedPage').css({display:'none'});
		$.ajax({
			type: "GET", 
				data: '&page='+variable, 
				url: variable+'.php', 
				success: function(html){
					var c = $("#contenuTexte"); // bloc de contenu
					c.html('<img class="chargement" src="./images/ajax_loader.gif" alt="en chargement..." /> En chargement...')
					.fadeTo(0, 0, function()
					{
						c.html(html).fadeTo(500, 1, function(){
							$('#piedPage').show('slow');
						});
					});
			}
		});
		
		$.ajax({
			type: "GET", 
				data: '&page='+variable, 
				url: variable+'Infos.php', 
				success: function(html){
					var c = $("#chargementInfos"); // bloc de contenu
					c.html('<img style="margin:15px 0 0 80px; text-align:center;" class="chargement" src="./images/ajax_loader.gif" alt="en chargement..." />')
					.animate({opacity:'1'}, 200).hide(500, function()
					{
						c.html(html).show(500);
					});
			}
		});
		return false;
	});
  
	$('#navigationHaut li a').css('cursor', 'pointer');
	// connexion

	$('#connexion').next('#login').css({display:'none'});
	$('#connexion')
		.click(function(){
			$(this).next('#login').slideToggle("slow");
			return false;
	});
	
	$('#close-login')
		.click(function(){
			$(this).parent().parent().parent().slideToggle("slow");
			return false;
	});
	
	if(!($.browser.msie))
	{
		$('#navigationHaut li a').each(function () {
			$(this).fadeTo(500,0).animate({width:'0px'}, 300,function () {
				$(this).fadeTo(500,1).animate({width:'+155px'}, 300);
			});
		});
	}

	if($.browser.msie && $.browser.version < 7) return;	
	$('#navigationHaut li')
			.find('a')
				.append('<span class="hover" />')
					.each(function () {
						var openFormation= $(this).find('.hover').css('opacity', 0);
						$(this).hover(function ()
						{
							$('#connexion').next('#login').hide();
							openFormation.stop().fadeTo(400, 1, function(){
								$(this).animate({height:'115px'}, 300);
							});
						}, function () {
							openFormation.stop().animate({height:'42px'}, 300,function(){
								$(this).fadeTo(400, 0);										
							});
						});	
					});
	
	$("#webmasterFormations li a")
		.hover(function (){
			$(this).stop().animate({fontSize:"1.15em"});
		},function () {
			$(this).animate({fontSize:"1em"});
		});

	$("#stageCarte a")
	.hover(function (){
		$(this).stop().animate({backgroundPosition:'0 -45px'}, 5);
	},function () {
		$(this).stop().animate({backgroundPosition:'0 0'},5);
	});	
	
	$("#stageMultimedia a")
	.hover(function (){
		$(this).stop().animate({backgroundPosition:'0 -44px'}, 5);
	},function () {
		$(this).stop().animate({backgroundPosition:'0 0'},5);
	});	
	
});

//EXTRAS 
/////////////////////////////////////////////////////

//add to favorite
function favoris(pageName, pageUrl)
{
	if (navigator.appName != 'Microsoft Internet Explorer')
	window.sidebar.addPanel(pageName,pageUrl,"");
	else 
	window.external.AddFavorite(pageUrl,pageName);
}
