/**
 *    Site-specific configuration settings for Highslide JS
 */
$(document).ready(function() {
    hs.graphicsDir = 'http://www.roadrash.no/wp-highslide/highslide/graphics/';
    hs.outlineType = 'custom';
    hs.dimmingOpacity = 0.75;
    hs.fadeInOut = true;
    hs.align = 'center';
    hs.marginBottom = 105;
    hs.captionEval = 'this.thumb.alt';

    // Add the slideshow controller
    hs.addSlideshow({
        slideshowGroup: (function() { // set the ssg to the result of an anonymous function
            var groups = [];
            $('.gallery').each(function(i, $item) { // loop over all galleries...
                groups.push($item.id); // ... and get their id's, which are identical to the ssg
            });
            return groups;
        })(),
        interval: 5000,
        repeat: false,
        useControls: true,
        fixedControls: false,
        overlayOptions: {
            className: 'text-controls',
            opacity: '1',
            position: 'bottom center',
            offsetX: '0',
            offsetY: '-60',
            relativeTo: 'viewport',
            hideOnMouseOut: false
        },
        thumbstrip: {
            mode: 'horizontal',
            position: 'bottom center',
            relativeTo: 'viewport'
        }

    });
    //};
    hs.numberPosition = 'caption';
    hs.transitions = ['expand', 'crossfade'];

    // for gallery
    $('.gallery-item a').addClass('highslide');
    $('.gallery-item a').each(function() {
        this.onclick = function() {
            return hs.expand(this, {
                slideshowGroup: this.parentNode.parentNode.parentNode.id
            });
        };
    });

	hs.onSetClickEvent = function ( sender, e ) {
		e.element.onclick = function () {
			return hs.expand(this, singleConfig);
		}
		return false;
	};

    var singleConfig = {
        slideshowGroup: 'single-image',
        outlineType: 'drop-shadow',
        wrapperClassName: 'borderless remove',
        numberPosition: null,
        dimmingOpacity: 0
    };

    hs.registerOverlay({
        slideshowGroup: 'single-image',
        html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
        position: 'top right',
        fade: 2
    });

});



hs.Expander.prototype.onInit = function() {
	hs.marginBottom = (this.slideshowGroup == 'single-image') ? 15 : 105;
}

