$(document).ready(function(){

    // next and previous buttons
    $('.galleryInfo .next').click(function(){
       var next = $(this).parents('.galleryInfo').next('.galleryInfo');
       if(next.length ==0)
            next = $('.galleryInfo:first');
       ChangeImage(next.attr("entity-id"));
       return false;
    });
    $('.galleryInfo .prev').click(function(){
       var prev = $(this).parents('.galleryInfo').prev('.galleryInfo');
       if(prev.length ==0)
            prev = $('.galleryInfo:last');
       ChangeImage(prev.attr("entity-id"));
       return false;
    });
    
    // expand and collapse the thumbnail list.
    $('.scriptOnly').css('display','inline');
    $('.collapse').hide();

    $('.expand').click(function(){
        $('#thumbs').removeClass('scrolling');
        $(this).hide();
        $('.collapse').show();
    });

    $('.collapse').click(function(){
        $('#thumbs').addClass('scrolling');
        $(this).hide();
        $('.expand').show();
    });

   // hover effect   
   $(".alphaHover").hover(function(){
      $(this).fadeTo("fast", 0.7)
     },function(){
       $(this).fadeTo("fast", 1)
     });

});

function ChangeImage(id)
{
    $(".galleryInfo").removeClass("visible")
    $(".thumbnail").removeClass("selected");
    $("#Image"+id+"Info").addClass("visible")
    $("#Thumbnail_"+id).addClass("selected");
    $("#ImageLarge").attr("src", $("#Image"+id+"Info").attr("image-url"));
}