function extractUrlParams(){	

	var t = location.search.substring(1).split('&');

	var f = [];

	for (var i=0; i<t.length; i++){

		var x = t[ i ].split('=');

		f[x[0]]=x[1];

	}

	return f;

}

                    

function isPair(value){
    
   if(value/2 == Math.round(value/2)) return true;
   else return false;
   
}

function afficheError(msg) {
    $(".error-message").append(msg);
    $("#dialog-error").dialog("open");
}

function getErrorJSON (data, name) {
	if ($.isPlainObject(data) && data.error) {
		afficheError(data.msg);
		return true;
	} else
		return false;
}
function getJSON (url, data, success, name) {
	var self = this;
	
	return $.getJSON(url, data, success)
	// Si la requête échoue
	.fail(function(dfr, statusText, statusInfo) {
		
		// Affiche un dialog d'erreur
		function showError() {
			afficheError("<i>" + url + "</i><br/>"+dfr.statusText + " " + dfr.status + " : " + statusInfo,
					name + " : getJSON()");
		}
		
		// Si on arrive pas à parser le JSON, on affiche le
		// message d'erreur par défaut
		try {
			if (getErrorJSON($.parseJSON(dfr.responseText), name)) {
				showError();
			}
		} catch (e) {
			showError();
		}
		
	})
	// Analyse du contenu pour remonter une erreur PHP/SQL
	.done(function(data) {
		getErrorJSON(data, name);
	});
}

function getImage(idEquipe, type){ 
    
    var imgElem = "";
                
    if(idEquipe == 10 && type==1){      
        imgElem = $('.photo-feminines > *').length;
    } else if (idEquipe == 1 && type==1){
        imgElem = $('.photo-d2 > *').length;
    } else if (idEquipe == 2 && type==1){
        imgElem = $('.photo-U7 > *').length;
    } else if (idEquipe == 3 && type==1){
        imgElem = $('.photo-U9 > *').length;
    } else if(idEquipe == 4 && type==1) {
        imgElem = $('.photo-U11 > *').length;
    } else if(idEquipe == 5 && type==1) {
        imgElem = $('.photo-U13 > *').length;
    } else if(idEquipe == 6 && type==1) {
        imgElem = $('.photo-U15 > *').length;
    } else if(idEquipe == 7 && type==1) {
        imgElem = $('.photo-U18 > *').length;
    } else if(idEquipe == 8 && type==1) {
        imgElem = $('.photo-U22 > *').length;
    } else if(idEquipe == 9 && type==1) {
        imgElem = $('.photo-loisir > *').length;
    }
    
    if(imgElem == 0){
        getJSON("php/json_images.php?action=getImage&idEquipe="+idEquipe+"&typeImg="+type, function(data){
           var html = "";
           if(idEquipe == 10 && type==1){
                //image equipe femme  
                $(".photo-feminines").html("");
                if(typeof(data[0]) != "undefined"){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-feminines").append(html);

            } else if (idEquipe == 1 && type==1){
                // equipe D2
                $(".photo-d2").html("");
               if(typeof(data[0]) != "undefined"){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-d2").append(html);
            } else if (idEquipe == 2 && type==1){
                // equipe U7
                $(".photo-U7").html("");
                if(typeof(data[0]) != "undefined"){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-U7").append(html);
            } else if (idEquipe == 3 && type==1){
                // equipe U9
                $(".photo-U9").html("");
                if(typeof(data[0]) != "undefined"){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-U9").append(html);
            } else if(idEquipe == 4 && type==1) {
                // equipe U11
                $(".photo-U11").html("");
                if(typeof(data[0]) != "undefined"){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-U11").append(html);
            } else if(idEquipe == 5 && type==1) {
                // equipe U13
                $(".photo-U13").html("");
                if(typeof(data[0]) != "undefined"){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-U13").append(html);
            } else if(idEquipe == 6 && type==1) {
                // equipe U15
                $(".photo-U15").html("");
                if(typeof(data[0]) != "undefined"){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-U15").append(html);
            } else if(idEquipe == 7 && type==1) {
                // equipe U18
                $(".photo-U18").html("");

                if(typeof(data[0]) != 'undefined'){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-U18").append(html);
            } else if(idEquipe == 8 && type==1) {
                // equipe U22
                $(".photo-U22").html("");
                if(typeof(data[0]) != 'undefined'){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-U22").append(html);
            } else if(idEquipe == 9 && type==1) {
                // equipe Loisir
                $(".photo-loisir").html("");

                if(typeof(data[0]) != "undefined"){
                    html = "<img width=\"600\" src=\""+data[0].lien+"\" title=\""+data[0].title+"\"/>";
                } else {
                        html = "<img src=\"css/images/photo_not_available.png\"/>";
                }
                $(".photo-loisir").append(html);
            }
        }).done(function(){
            $(".loader-168").hide(); 
        });
    
    }

}

function afficheNews(data) {
	$("#dialog-detail-news").html("");

	var html = "";
        var titleNews = "<div class=\"title-image-detail-news\"><img alt=\"\" title=\""+data[0].nomClub+"\" src=\"images/logo_mini/"+data[0].logoClub+"\"/></div><div class=\"title-text-detail-news\"> News du "+data[0].dateNews+"</div>";
        
        html += "<div class=\"title-detail-news\"><h3>"+data[0].titreNews+"</h3></div>";
		html += "<div class=\"content-detail-news\">"+data[0].texteNews+"</div>";
	
	$("#dialog-detail-news").append(html);
        $(".video-sondage").hide();
                            
	
	$("#dialog-detail-news").dialog({
		
		bgiframe: true, // ParamÃ¨tre pour assurer la compatibilitÃ© avec IE
		resizable: true, // On ne permet pas le redimensionnement de la fenetre de dialogue
		height:600,
		width:800,
		position:'center',
                title: titleNews,
		modal: true,
		overlay: {
			backgroundColor: '#000',
			opacity: 0.5
		},
		beforeClose: function() {
			$("#dialog-detail-news").html("");
                        $(".video-sondage").show();
                        
                        
		}
	});
}

function getJoueurMineur(idEq){
    
    var minElem = 0;
    
        if(idEq == 3){
           minElem = $('.U9-equipe > *').length;            
        } else if(idEq == 4){
            minElem = $('.U11-equipe > *').length; 
        }else if(idEq == 5){
            minElem = $('.U13-equipe > *').length; 
        }else if(idEq == 6){
            minElem = $('.U15-equipe > *').length; 
        }else if(idEq == 7){
            minElem = $('.U18-equipe > *').length; 
        }else if(idEq == 8){
            minElem = $('.U22-equipe > *').length; 
        }else if(idEq == 2){
            minElem = $('.U7-equipe > *').length; 
        }else if(idEq == 9){
            minElem = $('.loisir-equipe > *').length; 
        }else if(idEq == 10){
            $minElem = $('.femme-equipe > *').length; 
        }
    if(minElem == 0){
            if(idEq == 3){
                $(".loader-U9-eq").show();            
            } else if(idEq == 4){
                $(".loader-U11-eq").show();
            }else if(idEq == 5){
                $(".loader-U13-eq").show();
            }else if(idEq == 6){
                $(".loader-U15-eq").show();
            }else if(idEq == 7){
                $(".loader-U18-eq").show();
            }else if(idEq == 8){
                $(".loader-U22-eq").show();
            }else if(idEq == 2){
                $(".loader-U7-eq").show();
            }else if(idEq == 9){
                $(".loader-loisir-eq").show();
            }else if(idEq == 10){
                $(".loader-femme-eq").show();
            }    
        getJSON("php/json_joueurs.php?action=listMineur&categorie="+idEq, function(data){
            html ="";
            if(data.length > 0){		
                            html="<table class=\"table-journee\" border=\"2\"><tr><th>Nom</th><th>Prénom</th><th>Numéro</th><th>Poste</th><th>Statistiques</th></tr>";
                            for(var i=0; i<data.length; i++){
                                    html+="<tr>";
                                    html+="<td style=\"width:150px\">";
                                    html+=data[i].nom;
                                    html+="</td>";
                                    html+="<td>";
                                    html+=data[i].prenom;
                                    html+="</td>";
                                    html+="<td>";
                                    html+=data[i].num;
                                    html+="</td>";
                                    html+="<td>";
                                    html+=data[i].poste;
                                    html+="</td>";
                                    html+="<td>";
                                    if(data[i].stat != "no"){
                                            html+="<a href=\"http://www.eliteprospects.com/player.php?player="+data[i].stat+"\" target=\"blank_\" title=\"Statistiques Elite Prospect\"><img src=\"css/images/epstats_mini.gif\"/></a>";
                                    }
                                    html+="</td>";
                            }
            } else {
                            html="<i>Aucunes données ...</i>";
                    }
            if(idEq == 3){
                $(".U9-equipe").html("");
                $(".U9-equipe").append(html)
            } else if(idEq == 4){
                $(".U11-equipe").html("");
                $(".U11-equipe").append(html)
            }else if(idEq == 5){
                $(".U13-equipe").html("");
                $(".U13-equipe").append(html)
            }else if(idEq == 6){
                $(".U15-equipe").html("");
                $(".U15-equipe").append(html)
            }else if(idEq == 7){
                $(".U18-equipe").html("");
                $(".U18-equipe").append(html)
            }else if(idEq == 8){
                $(".U22-equipe").html("");
                $(".U22-equipe").append(html)
            }else if(idEq == 2){
                $(".U7-equipe").html("");
                $(".U7-equipe").append(html)
            }else if(idEq == 9){
                $(".loisir-equipe").html("");
                $(".loisir-equipe").append(html)
            }else if(idEq == 10){
                $(".femme-equipe").html("");
                $(".femme-equipe").append(html)
            }


        }).done(function(){
            if(idEq == 3){
                $(".loader-U9-eq").hide();            
            } else if(idEq == 4){
                $(".loader-U11-eq").hide();
            }else if(idEq == 5){
                $(".loader-U13-eq").hide();
            }else if(idEq == 6){
                $(".loader-U15-eq").hide();
            }else if(idEq == 7){
                $(".loader-U18-eq").hide();
            }else if(idEq == 8){
                $(".loader-U22-eq").hide();
            }else if(idEq == 2){
                $(".loader-U7-eq").hide();
            }else if(idEq == 9){
                $(".loader-loisir-eq").hide();
            }else if(idEq == 10){
                $(".loader-femme-eq").hide();
            } 
        });
    }
    
}

function getResultat(champ, poule){
     $("#dialog-loader").dialog("open");     
    getJSON("php/json_resultat.php?action=getOne&champ="+champ+"&poule="+poule, function(data){

            var htmlTitle = "";
            var htmlContent = "";
            for(var i=0; i<data.length; i++){
                htmlTitle ="<tr><th colspan=\"5\">"+data[i].libSaison+"</th></tr>";
                var cpt = i+1;
                if(data[i].nomClub == "Nantes") {
                    htmlContent +="<tr><td class=\"borderleftTD\" width=\"20px\"><strong style=\"color:#327399;\">"+cpt+"</strong></td><td width=\"20px\"><img alt=\""+data[i].nomClub+"\" title=\""+data[i].nomClub+"\" src=\"images/logo_classement/"+data[i].logo+"\"/>";
                    htmlContent +="</td><td><strong style=\"color:#327399;\">"+data[i].nomClub+"</strong></td><td width=\"45px\"><strong style=\"color:#327399;\">"+data[i].pts+" pts</strong></td></tr>";
                } else {
                    htmlContent +="<tr><td class=\"borderleftTD\" width=\"20px\">"+cpt+"</td><td width=\"20px\"><img alt=\""+data[i].nomClub+"\" title=\""+data[i].nomClub+"\" src=\"images/logo_classement/"+data[i].logo+"\"/>";
                    htmlContent +="</td><td>"+data[i].nomClub+"</td><td width=\"45px\">"+data[i].pts+" pts</td></tr>";
                }
                
            }
            $(".classement-championnat").text("");
            $(".classement-championnat").text(data[0].champ);
            if(poule == 1){
                $("#tabs-poule-a .TableScore table thead").html("");
                $("#tabs-poule-a .TableScore table thead").append(htmlTitle);
                $("#tabs-poule-a .TableScore table tbody").html("");
                $("#tabs-poule-a .TableScore table tbody").append(htmlContent);
            } else {
                $("#tabs-poule-b .TableScore table thead").html("");
                $("#tabs-poule-b .TableScore table thead").append(htmlTitle);
                $("#tabs-poule-b .TableScore table tbody").html("");
                $("#tabs-poule-b .TableScore table tbody").append(htmlContent);
            }
    });
    $("#dialog-loader").dialog("close");
}
function createTableLigne (data, elem, nbCol, colspan, clas){

            var HTMLligne = "" ;

            for(var i=1; i<nbCol+1; i++){
                    
				HTMLligne += "<td class=\""+clas+"\" colspan=\""+colspan+"\">" + data[i];+ "</td>";
                    
            }

            return HTMLligne;
 }

function in_array(array, p_val) {
    for(var i = 0; l = array.length, i < l; i++) {
        
        if(array[i] == p_val) {
            return true;
        }
    }
    return false;
}

function getPartenaires(groupe){
    var partElem = "";
    
        if(groupe == 0){           
           partElem = $('.institutionnel-content > *').length;
       } else if(groupe == 1){
           partElem = $('.master-content > *').length;
       } else if (groupe == 2){
           partElem = $('.gold-content > *').length;
       } else if(groupe == 3){
           partElem = $('.silver-content > *').length;
       } else if(groupe == 4){
           partElem = $('.invoire-content > *').length;
       } else if(groupe == 5){
           partElem = $('.media-content > *').length;
       } else {
           partElem = $('.fournisseur-content > *').length;
       }
    if(partElem == 0){
        $(".loader-partenaires").show();   
        getJSON("php/json_partenaires.php?action=grp&groupe="+groupe, function(data){
           var html = "";

           if(groupe == 0){
               html +="<h3>PARTENAIRES INSTITUTIONELS</h3>";
           } else if(groupe == 1){
               html +="<h3>PARTENAIRES MASTERS</h3>";
           } else if (groupe == 2){
               html +="<h3>PARTENAIRES GOLDS</h3>";
           }else if(groupe == 3){
               html +="<h3>PARTENAIRES SILVERS</h3>";
           }else if(groupe == 4){
               html +="<h3>PARTENAIRES IVOIRES</h3>";
           } else if(groupe == 5){
               html +="<h3>PARTENAIRES MEDIAS</h3>";
           } else {
               html +="<h3>PARTENAIRES FOURNISSEURS</h3>";
           }

           for (var i = 0; i < data.length; i++) {
               html +="<a class=\"thumbnail\" href=\""+data[i]["lien"]+"\" target=\"_blank\"><img style=\"vertical-align:middle;\" src=\"partenaires/"+data[i]["logoMini"]+"\" width=\"50px\"/><span><div class=\"partenaire-thumb\"><img src=\"partenaires/"+data[i]["logo"]+"\" /><p>"+data[i]["patenaire"]+"<p></div></span></a>";
           }


           if(groupe == 0){
               $(".institutionnel-content").html("");
               $(".institutionnel-content").append(html);
           } else if(groupe == 1){
               $(".master-content").html("");
               $(".master-content").append(html);
           } else if (groupe == 2){
               $(".gold-content").html("");
               $(".gold-content").append(html);
           } else if(groupe == 3){
               $(".silver-content").html("");
               $(".silver-content").append(html);
           } else if(groupe == 4){
               $(".invoire-content").html("");
               $(".invoire-content").append(html);
           } else if(groupe == 5){
               $(".media-content").html("");
               $(".media-content").append(html);
           } else {
               $(".fournisseur-content").html("");
               $(".fournisseur-content").append(html);
           }


        }).done(function(){
            $(".loader-partenaires").hide();   
        });
    }

}

function getPartenairesAccueil(){
    $("#dialog-loader").dialog("open");
    getJSON("php/json_partenaires.php?action=all", function(data){
       var html = "";;                   
       for (var i = 0; i < data.length; i++) {                      
           html += "<a class=\"wrapper\" target=\"_blank\" href=\""+data[i]["lien"]+"\" title=\""+data[i]["patenaire"]+"\"><img class=\"logo\" style=\"vertical-align:middle;\" src=\"partenaires/"+data[i]["logo"]+"\" alt=\""+data[i]["patenaire"]+"\"/></a>";
       }
       $(".marquee").append(html);
       
       marqueeInit({
            uniqueid: 'mycrawler2',
            style: {
                'padding': '3px',
                'width': '100%',
                'height': '100px'
            },
            inc: 5, //speed - pixel increment for each iteration of this marquee's movement
            mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false)
            moveatleast: 2,
            neutral: 150,
            addDelay: 100,
            savedirection: true,
            random: true
        });
        
        $(".marquee0").next().css('width','1006px');
       
    });
    $("#dialog-loader").dialog("close");
}

function createTdCalendar(dataIn,jour) {
    var tdHtml = "";

    if(dataIn["today"] == "true"){

       if(typeof(dataIn["adversaireN"])!='undefined'){
            if(dataIn["aNantes"] == "true"){
                    tdHtml += "<td class=\"date_has_event today locaux\"><img alt=\"\" title=\"Type de match : "+dataIn["categ"]+" Visiteurs : "+dataIn["adversaireN"]+"\" src=\"images/logo_mini/"+dataIn["adversaireL"]+"\"/><br />"+dataIn["heure"]+"</td>";
            } else {			
                    tdHtml += "<td class=\"today visiteurs\"><img alt=\"\" title=\"Type de match : "+dataIn["categ"]+" Locaux : "+dataIn["adversaireN"]+"\" src=\"images/logo_mini/"+dataIn["adversaireL"]+"\"/><br />"+dataIn["heure"]+"</td>";
            }
        } else {
            tdHtml += "<td class=\"today\">"+jour+"</td>";
        }
    } else {
        if(typeof(dataIn["adversaireN"])!='undefined'){
            if(dataIn["aNantes"] == "true"){
				tdHtml += "<td class=\"date_has_event locaux\"><img alt=\"\" title=\"Type de match : "+dataIn["categ"]+" Visiteurs : "+dataIn["adversaireN"]+"\" src=\"images/logo_mini/"+dataIn["adversaireL"]+"\"/><br />"+dataIn["heure"]+"</td>";
			} else {			
				tdHtml += "<td class=\"visiteurs\"><img alt=\"\" title=\"Type de match : "+dataIn["categ"]+" Locaux : "+dataIn["adversaireN"]+"\" src=\"images/logo_mini/"+dataIn["adversaireL"]+"\"/><br />"+dataIn["heure"]+"</td>";
			}						
        } else {
                tdHtml += "<td>"+jour+"</td>";
        }
    }

    return tdHtml;
}

function getNews(page) {
     var newsElem = $('#news-accueil .content > *').length;
    if(newsElem == 0) {
    $(".loader-news-club").show();
    getJSON("php/json_news.php?action=list", function(data){
	   if(data.length > 0) {		   
			$("#news-accueil .content").html("");
			for(var i=0;i<data.length;i++){
				var trHtml = "";
				//creation de la ligne
				trHtml +="<li><div class=\"news-item\">";
				trHtml +="<input class=\"id-news\" type=\"hidden\" value=\""+data[i].idNews+"\"/><div class=\"image-content-news\"><img alt=\"\" title=\""+data[i].nomClub+"\" src=\"images/logo_mini/"+data[i].logoClub+"\"/></div>";
				trHtml +="<div class=\"title-content-news\">"+data[i].dateNews+"  "+data[i].titreNews+"</div>";
				trHtml +="</div>";     
				
                                if(i== 4 || i==9 || i==14){
					
				} else {
                                    trHtml += "<div class=\"news-separation\"></div>";
                                }
				trHtml +="</li>";

				$("#news-accueil .content").append(trHtml);						  
			}
		   
			$('.news-item').click(function(e){

				var inputIdNews = $(this).children(".id-news");
							var idNews = inputIdNews.val();
							$('#dialog-detail-news').html("");
							$.getJSON("php/json_news.php?action=getOne&idNews="+idNews, function(data){
								afficheNews(data);
							});

							return e.preventDefault();
			});  
		} else {
			$("#news-accueil .content").html("");
			trHtml="<i>Aucunes données ...</i>";
			$("#news-accueil .content").append(trHtml);
		}		   
	  }).done(function(){
              $(".loader-news-club").hide();
			$('#news-accueil').pajinate({
				start_page : 0,
				items_per_page : 5	
			});
		});
    }
}
function getNewsEuroSport(){
  var newsElem = $('#news-accueil-Eu .content > *').length;
    if(newsElem == 0) {
        $(".loader-news-Eu").show(); 
        $("#news-accueil-Eu .content").html("");
         getJSON("php/json_euroSportNews.php", function(data){

                   var trHtml = "";
                    for(var i=0;i<data.length;i++){

                            //creation de la ligne
                            trHtml +="<li><div class=\"news-item\"><div class=\"image-content-news\"><img alt=\"\" title=\"EuroSport\" src=\"images/logo_mini/eurosport_mini.png\"/></div>";
                            trHtml +="<div class=\"title-content-news\"><a href=\""+data[i].lien+"\" target=\"_blank\">"+data[i].date+"  "+data[i].titre+"</a></div></div>";


                            if(i== 4 || i==9 || i==14){

                            } else {
                                trHtml += "<div class=\"news-separation\"></div>";
                            }
                            trHtml +="</li>";


                    }

                   $("#news-accueil-Eu .content").append(trHtml);						  

         }).done(function(){
             $(".loader-news-Eu").hide(); 
            $('#news-accueil-Eu').pajinate({
                    start_page : 0,
                    items_per_page : 5	
            });
        });
    }
}

function getNewsHockeyHebdo(page){
 var newsElem = $('#news-accueil-HB .content > *').length;
    if(newsElem == 0) {
        $(".loader-news-HB").show();
     getJSON("php/json_hockeyHebdo.php", function(data){

          $("#news-accueil-HB .content").html("");


                var trHtml = "";
                for(var i=0;i<data.length;i++){

                        //creation de la ligne
                        trHtml +="<li><div class=\"news-item\"><div class=\"image-content-news\"><img alt=\"\" title=\"Hockey Hebdo\" src=\"images/logo_mini/hockeyHebdo_mini.png\"/></div>";
                        trHtml +="<div class=\"title-content-news\"><a href=\""+data[i].lien+"\" target=\"_blank\">"+data[i].titre+"</a></div></div>";

                        if(i== 4 || i==9 || i==14){

                        } else {
                            trHtml += "<div class=\"news-separation\"></div>";
                        }
                        trHtml +="</li>";


                }

               $("#news-accueil-HB .content").append(trHtml);	
  
     }).done(function(){
        $(".loader-news-HB").hide(); 
        $('#news-accueil-HB').pajinate({
                start_page : 0,
                items_per_page : 5	
        });
    });
    } 
     
}

function getNewPhoto () {
    getJSON("php/json_galerie.php?action=lastPhoto", function(data){
        
		if(data["nbImg"] != 0){
            $(".news-photo").append(data["nbImg"]);
            $(".news-photo").show();
        } else {
			$(".news-photo").hide();
		}
    });
    

}

function getVideo() {       
    getJSON("php/json_video.php?action=one", function(data){
        
        var html = "";
        $(".video-accueil").html("");
        if(data != ""){
            html = "<object width=\"330\" height=\"215\"><param name=\"movie\" value=\"http://www.youtube.com/v/"+data+"?version=3&amp;hl=fr_FR&amp;rel=0\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/"+data+"?version=3&amp;hl=fr_FR&amp;rel=\" type=\"application/x-shockwave-flash\" width=\"330\" height=\"215\" allowscriptaccess=\"always\" allowfullscreen=\"true\"></embed></object>";
        
            $(".video-accueil").append(html);
        }
    });

}

function getDiapoAccueil(){
    var diapoElem = $('.panelContainer > *').length;
    if(diapoElem == 0) {
        getJSON("php/json_diapoAccueil.php?action=diapo", function(data){

                  var index = 0;
                  var htmlPanel = "";
                          var htmlLink = "";
                          var lenghtTab = 0;
                          lenghtTab = parseInt(data.length) - parseInt(1);
                          $(".panelContainer").html("");
                          $(".thumb-diapo").html("");

                        for(var i=0;i<data.length;i++){

                                htmlPanel +="<div class=\"panel\" title=\""+data[i]["titre"]+"\">";
                                htmlPanel +="<div class=\"wrapper\">";
                                if(data[i]["lien"] != ""){
                                    htmlPanel +="<div class=\"link-news\"><input type=\"hidden\" id=\"idNewsDiapo\" name=\"newsDiapo\" value=\""+data[i]["lien"]+"\"/><img src=\"images/photos/diapoAcceuil/"+data[i]["image"]+"\" alt=\"temp\" /></div>";
                                } else {
                                   htmlPanel +="<div><img src=\"images/photos/diapoAcceuil/"+data[i]["image"]+"\" alt=\"temp\" /></div>";
                                }
                                htmlPanel +="<div class=\"photo-meta-data\">";							
                                htmlPanel +="<span>"+data[i]["titre"]+"</span>";
                                htmlPanel +="</div>";
                                htmlPanel +="</div>";
                                htmlPanel +="</div>";

                                index = i+1;  

                                if(i == 0){			
                                        htmlLink += "<a href=\"#"+index+"\" class=\"cross-link active-thumb\"><img src=\"images/photos/diapoAcceuil/"+data[i]["thumb"]+"\" class=\"nav-thumb\" alt=\"temp-thumb\" /></a>";
                                        htmlLink += "<div id=\"movers-row\">";
                                } else {
                                        htmlLink += "<div><a href=\"#"+index+"\"  class=\"cross-link\"><img src=\"images/photos/diapoAcceuil/"+data[i]["thumb"]+"\" class=\"nav-thumb\" alt=\"temp-thumb\" /></a></div>";
                                }

                                if(i == lenghtTab){
                                        htmlLink += "</div>";
                                }
                                                               
                        }	
                         

                          $(".panelContainer").append(htmlPanel);
                          $(".thumb-diapo").append(htmlLink);


             }).done(function(){
                 
                    $('.link-news').click(function(e){

                        var inputIdNews = $(this).children("#idNewsDiapo");
                        var idNews = inputIdNews.val();
                        $('#dialog-detail-news').html("");
                        $.getJSON("php/json_news.php?action=getOne&idNews="+idNews, function(data){
								document.location.hash = "nahg-news?idNews="+idNews;
                                afficheNews(data);
                        });

                        return e.preventDefault();
                    });
                        var theInt = null;
                        var $crosslink, $navthumb;
                        var curclicked = 0;

                        theInterval = function(cur){
                                clearInterval(theInt);

                                if( typeof cur != 'undefined' )
                                        curclicked = cur;

                                $crosslink.removeClass("active-thumb");
                                $navthumb.eq(curclicked).parent().addClass("active-thumb");
                                        $(".stripNav ul li a").eq(curclicked).trigger('click');

                                var nbDiapo = $('.panel').length;

                                theInt = setInterval(function(){
                                        $crosslink.removeClass("active-thumb");
                                        $navthumb.eq(curclicked).parent().addClass("active-thumb");
                                        $(".stripNav ul li a").eq(curclicked).trigger('click');
                                        curclicked++;
                                        if( nbDiapo == curclicked )
                                                curclicked = 0;

                                }, 4000);
                        };

                        $(function(){

                                $("#main-photo-slider").codaSlider();

                                $navthumb = $(".nav-thumb");
                                $crosslink = $(".cross-link");

                                $navthumb
                                .click(function() {
                                        var $this = $(this);
                                        theInterval($this.parent().attr('href').slice(1) - 1);
                                        return false;
                                });

                                theInterval();
                        });




                 });
             }
    
}

function getMatch(){
    $("#dialog-loader").dialog("open");
    getJSON("php/json_live.php?action=match", function(data){
		$("#id_match").val(data.idMatch);				
    });
 $("#dialog-loader").dialog("close");
}

function getLastLiveInfos(idMatch) {
    if(idMatch != ""){
        $("#dialog-loader").dialog("open");
        getJSON("php/json_live.php?action=info&idMatch="+idMatch, function(data){

           //creation de la ligne
            var trHtml = "";
            var elem = $(".live_tab");

                    $(".live_tab table tbody").empty();
            //creation de la ligne
            trHtml +="<tr class =\"live-match-info\">";

            var tContentLigne = [];
            tContentLigne[1]="<b>Match "+data.categMatch+" du "+data.dateMatch+" à  "+data.heureMatch+" : </b>";


            trHtml += createTableLigne(tContentLigne,elem,1,4,'');
            trHtml +="</tr>";
            $(".live_tab table tbody").append(trHtml);

            trHtml = "";
            trHtml +="<tr class =\"live-match-info\">";
            var tContentLigne2 = [];
            tContentLigne2[1]="<b>Locaux : </b>";
            tContentLigne2[2]="<img alt=\"\" title=\""+data.nomLocaux+"\" src=\"images/logo_mini/"+data.logoLocaux+"\"/>";
            tContentLigne2[3]="<b>Visiteurs : </b>";
            tContentLigne2[4]="<img alt=\"\" title=\""+data.nomVisiteurs+"\" src=\"images/logo_mini/"+data.logoVisiteurs+"\"/>"
            trHtml += createTableLigne(tContentLigne2,elem,4,1,'');
            trHtml +="</tr>";
            $(".live_tab table tbody").append(trHtml);
        });
             $("#dialog-loader").dialog("close");
    }
}

function getLastLiveAction(idMatch) {
   if(idMatch != ""){
       $("#dialog-loader").dialog("open");
        getJSON("php/json_live.php?action=matchAction&idMatch="+idMatch, function(data){

           //creation de la ligne

            var elem = $(".live_act table tbody");
                    $(".live_act table tbody").empty();
            for(var i=0; i<data.length; i++) {
                var trHtml = "";
                            trHtml ="<tr>";
                var tContentLigne = [];
                var time = data[i].evtTime;
                var min = time.substr(0,2);
                var sec = time.substr(2,2);
                tContentLigne[1] = "<img alt=\"\" title=\""+data[i].nomClub+"\" src=\"images/logo_mini/"+data[i].logoCLub+"\"/>";
                            tContentLigne[2] =min+":"+sec+" "+data[i].evtLibelle+" ";
                            trHtml += createTableLigne(tContentLigne,elem,2,"","");
                trHtml +="</tr>";
                            $(".live_act table tbody").append(trHtml);
                            trHtml="";
                            var tContentLigne2 = [];
                            trHtml ="<tr>";
                if(data[i].evtLibelle == "But") {
                                    if(data[i].joueurNom !="null"){
                        tContentLigne2[1] =data[i].joueurNom+" "+data[i].joueurPrenom;
                    }
                            }

                            if(data[i].evtLibelle == "PÃ©nalitÃ©") {
                    if(data[i].joueurNom !="null"){
                        tContentLigne2[1] =data[i].joueurNom+" "+data[i].joueurPrenom+" "+data[i].evtPenaLibelle;
                    } else if (data[i].evtPenaLibelle){
                        tContentLigne2[1] =data[i].evtPenaLibelle;
                    }

                }
                            //alert(tContentLigne2.length);
                            if(tContentLigne2.length != 0) {
                                    trHtml += createTableLigne(tContentLigne2,elem,1,2,'align-center');
                            }
                            trHtml +="</tr>";

                $(".live_act table tbody").append(trHtml);
               trHtml ="";
               if(data[i].evtCom != ""){

                    trHtml ="<tr>";
                    var tContentLigne3 = [];
                    tContentLigne3[1] =data[i].evtCom;

                    trHtml += createTableLigne(tContentLigne3,elem,1,2,'');
                    trHtml +="</tr>";

                    $(".live_act table tbody").append(trHtml);
                }
            }
        });
     $("#dialog-loader").dialog("close");
   }
}

function getCalendrier(eq){
    $("#dialog-loader").dialog("open");
    getJSON("php/json_calendrier.php?action=current&equipe="+eq, function(data){
        $(".nahg-calendar table tbody").html("");
            var tabJours = new Array();
            tabJours["Lu"] = 1;
            tabJours["Ma"] = 2;
            tabJours["Me"] = 3;
            tabJours["Je"] = 4;
            tabJours["Ve"] = 5;
            tabJours["Sa"] = 6;
            tabJours["Di"] = 7;
            
            var tabMois = new Array();
            tabMois[1] = 31;
            tabMois[2] = 28;
            tabMois[3] = 31;
            tabMois[4] = 30;
            tabMois[5] = 31;
            tabMois[6] = 30;
            tabMois[7] = 31;
            tabMois[8] = 31;
            tabMois[9] = 30;
            tabMois[10] = 30;
            tabMois[11] = 30;
            tabMois[12] = 31;
                        
            $('.mois-calendar').text(data[0].LibelleMois);
            $(".calendar-equipe").text(data[0].eq);
            $('.num-mois').val(data[0].numMois);
            $('.annee').val(data[0].annee);
            $('.calendar-categ').val(data[0].nEq);
            
            var nbJours = tabMois[data[0].numMois];
            
            var Col = 1;
            var nextCol = 1;
            var trHtml = "";
            
            for(var y=1; y <=nbJours; y++) {                
                Col = nextCol;
                
                if(Col == 1) {
                    trHtml += "<tr>";
                    if(data[y]["jours"] == "Lu"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 2;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 2) {
                    if(data[y]["jours"] == "Ma"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 3;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 3) {
                    if(data[y]["jours"] == "Me"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 4;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 4) {
                    if(data[y]["jours"] == "Je"){
                       trHtml += createTdCalendar(data[y],y);
                        nextCol = 5;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 5) {
                    if(data[y]["jours"] == "Ve"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 6;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 6) {
                    if(data[y]["jours"] == "Sa"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 7;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 7) {
                    if(data[y]["jours"] == "Di"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 1;
                        if(y != nbJours){
                            trHtml += "</tr>";
                        }
                        
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        nextCol = 1;
                        if(y != nbJours){
                            trHtml += "</tr>";
                        }
                    }
                }
                
                if(y == nbJours){
                    var nbJourVide = 0;
                    
                    if(data[y]["jours"] == "Lu"){
                        nbJourVide = 6;
                    } else if(data[y]["jours"] == "Ma"){
                        nbJourVide = 5;
                    }else if(data[y]["jours"] == "Me") {
                        nbJourVide = 4;
                    } else if(data[y]["jours"] == "Je") {
                        nbJourVide = 3;
                    } else if(data[y]["jours"] == "Ve"){
                        nbJourVide = 2;
                    } else if (data[y]["jours"] == "Sa") {
                        nbJourVide = 1;
                    }
                    
                    for(var z=1;z<=nbJourVide;z++) {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                    }
                    trHtml += "</tr>";
                }
            }
           
             $(".nahg-calendar table tbody").append(trHtml);                         
    });
 $("#dialog-loader").dialog("close");
}

function getNextMatch(cate){
    $("#dialog-loader").dialog("open");
    getJSON("php/json_calendrier.php?action=nextMatch&cate="+cate, function(data){
        var html ="";
        $(".prochain-match-content").html("");
		if(data.length >0){	
			if(typeof(data[0]["nomLocaux"])!='undefined'){
				html += "<table class=\"tab-prochain-match\">";
				html += "<tr>";
				html += "<td class=\"pm-date\" colspan=\"3\">"+data[0].date+" à "+data[0].heure+"</td>";
				html += "</tr>";
				html += "<tr>";
				html += "<td class=\"pm-logo-eq1\"><img alt=\"\" title=\"Locaux : "+data[0].nomLocaux+"\" src=\"images/logo_club_accueil/"+data[0].logoLocaux+"\"/></td><td> - </td><td class=\"pm-logo-eq2\"><img alt=\"\" title=\"Visiteurs : "+data[0].nomVisiteur+"\" src=\"images/logo_club_accueil/"+data[0].logoVisiteur+"\"/></td>";
				html += "</tr>";
				html += "<tr>";
				html += "<td class=\"pm-eq1\">"+data[0].nomLocaux+"</td><td> - </td><td class=\"pm-eq2\">"+data[0].nomVisiteur+"</td>"
				html += "</tr>";
				html += "</table>";				
			} 
		} else {
			html ="<i>Pas de match programmé ...</i>";
		}
		$(".prochain-match-content").append(html);
    });
     $("#dialog-loader").dialog("close");
}

function getLastResult(champ){
    $("#dialog-loader").dialog("open");
    getJSON("php/json_championnat.php?action=lastResult&categ="+champ, function(data){
        $(".prochain-last-result-content").html("");
            var html="";

            if(typeof(data.dateJournee) !='undefined'){
                html += "<table class=\"tab-dernier-result\">";
                html +="<tr><td class=\"dr-date\" colspan=\"3\">"+data.dateJournee+" à "+data.heureRencontre+"</td></tr>";
                html +="<tr><td class=\"dr-logo-eq1\"><img alt=\"\" title=\"Locaux : "+data.clubL+"\" src=\"images/logo_club_accueil/"+data.logoL+"\"/></td><td class=\"dr-result\">"+data.resultatL+" - "+data.resultatV+"</td><td class=\"dr-logo-eq2\"><img alt=\"\" title=\"Visiteurs : "+data.clubV+"\" src=\"images/logo_club_accueil/"+data.logoV+"\"/></td></tr>";
                html +="<tr><td class=\"dr-eq1\">"+data.clubL+"</td><td> - </td><td class=\"dr-eq2\">"+data.clubV+"</td></tr>";
                html +="</table>";
            } else {
                html +="<i>Pas de résultat disponible ...</i>";
            }
            
        
        $(".prochain-last-result-content").append(html);
    });
    $("#dialog-loader").dialog("close");
}

function getCalendrierByMois(mois,annee,eq){
    $("#dialog-loader").dialog("open");
    getJSON("php/json_calendrier.php?action=mois&equipe="+eq+"&mois="+mois+"&annee="+annee, function(data){
            $(".calendar-equipe").text(data[0].eq);
            $(".nahg-calendar table tbody").html("");
            var tabJours = new Array();
            tabJours["Lu"] = 1;
            tabJours["Ma"] = 2;
            tabJours["Me"] = 3;
            tabJours["Je"] = 4;
            tabJours["Ve"] = 5;
            tabJours["Sa"] = 6;
            tabJours["Di"] = 7;
            
            var tabMois = new Array();
            tabMois[1] = 31;
            tabMois[2] = 28;
            tabMois[3] = 31;
            tabMois[4] = 30;
            tabMois[5] = 31;
            tabMois[6] = 30;
            tabMois[7] = 31;
            tabMois[8] = 31;
            tabMois[9] = 30;
            tabMois[10] = 30;
            tabMois[11] = 30;
            tabMois[12] = 31;
            
            $('.mois-calendar').text(data[0].LibelleMois);
            
            $('.num-mois').val(data[0].numMois);
            
            var nbJours = tabMois[data[0].numMois];
            
            var Col = 1;
            var nextCol = 1;
            var trHtml = "";
            
            for(var y=1; y <=nbJours; y++) {                
                Col = nextCol;
                
                if(Col == 1) {
                    trHtml += "<tr>";
                    if(data[y]["jours"] == "Lu"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 2;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 2) {
                    if(data[y]["jours"] == "Ma"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 3;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 3) {
                    if(data[y]["jours"] == "Me"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 4;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 4) {
                    if(data[y]["jours"] == "Je"){
                       trHtml += createTdCalendar(data[y],y);
                        nextCol = 5;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 5) {
                    if(data[y]["jours"] == "Ve"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 6;
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 6) {
                    if(data[y]["jours"] == "Sa"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 7;
                    }else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        Col++;
                    }
                }

                if(Col == 7) {
                    if(data[y]["jours"] == "Di"){
                        trHtml += createTdCalendar(data[y],y);
                        nextCol = 1;
                        if(y != nbJours){
                            trHtml += "</tr>";
                        }
                        
                    } else {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                        nextCol = 1;
                        if(y != nbJours){
                            trHtml += "</tr>";
                        }
                    }
                }
                
                if(y == nbJours){
                    var nbJourVide = 0;
                    
                    if(data[y]["jours"] == "Lu"){
                        nbJourVide = 6;
                    } else if(data[y]["jours"] == "Ma"){
                        nbJourVide = 5;
                    } else if(data[y]["jours"] == "Me") {
                        nbJourVide = 4;
                    } else if(data[y]["jours"] == "Je") {
                        nbJourVide = 3;
                    } else if(data[y]["jours"] == "Ve"){
                        nbJourVide = 2;
                    } else if (data[y]["jours"] == "Sa") {
                        nbJourVide = 1;
                    }
                    
                    for(var z=1;z<=nbJourVide;z++) {
                        trHtml += "<td class=\"padding\">&nbsp;</td>";
                    }
                    trHtml += "</tr>";
                }     
            }

             $(".nahg-calendar table tbody").append(trHtml);
             
    });
 $("#dialog-loader").dialog("close");
}

function changePartInfo (id) {
    $('.nahg-partenaires-slide').hide();
    $('.info-prat').hide();
    $(id).fadeIn(500);
}

/*function pageselectCallback(page_index, jq){
    var new_content = $('#hiddenresult div.result:eq('+page_index+')').clone();
    $('#Searchresult').empty().append(new_content);
    return false;
}*/
function pageselectCallback(page_index, jq){
// Get number of elements per pagionation page from form
var items_per_page = 5;
var max_elem = Math.min((page_index+1) * items_per_page, $('#hiddenresult div.result').length);
var newcontent = '';
// Iterate through a selection of the content and build an HTML string
for(var i=page_index*items_per_page;i<max_elem;i++)
{
newcontent += $('#hiddenresult div.result:eq(1)').clone();
newcontent += $('#hiddenresult div.result:eq(2)').clone();
newcontent += $('#hiddenresult div.result:eq(3)').clone();
}
// Replace old content with new content
$('#Searchresult').html(newcontent);
// Prevent click event propagation
return false;
} 
           
function getNomImageJoueur(image){
    
    var tabTxt = image.split('/');
    
    var nbLigne = (tabTxt.length) - 1;
    
    var nomImage = tabTxt[nbLigne];
    
    return nomImage;
    
} 

function getJoueurs (categorie) {
    var joueurElem = $('.equipe-d2-joueurs > *').length;
    if(joueurElem == 0) {
        $(".loader-eq-D2").show();
	getJSON("php/json_joueurs.php?action=list&categorie="+categorie, function(data){
		$(".equipe-d2-joueurs").html("");
		if(data[0][0]["error"] != "true"){
			var html = "";
			html += "<h3>Gardiens</h3>";
			html += "<table><tr>";
			var cpt = 1;
			for(var i=0; i<data[0].length; i++) {
				var nomImage0 = getNomImageJoueur(data[0][i].photo);
                                if(cpt <6){                                    
					html += "<td><div class=\"cadre-joueur\"><a class=\"agrand-img\" href=\"#\"><img width=\"100\" border=\"0\" alt=\""+data[0][i].nom+"\" src=\""+data[0][i].photo+"\"><span><img src=\"images/equipes/premiere/max_portrait/"+nomImage0+"\" width=\"400\"/></span></a><table style=\"width:100%;\"><tr><td>"+data[0][i].nom+"</td><td rowspan=\"2\"><div class=\"btn-aff-info-joueur ui-icon ui-icon-newwin\"><input id=\"id-joueur\" type=\"hidden\" value=\""+data[0][i].id_joueur+"\"/></div></td></tr><tr><td>"+data[0][i].prenom+"</td></tr></table></div></td>";
					cpt++;
				} else {
					if(cpt == 6){
						cpt=1;
						html += "<tr><td><div class=\"cadre-joueur\"><a class=\"agrand-img\" href=\"#\"><img width=\"100\"  border=\"0\" alt=\""+data[0][i].nom+"\" src=\""+data[0][i].photo+"\"><span><img src=\"images/equipes/premiere/max_portrait/"+nomImage0+"\" width=\"400\"/></span></a><table style=\"width:100%;\"><tr><td>"+data[0][i].nom+"</td><td rowspan=\"2\"><div class=\"btn-aff-info-joueur ui-icon ui-icon-newwin\"><input id=\"id-joueur\" type=\"hidden\" value=\""+data[0][i].id_joueur+"\"/></div></td></tr><tr><td>"+data[0][i].prenom+"</td></tr></table></div></td>";
						cpt++;
					} 
				}
			}
			html += "</tr></table>";
			html += "<h3>Défenseur</h3>";
			html += "<table><tr>";
			cpt = 1;
			for(var j=0; j<data[1].length; j++) {
                                var nomImage1 = getNomImageJoueur(data[1][j].photo);
				if(cpt <6){
					html += "<td><div class=\"cadre-joueur\"><a class=\"agrand-img\" href=\"#\"><img width=\"100\" border=\"0\" alt=\""+data[1][j].nom+"\" src=\""+data[1][j].photo+"\"><span><img src=\"images/equipes/premiere/max_portrait/"+nomImage1+"\" width=\"400\"/></span></a><table style=\"width:100%;\"><tr><td>"+data[1][j].nom+"</td><td rowspan=\"2\"><div class=\"btn-aff-info-joueur ui-icon ui-icon-newwin\"><input id=\"id-joueur\" type=\"hidden\" value=\""+data[1][j].id_joueur+"\"/></div></td></tr><tr><td>"+data[1][j].prenom+"</td></tr></table></div></td>";
					cpt++;
				} else {
					if(cpt == 6){
						cpt = 1;
						html += "<tr><td><div class=\"cadre-joueur\"><a class=\"agrand-img\" href=\"#\"><img width=\"100\"  border=\"0\" alt=\""+data[1][j].nom+"\" src=\""+data[1][j].photo+"\"><span><img src=\"images/equipes/premiere/max_portrait/"+nomImage1+"\" width=\"400\"/></span></a><table style=\"width:100%;\"><tr><td>"+data[1][j].nom+"</td><td rowspan=\"2\"><div class=\"btn-aff-info-joueur ui-icon ui-icon-newwin\"><input id=\"id-joueur\" type=\"hidden\" value=\""+data[1][j].id_joueur+"\"/></div></td></tr><tr><td>"+data[1][j].prenom+"</td></tr></table></div></td>";
						cpt++;
					} 
				}
			}
			
			html += "</tr></table>";
			html += "<h3>Attaquants</h3>";
			html += "<table><tr>";
			cpt = 1;
			for(var k=0; k<data[2].length; k++) {
                            var nomImage2 = getNomImageJoueur(data[2][k].photo);
				if(cpt <6){
					html += "<td><div class=\"cadre-joueur\"><a class=\"agrand-img\" href=\"#\"><img width=\"100\"  border=\"0\" alt=\""+data[2][k].nom+"\" src=\""+data[2][k].photo+"\"><span><img src=\"images/equipes/premiere/max_portrait/"+nomImage2+"\" width=\"400\"/></span></a><table style=\"width:100%;\"><tr><td>"+data[2][k].nom+"</td><td rowspan=\"2\"><div class=\"btn-aff-info-joueur ui-icon ui-icon-newwin\"><input id=\"id-joueur\" type=\"hidden\" value=\""+data[2][k].id_joueur+"\"/></div></td></tr><tr><td>"+data[2][k].prenom+"</td></tr></table></div></td>";
					cpt++;
				}else {
					if(cpt == 6){
						cpt = 1;
						html += "<tr><td><div class=\"cadre-joueur\"><a class=\"agrand-img\" href=\"#\"><img width=\"100\" border=\"0\" alt=\""+data[2][k].nom+"\" src=\""+data[2][k].photo+"\"><span><img src=\"images/equipes/premiere/max_portrait/"+nomImage2+"\" width=\"400\"/></span></a><table style=\"width:100%;\"><tr><td>"+data[2][k].nom+"</td><td rowspan=\"2\"><div class=\"btn-aff-info-joueur ui-icon ui-icon-newwin\"><input id=\"id-joueur\" type=\"hidden\" value=\""+data[2][k].id_joueur+"\"/></div></td></tr><tr><td>"+data[2][k].prenom+"</td></tr></table></div></td>";
						cpt++;
					} 
				}
			}
			html += "</tr></table>";
			html += "<h3>Coach</h3>";
			html += "<table><tr>";
			cpt = 1;
			for(var l=0; l<data[3].length; l++) {
                            var nomImage3 = getNomImageJoueur(data[3][l].photo);
				if(cpt <6){
					html += "<td><div class=\"cadre-joueur\"><a class=\"agrand-img\" href=\"#\"><img width=\"100\"  border=\"0\" alt=\""+data[3][l].nom+"\" src=\""+data[3][l].photo+"\"><span><img src=\"images/equipes/premiere/max_portrait/"+nomImage3+"\" width=\"400\"/></span></a><table style=\"width:100%;\"><tr><td>"+data[3][l].nom+"</td><td rowspan=\"2\"><div class=\"btn-aff-info-joueur ui-icon ui-icon-newwin\"><input id=\"id-joueur\" type=\"hidden\" value=\""+data[3][l].id_joueur+"\"/></div></td></tr><tr><td>"+data[3][l].prenom+"</td></tr></table></div></td>";
					cpt++;
				} else {
					if(cpt == 6){
						cpt = 1;
						html += "<tr><td><div class=\"cadre-joueur\"><a class=\"agrand-img\" href=\"#\" ><img width=\"100\"  border=\"0\" alt=\""+data[3][l].nom+"\" src=\""+data[3][l].photo+"\"><span><img src=\"images/equipes/premiere/max_portrait/"+nomImage3+"\" width=\"400\"/></span></a><table style=\"width:100%;\"><tr><td>"+data[3][l].nom+"</td><td rowspan=\"2\"><div class=\"btn-aff-info-joueur ui-icon ui-icon-newwin\"><input id=\"id-joueur\" type=\"hidden\" value=\""+data[3][l].id_joueur+"\"/></div></td></tr><tr><td>"+data[3][l].prenom+"</td></tr></table></div></td>";
						cpt++;
					} 
				}
			}
			html += "</tr></table>";
			
			$(".equipe-d2-joueurs").append(html);
			$('.btn-aff-info-joueur').click(function(e){
                        var inputIdJoueur = $(this).children("#id-joueur");
                        var idJoueur = inputIdJoueur.val();
			var htmlStat = "";
                        var htmlJoueur = "";
                        
			$.getJSON("php/json_joueurs.php?action=joueur&idJoueur="+idJoueur, function(data){

                                        var nomImageInfo = "statique_"+getNomImageJoueur(data[1].photo);
                                       
                                        htmlJoueur +="<div class=\"joueur-info float-left\"><a class=\"agrand-img-info-joueur float-left\"><img class=\"float-left\" width=\"180\" src=\"images/equipes/premiere/"+data[1].photo+"\"><span><img src=\"images/equipes/premiere/max_portrait/"+nomImageInfo+"\" width=\"400\"/></span></a><div class=\"text-info-joueur float-left\"><table><tr><td colspan=\"2\"><span class=\"nom-joueur corner-5\">"+data[0].nom+" "+data[0].prenom+"</span></td></tr><tr><td colspan=\"2\"><span>Date de naissance : "+data[1].dateNaiss+"</span></td></tr><tr><td class=\"valign-center nationalite\"><span>Nationalité : </td><td class=\"valign-center\"><img src=\"images/equipes/nationalite/24/"+data[1].nationalite+"\"/></span></td></tr><tr><td colspan=\"2\"><span>Taille : "+data[1].taille+"</span></td></tr><tr><td colspan=\"2\"><span>Poids : "+data[1].poid+"</span></td></tr><tr><td colspan=\"2\"><span>Coté (Lance/Attrape) : "+data[1].cote+"</span></td></tr><tr><td colspan=\"2\"><span>Club dernière saison : "+data[1].lastClub+"</span></td></tr></table></div><!--<div class=\"mot-joueur\"><h1>Pour les supporters<img src=\"css/images/logo_corsaires_mot_joueur.png\"/></h1><div class=\"mot-joueur-content\"></div></div>--></div>";
                                   
					htmlStat = "<iframe src=\"http://www.eliteprospects.com/iframe_player_stats.php?player="+data[0].idStatJoueur+"\" width=\"100%\" height=\"330\" scrolling=\"yes\" frameborder=\"0\" ></iframe>";
                        }).done(function(){
                            $(".info-joueur").append(htmlJoueur);
                            $(".stats-joueur").append(htmlStat);
                            $("#dialog-info-joueur").dialog("open");
                            
                        });
	
            return e.preventDefault();
    });
}
}).done(function(){
    $(".loader-eq-D2").hide();
});
    }
        
}

/*function testInsert(){
    getJSON("php/json_championnat.php?action=insert", function(data){
            
    }).done(function (){
        alert("fini");});
}*/

function  getCalendrierAll(){
    $("#calendar").html("");
    
    $('#calendar').fullCalendar({
                        theme: true,
                           editable: false,
                           weekends: true,
                           allDaySlot: false,
                           allDayDefault: false,
                           slotMinutes: 15,
                           firstHour: 8,
                           minTime: 8,
                           maxTime: 22,
                           lazyFetching :true,
                           header: {
                                left: 'prev,next today',
                                center: 'title',
                                right: 'month'
                            },
                  
            events: "php/json_calendrier.php?action=all", 
            eventClick: function(event) {
                if (event.url) {

                    $(".event-message").append(event.url);
                    $("#dialog-event").dialog({

                            bgiframe: true, // ParamÃ¨tre pour assurer la compatibilitÃ© avec IE
                            resizable: false, // On ne permet pas le redimensionnement de la fenetre de dialogue
                            height:300,
                            width:400,// 220 pixels de hauteurs
                            modal: true,
                            overlay: {
                                    backgroundColor: '#000',
                                    opacity: 0.5
                            }, 
                            buttons: [
                                    {
                                            text: "Ok",
                                            click: function() {
                                                $(".event-message").html("");
                                                $(this).dialog("close");

                                        }
                                    }
                            ]
                    });
                }
            },loading: function(bool) {
                    if (bool){
                        $("#dialog-loader").dialog("open");
                    } else {
                        $("#dialog-loader").dialog("close");
                    }
            }     
            

        });
        $('#calendar').fullCalendar( 'refetchEvents' );

}

function getNewsAll(){
    $("#dialog-loader").dialog("open");
    getJSON("php/json_news.php?action=all", function(data){

        $(".content").html("");
        var trHtml = "";
            for(var i=0; i<data.length; i++){

                    trHtml +="<li><div class=\"result\"><div class=\"news\"><div class=\"news-title\">";
                    trHtml +="<input class=\"id-news-page\" type=\"hidden\" value=\""+data[i].idNews+"\"/>";            
                    trHtml += data[i].dateNews+"  "+data[i].titreNews+"<div class=\"btn-aff-news ui-icon ui-icon-newwin\"></div>";
                   /* trHtml +="<div class=\"news-fb\"><a href=\"https://twitter.com/share\" class=\"twitter-share-button\" data-url=\"http://www.nahg.fr/index.html#nahg-news?idNews="+data[i].idNews+"\" data-text=\""+data[i].titreNews+"\" data-count=\"none\" data-lang=\"fr\">Tweeter</a><script type=\"text/javascript\" src=\"//platform.twitter.com/widgets.js\"></script></div>";
                    trHtml +="<div class=\"news-fb\"><a name=\"fb_share\" type=\"button\" share_url=\"http://www.nahg.fr/index.html#nahg-news?idNews="+data[i].idNews+"\">Publier</a><script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" type=\"text/javascript\"></script></div>";*/
                    trHtml +="</div></div></div></li>";            
            }
            $("#news-content .content").append(trHtml);	   
    }).done(function(){
        $('#news-content').pajinate({
        start_page : 0,
        items_per_page : 15	
    });
     $('.btn-aff-news').click(function(e){
            var inputIdNews = $(this).prev();
            var idNews = inputIdNews.val();                        
            $('#dialog-detail-news').html("");
            $.getJSON("php/json_news.php?action=getOne&idNews="+idNews, function(data){
                document.location.hash = "nahg-news?idNews="+idNews;
                afficheNews(data);
            });

            return e.preventDefault();
    });
    });
          

    $("#dialog-loader").dialog("close");
}



function getNbJournee(page, championnat) {
    var journeeElem = "";
    
    if(page == 1){
        journeeElem = $('#championnat-d2-content-pouleA .content > *').length;
    }else if (page == 2){
        journeeElem = $('#championnat-d2-content .content > *').length;
    } else if(page == 0){             
        journeeElem = $('#championnat-d2-content-corsaires .content > *').length;
    } else if(page == 3){             
        journeeElem = $('.championnat-d2-CFrance > *').length;
    } else if(page == 4){             
        journeeElem = $('#championnat-d2-CFrance-corsaires .content > *').length;
    } else if(page == 5){             
        journeeElem = $('#U22-championnat .content > *').length;
    } else if(page == 6){             
        journeeElem = $('.U7-championnat .content > *').length;
    } else if(page == 7){             
        journeeElem = $('.U9-championnat .content > *').length;
    } else if(page == 8){             
        journeeElem = $('.U11-championnat .content > *').length;
    } else if(page == 9){             
        journeeElem = $('.U13-championnat .content > *').length;
    } else if(page == 10){             
        journeeElem = $('.U15-championnat .content > *').length;
    } else if(page == 11){             
        journeeElem = $('.U18-championnat .content > *').length;
    } else if(page == 12){             
        journeeElem = $('.loisir-championnat .content > *').length;
    } else if(page == 13){             
        journeeElem = $('.femme-championnat .content > *').length;
    } else {
        journeeElem = $('.tournoi-match-amicaux-content > *').length;
    }
    
    if(journeeElem == 0) {
        getJSON("php/json_championnat.php?action=nbJournee&championnat="+championnat, function(data){
                getInfoChampionnat(page, data);            
        });    
    }

}

function getInfoChampionnat(page, nbJournee) {     
        
    if(page == 0) {        
        getJourneeNantes(nbJournee,1);
    }else if (page == 1){
        getJournee(nbJournee,1,1);
    } else if(page == 2){
        getJournee(nbJournee,1,2);
    } else if(page == 3){
        getJournee(nbJournee,12,"");
    } else if(page == 4){
        getJourneeNantes(nbJournee,12);
    }else if(page == 5){
        getJourneeNantes(nbJournee,8);
    }else if(page == 6){
        getJourneeNantes(nbJournee,2);
    }else if(page == 7){
        getJourneeNantes(nbJournee,3);
    }else if(page == 8){
        getJourneeNantes(nbJournee,4);
    }else if(page == 9){
        getJourneeNantes(nbJournee,5);
    }else if(page == 10){
        getJourneeNantes(nbJournee,6);
    }else if(page == 11){
        getJourneeNantes(nbJournee,7);
    }else if(page == 12){
        getJourneeNantes(nbJournee,9);
    }else if(page == 13){
        getJourneeNantes(nbJournee,10);
    }else {
        getJourneeNantes(nbJournee,12);
    }
    
}


function getListInfo() {
    $("#dialog-loader").dialog("open");
    $(".nahg-D2-list-player").html("");
    getJSON("php/json_joueurs.php?action=listInfo", function(data){
        var html = "<table class=\"table-list-joueur\" border=\"2\"><tr><th>Numéro</th><th>Joueur</th></tr>";
        for(var i=0; i<data.length; i++){
            html += "<tr><td class=\"num-joueur\" ><span>"+data[i].num+"</td><td>"+data[i].nom+" "+data[i].prenom+"</td></tr>"
        }
        html += "</table>";
        
        $(".nahg-D2-list-player").append(html);        
    });
    $("#dialog-loader").dialog("close");

}

function getJournee(nbJournee,championnat, poule) {
    
        if(poule == 2){
            $(".loader-champ-d2-content-pouleB").show(); 
        }else if (poule == 1){
            $(".loader-champ-d2-content-pouleA").show();
        } else if(poule == ""){             
            $(".loader-d2-CFrance").show();        
        }        
        getJSON("php/json_championnat.php?action=list&championnat="+championnat+"&poule="+poule, function(data){
                //var title = "";
                var html = "";
                var passed = false;
                for(var y=1; y<=nbJournee; y++){

                    /*title = "Journée "+y;
                    html += "<li><h4>"+title+"</h4>";
                    html += "<table class=\"table-journee\" border=2><tr><th>Date</th><th>Locaux</th><th>Visiteurs</th><th>Heure</th><th>Résultat</th></tr>";*/
                    for(var i=0; i<data.length; i++){ 
                        if(data[i].journee == y || data[i].journee == 30+y){
                            if(passed == false){
                                html += "<li><h4>"+data[i].titleJ+"</h4>";
                                html += "<table class=\"table-journee\" border=2><tr><th>Date</th><th>Locaux</th><th>Visiteurs</th><th>Heure</th><th>Résultat</th></tr>";
                                passed = true;
                            }
                            html += "<tr><td>"+data[i].dateJournee+"</td>";
                            if(data[i].clubL == 'Nantes'){
                                if(championnat == 12 && parseInt(data[i].resultatL) > parseInt(data[i].resultatV)) {
                                    html+="<td class=\"isNantes qualified\">"+data[i].clubL+"</td>";
                                } else if(championnat != 12){
                                    html+="<td class=\"isNantes\">"+data[i].clubL+"</td>";
                                } else {
                                    html+="<td class=\"isNantes\">"+data[i].clubL+"</td>";
                                }

                            } else {
                                 if(championnat == 12 && parseInt(data[i].resultatL) > parseInt(data[i].resultatV)) {
                                    html+="<td class=\"qualified\">"+data[i].clubL+"</td>";
                                } else if (championnat != 12){
                                    html+="<td>"+data[i].clubL+"</td>";
                                } else {
                                    html+="<td>"+data[i].clubL+"</td>";
                                }
                            }

                            if(data[i].clubV == 'Nantes'){
                                if(championnat == 12 && parseInt(data[i].resultatV) > parseInt(data[i].resultatL)) {
                                    html+="<td class=\"isNantes qualified\">"+data[i].clubV+"</td>";                                
                                } else if (championnat != 12){
                                    html+="<td class=\"isNantes\">"+data[i].clubV+"</td>";
                                } else {
                                    html+="<td class=\"isNantes\">"+data[i].clubV+"</td>";
                                }
                            } else {
                                if(championnat == 12 && parseInt(data[i].resultatV) > parseInt(data[i].resultatL)) {
                                    html+="<td class=\"qualified\">"+data[i].clubV+"</td>";
                                } else if (championnat != 12){
                                    html+="<td>"+data[i].clubV+"</td>";
                                } else {
                                    html+="<td>"+data[i].clubV+"</td>";
                                }
                            }


                            html +="<td>"+data[i].heureRencontre+"</td>"
                            if(data[i].prolongTirBut == 1){
                                html +="<td>"+data[i].resultatL+" - "+data[i].resultatV+" (OT)</td>";
                            } else {
                                html +="<td>"+data[i].resultatL+" - "+data[i].resultatV+"</td>";
                            }
                            html +="</tr>";
                        } else {
                            passed = false;
                        }
                    }
                    html += "</table></li>";
                }
                if(poule == 2){
                    $("#championnat-d2-content .content").append(html); 
                }else if (poule == 1){
                    $("#championnat-d2-content-pouleA .content").append(html); 
                } else if(poule == ""){                                 
                    $("#championnat-d2-CFrance .content").append(html);
                }

        }).done(function(){
            if(poule == 2){
                $(".loader-champ-d2-content-pouleB").hide();
                $('#championnat-d2-content').pajinate({
                start_page : 0,
                items_per_page : 5});
            } else if (poule == 1) {
                $(".loader-champ-d2-content-pouleA").hide();
                $('#championnat-d2-content-pouleA').pajinate({
                start_page : 0,
                items_per_page : 5});
            } else {
                $(".loader-d2-CFrance").hide(); 
                $('#championnat-d2-CFrance').pajinate({
                start_page : 0,
                items_per_page : 5});
            }

        });
    }

function getJourneeNantes(nbJournee,championnat) {

            if(championnat == 12){
                $(".loader-d2-CFrance-corsaires").show();
            } else if (championnat ==1) {
                $(".loader-champ-D2-corsaire").show();                                
            } else if(championnat == 8){
                $("#U22-championnat .content").html("");                
                $(".loader-U22-champ").show();
        } else if (championnat == 2){
                $(".U7-championnat .content").html("");
                $(".loader-U7-champ").show();
            } else if (championnat == 3){
                $(".U9-championnat .content").html("");
                $(".loader-U9-champ").show();
            } else if (championnat == 4){
                $(".U11-championnat .content").html("");
                $(".loader-U11-champ").show();
            } else if (championnat == 5){
                $(".U13-championnat .content").html("");
                $(".loader-U13-champ").show();
            } else if (championnat == 6){
                $(".U15-championnat .content").html("");
                $(".loader-U15-champ").show();
            } else if (championnat == 7){
                $(".U18-championnat .content").html("");
                $(".loader-U18-champ").show();
            } else if (championnat == 9){
                $(".loisir-championnat .content").html("");
                $(".loader-loisir-champ").show();
            } else if (championnat == 10){
                $(".femme-championnat .content").html("");
                $(".loader-femme-champ").show();
            }

    $("#championnat-d2-content-corsaires .content").html("");
    getJSON("php/json_championnat.php?action=listNantes&championnat="+championnat, function(data){
            var html = "";
            
            if(data.length > 0){                   
             html += "<table class=\"table-journee\" border=2><tr><th>Journée</th><th>Date</th><th>Locaux</th><th>Visiteurs</th><th>Heure</th><th>Résultat</th></tr>";
                for(var y=1; y<=nbJournee; y++){               
                    for(var i=0; i<data.length; i++){ 
                        if(data[i].journee == y || data[i].journee == 30+y){                      
                            html += "<tr>";
                            html += "<td>"+y+"</td>";
                            html += "<td>"+data[i].dateJournee+"</td>";
                            if(data[i].clubL == 'Nantes'){
                                if(championnat == 12 && parseInt(data[i].resultatL) > parseInt(data[i].resultatV)) {
                                    html+="<td class=\"isNantes qualified\">"+data[i].clubL+"</td>";
                                } else if (championnat != 12){
                                    html+="<td class=\"isNantes\">"+data[i].clubL+"</td>";
                                } else {
                                    html+="<td class=\"isNantes\">"+data[i].clubL+"</td>";
                                }

                            } else {

                                if(championnat == 12 && parseInt(data[i].resultatL) > parseInt(data[i].resultatV)) {
                                    html+="<td class=\"qualified\">"+data[i].clubL+"</td>";
                                } else if (championnat != 12){
                                    html+="<td>"+data[i].clubL+"</td>";
                                } else {
                                    html+="<td>"+data[i].clubL+"</td>";
                                }
                            }

                            if(data[i].clubV == 'Nantes'){
                                if(championnat == 12 && parseInt(data[i].resultatV) > parseInt(data[i].resultatL)) {
                                    html+="<td class=\"isNantes qualified\">"+data[i].clubV+"</td>";                                
                                } else if (championnat != 12){
                                    html+="<td class=\"isNantes\">"+data[i].clubV+"</td>";
                                } else {
                                    html+="<td class=\"isNantes\">"+data[i].clubV+"</td>";
                                }
                            } else {
                                if(championnat == 12 && parseInt(data[i].resultatV) > parseInt(data[i].resultatL)) {
                                    html+="<td class=\"qualified\">"+data[i].clubV+"</td>";
                                } else if (championnat != 12){
                                    html+="<td>"+data[i].clubV+"</td>";
                                } else {
                                    html+="<td>"+data[i].clubV+"</td>";
                                }
                            }


                            html +="<td>"+data[i].heureRencontre+"</td>"
                            if(data[i].prolongTirBut == 1){                            
                                html +="<td>"+data[i].resultatL+" - "+data[i].resultatV+" (OT)</td>";
                            } else {
                                html +="<td>"+data[i].resultatL+" - "+data[i].resultatV+"</td>";
                            }                       
                        }
                    }
                    html += "</tr>";
                }
                html += "</table>";
            } else {
                html = "<li style=\"font-weight: normal;\"><i>Aucune donnée ...</i></li>";
            }     
            
            if(championnat == 12){
                $("#championnat-d2-CFrance-corsaires .content").html(""); 
                $("#championnat-d2-CFrance-corsaires .content").append(html); 
            } else if (championnat ==1) {
                $("#championnat-d2-content-corsaires .content").html("");                
                $("#championnat-d2-content-corsaires .content").append(html);
            } else if(championnat == 8){
                $("#U22-championnat .content").html("");
                $("#U22-championnat .content").append(html);                
            } else if (championnat == 2){
                $(".U7-championnat .content").html("");
                $(".U7-championnat .content").append(html);
            } else if (championnat == 3){
                $(".U9-championnat .content").html("");
                $(".U9-championnat .content").append(html);
            } else if (championnat == 4){
                $(".U11-championnat .content").html("");
                $(".U11-championnat .content").append(html);
               
            } else if (championnat == 5){
                $(".U13-championnat .content").html("");
                $(".U13-championnat .content").append(html);
            } else if (championnat == 6){
                $(".U15-championnat .content").html("");
                $(".U15-championnat .content").append(html);
            } else if (championnat == 7){
                $(".U18-championnat .content").html("");
                $(".U18-championnat .content").append(html);
            } else if (championnat == 9){
                $(".loisir-championnat .content").html("");
                $(".loisir-championnat .content").append(html);
            } else if (championnat == 10){
                $(".femme-championnat .content").html("");
                $(".femme-championnat .content").append(html);
            }
                

       
    }).done(function(){
        if(championnat == 12){
            $(".loader-d2-CFrance-corsaires").hide();
        } else if (championnat ==1) {
            $(".loader-champ-D2-corsaire").hide();
        } else if(championnat == 8){
            $(".loader-U22-champ").hide(); 
        } else if (championnat == 2){
            $(".loader-U7-champ").hide();
        } else if (championnat == 3){
            $(".loader-U9-champ").hide();
        } else if (championnat == 4){
            $(".loader-U11-champ").hide();
        } else if (championnat == 5){
            $(".loader-U13-champ").hide();
        } else if (championnat == 6){
           $(".loader-U15-champ").hide();
        } else if (championnat == 7){
            $(".loader-U18-champ").hide();
        } else if (championnat == 9){
            $(".loader-loisir-champ").hide();
        } else if (championnat == 10){
            $(".loader-femme-champ").hide();
        }
    });

}

function getNewsUrl(idNews){
     $('#dialog-detail-news').html("");
    $.getJSON("php/json_news.php?action=getOne&idNews="+idNews, function(data){
        afficheNews(data);
    });
}

function getMatchAmicaux(champ){
    var amicElem = 0;
    if(champ == 11){
        amicElem = $('.tournoi-match-amicaux-content > *').length;        
    } else if (champ == 14){
        amicElem = $('.U7-tournois > *').length;         
    } else if (champ == 15){
        amicElem = $('.U9-tournois > *').length; 
    } else if (champ == 16){
        amicElem = $('.U11-tournois > *').length; 
    } else if (champ == 17){
        amicElem = $('.U13-tournois > *').length; 
    } else if (champ == 18){
        amicElem = $('.U15-tournois > *').length; 
    } else if (champ == 19){
        amicElem = $('.U18-tournois > *').length; 
    } else if (champ == 20){
        amicElem = $('#U22-tournois > *').length;         
    } else if (champ == 21){
        amicElem = $('.loisir-tournois > *').length; 
    } else if (champ == 22){
        amicElem = $('.femme-tournois > *').length; 
    }
    if (amicElem == 0){
        if(champ == 11){
            $(".loader-d2-amic").show();
            $(".tournoi-match-amicaux-content").html("");
        } else if (champ == 14){
            $(".loader-U7-amic").show();
            $(".U7-tournois").html("");
        } else if (champ == 15){
            $(".loader-U9-amic").show();
            $(".U9-tournois").html("");
        } else if (champ == 16){
            $(".loader-U11-amic").show();
            $(".U11-tournois").html("");
        } else if (champ == 17){
            $(".loader-U13-amic").show();
            $(".U13-tournois").html("");
        } else if (champ == 18){
            $(".loader-U15-amic").show();
            $(".U15-tournois").html("");
        } else if (champ == 19){
            $(".loader-U18-amic").show();
            $(".U18-tournois").html("");
        } else if (champ == 20){
            $(".loader-U22-amic").show();
            $("#U22-tournois").html("");
        } else if (champ == 21){
            $(".loader-loisir-amic").show();
            $(".loisir-tournois").html("");
        } else if (champ == 22){
            $(".loader-femme-amic").show();
            $(".femme-tournois").html("");
        } 

        getJSON("php/json_championnat.php?action=amical&idChamp="+champ, function(data){
                var html = "";
                if(data.length > 0){
                     html += "<table class=\"table-journee\" border=2><tr><th>Date</th><th>Locaux</th><th>Visiteurs</th><th>Heure</th><th>Résultat</th></tr>";

                        for(var i=0; i<data.length; i++){ 

                                html += "<tr>";
                                html += "<td>"+data[i].dateJournee+"</td>";
                                if(data[i].clubL == 'Nantes'){
                                    html+="<td class=\"isNantes\">"+data[i].clubL+"</td>";
                                } else {
                                    html+="<td>"+data[i].clubL+"</td>";
                                }

                                if(data[i].clubV == 'Nantes'){
                                    html+="<td class=\"isNantes\">"+data[i].clubV+"</td>";
                                } else {
                                    html+="<td>"+data[i].clubV+"</td>";
                                }
                                html +="<td>"+data[i].heureRencontre+"</td>"
                                if(data[i].prolongTirBut == 1){
                                    html +="<td>"+data[i].resultatL+" - "+data[i].resultatV+" (OT)</td>";
                                } else {
                                    html +="<td>"+data[i].resultatL+" - "+data[i].resultatV+"</td>";
                                }                       

                        }
                        html += "</tr>";

                    html += "</table>";
                } else {
                    html = "<i>Aucune donnée ...</i>"
                }
                if(champ == 11) {
                    $(".tournoi-match-amicaux-content").append(html);
                }if(champ == 14) {
                    $(".U7-tournois").append(html);
                } else if (champ == 15){
                    $(".U9-tournois").append(html);
                } else if (champ == 16){
                    $(".U11-tournois").append(html);
                } else if (champ == 17){
                    $(".U13-tournois").append(html);
                } else if (champ == 18){
                    $(".U15-tournois").append(html);
                } else if (champ == 19){
                    $(".U18-tournois").append(html);
                } else if (champ == 20){
                    $("#U22-tournois").append(html);
                } else if (champ == 21){
                    $(".loisir-tournois").append(html);
                } else if (champ == 22){
                    $(".femme-tournois").append(html);
                }



        }).done(function(){
            if(champ == 11) {
                $(".loader-d2-amic").hide();
            } else if (champ == 14){
                $(".loader-U7-amic").hide();
            } else if (champ == 15){
                $(".loader-U9-amic").hide();
            } else if (champ == 16){
                $(".loader-U11-amic").hide();
            } else if (champ == 17){
                $(".loader-U13-amic").hide();
            } else if (champ == 18){
                $(".loader-U15-amic").hide();
            } else if (champ == 19){
                $(".loader-U18-amic").hide();
            } else if (champ == 20){
                $(".loader-U22-amic").hide();
            } else if (champ == 21){
                $(".loader-loisir-amic").hide();
            } else if (champ == 22){
                $(".loader-femme-amic").hide();
            }
        });
    }
}

function getStaffContent(idStaff){
            var staffElem = 0;
            if(idStaff == 1){                
                staffElem = $('.staff-bureau-orga > *').length;  
            } else if(idStaff == 2){
                staffElem = $('.staff-comite-orga > *').length;  
            } else if (idStaff == 3){
                staffElem = $('.staff-entrai-orga > *').length; 
            } else if (idStaff == 4){
                staffElem = $('.staff-resp-orga > *').length;
            } else if (idStaff == 5){
                staffElem = $('.staff-com-orga > *').length;
            }
if(staffElem == 0){
            if(idStaff == 1){
                $(".loader-staff-bureau").show();
            } else if(idStaff == 2){
                $(".loader-staff-comite").show();
            } else if (idStaff == 3){
                $(".loader-staff-entr").show();
            } else if (idStaff == 4){
                $(".loader-staff-resp").show();
            } else if (idStaff == 5){
                $(".loader-staff-com").show();
            } 
    getJSON("php/json_staff.php?action=staff&idStaff="+idStaff, function(data){
        var html = "";
        // bureau
        if(idStaff == 1){
            $(".staff-bureau-orga").html("");
            html = "<table>";
            for (i = 0; i < data.length; i++) {
                html+="<tr>";
                if(data[i].photoStaff != ""){
                    html+="<td><img src=\"images/staff/"+data[i].photoStaff+"\" width=\"100\" /></td>";
                } else {
                    html+="<td><img src=\"images/staff/xxx.jpg\" width=\"100\"/></td>";
                }
                html+="<td><b>"+data[i].nomStaff+" "+data[i].prenomStaff+"</b>";
                
                if(data[i].mailStaff != ""){
                    html+="<br/>"+data[i].mailStaff;
                }
                
                html+="<br/><span class=\"libelle-fonction\">"+data[i].libTypeStaff+"</span>";

                if(data[i].mailFonction !=""){
                    html+="<br/>"+data[i].mailFonction;
                }         

                if(data[i].com1 != ""){

                    html+="<br/><span class=\"libelle-fonction\">"+data[i].com1+"</span>";
                    if(data[i].comMail1 !=""){
                        html+="<br/>"+data[i].comMail1;
                    }
                    if(data[i].com2 != ""){

                        html+="<br/><span class=\"libelle-fonction\">"+data[i].com2+"</span>";
                        if(data[i].comMail2 !=""){
                            html+="<br/>"+data[i].comMail2;
                        }

                        if(data[i].com3 != ""){

                            html+="<br/><span class=\"libelle-fonction\">"+data[i].com3+"</span>";
                            if(data[i].comMail3 !=""){
                            html+="<br/>"+data[i].comMail3;
                        }
                        }
                    }                                        
                }
                html+="</td></tr>";
                
            }
            html += "</table>";
            //console.log(html);
            $(".staff-bureau-orga").append(html);
        } else {
            // comite            
            html="";
            //constraction tableau global
            html = "<table class=\"no-border\">";
            for (i = 0; i < data.length; i++) {
                if(isPair(i)){
                    html +="<tr>";
                    html+="<td><table><tr>";
                       if(data[i].photoStaff != ""){
                            html+="<td><img src=\"images/staff/"+data[i].photoStaff+"\" width=\"100\" /></td>";
                        } else {
                            html+="<td><img src=\"images/staff/xxx.jpg\" width=\"100\"/></td>";
                        }
                            
                    html +="<td><b>"+data[i].nomStaff+" "+data[i].prenomStaff+"</b>";
                    if(data[i].libTypeStaff != "notype"){
                        html+="<br/><span class=\"libelle-fonction\">"+data[i].libTypeStaff+"</span>";
                    }
                    if(data[i].mailStaff != ""){
                        html+="<br/>"+data[i].mailStaff;
                    }
                    if(data[i].mailFonction !=""){
                        html+="<br/>"+data[i].mailFonction;
                    }         

                    if(data[i].com1 != ""){

                        html+="<br/><span class=\"libelle-fonction\">"+data[i].com1+"</span>";
                        if(data[i].comMail1 !=""){
                            html+="<br/>"+data[i].comMail1;
                        }
                        if(data[i].com2 != ""){

                            html+="<br/><span class=\"libelle-fonction\">"+data[i].com2+"</span>";
                            if(data[i].comMail2 !=""){
                                html+="<br/>"+data[i].comMail2;
                            }

                            if(data[i].com3 != ""){

                                html+="<br/><span class=\"libelle-fonction\">"+data[i].com3+"</span>";
                                if(data[i].comMail3 !=""){
                                html+="<br/>"+data[i].comMail3;
                            }
                            }
                        }                                        
                    }
                    html+="</td></tr></table></td>";
                    
                    if(i==((data.length)-1) && isPair((data.length)-1)){
                        html+="</tr>";
                    }
                    
                } else {
                     html+="<td><table><tr>";
                        if(data[i].photoStaff != ""){
                            html+="<td><img src=\"images/staff/"+data[i].photoStaff+"\" width=\"100\"/></td>";
                        } else {
                            html+="<td><img src=\"images/staff/xxx.jpg\" width=\"100\" /></td>";
                        }
                            
                    html +="<td><b>"+data[i].nomStaff+" "+data[i].prenomStaff+"</b>";
                    if(data[i].libTypeStaff != "notype"){
                        html+="<br/><span class=\"libelle-fonction\">"+data[i].libTypeStaff+"</span>";
                    }
                    if(data[i].mailStaff != ""){
                        html+="<br/>"+data[i].mailStaff;
                    }
                    if(data[i].mailFonction !=""){
                        html+="<br/>"+data[i].mailFonction;
                    }         

                    if(data[i].com1 != ""){

                        html+="<br/><span class=\"libelle-fonction\">"+data[i].com1+"</span>";
                        if(data[i].comMail1 !=""){
                            html+="<br/>"+data[i].comMail1;
                        }
                        if(data[i].com2 != ""){

                            html+="<br/><span class=\"libelle-fonction\">"+data[i].com2+"</span>";
                            if(data[i].comMail2 !=""){
                                html+="<br/>"+data[i].comMail2;
                            }

                            if(data[i].com3 != ""){

                                html+="<br/><span class=\"libelle-fonction\">"+data[i].com3+"</span>";
                                if(data[i].comMail3 !=""){
                                html+="<br/>"+data[i].comMail3;
                            }
                            }
                        }                                        
                    }
                    html+="</td></tr></table></td>";
                    
                    if(i==((data.length)-1) && !isPair((data.length)-1)){
                        html+="</tr>";
                    }
                }
            }
            if(idStaff == 2){
                $(".staff-comite-orga").append(html);
            } else if (idStaff == 3){
                $(".staff-entrai-orga").append(html);
            } else if (idStaff == 4){
                $(".staff-resp-orga").append(html);
            } else if (idStaff == 5){
                $(".staff-com-orga").append(html);
            }            
        }
    
        
    }).done(function(){
        if(idStaff == 1){
                $(".loader-staff-bureau").hide();
            } else if(idStaff == 2){
                $(".loader-staff-comite").hide();
            } else if (idStaff == 3){
                $(".loader-staff-entr").hide();
            } else if (idStaff == 4){
                $(".loader-staff-resp").hide();
            } else if (idStaff == 5){
                $(".loader-staff-com").hide();
            } 
    });
}
 
}

function getD2equipe() {
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").show();
    getImage(1, 1);    
    getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    getListInfo();
    changePartInfo(".info-D2")
    getJoueurs("D2");
}

function getD2champ() {
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").show();
    getCalendrier(1);
    getLastResult(1);
    changePartInfo(".info-D2");
    getNbJournee(0,1);
    $("#championnat-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){               
                getNbJournee(0,1);      
           }else if (ui.index == 1){               
                getNbJournee(1,1);
           } else {               
                getNbJournee(2,1);
           }
       }
    });
}

function getD2coupeFr() {
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").show();
    getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    changePartInfo(".info-D2");
    getNbJournee(4,12);    
    $("#championnat-CFrance-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
               getNbJournee(4,12);    
           } else {
               getNbJournee(3,12);
           } 
       }
    });
}

function getD2tournMatchAm() {
    $(".video-sondage").hide();
    $("#accordion").show(); 
    $(".bloc-classement-d2").show();
    getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    getMatchAmicaux(11);
    changePartInfo(".info-D2");
}

function getMoustiques(){
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").hide();
    getImage(3, 1);
    getCalendrier(3);
    getLastResult(3);
    getNextMatch(3);
    getJoueurMineur(3);       
    $("#moustique-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
              getJoueurMineur(3);  
           } else if(ui.index == 1){               
                 getNbJournee(7,3);
           } else {
               getMatchAmicaux(15);
           }
       }
    });
}

function getPartenairesContent(){
    // on cache la video/sondage
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").show();
    // on affiche le calendrier D2
    getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    // 
    
    // pour chaque groupe de partenaire on charge la liste

    getPartenaires(0);
    getPartenaires(1);
    getPartenaires(2);
    getPartenaires(3);
    getPartenaires(4);
    getPartenaires(5);
    getPartenaires(6);            			  


}

function getPoussins(){
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").hide();
    getImage(4, 1)
    getCalendrier(4);
    getLastResult(4);
    getJoueurMineur(4);    
    $("#poussin-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
              getJoueurMineur(4);  
           } else if(ui.index == 1){               
                 getNbJournee(8,4);
           } else {
               getMatchAmicaux(16);
           }
       }
    });
}

function getBenjamins(){
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").hide();
    getImage(5, 1)
    getCalendrier(5);
    getLastResult(5);
    getNextMatch(5);
    getJoueurMineur(5);    
    $("#benjamin-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
              getJoueurMineur(5);  
           } else if(ui.index == 1){               
                 getNbJournee(9,5);
           } else {
               getMatchAmicaux(17);
           }
       }
    });
}

function getMinimes(){
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").hide();
    getImage(6, 1)
    getCalendrier(6);
    getNextMatch(6);
    getLastResult(6);
    getJoueurMineur(6);    
    $("#minimes-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
              getJoueurMineur(6);  
           } else if(ui.index == 1){               
                 getNbJournee(10,6);
           } else {
               getMatchAmicaux(18);
           }
       }
    });
    
}

function getCadets(){
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").hide();
    getImage(7, 1)
    getCalendrier(7);
    getLastResult(7);
    getNextMatch(7);
    getJoueurMineur(7);    
    $("#cadets-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
              getJoueurMineur(7);  
           } else if(ui.index == 1){               
                 getNbJournee(11,7);
           } else {
               getMatchAmicaux(19);
           }
       }
    });
    
}

function getJuniors(){
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").hide();
    getImage(8, 1)
    getCalendrier(8);
    getLastResult(8);
    getNextMatch(8);
    getJoueurMineur(8);    
    $("#juniors-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
              getJoueurMineur(8);  
           } else if(ui.index == 1){               
                 getNbJournee(5,8);
           } else {
               getMatchAmicaux(20);
           }
       }
    });
}

function getEcole(){
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").hide();
    getImage(2, 1)
    getCalendrier(2);
    getLastResult(2);
    getNextMatch(2);
    getJoueurMineur(2);    
    $("#ecole-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
              getJoueurMineur(2);  
           } else if(ui.index == 1){               
                 getNbJournee(6,2);
           } else {
               getMatchAmicaux(14);
           }
       }
    });
}

function getLoisirs(){
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").hide();
    getCalendrier(9);
    getImage(9, 1)
    getJoueurMineur(9);
    getNextMatch(9);
    getLastResult(9);    
    $("#loisir-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
              getJoueurMineur(9);  
           } else if(ui.index == 1){               
                 getNbJournee(12,9);
           } else {
               getMatchAmicaux(21);
           }
       }
    });
}

function getFeminines(){
    $(".video-sondage").hide();
    $("#accordion").show();
    $(".bloc-classement-d2").hide();
    getImage(10, 1)
    getCalendrier(10);
    getLastResult(10);
    getNextMatch(10);
    getJoueurMineur(10);    
    $("#feminines-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){
              getJoueurMineur(10);  
           } else if(ui.index == 1){               
                 getNbJournee(13,10);
           } else {
               getMatchAmicaux(22);
           }
       }
    });
}

function getRdv(){
    $(".video-sondage").hide();
    $('.info-prat').hide();
    $("#accordion").hide();
    
    getCalendrierAll();    
}

function getNewsPage(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
    getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);    
    getNewsAll();
}

function getLiens(){
    /*$("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
    changePage(".nahg-liens");
    document.location.hash = "nahg-liens";*/
    	$("#dialog-prochainement").dialog({

			bgiframe: true, // ParamÃ¨tre pour assurer la compatibilitÃ© avec IE
			resizable: false, // On ne permet pas le redimensionnement de la fenetre de dialogue
			height:200,
			width:300,// 220 pixels de hauteurs
			modal: true,
			close: function(event, ui) {getAccueil();},
			overlay: {
					backgroundColor: '#000',
					opacity: 0.5
			}, 
			buttons: [
					{
							text: "Ok",
							click: function() {
								getAccueil();
								$(this).dialog("close");
						}
					}
			]
	});
}

function getLive(){
	$("#dialog-prochainement").dialog({

			bgiframe: true, // ParamÃ¨tre pour assurer la compatibilitÃ© avec IE
			resizable: false, // On ne permet pas le redimensionnement de la fenetre de dialogue
			height:200,
			width:300,// 220 pixels de hauteurs
			modal: true,
			close: function(event, ui) {getAccueil();},
			overlay: {
					backgroundColor: '#000',
					opacity: 0.5
			}, 
			buttons: [
					{
							text: "Ok",
							click: function() {
								getAccueil();
								$(this).dialog("close");
						}
					}
			]
	});
}

function getStaff(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
    $(".staff-bureau-orga").html("");
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    getStaffContent(1);   
    
    
     $("#staff-tabs").tabs({
       select: function(event, ui) {
           if(ui.index == 0){                
                getStaffContent(1);     
           }else if (ui.index == 1){
                getStaffContent(2);
           } else if (ui.index == 2) {
                getStaffContent(3);
           }else if (ui.index == 3) {
                getStaffContent(4);
           } else {
               getStaffContent(5);
           }
       }
    });
}

function getInscription(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getStage(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getContact(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getAcces(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
    getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getTelechargement(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getMaj(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getRegles(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getEquipement(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getPatinoire(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
    getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
    $(".patinoire-content .diaporama1").jDiaporama({
        animationSpeed: "slow",
        delay:6
    });
}

function getDevenirPartenaire(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
    getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getPartenairesPrestation(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getCE(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
	getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getTarif(){
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
    getCalendrier(1);
    getLastResult(1);
    getNextMatch(1);
    
}

function getAccueil(){
    $('.nahg-acceuil').fadeIn(500);
    $('.info-prat').hide();
    $('.nahg-page').hide();
    $(".bloc-classement-d2").show();
    $("#accordion").show();
    $(".video-sondage").show();
    $(".bloc-classement-d2").show();
    getNews(1);
    getCalendrier(1);
    getNextMatch(1);
    getLastResult(1);
    getResultat(1,2);                                                             
    getDiapoAccueil();
    getVideo();
    document.location.hash = "accueil";
}

function getPubEntree(){
	
	var partElem = "";         
        partElem = $('#popup3 > *').length;	
	if(partElem == 0) {
            getJSON("php/json_diapoAccueil.php?action=pub", function(data){
                        var html = "";
                if(data.length > 0){
                                html = "<img class=\"pub-accueil\" src=\"images/photos/pub/"+data[0].image+"\" width=\"400px\" /> ";
                                $("#popup3").append(html);
                        } else {
							return
						}


            }).done(function(){
					partElem2 = $('#popup3 > *').length;
						if(	partElem2 != 0){
	                    var popID = 'popup3'; 
	                    var popURL = '#?w=400'; 
	                    var query= popURL.split('?');
	                    var dim= query[1].split('&');
	                    var popWidth = dim[0].split('=')[1];

	                    $('#' + popID).fadeIn().css({'width': Number( popWidth )}).prepend('<a href="#" class="close"><img src="css/images/close_pop.png" class="btn_close" title="Fermer" alt="Close" /></a>');

	                    var popMargTop = ($('#' + popID).height() + 95) / 2;
	                    var popMargLeft = ($('#' + popID).width() + 80) / 2;

	                    $('#' + popID).css({ 
	                                    'margin-top' : -popMargTop,
	                                    'margin-left' : -popMargLeft
	                    });

	                    $('body').append('<div id="fade"></div>');
	                    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();


	                    $('a.close, #fade').live('click', function() {
	                            $('#fade , .popup_block').fadeOut(function() {
	                                            $('#fade, a.close').remove();  
	                            });

	                            return false;
	                    } );
					}
                });
	}
}

function init() {

    $('.nahg-acceuil').fadeIn(500);
    $('.info-prat').hide();
    $('.nahg-page').hide();
    
    // recuperation de la totalitÃ© des partenaires
    getPartenairesAccueil();
    
    
	$(".error-msg button").button({
         icons: {
             primary: "ui-icon-circle-close"
         },
         text: false
     	}).click(function (e) {
			$(this).parent().fadeOut();
			return e.preventDefault();
		});
     
   
    
    $('.link-equipe-d2').click(function(e) {
        changePage(".nahg-lad2");
        getD2equipe();		
        document.location.hash = "nahg-lad2";	
            return e.preventDefault();
    });

    $('.link-acceuil').click(function(e) {
            $("#accordion").fadeIn(500);
            $(".video-sondage").fadeIn(500);
            getAccueil();
            changePage(".nahg-acceuil");
            changePartInfo(".nahg-partenaires-slide");
            $(".accordion-nahg-video").show();
            document.location.hash = "accueil";
            return e.preventDefault();
    });
    $('.link-championnat-D2').click(function(e) {            
            document.location.hash = "nahg-championnat-D2";
            getD2champ();
            changePage(".nahg-championnat-D2");
            return e.preventDefault();
    });
    $('.link-coupeFr-D2').click(function(e) {            
            document.location.hash = "nahg-coupeFr-D2";
            getD2coupeFr();
            changePage(".nahg-coupeFr-D2");
            return e.preventDefault();
    });
    $('.link-tournois-matchA-D2').click(function(e) {            
            document.location.hash = "nahg-tournois-matchA-D2";
            getD2tournMatchAm();
            changePage(".nahg-tournois-matchA-D2");
            return e.preventDefault();
    });
    $('.link-partenaires').click(function(e) {            
            getPartenairesContent()
            changePartInfo(".video-sondage");
            changePage(".nahg-partenaires");
            document.location.hash = "nahg-partenaires";
            return e.preventDefault();
    });
    $('.link-equipe-moustique').click(function(e) {
            getMoustiques();         
            document.location.hash = "nahg-moustiques";
            changePage(".nahg-moustiques");
            changePartInfo(".info-U9");
            return e.preventDefault();
    });
    $('.link-equipe-poussins').click(function(e) {
            getPoussins();
            changePage(".nahg-poussin");
            changePartInfo(".info-U11");
            document.location.hash = "nahg-poussin";
            return e.preventDefault();
    });
    $('.link-equipe-benjamins').click(function(e) {
            getBenjamins();
            changePage(".nahg-benjamin");
            changePartInfo(".info-U13");
            document.location.hash = "nahg-benjamin";
            return e.preventDefault();
    });
    $('.link-equipe-minimes').click(function(e) {
            getMinimes();
            changePage(".nahg-minimes");
            changePartInfo(".info-U15");
            document.location.hash = "nahg-minimes";
            return e.preventDefault();
    });
    $('.link-equipe-cadets').click(function(e) {
            getCadets();
            changePage(".nahg-cadets");
            changePartInfo(".info-U18");
            document.location.hash = "nahg-cadets";
            return e.preventDefault();
    });
    $('.link-equipe-juniors').click(function(e) {
            getJuniors();
            changePage(".nahg-juniors");
            changePartInfo(".info-U22");
            document.location.hash = "nahg-juniors";
            return e.preventDefault();
    });
    $('.link-equipe-ecole').click(function(e) {
            getEcole();
            changePage(".nahg-ecole");
            changePartInfo(".info-U7");
            document.location.hash = "nahg-ecole";
            return e.preventDefault();
    });
    $('.link-equipe-loisir').click(function(e) {
            getLoisirs();
            changePage(".nahg-loisir");
            changePartInfo(".info-loisirs");
            document.location.hash = "nahg-loisir";
            return e.preventDefault();
    });
    $('.link-equipe-feminines').click(function(e) {
            getFeminines();
            changePage(".nahg-feminines");
            changePartInfo(".info-femmes");
            document.location.hash = "nahg-feminines";
            return e.preventDefault();
    });
    $('.link-rendez-vous-club').click(function(e) {
            changePage(".nahg-calendar-club");
            document.location.hash = "nahg-calendar-club";
            getRdv();          
            return e.preventDefault();
    });
    
    $('.link-news').click(function(e) {                 
            getNewsPage();        
            changePage(".nahg-news");
            document.location.hash = "nahg-news";         
            return e.preventDefault();
    });
    
    $('.link-liens').click(function(e) {                 
        getLiens();        
        document.location.hash = "nahg-liens";         
        return e.preventDefault();
    });
    
    $('.link-live').click(function(e) {                 
        getLive();        
        document.location.hash = "nahg-live";         
        return e.preventDefault();
    });
    
    $('.link-staff').click(function(e) {                 
        getStaff();        
        changePage(".nahg-staff");
        document.location.hash = "nahg-staff";        
        return e.preventDefault();
    });
    $('.link-inscription').click(function(e) {                 
        getInscription();        
        changePage(".nahg-inscription");
    document.location.hash = "nahg-inscription";         
        return e.preventDefault();
    });
    $('.link-stage').click(function(e) {                 
        getStage();        
        changePage(".nahg-stage");
    document.location.hash = "nahg-stage";         
        return e.preventDefault();
    });
    $('.link-contact').click(function(e) {                 
        getContact();        
        changePage(".nahg-contact");
        document.location.hash = "nahg-contact";        
        return e.preventDefault();
    });
    $('.link-acces').click(function(e) {                 
        getAcces();    
        changePage(".nahg-acces");
        document.location.hash = "nahg-acces";
        document.location.hash = "nahg-acces";         
        return e.preventDefault();
    });
    $('.link-telechargement').click(function(e) {                 
        getTelechargement();        
        changePage(".nahg-telechargement");
    document.location.hash = "nahg-telechargement";        
        return e.preventDefault();
    });
    $('.link-maj').click(function(e) {                 
        getMaj();        
        changePage(".nahg-maj");
        document.location.hash = "nahg-maj";         
        return e.preventDefault();
    });
    $('.link-regles').click(function(e) {                 
        getRegles();        
        changePage(".nahg-regles");
        document.location.hash = "nahg-regles";         
        return e.preventDefault();
    });
    $('.link-equipement').click(function(e) {                 
        getEquipement();        
        changePage(".nahg-equipement");
        document.location.hash = "nahg-equipement";         
        return e.preventDefault();
    });
    $('.link-patinoire').click(function(e) {                 
        getPatinoire();        
        changePage(".nahg-patinoire");
        document.location.hash = "nahg-patinoire";         
        return e.preventDefault();
    });
    
    $('.link-devenir-partenaires').click(function(e) {  
        $('.nahg-acceuil').hide();
        getDevenirPartenaire();        
        changePage(".nahg-devenir-partenaires");
        document.location.hash = "nahg-devenir-partenaires";         
        return e.preventDefault();
    });
    
    $('.link-partenaires-prestation').click(function(e) {                 
        getPartenairesPrestation();        
        changePage(".nahg-partenaires-prestation");
        document.location.hash = "nahg-partenaires-prestation";         
        return e.preventDefault();
    });
    $('.link-ce').click(function(e) {                 
        getCE();        
        changePage(".nahg-ce");
        document.location.hash = "nahg-ce";        
        return e.preventDefault();
    });
    
    $('.link-tarif').click(function(e) {                 
        getTarif();        
        changePage(".nahg-tarif");
        document.location.hash = "nahg-tarif";         
        return e.preventDefault();
    });	
    
    $(".calendar-prev, .calendar-next" ).button();
    
    $(".calendar-next").click(function(e) {
        
        var mois = parseInt($(".num-mois").val());
        var annee =parseInt($(".annee").val());
        var eq = $(".calendar-categ").val();
        if(mois == 12){
            mois = 1;            
            annee = annee + parseInt(1);
            $(".annee").val(annee);
            getCalendrierByMois(mois,annee,eq);
        } else {
            mois = parseInt($(".num-mois").val())+ parseInt(1);
            getCalendrierByMois(mois,annee,eq);
        }
         
         return e.preventDefault();
     });

     $(".calendar-prev").click(function(e) {
        var mois = parseInt($(".num-mois").val());
        var annee =parseInt($(".annee").val());
        var eq = $(".calendar-categ").val();
        if(mois == 1){
            mois = 12;            
            annee = annee - parseInt(1);
            $(".annee").val(annee);
            getCalendrierByMois(mois,annee,eq);
        } else {
            mois = parseInt($(".num-mois").val())- parseInt(1);
            getCalendrierByMois(mois,annee,eq);
        }
     });

    
    
    
	$('.pagination-1').click(function(e) {
			var obj = $(this);
			getNews(1);			
			
			if(!obj.hasClass("active")) {
				obj.removeClass("inactive");
				obj.addClass("active");
				$('.pagination-2').removeClass("active");
				$('.pagination-2').addClass("inactive");
				$('.pagination-3').removeClass("active");
				$('.pagination-3').addClass("inactive");
			}
	        return e.preventDefault();
	});
	
	$('.pagination-2').click(function(e) {
			var obj = $(this);
			getNews(2);
			if(!obj.hasClass("active")) {
				obj.removeClass("inactive");
				obj.addClass("active");
				$('.pagination-1').removeClass("active");
				$('.pagination-1').addClass("inactive");
				$('.pagination-3').removeClass("active");
				$('.pagination-3').addClass("inactive");
			}
	        return e.preventDefault();
	});
	
	$('.pagination-3').click(function(e) {
			var obj = $(this);
			getNews(3);
			if(!obj.hasClass("active")) {
				obj.removeClass("inactive");
				obj.addClass("active");
				$('.pagination-1').removeClass("active");
				$('.pagination-1').addClass("inactive");
				$('.pagination-2').removeClass("active");
				$('.pagination-2').addClass("inactive");
			}
	        return e.preventDefault();
	});
        
        $('.paginationHB-1').click(function(e) {
			var obj = $(this);
			getNewsHockeyHebdo(1);			
			
			if(!obj.hasClass("active")) {
				obj.removeClass("inactive");
				obj.addClass("active");
				$('.paginationHB-2').removeClass("active");
				$('.paginationHB-2').addClass("inactive");
				$('.paginationHB-3').removeClass("active");
				$('.paginationHB-3').addClass("inactive");
			}
	        return e.preventDefault();
	});
	
	$('.paginationHB-2').click(function(e) {
			var obj = $(this);
			getNewsHockeyHebdo(2);
			if(!obj.hasClass("active")) {
				obj.removeClass("inactive");
				obj.addClass("active");
				$('.paginationHB-1').removeClass("active");
				$('.paginationHB-1').addClass("inactive");
				$('.paginationHB-3').removeClass("active");
				$('.paginationHB-3').addClass("inactive");
			}
	        return e.preventDefault();
	});
	
	$('.paginationHB-3').click(function(e) {
			var obj = $(this);
			getNewsHockeyHebdo(3);
			if(!obj.hasClass("active")) {
				obj.removeClass("inactive");
				obj.addClass("active");
				$('.paginationHB-1').removeClass("active");
				$('.paginationHB-1').addClass("inactive");
				$('.paginationHB-2').removeClass("active");
				$('.paginationHB-2').addClass("inactive");
			}
	        return e.preventDefault();
	});
		    
    $('.btn-connexion').click(function(e){
        if(testConnexionSaisie()){
            var obj = $(".connexion");
            submit(obj,"php/json_login.php",function(data) {
                
                var url = "http://localhost:81/nahg/"+data.redirect;  
                $(location).attr("href", url);
            });
        }
                              

        return e.preventDefault();
    });
    
    function testConnexionSaisie() {
        var returnValue = false;
        var obj = $(".login-saisi");		
        if(obj.val() == ""){                			
            afficheError("Vous devez saisir un login !");
            returnValue = false;
                
        } else {			
                obj = $(".pass-saisi");		
                if(obj.val() == ""){                
                    obj.addClass(".border-error");		
                    afficheError("Vous devez saisir un mot de passe !");
                    returnValue = false;
                } else {			
                        returnValue = true;
                }   
        }
        return returnValue;
    }
$("#dialog-loader").dialog({
        autoOpen:false,
        bgiframe: true, // ParamÃ¨tre pour assurer la compatibilitÃ© avec IE
        resizable: false, // On ne permet pas le redimensionnement de la fenetre de dialogue
        height:200, // 220 pixels de hauteurs
        width:300,
        modal: true,
        overlay: {
                backgroundColor: '#000',
                opacity: 0.5
        }
});
$("#dialog-credit").dialog({
        autoOpen:false,
        bgiframe: true, // ParamÃ¨tre pour assurer la compatibilitÃ© avec IE
        resizable: false, // On ne permet pas le redimensionnement de la fenetre de dialogue
        height:300, // 220 pixels de hauteurs
        width:400,
        modal: true,
        overlay: {
                backgroundColor: '#000',
                opacity: 0.5
        }
});
$("#dialog-error").dialog({
	autoOpen:false,	
        bgiframe: true, // ParamÃ¨tre pour assurer la compatibilitÃ© avec IE
        resizable: false, // On ne permet pas le redimensionnement de la fenetre de dialogue
        height:300,
        width:400,// 220 pixels de hauteurs
        modal: true,
        overlay: {
                backgroundColor: '#000',
                opacity: 0.5
        }, 
        buttons: [
                {
                        text: "Ok",
                        click: function() {
                            $(".error-message").html("");
                            $(this).dialog("close");

                    }
                }
        ]
});
$("#dialog-info-joueur").dialog({
        autoOpen:false,
        bgiframe: true, // ParamÃ¨tre pour assurer la compatibilitÃ© avec IE
        resizable: true, // On ne permet pas le redimensionnement de la fenetre de dialogue
        width:1000,
        height:700, // 220 pixels de hauteurs
        modal: true,
        overlay: {
                backgroundColor: '#000',
                opacity: 0.5
        },
        beforeClose: function() {
                $(".info-joueur").html("");
                $(".stats-joueur").html("");

        }
});
$("#dialog-pub").dialog({
        autoOpen:false,
        bgiframe: true, // ParamÃ¨tre pour assurer la compatibilitÃ© avec IE
        resizable: true, // On ne permet pas le redimensionnement de la fenetre de dialogue
        modal: true,
        overlay: {
                backgroundColor: '#000',
                opacity: 0.5
        }
});



}

