// 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, getWindowObject){
    // 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
     // getWindowObject == [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.bajoodoo.com','newPopup',756,556,
     //    'location=no,menubar=no,personalbar=no,resizeable=no,
     //    scrollbars=no,status=no,toolbar=no', true));
     */
    // reset missing heights and widths
    if (width == null) {
        width = parseInt(screen.availWidth) - 12;
    }
    if (height == null) {
        height = parseInt(screen.availHeight) - 64;
    }
    // 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;

    if (popup.length > 0) {
        var obj = popup.shift();
        WindowClose(obj);
    }
    // opening command
    var win = window.open(file, name, options + "width=" + width + ",height=" + height + ",left=" + pos_x + ",top=" + pos_y + ",screenX=" + pos_x + ",screenY=" + pos_y + ",top=" + pos_y);
    popup.push(win);
    // move and focus if the new popup was opened successfully
    if (win != null) {
        // make sure the new popup is in front of the opener
        win.focus();
    }
    // deliver '[window object]' if requested
    if (getWindowObject == true) {
        // return the '[window object]' of the new popup
        return (win);
    }
}

function flashMapped(mID, lng) {

	// dimension limit
	var maxDim = 2880;
	
	// shrink popup
	var distH = 56;
	var distW = 32;
	
	// calculate popup width
	var actWidth = parseInt(screen.availWidth);
	var theWidth = (actWidth-distW) - (actWidth-distW)%10;
	if (theWidth > maxDim) {
		theWidth = maxDim;
	}
	
	// calculate popup height
	var actHeight = parseInt(screen.availHeight);
	var theHeight = (actHeight-distH) - (actHeight-distH)%10;
	if (theHeight > maxDim) {
		theHeight = maxDim;
	}
	urchinTracker("/atlas.html");
	if (!WindowOpen('http://atlas.flashMapped.com/inBetweenCreation.php?w='+theWidth+'&h='+theHeight+'&mID='+mID+'&lng='+lng,'flashMapped', theWidth, theHeight, 'location=no,menubar=no,personalbar=no,resizeable=no,scrollbars=no,status=no,toolbar=no', true)) {
	   if (lng == "enEN") {
	      createInfoBar('Please deactivate your popup-blocker, because the demo-application cannot be loaded otherwise ...', '#', '_self', true);
	   } else {
	      createInfoBar('Bitte deaktivieren Sie Ihren PopUp-Blocker, da die Demo-Anwendung ansonsten nicht gestartet werden kann ...', '#', '_self', true);
	   }
 }
}