
var constImageMax = 63;
var constViewMax = 17;

$(document).ready(function(){
	
	var topimage_html = new Array();
	var topimages = new Array();
	
	var get_html = function(){
		html = '';
		key = 1 + Math.floor(Math.random()*constImageMax);
		html += '<a href="http://www.carocara.com/images/topimages/'+topimages[key].image+'" rel="prettyPhoto[image]">';
		html += '<img src="http://www.carocara.com/images/50/'+topimages[key].thumb+'" />';
		html += '</a> ';
		for(j=0; j<topimage_html.length; j++){
			if( html == topimage_html[j] ) return get_html();
		}
		return html;
	}
	var make_topimages = function(){
		
		for(i=1; i<=constImageMax; i++){
			if(i < 10) zero = '00'; else zero = '0'; 
			file = 'CAROIMG_'+zero+i+'.jpg';
			topimages[i] = { thumb:'thumb_'+file ,image:file };
		}
		for(i=0; i<constViewMax; i++){
			topimage_html[i] = get_html();
		}
		$('.thumb').html(topimage_html.join(''));
		
	}
	make_topimages();
	$("a[rel^='prettyPhoto']").prettyPhoto(function(){animation_speed:'slow'});
	
});
