$(document).ready(function(){

    $('#AfficherPhotosLink').click(function(e){
		e.preventDefault();
		
		var Photos = '<div class="pika" style="margin: 0 auto; width: 630px;"></div>';
		
		$.getJSON('GetPhotos.php', {}, function(Data){
			$.fancybox(Photos, {
				height: 510,
				width: 650,
				autoDimensions: false,
				onComplete: function(){ 
					$('.pika').PikaChoose({
						autoPlay: false,
						carousel: true,
						data: Data
					});
				}
			});
		});
    });

    $('#PhotosParcours li a').click(function(e){
		e.preventDefault();
		
        var Parameters = $(this).attr('rel').split('|');
		var Photos = '<div class="pika" style="margin: 0 auto; width: 630px;"></div>';
		
		$.getJSON('GetPhotos.php', {Parcours: Parameters[0]}, function(Data){
			$.fancybox(Photos, {
				height: 510,
				width: 650,
				autoDimensions: false,
				onComplete: function(){ 
					$('.pika').PikaChoose({
						autoPlay: false,
						carousel: true,
						data: Data,
						startOn: Parameters[1],
						buildFinished: function(){
							$('.pika li:eq('+Parameters[1]+') img').trigger('click');
						}
					});
				}
			});
		});
    });


    if($('#HomepageCarousel').size())
        $('#HomepageCarousel').roundabout({
            easing: 'easeInQuad',
            btnPrev: '#CarouselNext',
            btnNext: '#CarouselBack'
        });

    GoogleMap.Setup(46.487608,-70.834351);

    $('#CommentsTextArea').focus(function(){
       if($(this).val() == 'QUESTIONS/COMMENTAIRES')
           $(this).val(null);
    });

    $('#Navigation ul').lavaLamp({fx: 'easeOutQuad', speed: 700});

});

GoogleMap = {
  Map:null,
  Setup:function(Latitude, Longitude){

    if($('#GoogleMap').size()){
      var Coordinates = new google.maps.LatLng(Latitude, Longitude);
      var Options = {
        zoom: 14,
        center: Coordinates,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      
      GoogleMap.Map = new google.maps.Map(document.getElementById('GoogleMap'), Options);

      var Marker = new google.maps.Marker({
          position: Coordinates,
          map: GoogleMap.Map,
          title: 'Contact'
      });
    }

  }
}

