hs.graphicsDir = '/custom/highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.showCredits = false;

var thumbExpand = {
        expanding: false
}

hs.Expander.prototype.onBlur = function(){
        thumbExpand.expanding = true;
}

hs.Expander.prototype.onBeforeClose = function(){
        thumbExpand.expanding = false;
}

hs.Expander.prototype.onAfterClose = function(){
        if(thumbExpand.expanding)
                return;

        $("#overlay").fadeOut("fast", function()
        {
                $("#overlay").css("display", "none");
		$("#overlay").fadeTo(0, 0);
        });
}

hs.Expander.prototype.onBeforeExpand = function(){
        thumbExpand.expanding = true;
        $("#overlay").css("display", "block");
        $("#overlay").fadeTo("slow", 0.8);
}

$(document).ready(function(){

        // Initialize slideshow groups.

        $(".thumb-expand-group").each(function() {
                var groupName = $(this).attr("rel");
                hs.addSlideshow({
                        slideshowGroup: groupName,
                        interval: 5000,
                        repeat: false,
                        useControls: true,
                        fixedControls: 'fit',
                        overlayOptions: {
                                opacity: .75,
                                position: 'bottom center',
                                hideOnMouseOut: true
                        }
                });
        });

        // Initialize overlay.

        $("#overlay").fadeTo(0, 0);

        // Add onclick handler for each thumb expander.
        
        $("a.thumb-expand").each(function() {
        
                this.onclick = function() {
                        
                        // Make sure overlay always covers page.
                        // IE6 has problems with height.
                
                        if($.browser.msie && $.browser.version <= 6.0) 
                        {
                                var windowHeight = $(document).height();
                                $('#overlay').height(windowHeight);
                        }
                        else
                        {
                                $('#overlay').css("position", "fixed");
                        }
                
                        // Check whether this image is part of a slideshow 
                        // group.
                
                        var parents = $(this).parents(".thumb-expand-group");
                        
                        if(parents.length > 0)
                        {
                                var groupName = $(parents.get(0)).attr("rel");
                        }
                        else
                        {       
                                groupName = Math.random();
                        }
                        return hs.expand(this, { slideshowGroup: groupName });
                }
        });
});             
                
