// ------------------------------------------------------------------------------------------------
// Diverse Funktionen fuer Staheli Metzg Frauenfeld
// Autor : www.simplified.ch
// ------------------------------------------------------------------------------------------------


// Berechne Total des Warenkorbes
    function rechneTotal(cForm) {
        var Total = 0;
        for (i = 0; i < cForm.length; i++) {
            var tempobj = cForm.elements[i];
            if (tempobj.type == "text" && tempobj.value != '') {
                var objName = tempobj.id + '_preis'
                Total += tempobj.value * cForm[objName].value;
            }
        }
        document.getElementById('TotalPreis').innerHTML = runden(Total) + ' Fr.'
        }

// Runden auf CH 5 Rappen
    function runden(x) {
        // CH Version auf 5 Rappen genau runden
        var ch = (Math.round(x * 20))/20;
        var k = (Math.round(ch * 100) / 100).toString();
        k += (k.indexOf('.') == -1) ? '.00' : '00';
        return k.substring(0, k.indexOf('.') + 3);
    }

// Toggle Tagesmenus
    function showDayMenu(dayID) {
        document.getElementById('DI').style.backgroundColor = '#C5C5C5';
        document.getElementById('MI').style.backgroundColor = '#C5C5C5';
        document.getElementById('DO').style.backgroundColor = '#C5C5C5';
        document.getElementById('FR').style.backgroundColor = '#C5C5C5';
        document.getElementById(dayID).style.backgroundColor = '#f0f0f0';
        document.getElementById('_DI').style.zIndex = 0;
        document.getElementById('_MI').style.zIndex = 0;
        document.getElementById('_DO').style.zIndex = 0;
        document.getElementById('_FR').style.zIndex = 0;
        document.getElementById('_' + dayID).style.zIndex = 99;
        }

// ------------------------------------------------------------------------------------------------
// PopUp Editor Fenster
// ------------------------------------------------------------------------------------------------
    function PopUpWindow(thePage, theID, theName) {
        pop_config = ""
        pop_config += "toolbar=yes,";
        pop_config += "location=no,"
        pop_config += "directories=no,";
        pop_config += "status=yes,"
        pop_config += "menubar=no,"
        pop_config += "scrollbars=yes,"
        pop_config += "resizable=yes,"
        pop_config += "copyhistory=no,"
        var wHeight = 960;
        if (screen.height < 960) {
            wHeight = screen.height - 100;
        }
        pop_config += "left=" + (screen.width - 700) / 2 + ","
        pop_config += "top=" + (screen.height - wHeight) / 2 + ","
        pop_config += "width=700,"
        pop_config += "height=" + wHeight + ","
        var ret = window.open(thePage + theID, theName, "" + pop_config + "");
        ret.focus();
    }

