// Set up DHTML version of link to this book

if(!$.browser.opera && !($.browser.msie && $.browser.version.substr(0,1) == "6"))
{
    if ($('.stepcarousel').length > 0)
    {
        stepcarousel.setup({
            galleryid: 'linkstyles', //id of carousel DIV
            beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
            panelclass: 'panel', //class of panel DIVs each holding content
            panelbehavior: {speed:300, wraparound:false, persist:true},
            defaultbuttons: {enable: true, moveby: 1, leftnav: ['/test/back.gif', -10, 100], rightnav: ['/test/forward.gif', -10, 100]},
            statusvars: ['statusA', 'statusB', 'statusC'], // Register 3 "status" variables
            contenttype: ['inline'], // content type <--No comma following the very last parameter, always!
            defaultbuttonsfade: 0
        });
        $(document).ready(function(){
            // Move back and forward buttons into the slide panel
            a = $("#panelForwardBtn").clone(true);
            b = $("#panelBackBtn").clone(true);
            $("#panelForwardBtn").remove();
            $("#panelBackBtn").remove();
            $('#linkstyles').append(a);
            $('#linkstyles').append(b);
            // Add a 'close' link
            $('#linkstyles').append("<a href='#' id='closeLinkBox'>Close</a>");
            $('#closeLinkBox').click(function(e) { $.unblockUI(); e.preventDefault(); });
            // Some visuals for the link to box
            $("#linkstyles h2").corner("bottom");
            $(".linktous a").click(function(e) {
                $.blockUI({ message: $('#linkstyles'), css: { width: '350px' } });
                // Put the buttons in the right place
                $("#panelBackBtn").css("z-index", "1050");
                $("#panelForwardBtn").css("z-index", "1050");
                $(".stepcarousel").css("margin-top", "0");
                $(".blockPage").css("width", "480px");
                where = $(".stepcarousel").offset();
                scrnTop = $(window).scrollTop();
                panelHeight = $(".stepcarousel").height();
                panelWidth = $(".stepcarousel").width();
                buttonHeight = $("#panelForwardBtn").height();
                buttonWidth = $("#panelForwardBtn").width();
                $("#panelForwardBtn").css("top", where.top - scrnTop + panelHeight/2 - buttonHeight/2);
                $("#panelBackBtn").css("top", where.top  - scrnTop + panelHeight/2 - buttonHeight/2);
                $("#panelForwardBtn").css("left", where.left + panelWidth - buttonWidth/3);
                $("#panelBackBtn").css("left", where.left - buttonWidth/3*2);
                $("#panelForwardBtn").css("position", "fixed");
                $("#panelBackBtn").css("position", "fixed");
                // Put the closed link in the right place
                closeWidth = $("#closeLinkBox").width();
                closeHeight = $("#closeLinkBox").height();
                $("#closeLinkBox").css("position", "fixed");
                $("#closeLinkBox").css("top", where.top  - scrnTop + panelHeight - closeHeight - 5);
                $("#closeLinkBox").css("left", where.left + panelWidth - closeWidth - 5 );
                //stepcarousel.addnavbuttons(stepcarousel.config,$(".panel"));
                e.preventDefault();
              });
        });
    }
}
