$(function () {

    if (scripts_isIE6) $(document).pngFix();

    $('a.ro').mbRollover();

    if ($.fn.prettyPhoto) {
        $("a[rel^='lightbox']").prettyPhoto({
            animationSpeed: 'slow',
            padding: 40,
            opacity: 0.85,
            showTitle: false,
            allowresize: true,
            counter_separator_label: '/',
            theme: 'light_rounded'
        });
    }

    if ($.fn.mbBookShowcase) {
        $("#tray-wrapper").mbBookShowcase({
            targetTray: 'showcaseTrays', //div id of tray in your php fetch file trays.php
            detailsImg: 'book',
            itemClass: 'book',
            imgClass: 'bookImg',
            mOvrClass: 'book-ovr',
            selClass: 'book-sel',
            phpFetchFile: 'showcaseBooks.php',
            klass: 'mbBookShowcase',
            bookId: g_showcaseRecord,
            followLink: false,
            loadTrayFromExternalFile: false
        }, function() {
            var str = this.clickid;
            str = str.substring(1);
            $("#showcaseHiddenRecord").val(str);
            if (this.event == "click") {
                $.ajax({
                    url: "/showcaseSaveItem.php?record=" + str
                });
            }
        });

        $("#book").live('click', function () {
            document.showcaseForm.submit();
        });
    }

    if($("#gallery-refine").length>0){
        var ht = $("#gallery-refine").height();
        //alert(ht);
        var ht1 = ht+38;  //87
        var ht2 = ht+42;  //95
        $("#gallery .gallery-orderBy").css("top", ht1+"px");
        $(".gallery-page:first").css("top", ht2+"px");
        //$(".gallery-page:last").hide();
        $(".gallery-page:last").css({ top: "default", bottom: "-12px", left: 0 });
        $(".gallery-prev:last").css("visibility","visible");
        $(".gallery-next:last").css("visibility","visible");
        
        var nextText = $(".gallery-next > a").html();
        var prevText = $(".gallery-prev > a").html();
        //nextText = nextText.replace(//,"");
        $(".gallery-next > a").html('');
        $(".gallery-prev > a").html('');

        $(".gallery-next > a").html('<img src="/images/nextArrow.gif" style="float: right; display: inline; border-style:0; position: relative; left: -7px; top: -6px; z-index: 1;" />'+nextText);
        $(".gallery-prev > a").html('<img src="/images/previousArrow.gif" style="float: left; display: inline; border-style:0; position: relative; left: 7px; top: -6px; z-index: 1;" />'+prevText);

    }
});
