function MakeSelectionText(theForm, selectName, text) {

    for (i=0; i<theForm.elements.length; i++) {
        theElement = theForm.elements[i];
        if (theElement.name==selectName) {
            for (j=0; j<theElement.length; j++) {
                theOption = theElement.options[j];
                if (theOption.text == value && !done ) {
                    theElement.selectedIndex = j;
                    done = true;
                }    
            }
        }
    }
}

function MakeSelectionVal(theForm, selectName, value) {
    var done = false
    for (i=0; i<theForm.elements.length; i++) {
        theElement = theForm.elements[i];
        if (theElement.name==selectName) {
            for (j=0; j<theElement.length; j++) {
                theOption = theElement.options[j];
                if (theOption.value == value && !done ) {
                    theElement.selectedIndex = j;
                    done = true;
                }
            }
        }
    }
}

function showMsgBox ( target, msgBox ) {     
    var thePosition = document.getElementById(target);
    var theMsgBox = document.getElementById(msgBox);
    thePosition.appendChild(theMsgBox);
    theMsgBox.style.display='block';
    window.scrollTo (thePosition.offsetLeft, thePosition.offsetTop);
}

function showStdMsgBox ( target, msgBox ) {     
    //var thePosition = document.getElementById(target);
    var theMsgBox = document.getElementById(msgBox);
    //thePosition.appendChild(theMsgBox);
    theMsgBox.style.display='block';
    //window.scrollTo (thePosition.offsetLeft, thePosition.offsetTop);
}

function initMenu( invalidate ) {

    var cookieString=document.cookie;
    var cookieName = "SESSION_ID=";
    var loggedon = false;
    
    if( !invalidate ) {
        if( cookieString.length >= 0 ){
            var i = cookieString.indexOf(cookieName);
            if( i != -1 ){
                i += cookieName.length;
                var j = cookieString.indexOf( "," , i );
                if( j == -1 ) { j = cookieString.length; }    
                cookieValue = unescape( cookieString.substring( i, j ));
                if( cookieValue != "-1" && cookieValue != "" ){
                    loggedon = true;
                }
            }    
        }
    }    

    var theHeadlineContent = document.getElementById("headline-content");

    if( loggedon ) {
        document.getElementById("menu-bottom-loggedoff").style.display = "none";
        document.getElementById("menu-bottom-loggedon").style.display = "block";
        if( theHeadlineContent ) theHeadlineContent.innerHTML = "Sie sind eingeloggt";
    } else {
        document.getElementById("menu-bottom-loggedon").style.display = "none";
        document.getElementById("menu-bottom-loggedoff").style.display = "block";
        if( theHeadlineContent ) theHeadlineContent.innerHTML = "";
    }
}

function hideSearchBox() {
    var theSearchbox = document.getElementById('searchBox');
    if( theSearchbox ) theSearchbox.style.visibility ='hidden';
}

function showSearchBox() {
    var theSearchbox = document.getElementById('searchBox');
    if( theSearchbox ) theSearchbox.style.visibility ='visible';
}

function openPage ( url, returnURL ) {
    var newURL = url;
    if( returnURL ) newURL += "&url=" + escape(document.location.href);
    document.location.href = newURL;
}

function openTCPage ( url, returnURL ) {
    var newURL = url;
    //if( returnURL ) newURL += "&url=" + escape(document.location.href);
    //document.location.href = newURL;
	window.open(newURL,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,menubar=no,width=620,height=1500');
}
