// JavaScript Document
$move_by = 220;
$frame_left = 0;
$frame_no = 1;

$(document).ready(function()
{
	$max_clicks = $("#image_container").children().size(); 	
	$imgCont = $move_by * $max_clicks; 
	$("#image_container").css({width : $imgCont}); 
	$(".prev").click(function()
		{

			/* Set the new position & frame number */
			$new_frame_no = (($frame_no/1)-1);
			$new_left = (($frame_left/1) + $move_by);
			/* Check if we're moving too far over */
			if($new_frame_no <= 0)
				{
					/* Move the images all the way left, minus one frame */
					$new_left = -($move_by*$max_clicks)+$move_by;
					$new_frame_no = $max_clicks;
					
					
				}
			$new_left_attr = $new_left+"px";
			$("#image_container").animate({left: $new_left_attr}, 800 );
			$frame_left = $new_left;
			$frame_no = $new_frame_no;
			
					
					
	
		});
	$(".next").click(function()
		{
			/* Set the new position & frame number */
			$new_frame_no = (($frame_no/1)+1);
			$new_left = (($frame_left/1) - $move_by);
			/* Check if we're moving too far over */
			if($new_frame_no >= $max_clicks)
				{		
					/* Move all the way right, to the beginning*/
					$new_left = 0;
					$new_frame_no = 1;
				}				
			$new_left_attr = $new_left+"px";
			$("#image_container").animate({left: $new_left_attr}, 800 );
			$frame_left = $new_left;
			$frame_no = $new_frame_no;
		});	
});

function loadvideo(idvideo,hauteur){
	// vide les resultats courants
	$('div#videogal').text('');
	
	// affiche l'image de loading
	$('div#loading').css('display','block');
	
	
	//appel ajax
	$.ajax({
		type:"GET",
		url:'/'+siteAccess+'/afnor_video/ajax_video/videogal/'+hauteur+'/'+idvideo,
		datatype: 'text',
		success: function(result){								
			$('div#videogal').append(result);
			$('div#loading').css('display','none');
     	},
     	error: function(){
			$('div#loading').css('display','block');
     	}
		
	});
}



