var Collection = 
{
	oThis: '',
	iCompteurImage: 1,
	iNbImage: 0,
	
	/** clickImage
	 * @desc: Séléction d'une image
	 * @event click
	 * @param
	 */
		
	clickImage: function()
	{
		if (Collection.iNbImage == Collection.iCompteurImage)
		{
			// On revient à la première image
			Collection.iCompteurImage = 1;
			$(Collection.oThis).css('border', 'gray 1px solid');
			Collection.oThis = $('.container_image_miniature_modele:first-child');
			$(Collection.oThis).css('border', '#CA2221 1px solid');
		}
		else
		{
			// Image suivante
			$(Collection.oThis).css('border', 'gray 1px solid');
			$(Collection.oThis).next().css('border', '#CA2221 1px solid');
			Collection.oThis = $(Collection.oThis).next();
			
			Collection.iCompteurImage++;
		}
		
		var sLink = $(Collection.oThis).find('.url_image').html();
		
		$('#image_detail_modele #image_detail').fadeOut(function()
		{
			$('#image_detail_modele #image_detail').attr('src', sLink);
			
			$('#image_detail_modele #image_detail').fadeIn();
		});
	}
};




$(document).ready( function () 
{ 
	/*
	 * Click sur une collection / type de modele
	 */
	
	$('.title_collection').click( function()
	{
		$('.list_type_modele').each( function()
		{
			if ($(this).is(':visible'))
			{
				$(this).slideUp();
			}
		});
		
		
		if ( $(this).parent().find('.list_type_modele').is(':visible') )
		{
			$(this).parent().find('.list_type_modele').slideUp();
		}
		else
		{
			$(this).parent().find('.list_type_modele').slideDown();
		}
	});
	
	
	/*
	 * Click sur un bloc description
	 */
	
	$('.description_title_column').click( function()
	{
		if ( $(this).parent().find('.bloc_contenu').is(':visible') )
		{
			$(this).css('border-bottom', '');
			$(this).parent().find('.bloc_contenu').slideUp();
		}
		else
		{
			$(this).css('border-bottom', 'solid 1px gray');
			$(this).parent().find('.bloc_contenu').slideDown();
		}
	});
	
	/*
	 * Click sur une miniature
	 */
	$('.container_image_miniature_modele').click( function()
	{
		$('.container_image_miniature_modele').css('border', 'gray 1px solid');
		$(this).css('border', '#CA2221 1px solid');
		
		var sLink = $(this).find('.url_image').html();
		Collection.iCompteurImage = $(this).find('.position_image').html();
		Collection.oThis = this;
		
		$('#image_detail_modele #image_detail').fadeOut(function()
		{
			$('#image_detail_modele #image_detail').attr('src', sLink);
			
			$('#image_detail_modele #image_detail').fadeIn();
		});
	});
	
	$('.container_image_miniature_modele').each(function ()
	{
		Collection.iNbImage++;
	});
	
	/*
	if (Collection.iNbImage > 1)
	{
		var  timer = setInterval("Collection.clickImage()", 7000);
		
		$('.container_image_miniature_modele:first-child').css('border', '#CA2221 1px solid');
		Collection.oThis = $('.container_image_miniature_modele:first-child');
	}
	*/
}); 
