/**
 * Javascript Window Popper V1.01
 * ------------------------------
 * Browser unabhängiger Fenster öffner
 * (c) 2000 by KutscherKonzept
 * @author Michael Nagler &lt;nagler@kutscherkonzept.de&gt;
 *
 * Methoden:
 *
 * 1) popup( url, width, height, top, left, name, features )
 *
 *    Öffnet ein neues Fenster mit der angegebenen URL, Breite und Höhe. Das Fenster wird
 *    auf dem Bildschirm zentriert, wenn die Angaben top und left fehlen.
 *
 *    Wenn kein Name angegeben wird, wird ein eindeutiger Name automatisch generiert.
 *    Falls keine Features angegeben werden, erhält das Fenster auch keine. Wenn ein Feature
 *    gewünscht wird, kann dieses einfach durch seinen Namen angegeben werden.
 *
 *    Unterstützte Features sind:
 *    toolbar, scrollbars, menubar, resizeable, status, location, directories
 *
 *    Beispiel: popup( "help.html", 420, 420, null, null, "help", "scrollbar" );
 *
 * Variablen:
 *
 * 1) defaultWidth		Voreingestellte Breite, falls der Parameter bei width popup() fehlt
 *
 * 2) defaultWidth		Voreingestellte Höhe, falls der Parameter height bei popup() fehlt
 *
 */

var defaultWidth  = 580;
var defaultHeight = 420;

// --------------------------------------------------------------------------------------
// private
var count = 0;

// popup( url, <name>, <features>, width, height, top, left )
function popup( url, width, height, top, left, name, features )
{
	if( width == null )  width  = defaultWidth;
	if( height == null ) height = defaultHeight;

	if( document.all )
	{
		availWidth  = window.screen.availWidth;
		availHeight = window.screen.availHeight;

		if( top  == null ) top  = ",top="  + ( availHeight / 2 - height / 2 ); else top  = ",top=" + top;
		if( left == null ) left = ",left=" + ( availWidth  / 2 - width  / 2 ); else left = ",left="+ left;
	}
	else
	{
		if( top  == null ) top  = (screen.height) ? ",screenY=" + (screen.height / 2 - height / 2 ) : ""; else top  = ",screenX="+ top;
		if( left == null ) left = (screen.width)  ? ",screenX=" + (screen.width  / 2 - width  / 2 ) : ""; else left = ",screenY="+ left;
	}

	tmp = ""
	if( features != null && typeof( features ) == "string" ) {
		tmp = "toolbar=" + ( features.indexOf("toolbar") > - 1 ? "yes" : "no" ) + ",";
		tmp += "scrollbars=" + ( features.indexOf("scrollbar") > - 1 ? "yes" : "no" ) + ",";
		tmp += "menubar=" + ( features.indexOf("menubar") > - 1 ? "yes" : "no" ) + ",";
		tmp += "resizable=" + ( features.indexOf("resizable") > - 1 ? "yes" : "no" ) + ",";
		tmp += "status=" + ( features.indexOf("status") > - 1 ? "yes" : "no" ) + ",";
		tmp += "location=" + ( features.indexOf("location") > - 1 ? "yes" : "no" ) + ",";
		tmp += "directories=" + ( features.indexOf("directories") > - 1 ? "yes" : "no" ) + ",";
		features = tmp+"width="+ width +",height="+ height + top + left;
	} else {
		features = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,"
		         + "resizable=no,width="+ width +",height="+ height + top + left;
	}

	// alert( features );
	if( name == null ) {
		id = Math.floor( Math.random() * 8192 );
		name = "Win"+id;
	}

	win = window.open( url, name, features);

	if( win ) {
		win.focus();
	}
}



