function wopen ( url, popupname, attributes ) {
    // oeffnet ein neues fenster mit den uebergebenen
    // eigenschaften. alle fester werden im window
    // objekt gespeichert. Dies erlaubt eine spaetere
    // Manipulation der Fenster per Javascript
  window[popupname] = window.open ( url, popupname, attributes )
  window[popupname].focus()
}

function setImg ( obj, img ) {
    // erfordert ein img objekt in der html seite im stil von
    // var myImg     = new Image();
    //     myImg.src = "/global/media/pic/pic_black.gif";
    //
    // anwendung wie folgt:
    // onmouseover = "Javascript:setImg(this,myImg1);"
    // onmouseout  = "Javascript:setImg(this,myImg2);"

    i       = obj.src;
    obj.src = img.src
    img.src = i;
}

function Browser() {
	var  b = navigator.appName;
	if      ( b == "Netscape"                    ) this.b = "ns";
	else if ( b == "Microsoft Internet Explorer" ) this.b = "ie";
	else this.b = b;
	this.version = navigator.appVersion;
	this.v = parseInt ( this.version );
	this.ns   = ( this.b == "ns" && this.v >= 4 );
	this.ns4  = ( this.b == "ns" && this.v == 4 );
	this.ns5  = ( this.b == "ns" && this.v == 5 );
	this.ie   = ( this.b == "ie" && this.v >= 4 );
	this.ie4  = ( this.version.indexOf ( 'MSIE 4'   ) > 0 );
	this.ie5  = ( this.version.indexOf ( 'MSIE 5'   ) > 0 );
	this.ie55 = ( this.version.indexOf ( 'MSIE 5.5' ) > 0 );
	this.ie6  = ( this.version.indexOf ( 'MSIE 6'   ) > 0 );
	this.dom  = ( ( document.createRange&& ( document.createRange().createContextualFragment ) ) ? true : false );
	this.min  = ( this.ns||this.ie);
	var ua=navigator.userAgent.toLowerCase();
	if      ( ua.indexOf ( "win" ) >-1 ) this.platform = "win32";
	else if ( ua.indexOf ( "mac" ) >-1 ) this.platform = "mac";
	else this.platform = "other";
}

function resizeWindow ( thisW, thisH ) {
    // Nimmt ein Window und aendert seine groesse. Wird fuer die Popups benutzt
    // um, so weit moeglich, scrollen zu verhindern.
    // Das Fenster wird auf einem Drittel hoehe der Desktop Groesse platziert und
    // horizontal zentriert.
    
    // pruefen ob eine Groessenangabe nicht passt.
    if ( thisW > screen.availWidth  ) thisW = screen.availWidth;
    if ( thisH > screen.availHeight ) thisH = screen.availHeight;


    // position Festlegen
    // Left
    thisL = ( screen.availWidth - thisW ) / 2

    // Top
    if      ( thisH == screen.availHeight                                       ) thisT = 0;
    else if ( thisH <  screen.availHeight && thisH > screen.availHeight * 3 / 4 ) thisT = screen.availHeight - thisH;
    else if ( thisH <  screen.availHeight * 3 / 4                               ) thisT = screen.availHeight / 4;

    // Browserabhaengige Groessenanpassungen
    is = new Browser();
    if ( is.ns5 ) {
        thisW -= 15;
    }

    // Groesse und Position zuweisen
    window.resizeTo ( thisW, thisH );
    window.moveTo   ( thisL, thisT );
}

function editOnFocus ( theField ) {
	theField.value = "";
	theField.focus();
}

function showOverlayPopup(url, width, height, left, top){
	var popup;
	var toolbar;
	var closeButton;
	var closeButtonLink;
	var iframe;
	
	popup = document.createElement("div");
	popup.id = "svpopup"
	popup.style.position = "absolute";
	popup.style.left = left;
	popup.style.top = top;
	popup.style.width = width + "px";
	popup.style.height = height + "px";
	popup.style.border = "1px solid #555";
	
	toolbar = document.createElement("div");
	toolbar.style.position = "relative";
	toolbar.style.background = "#B62716"
	toolbar.style.width = "100%"
	toolbar.style.height = "25px"
	
	closeButton = document.createElement("div");
	closeButton.style.position = "absolute"
	closeButton.style.top = "5px"
	closeButton.style.left = "345px"
	closeButton.style.width = "60px";
	closeButton.style.height = "15px";
	
	closeButtonLink = document.createElement("a")
	closeButtonLink.onclick = function(){popup.style.display = "none"; return false}
	closeButtonLink.href = "#"
	closeButton.style.position = "absolute"
	closeButtonLink.style.color = "#fff";
	closeButtonLink.appendChild(document.createTextNode("schließen"))
	
	closeButton.appendChild(closeButtonLink);
	
	iframe = document.createElement("iframe");
	iframe.style.position = "relative";
	iframe.style.width = "100%";
	iframe.style.height = (height-25) + "px";
	iframe.style.border = "0";
	iframe.style.overflow = "none";
	iframe.src = url;
	iframe.frameborder = 0;
	iframe.scrolling = "no";
	
	toolbar.appendChild(closeButton);
	popup.appendChild(toolbar);
	popup.appendChild(iframe);
	
	document.body.appendChild(popup);
}

