//Photo Gallery

function ScrollToPhotoPlaceHolder(){
	var destination = $('#PhotoPlaceHolder').offset().top;
	$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 1700 );
}

//http://jqueryfordesigners.com/image-loading/
function GalleryLoadPhoto(oLink){
	//var img = new Image()
	//$(img).load(function () {
	$('#PhotoPlaceHolder img').hide().load(function () {
            //$(this).hide();
            //$('#loader').removeClass('loading').append(this);
			//$(this).fadeIn('fast').animate({width:'100px'},1500)
            $(this).fadeIn('fast');
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', $(oLink).attr('href'));
	$('#PhotoPlaceHolder a').attr('href', $(oLink).attr('href'));
	//$('#PhotoPlaceHolder').height($('#PhotoPlaceHolder img').height() + 8)
	$('#Gallery-photo-title').html($.trim($(oLink).attr('title')))
}

function CreateGallery(){
    if($('.scrollPage').length==0) return false
    $('.scrollPage').fadeTo('fast',0.7).hover(
	    function(){
		    $(this).fadeTo('fast',1)
		},
		function(){
		    $(this).fadeTo('fast',0.7)
		}
	)
	
	$('.scrollPage').click(function() {
		GalleryLoadPhoto(this)
	   	if($('.scrollPage').length>8) ScrollToPhotoPlaceHolder()
	   	return false;
	});
}


//Create jQuery LightBox gallery
function CreatejQueryLightboxGallery(){
    $('a[@rel*=lightbox]').lightBox();
}

$(document).ready(function(){
	//CreateGallery()	   
	CreatejQueryLightboxGallery()
})
