/*
 * SB Expand - ShadowBox modification by pandaking (slideshow support by migf1)
 * Allow's the expansion of large images to their original size.
 */

var sbe_isDrag = true;		// global flag

// Changes all images back to resize if they were already on drag.
var sbe_cleanup = function(){
	if (sbe_isDrag){
		var sbe = Shadowbox.getCurrent();
		sbe.options["handleOversize"] = "resize";
		Shadowbox.setup(sbe.link, sbe.options);
		sbe_icon(sbe);
		sbe_isDrag = false;
	}
	sbe_isDrag = true;	// migf1: dunno why this is needed (it somehow resets image to "resize")
}

// Show/Hide icon, depending on object (detremined by the player).
var sbe_icon = function(sbe){
	sbe.options["handleOversize"]="resize";
	if ( sbe["player"] !== "img" ) {
		var el = document.getElementById('sb-nav-expand');
		el.style.display = 'none';
	}
	else {
		var el = document.getElementById('sb-nav-expand');
		el.style.display = 'block';
	}
	Shadowbox.setup(sbe.link, sbe.options); 
}

// Forces the currently displayed image to "resize" mode and Closes Shadowbox		
var sbe_close = function() {
	var sbe = Shadowbox.getCurrent();
	sbe.options["handleOversize"] = "resize";
	Shadowbox.close();
}

// Function to switch between the full and the auto-shrunk dimensions of an image
// (it is done by switcing the handleOversize option of the image between "drag" and "resize")
function sb_expand() {
	sbe_isDrag = false;

	var sbe = Shadowbox.getCurrent();
	if ( sbe.options["handleOversize"] === "drag" ) {
		sbe.options["handleOversize"] = "resize";
		// Shadowbox.play();	// uncomment for resuming slideshow when icon is press for 2nd time 
	}
	else {
		Shadowbox.pause();		// in case of a slidshow going on, pause it before expanding image
		sbe.options["handleOversize"] = "drag";
	}
	Shadowbox.change(Shadowbox.current);
}

/*
 * SB Expand - ShadowBox modification by pandaking (slideshow support by migf1)
 * Allow's the expansion of large images to their original size.
*/
