﻿// Shows an image in a popup window
//
// src:    The url of the image
// width:  The image width 
// height: The image height
// title:  The window title
function ShowImg(src, width, height, title)
{
	// Consider the border of the window
	windowWidth = width + 20;
	windowHeight = height + 30;

	// Center the window position on the screen
	windowLeft = screen.width / 2 - windowWidth / 2;
	windowTop  = screen.height / 2 - windowHeight / 2 - 20;

	// Encode the strings into an url compatible text
	title = UrlEncode(title);

	// Open the window
	window.open("../services/imagebox.html?src=" + src 
	    + ",width=" + width 
	    + ",height=" + height
    	+ ",title=" + title 	    
	,"_blank"
	,"width=" + windowWidth 
	    + ",height=" + windowHeight 
	    + ",left=" + windowLeft 
	    + ",top=" + windowTop);
}


// Encode a string value into an url compatible text
//
// str:    The string value
// return: An url compatible string
function UrlEncode(str)
{
	str = str.replace(/ä/g,"%E4");
	str = str.replace(/Ä/g,"%C4");
	str = str.replace(/ö/g,"%F6");
	str = str.replace(/Ö/g,"%D6");
	str = str.replace(/ü/g,"%FC");
	str = str.replace(/Ü/g,"%DC");
	str = str.replace(/ß/g,"%DF");
	str = str.replace(/ /g,"%20");
	return(str);
}
