/**
 * @author Edgeward
 */

$(document).ready(function(){
	
	var thumbItem = $('#thumb_list li a');
	thumbItem.click(function(){
		return changeImage($(this));		
	});
	
	function changeImage(imgLink){
		var largeImage = $('#large_image');
		var photo = $('#large_image img');
		var height = largeImage.height();
		largeImage.height(height+'px');
		src = imgLink.children('img').attr('src');
		var img = src.replace('_t.jpg','.jpg');
		photo.fadeOut(600,function(){
			imgPreloader = new Image();
			// once image is preloaded, show big image
			imgPreloader.onload=function(){
				newHeight = imgPreloader.height;
				if(newHeight < height) newHeight = height;
				largeImage.animate({ height: newHeight + 'px'}, 400,'',function(){
					photo.attr('src',img).fadeIn(800);
				});
	
			};			
			imgPreloader.src = img;
		});
		return false;
	}
	
	// Lightbox
	$('a.lightbox').lightBox({
		imageLoading:			'../img/lightbox/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
		imageBtnPrev:			'../img/lightbox/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
		imageBtnNext:			'../img/lightbox/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
		imageBtnClose:			'../img/lightbox/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
		imageBlank:				'../img/lightbox/lightbox-blank.gif',
		overlayOpacity:			0.6
	});
	
});





