/* ID des Popups und des Close Buttons (muss mit CSS Datei uebereinstimmen) */
var popup_id="popupdiv";
var popup_close_id="popup_close_img";


function createPopUp(content,id) {
    
    
    /* altes Popup schliessen, wenn vorhanden */
    destroyPopUp();
    
    
    /* Fensterhoehe fuer Schatten */
    var schatten_hoehe=0;
    
    
    /* IE6 - Selectfelder verstecken und Fensterhoehe ermitteln */
    if(navigator.appVersion.indexOf("MSIE 6")>-1) {
        for(var i=0; i<parent.document.getElementsByTagName("select").length; i++) {
            parent.document.getElementsByTagName("select")[i].style.visibility="hidden";
        }
        
        if (window.parent.innerHeight) {
          schatten_hoehe=window.parent.innerHeight;
        } else if (parent.document.body && parent.document.body.offsetHeight) {
          schatten_hoehe=parent.document.body.offsetHeight;
        }
        
    }


    /* Fensterhoehe ermitteln, wenn noch nicht vorhanden */
    if(schatten_hoehe<=0) {
        schatten_hoehe="100%";
    } else {
        schatten_hoehe=schatten_hoehe+"px";
    }


    /* Scrollhoehe ermitteln */
    var scrollhoehe = 0;
    if( typeof( window.parent.pageYOffset ) == 'number' ) {
        /* Netscape */
        scrollhoehe = window.parent.pageYOffset;
    } else if( parent.document.body && parent.document.body.scrollTop ) {
        /* DOM */
        scrollhoehe = parent.document.body.scrollTop;
    } else if( parent.document.documentElement && parent.document.documentElement.scrollTop ) {
        /* IE6 */
        scrollhoehe = parent.document.documentElement.scrollTop;
    }


    /* Oberen Rand ermitteln */
    var rand_oben=scrollhoehe+100;


    /* Popup erstellen */
    var div = parent.document.createElement("div");
    div.innerHTML = "<div id=\""+popup_id+"\"><img id=\""+popup_close_id+"\" name=\""+popup_close_id+"\" src=\"/images/icons/popup_close.gif\" alt=\"close\" border=\"0\" onclick=\"destroyPopUp();\"/><div class=\"popup_schatten\" style=\"height:"+schatten_hoehe+";\" onclick=\"destroyPopUp();\"></div><div id=\""+id+"\" class=\"popup\" style=\"top:"+rand_oben+"px;\">"+content+"</div></div>";
    parent.document.body.appendChild(div.firstChild); 
    
    /* Popup Close Button */
    if(parent.document.getElementById(popup_close_id)!=null) {
        
        
        /* Breite vom Popup Fenster ermitteln */
        var weiter=true;
        var popup_breite=0;
        if(window.parent.getComputedStyle) {
            popup_breite=window.parent.getComputedStyle(parent.document.getElementById(id),"").getPropertyValue("width");
        } else if(parent.document.getElementById(id).currentStyle && popup_breite==0) {
            popup_breite=parent.document.getElementById(id).currentStyle.width;
        } else if(parent.document.ids && popup_breite==0) {
            popup_breite=parent.document.layers[id].width;
        } else if(parent.document.all && popup_breite==0) {
            popup_breite=parent.document.all.id.style.width;
        } else {
            weiter=false;
        }
        
        if(weiter==true && popup_breite!=null && popup_breite!="undefined") {
            
            /* px von Breite entfernen */
            popup_breite = parseFloat(popup_breite);
            
            if (!isNaN(popup_breite) && popup_breite>40) {
                               
                /* Position errechnen */
                var close_img_rand_links=(popup_breite/2)-22;
                close_img_rand_links = Math.round(close_img_rand_links);
                var close_img_rand_oben=rand_oben-4;
                
                /* Style zuweisen und einblenden */
                parent.document.getElementById(popup_close_id).style.left="50%";
                parent.document.getElementById(popup_close_id).style.marginLeft=close_img_rand_links+"px";
                parent.document.getElementById(popup_close_id).style.top=close_img_rand_oben+"px";
                parent.document.getElementById(popup_close_id).style.display='inline';
            }
        }
    }
}



function destroyPopUp() {
    
    /* IE6 - Selectfelder einblenden */
    if(navigator.appVersion.indexOf("MSIE 6")>-1) {
        for(var i=0; i<parent.document.getElementsByTagName("select").length; i++) {
            parent.document.getElementsByTagName("select")[i].style.visibility="visible";
        }
    }
    
    /* Popup schliessen, wenn vorhanden */
    if(parent.document.getElementById(popup_id)!=null) {
        parent.document.body.removeChild(parent.document.getElementById(popup_id));
    }
    
}
