/**
 * Description: JavaScripts for Schattdecor
 *  
 */

/**
 * Description: generic popup function 
 * 
 * @param url => the url to open; no default is set
 * @param size => the size of the popup window in the format "width x height"; default ist set to: 400x400 
 * @param params => the params for the popup window; default ist set to: location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no
 * @param name => the name of the popup window; default is set to: popup
 */
function popup (url, size, params, name) {
	
	// default settings
	var defName = "popup";
	var defParams = "location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no";
	var defWidth = 400;
	var defHeight = 400;
	
	var win;
	var left;
	var top;
	var width;
	var height;
	
	// setting new window width and height
	if (size != undefined) {
		var sizes = size.split("x");
		width = sizes[0];
		height = sizes[1];	
	}
	
	// setting params
	name = (name == undefined || name == '') ? defName : name;
	params = (params == undefined || params == '') ? defParams : params;
	width = (width == undefined || name == '') ? defWidth : width;
	height = (height == undefined || name == '') ? defHeight : height;
	left = (screen.width-width) / 2;
	top = (screen.height-height) / 2;
	
	// open window
	win = window.open(url, name, "height="+height+",width="+width+",left="+left+",top="+top+","+params+",screenX="+left+",screenY="+top);
	win.focus();
}