﻿jQuery(function( $ ){	 

	// Récupération de la taille total des archives de concert	
	var hauteur_total = $(".div-gigpress-archive").height();
	// Racourcissement des archives de concert
	$(".div-gigpress-archive").height('490px');

	function centre_div(){
		// On rÃ©cupÃ¨re d'abord les informations de largeur du navigateur
		var $window_width = $(window).width();
		
		// On rÃ©cupÃ¨re la taille de notre div gÃ©nÃ©rale
		var $div_width = $('#centrage').width();
			
		// On calcul maintenant de combien de pixel il faut dÃ©caler Ã  gauche notre div
		var $decalage = ($window_width-$div_width)/2;
		
		// On définit la taille de notre div de chargement comme celle du navigateur
		$("#loading").width($window_width);
		
		// On vÃ©rifie que le contenu n'est pas plus grand que le navigateur
		if($window_width > $div_width){	
		
			// On place maintenant notre div au centre		
			$("#centrage").css('marginLeft',$decalage+'px');			
		}else{
			$("#centrage").css('marginLeft','0px');
		}	
	}	
	
	function mobile_or_not(){
		// On rÃ©cupÃ¨re d'abord les informations de largeur du navigateur
		var $window_width = $(window).width();
		var $mobile_width = 720;
		//Si on est sur un mobile
	    if($window_width < $mobile_width){
			// On cache notre page de chargement
			//$("#loading").hide();
			// On cache certain éléments
			// La colonne map des concert
			//$("th:contains('Map')").hide();
		}else{
			// On montre certain éléments
			// La colonne map des concert
			//$("th:contains('Map')").show();
			//On scroll au bon endroit
			$(window).scrollTo( {top:'0px', left:'50%'}, 1 );
		}
	}
	
	var $window_width = $(window).width();
	var $mobile_width = 720;
	
	//Si on est  pas sur un mobile
	if($window_width > $mobile_width){
		// On cache le contenu de notre page
		$("#centrage").hide(1);
	}
	
	//centre_div();
	mobile_or_not();
	
	
	// On appel notre fonction lorsque tous les Ã©lÃ©ments sont chargÃ©s
	$(window).load(function() {		
		//centre_div();	
		mobile_or_not();	
		// On fait disparaitre notre page de chargement
        	$("#loading").fadeOut(function() { 
        		//Ensuite on fait apparaitre notre contenu
            $("#centrage").fadeIn(1000);                         
            $("#footer-container").fadeIn(1000);
            //$(window).scrollTo( {top:'0px', left:'50%'}, 1 );
      	  }); 					      
	});
	
	// On change le placement lors du redimenssionnement de notre fenÃªtre
	$(window).resize(function() {
		//centre_div();
		mobile_or_not();
	});

	$('#facebook-wall').fbWall({
	id:'bigblast.band',
	accessToken:'AAAC7gAoWDQ0BADjnb412dSCCNLUrVb6byEjMEdBWpi8ByC0Yj3yy1OPRLh0GXslBscpJ4toFgRvRldMw3ZCSQAEHZB9fgZD',
	showGuestEntries:false,
	showComments:true,
	max:5,
	timeConversion:24
	});	

	// On detect si le navigateur est IE			
$(document).bind('keydown',function(e){			
	if (e.keyCode == '37') {
		return false;	
	}
	if (e.keyCode == '39') {
		return false;	
	}
});


$(window).bind('keydown',function(e){																																							
		// This is when left arrow is pressed					   												
	  	if (e.which == '37') {
			return false;				
	  	}
	  		 
	  	// This is when right arrow is pressed
	  	if (e.which == '39') {
	  	 	return false;
	  	}

	});
	
$(".gigpress-header").append('<th class="gigpress-more" scope="col">Full info</th>');
$(".gigpress-row").append('<td class="gigpress-more" scope="col"><a href="#" class="gigpress-more-info">Full info</a></td>');
$("td.description").attr('colspan','5');
$('.gigpress-links-cell').remove();
$(".gigpress-more-info").toggle(
	function(){
	$(this).parent().parent().next().show();
	$(this).text("Hide info");
	},
	function(){
	$(this).parent().parent().next().hide();
	$(this).text("Full info");
	}
	);


$("#button-archive-gig").toggle(
	function(){
		$(".div-gigpress-archive").animate({
		    height: hauteur_total+"px"
		  }, 1500 );
		$(this).text("Close archive");
	},
	function(){
		$(".div-gigpress-archive").animate({
		    height: "490px"
		  }, 1500 );
		$(this).text("Full archive");
	}
	);
}); 



