// create new Array for storing all opened popups
var popup = new Array();
// function to initialise the opening process
function WindowOpen(file, name, width, height, options, willReturn) {
  // PARAMETERS
    /*
    // file ==> [STRING]
    //    file to open in new popup.
    // name ==> [STRING]
    //    unique id to handle the new popup.
    // width ==> [INTEGER]
    //    width of the new popup.
    // height ==> [INTEGER]
    //    height of the new popup.
    // options ==> [STRING]
    //    comma separated list of attributes for the new popup.
    //    a copmplete list of attributes is available under
    //    http://de.selfhtml.org/javascript/objekte/window.htm#open
    // willReturn == [BOOL] (optional)
    //    if true and the new popup was opened successfully,
    //    '[window object]' of the new popup will be returned.
    // RETURN
    //    -none- (if willReturn is false or not given)
    //    '[window object]' (if willReturn is true)
    // EXAMPLE CALL
    //    WindowOpen('http://www.netzbewegung.com','newPopup',756,556,
    //    'location=no,menubar=no,personalbar=no,resizeable=no,
    //    scrollbars=no,status=no,toolbar=no', true));
    */
  // calculate X-position
	var pos_x = parseInt( (screen.availWidth - width) / 2 );
  // calculate Y-position
	var pos_y = parseInt( (screen.availHeight - height) / 2 );
  // join comma to options if necessary
	options = options.length ? options+"," : options;
  // opening command
	popup[name] = window.open(file, name, options+"width="+width+",height="+height+",left="+pos_x+",top="+pos_y+",screenX="+pos_x+",screenY="+pos_y+",top="+pos_y);
  // move and focus if the new popup was opened successfully
  if (popup[name]) {
    // move the new popup again to make sure the right positioning while 'window.open'
  	popup[name].moveTo(pos_x, pos_y);
    // make sure the new popup is in front of the opener
  	popup[name].focus();
  }
  // deliver '[window object]' if requested
  if (willReturn == true) {
    // return the '[window object]' of the new popup
    return(popup[name]);
  }
}

