// NAVIGATION
$(document).ready(function(){
	$("#mh > li > ul").css( "opacity", "0.9" ) ;
	$("#mh > li > h2 > img").click( function(e) { 
		$("#mh > li > ul").hide() ;								
		switch ( e.target.id  ) {
			case "loto":
			$("#menuLoto > ul").show() ; return false ; 
			break ;
			case "foot":
			$("#menuFoot > ul").show() ; return false ;
			break ;
			case "pari":
			$("#menuPari > ul").show() ; return false ;
			break ;
			case "espace":
			$("#menuEspace > ul").show() ; return false ;
			break ;
			}
	} );
});
$(document).click(function(){
	$("#mh > li > ul").hide() ;
});

// FONCTIONS V1
function oubli() {
n = window.open('required/oubli.php','oubli','width=440px, height=210px, top=100px, left=200px') ;
n.focus() ;
}

function minuscule(form,champs) {
var texte = document.forms[''+form+''].elements[''+champs+''].value ;
var cible = document.forms[''+form+''].elements[''+champs+''] ; 
var texteMin = texte.toLowerCase() ;
cible.value = texteMin ;
}

// AJAX
$( "body" ).append ( '<div id="bg-loader"></div><div id="loader"><span>Chargement en cours...</span></div>' ) ;
var requete = 0 ;

function majax ( action , plabel, pvalue, zoneRetour, pld )
{
	if ( requete == 0 )
	{ 
		 requete = 1 ;
		 if ( pld == 1 ) setLoader() ;
		 var chainePost = "action="+action ;
		 for ( var i = 0 ; i < plabel.length ; i++) chainePost += '&'+plabel[i]+'='+pvalue[i] ;
		 
		$.ajax({
		   type: "POST",
		   url: "ajax-php/",
		   data: chainePost,
		   success: function retour( reponse ) {
				if ( pld == 1 ) setTimeout ( function() { setLoader() ; }, 600 ); 
				var retourAJAX = reponse.split("|") ;
				for ( var i = 0 ; i < zoneRetour.length ; i++) $( "#"+zoneRetour[i] ).html( retourAJAX[i] ) ;
				requete = 0 ;
				}
		 });
	 }
}

function setLoader () {
	if ( $("#loader" ).css("display") =="block" )
	{
		$("#bg-loader").fadeOut('speed') ;
		$("#loader").fadeOut('speed') ;
		requete = 0 ;
	} else {
		$("#loader").css( "left", ( $('body').width() / 2 ) - 255 ) ;
		$("#loader").css( "top", 180 ) ;
		$("#bg-loader").css( "left", 0 ) ;
		$("#bg-loader").css( "top", 0 ) ;
		$("#bg-loader").css( "width", $(window).width() ) ;
		$("#bg-loader").css( "height", $(window).height() ) ;
		$("#bg-loader").css( "opacity", 0.2 ) ;
		$("#bg-loader").fadeIn("speed") ;
		$("#loader").fadeIn("speed") ;
	}
}

$(window).resize(function(){ $("#bg-loader").css( "width", $(window).width()  ) ;  $("#bg-loader").css( "height", $(window).height() ) ; }) ;
