jq(document).ready(function(){
                
    // center the images
    jq(".photoAlbumEntry img").load(function () {
        for(i = 0; i < jq("img.min").length; i++) {
            centerImage(jq("img.min").eq(i), jq("img.min").eq(i).outerWidth(), jq("img.min").eq(i).outerHeight(), 42, 42);
        }
    });

    function centerImage(ele, w, h, pw, ph) {
        var heightdiff = -((h - ph) / 2);
        var widthdiff = -((w - pw) / 2);
        
        jq(ele).css("margin-left", widthdiff);
        jq(ele).css("margin-top", heightdiff);
    }
    
    // show the first gallery preview
    jq(".galleryPreview div:first").css("display","block");
    
    // change preview on thumbnail hover
    jq(".photoAlbumEntryWrapper img").hover(
        function(){
            var current = jq(this).attr("id").replace(/thumb-/, "");
            displayPreview(current);
        }, function () {
            //nothing
        });
    
    function displayPreview(current) {
        jq(".galleryPreview div").css("display","none");
        jq("#preview-"+current).css("display","block");
    }
    
});
