$(document).ready(function() {
	
	var wrap = $('#property_photos');	
	var items = $('#property_photos li');
	
	wrap.after('<ul id="property_photos_nav"></ul>');
	
	// Create the navigation items
	for(i=items.size()-1; i>-1; i--) {
		var src = items.eq(i).find('img').attr('src');
		$('#property_photos_nav').prepend('<li><img src="'+ src +'" /></li>');
	}
	
	$('#property_photos li').not(':eq(0)').hide();
	$('#property_photos').eq(0).addClass('current');
	
	$('#property_photos_nav li').click(function() {
		
		if( !$(this).hasClass('current') ) {		
			$('#property_photos_nav li').removeClass('current');
			
			index = $(this).addClass('current').index();	
											  
			$('#property_photos li').fadeOut(800);
			$('#property_photos li').eq(index).fadeIn(800);
		}
		
		return false;
		
	});
	
	// Colorbox settings
	$("a[rel='lightbox']").colorbox({opacity: 0.75});

});
