hs.graphicsDir = '/js/u/highslide/graphics/';
hs.showCredits = false;
hs.creditsHref = '';
hs.transitions = ['expand', 'crossfade'];
hs.objectLoadTime = 'before'; // Load iframes 'before' or 'after' expansion.
hs.outlineType = null;
hs.fadeInOut = true;
//hs.headingEval = 'this.thumb.alt';
hs.align = 'center';
hs.dimmingOpacity = 0.7;

hs.lang.creditsText = '';
hs.lang.creditsTitle = '';

hs.Expander.prototype.onAfterExpand = function(sender) {
	var h = jQuery(".controlbar").parent("div").css("height");
	var w = jQuery(".controlbar").parent("div").css("width");
	if (typeof((jQuery(".controlbar").attr("id"))) != "undefined") {
		if (((jQuery(".controlbar").attr("id")).indexOf("hsId")) == 0) {
			jQuery(".controlbar").css( { "height" : h , "width" : w, "position" : "absolute"} );
		}
	}
	jQuery(".highslide-previous, .highslide-next, .highslide-close").fadeIn("200");
};

var hsImgControlBar = '	<a href="#" onclick="return hs.previous(this)" title="'+locale["prev"]+'" class="highslide-previous"><span>'+locale["prev"]+'</span></a>';
hsImgControlBar += '	<a href="#" onclick="return hs.next(this)" title="'+locale["next"]+'" class="highslide-next"><span>'+locale["next"]+'</span></a>';
var hsImgClose = '	<a href="#" onclick="hs.close(this); return false;" class="highslide-close"><span>'+locale["close"]+'</span></a>';

hs.registerOverlay({
		className: 'controlbar',
		thumbnailId: null,
		position: 'top left',
		html: hsImgClose,
		hideOnMouseOut: false,
		opacity: 1
});

if ( !($.browser.msie && ($.browser.version.substr(0,3)=="6.0" || $.browser.version.substr(0,2)=="5.")) ) {
hs.registerOverlay({
		className: 'controlbar',
		thumbnailId: null,
		position: 'top left',
		html: hsImgControlBar,
		hideOnMouseOut: true,
		opacity: 1
});
}

function hideControls() {
	$(".highslide-previous, .highslide-next, .highslide-close").hide();
}


hs.Expander.prototype.onBeforeExpand = function (sender) {
		if (sender.a.className.indexOf("hs-htmlExpand") > -1) {
			var closeButton = document.createElement('div');
			closeButton.innerHTML = hsImgClose;
			sender.createOverlay( { overlayId: closeButton, position: "top right", hideOnMouseOut: false, opacity: 1 }  );
		} else {
			hideControls();
			if(sender.thumb.alt != ""){
				var photoTitle = document.createElement('div');
				photoTitle.className = "highslide-photo-title";
				photoTitle.innerHTML = sender.thumb.alt;
				if ($.browser.msie) {
					sender.createOverlay( { overlayId: photoTitle, position: "top left", hideOnMouseOut: true, opacity: 1, width: '100%' } );
				} else {
					sender.createOverlay( { overlayId: photoTitle, position: "top left", hideOnMouseOut: true, opacity: 0.6, width: '100%' } );
				}
			}
		}
};

function init() {
	/* gallery on demand */
	var paramGallery = getParameter("hsi");
	if (typeof paramGallery != "undefined") {
		openHighslideGallery(paramGallery);
	}
}
function openHighslideGallery(id) {
	if ($("#"+id)) {
		var anch = document.getElementById(id);
		hs.expand(anch, { fadeInOut: false, wrapperClassName: 'wide-border imageHighslide'});
	}
}
$(document).ready(function(){
	init();
});
