﻿// (c) unternehmen online GmbH & Co. KG
// 02 / 2009
// author: Agis Wichert

function UO_HideContainer( containerID, useBlock ){
    var container = false;
    if( ( typeof containerID ).toLowerCase() == "object" ){
        container = containerID;
    }
    else if( ( typeof containerID ).toLowerCase() == "string" ){
        container = document.getElementById(containerID);
    }
    
    if( container ){
        container.style.visibility = "hidden";
        if( useBlock )
            container.style.display = "none";
    }
}

function UO_ShowContainer( containerID, useBlock ){
    var container = false;
    if( ( typeof containerID ).toLowerCase() == "object" ){
        container = containerID;
    }
    else if( ( typeof containerID ).toLowerCase() == "string" ){
        container = document.getElementById(containerID);
    }
    if( container ){
        container.style.visibility = "visible";
        if( useBlock )
            container.style.display = "block";
    }
}

function UO_ToggleVisibility( containerID, useBlock ){
    var container = false;
    if( ( typeof containerID ).toLowerCase() == "object" ){
        container = containerID;
    }
    else if( ( typeof containerID ).toLowerCase() == "string" ){
        container = document.getElementById(containerID);
    }
    if( container ){
        if( container.style.visibility == "hidden" ){
            UO_ShowContainer(container, useBlock);
        }
        else{
            UO_HideContainer(container, useBlock);
        }
    }
}

function UO_ToggleText( containerID, text1, text2 ){
     var container = false;
    if( ( typeof containerID ).toLowerCase() == "object" ){
        container = containerID;
    }
    else if( ( typeof containerID ).toLowerCase() == "string" ){
        container = document.getElementById(containerID);
    }
    if( container ){
        if( container.firstChild.nodeValue == text1 ){
            container.firstChild.nodeValue = text2;
        }
        else if( container.firstChild.nodeValue == text2 ){
            container.firstChild.nodeValue = text1;
        }
    }
}

function UO_SwapImage(containerID){
    var container = false;
    var dom = location.protocol + "//" + document.domain;
    
    if( ( typeof containerID ).toLowerCase() == "object" ){
        container = containerID;
    }
    else if( ( typeof containerID ).toLowerCase() == "string" ){
        container = document.getElementById(containerID);
    }
    if( container ){
        if( arguments.length > 2 ){
            for( var i = 1; i < arguments.length; i++ ){
                var arg = arguments[i] + '';
                if( arg.indexOf("http") == -1 && dom.indexOf("http") != -1 ){
                    arg = dom + arg;
                }
                if( container.src == arg ){
                    if( arguments.length > (i + 1 ) ){
                        container.src = arguments[i+1];
                        break;
                    }
                    else{
                        container.src = arguments[1];
                        break;
                    }
                }
            }
        }
        else if( arguments.length == 2 ){
            container.src = arguments[1];
        }
    }
}


function UO_ToggleCss(containerID) {
    var container = false;
    if ((typeof containerID).toLowerCase() == "object") {
        container = containerID;
    }
    else if ((typeof containerID).toLowerCase() == "string") {
        container = document.getElementById(containerID);
    }
    if (container) {
        if (arguments.length > 2) {
            for (var i = 1; i < arguments.length; i++) {
                var arg = arguments[i] + '';
                if (container.className == arg) {
                    if (arguments.length > (i + 1)) {
                        container.className = arguments[i + 1];
                        break;
                    }
                    else {
                        container.className = arguments[1];
                        break;
                    }
                }
            }
        }
        else if (arguments.length == 2) {
            container.className = arguments[1];
        }
    }
}
