ct = 0;
function chct(x){
    ct = x;
}
try{
    window.addEventListener('DOMContentLoaded', initShadow, false);
}
catch(Err){
    window.attachEvent('onload',initShadow);
}
function initShadow(){
    oBody = document.getElementsByTagName("body").item(0);
 
    oShadow = document.createElement("div");
    oShadow.setAttribute('id','cockpit_shadow');
    
    try{//Microsoft IFrame Erstellen mit Name-Attribute
        oFrame = document.createElement("<iframe name='cockpit_editframe'>");
    }
    catch(Err){//Alle Anderen IFrame Erstellen
        oFrame = document.createElement("iframe");
        oFrame.setAttribute('name', 'cockpit_editframe');
    }
    oFrame.setAttribute('id','cockpit_editframe');

}       
function showx(link){
    if(document.documentElement.scrollHeight > document.documentElement.clientHeight){
        var hoehe = document.documentElement.scrollHeight+25+"px";
        var framehoehe = document.documentElement.scrollHeight-15+"px";
    }
    else{
        var hoehe = document.documentElement.clientHeight+"px";
        var framehoehe = document.documentElement.clientHeight-40+"px";
    }
    oShadow.style.height = hoehe;
    oFrame.style.height = framehoehe;
    oFrame.setAttribute('src',link);
    oBody.appendChild(oShadow);
    oBody.appendChild(oFrame);
    return true;
}

function close(){
    try{
        oFrame.attachEvent('onload', zwclose);
    }
    catch(Err){
        oFrame.onload = function (){ zwclose(); };
    }
}
function zwclose(){
    try{
        oFrame.detachEvent('onload', zwclose);
    }
    catch(Err){
        oFrame.onload = dummy;
    }
    closeShadow(0);
}
function closeReload(){
    try{
        oFrame.attachEvent('onload', function (){ zwcloserel(); });
    }
    catch(Err){
        oFrame.onload = function (){ zwcloserel(); };
    }
}
function zwcloserel(){
    try{
        oFrame.detachEvent('onload', zwcloserel);
    }
    catch(Err){
        oFrame.onload = dummy;
    }
    if(ct != -1){
        chct(0);
        closeShadow(1);
    }
    else{
        chct(0);
    }
}
function closeShadow(x){
    try{
        oBody.removeChild(oShadow);
        oFrame.setAttribute('src', '');
        oBody.removeChild(oFrame);
        if(x>0){
            window.setTimeout('location.reload()', 1000);
        }
    }
    catch(Err){
        return false;
    }
}
function dummy(){
    return true;
}
function changeBG(name, bild){
    var ChangeElem = document.getElementsByName(name).item(0);
    ChangeElem.style.backgroundImage = "url("+bild+")";
}
function changeBGID(id, bild){
    var ChangeElem = document.getElementById(id);
    ChangeElem.style.backgroundImage = "url("+bild+")";
}
function durchsuchen(id){
    quelle = document.getElementById(id);
    ziel = document.getElementById(id+"_input");
    ziel.value = quelle.value;
}
