function sbg() {} //make le.js:init() not error out

/**
 * Returns the Scene7 image specifier from an URL. 
 *
 * @param url The URL. 
 *  
 */
function getScene7ImageSpecifier(url)
{
	if (url != null)
	{
		var lastIndex = url.lastIndexOf('/');
		url = url.substr(lastIndex+1);			
	}
	return url;
}

/**
 * Returns the Scene7 image server root from an URL. 
 *
 * @param url The URL. 
 *  
 */
function getScene7ImageServerRoot(url)
{
	if (url != null)
	{
		var lastIndex = url.lastIndexOf('/');
		if (lastIndex != -1) {
			url = url.substr(0, lastIndex+1);
		}
	}
	return url;
}

/**
 * Creates the photo viewer.
 * <p>
 * To make this work an empty div element with the name izView must be defined. The CSS information for the width and 
 * height is taken for calculating the correct measures.
 * @param imagePath The initial image path.
 * @param altName The alternative name of the image.
 * @param width The width.
 * @param height The height.
 */
function createPhotoViewer (imagePath, altName, width, height) {
	var imageSpecifier = getScene7ImageSpecifier(imagePath)+"?op_sharpen=1";
	var viewWidth = jQuery("#izView:first").css("width").match(/\d+/)[0];
	var viewHeight = jQuery("#izView:first").css("height").match(/\d+/)[0];
	var s7zoom = new SjZViewer(getScene7ImageServerRoot(imagePath), imageSpecifier, viewWidth, viewHeight, width, height);

	s7zoom.enableNav(3, 0, 0, 40, 50);
	s7zoom.setZoomStep(1);
	s7zoom.setMaxZoom(100);

	/**
	 * Executed when the image is zoomed in.
	 */
	s7zoom.onEvent.onImageZoomedIn = function(x) {

	};

	/**
	 * This function executes when an image was resetted.
	 */
	s7zoom.onEvent.onImageResetted = function (x) {
	};
	
	/**
	 * This function executes when an image was exchanged.
	 */
	s7zoom.onEvent.onImageChanged = function (oldImage, newImage) {
//		jQuery("#SjElement7").css("visibility", "visible");
//		jQuery("#SjElement7").css("width", "30px");
//		jQuery("#SjElement7").css("height", "45px");
//		jQuery("#SjElement7_img").css("width", "30px");
//		jQuery("#SjElement7_img").css("height", "45px");
//		
//
//		jQuery("#SjElement8").css("visibility", "visible");
//		jQuery("#SjElement8").css("width", "30px");
//		jQuery("#SjElement8").css("height", "45px");
//		jQuery("#SjElement8_img").css("width", "30px");
//		jQuery("#SjElement8_img").css("height", "45px");
//		jQuery("#SjElement9").css("width", "30px");
//		jQuery("#SjElement9").css("height", "45px");
//		jQuery("#SjElement9_img").css("width", "26px");
//		jQuery("#SjElement9_img").css("height", "41px");
	};

	/**
	 * This function changes images.
	 * @param url The new URL.
	 * @param w The width
	 * @param h The height
	 */
	s7zoom.changeImage = function(url, w, h) {
		url=url+"?op_sharpen=1";
		s7zoom.setImage(url, true, w, h);
	};

	s7zoom.initZoomControls = function() {
		s7zoom.zoomOutButton = jQuery("#outButton");
		s7zoom.zoomInButton = jQuery("#inButton");
		s7zoom.resetButton = jQuery("#resetButton");

		s7zoom.zoomOutButton.click(function() {
			s7zoom.zoomOut();
		});

		s7zoom.zoomInButton.click(function() {
			s7zoom.zoomIn();
		});

		s7zoom.resetButton.click(function() {
			s7zoom.reset();
		});
	};
	return s7zoom;

}


