$(function(){
				
	$('#manufacture').change(function(){
		$.post('/vertigo/search',
		{
			'content_type': 'packshot',
			'content_id' : $('option:selected', this).data('id'),
			'count' : 5,
			'offset' : 0
		},
		function(data){
			$('.packshot-list *').remove();
			$('#next, #prev').hide();

			var list = data.list;
			var file_count = data.file_count;

			for(var i in list){
				var $img = $('<img>', {
					'src': '/upload/cache/200_'+list[i].file
					}).appendTo('.packshot-list').hide();
				if(i == 0) $img.show().addClass('active');
			}	

			if(file_count > 1)  {
				$('#next').show();
			}
						
		});					
	})
				
	$('#next').click(function(){
		if( $('.packshot-list .active').next().length ) {
			$('.packshot-list .active').removeClass('active').hide().next().show().addClass('active');
			$('#prev').show();
			if( ! $('.packshot-list .active').next().length ) {
				$('#next').hide();
			}
		} 
	});

	$('#prev').click(function(){
		if( $('.packshot-list .active').prev().length ) {
			$('.packshot-list .active').removeClass('active').hide().prev().show().addClass('active');
			$('#next').show();
			if( ! $('.packshot-list .active').prev().length ) {
				$('#prev').hide();
			}
		} 
	});

	$('#manufacture').change();
});
	
