/**
 * @author The One
 */

$(document).ready(function()
{
		$('.fotos .current .loading').css({
			'opacity': 0.7,
			'display': 'none'
		});
		
		function ToggleClass(newOne){
			$(newOne).get(0).className='active';
			$('.preview a').not(newOne).get(0).className='';
		}
		
		$('.preview a').click(
			function () {
				
				ToggleClass(this);
				 
				var load = this;
				var href = $(this).attr('href');
				
				if ($(this).get(0).loaded == undefined)
				{
					$('.current .loading').fadeIn(50);
					$('.current img').attr('src',href);
					loadimage = new Image();
					loadimage.onload = function () {
						$('.current .loading').fadeOut(500);
						load.loaded = true;
					}
					loadimage.src = href;
				}
				else
				{
					$('.current img').attr('src',href);
				}
				return false;
			}
		);
		
}
);
