hs.graphicsDir = '/highslide/graphics/';
hs.showCredits = false;
hs.preserveContent = false;
hs.registerOverlay({ html: '<div class="cartclosebutton" onclick="return parent.window.hs.getExpander(this.myid).close();" title="Close"></div>',
	thumbnailId: 'myBasket', position: "top right", fade: 2, useOnHtml: true
});

if (document.title.indexOf('About') != -1) {
	hs.transitions = ['expand', 'crossfade'];
	hs.outlineType = 'glossy-dark';
	hs.wrapperClassName = 'dark';
	hs.marginBottom = 105; // make room for the thumbstrip and the controls

	// Add the slideshow providing the controlbar and the thumbstrip
	hs.addSlideshow({
		slideshowGroup: 1,
		interval: 5000,
		repeat: false,
		useControls: true,
		overlayOptions: {
			className: 'text-controls',
			position: 'bottom center',
			relativeTo: 'viewport',
			offsetY: -10
		},
		thumbstrip: {
			position: 'bottom center',
			mode: 'horizontal',
			relativeTo: 'viewport',
			offsetY: -40
		}
	});
	hs.addSlideshow({
		slideshowGroup: 2,
		interval: 5000,
		repeat: false,
		useControls: true,
		overlayOptions: {
			className: 'text-controls',
			position: 'bottom center',
			relativeTo: 'viewport',
			offsetY: -10
		},
		thumbstrip: {
			position: 'bottom center',
			mode: 'horizontal',
			relativeTo: 'viewport',
			offsetY: -40
		}
	});
	var miniGalleryOptions1 = {
		thumbnailId: 'thumb1',
		fadeInOut: true,
		align: 'center',
		slideshowGroup: 1,
		dimmingOpacity: 0.8
	}
	var miniGalleryOptions2 = {
		thumbnailId: 'thumb2',
		fadeInOut: true,
		align: 'center',
		slideshowGroup: 2,
		dimmingOpacity: 0.8
	}
} else if (document.title.indexOf('Dialogs') != -1) {
	hs.transitions = ['expand', 'crossfade'];
	hs.restoreCursor = null;
	hs.lang.restoreTitle = 'Click for next image';
	hs.wrapperClassName = 'borderless';

	// Add the slideshow providing the controlbar and the thumbstrip
	hs.addSlideshow({
		slideshowGroup: 'group1',
		interval: 5000,
		repeat: true,
		useControls: true,
		overlayOptions: {
			position: 'bottom right',
			offsetY: 50
		},
		thumbstrip: {
			position: 'above',
			mode: 'horizontal',
			relativeTo: 'expander'
		}
	});

	// Options for the in-page items
	var inPageOptions = {
		slideshowGroup: 'group1',
		outlineType: null,
		allowSizeReduction: true,
		wrapperClassName: 'in-page controls-in-heading',
		useBox: true,
		width: 660,
		height: 600,
		targetX: 'gallery-area 10px',
		targetY: 'gallery-area',
		captionEval: 'this.thumb.alt',
		autoplay: true
	}

	// Open the first thumb on page load
	hs.addEventListener(window, 'load', function () {
		document.getElementById('thumb1').onclick();
	});

	// Cancel the default action for image click and do next instead
	hs.Expander.prototype.onImageClick = function () {
		if (/in-page/.test(this.wrapper.className)) return hs.next();
	}

	// Under no circumstances should the static popup be closed
	hs.Expander.prototype.onBeforeClose = function () {
		if (/in-page/.test(this.wrapper.className)) return false;
	}
	// ... nor dragged
	hs.Expander.prototype.onDrag = function () {
		if (/in-page/.test(this.wrapper.className)) return false;
	}

	// Keep the position after window resize
	hs.addEventListener(window, 'resize', function () {
		var i, exp;
		hs.getPageSize();

		for (i = 0; i < hs.expanders.length; i++) {
			exp = hs.expanders[i];
			if (exp) {
				var x = exp.x,
					y = exp.y;

				// get new thumb positions
				exp.tpos = hs.getPosition(exp.el);
				x.calcThumb();
				y.calcThumb();

				// calculate new popup position
				x.pos = x.tpos - x.cb + x.tb;
				x.scroll = hs.page.scrollLeft;
				x.clientSize = hs.page.width;
				y.pos = y.tpos - y.cb + y.tb;
				y.scroll = hs.page.scrollTop;
				y.clientSize = hs.page.height;
				exp.justify(x, true);
				exp.justify(y, true);

				// set new left and top to wrapper and outline
				exp.moveTo(x.pos, y.pos);
			}
		}
	});
}
