// Prüft den Einzelplatz-Login auf Verfügbarkeit von Javascript und Cookies
function InitLogin() {
    document.getElementById("Info").style.visibility="hidden";
    document.getElementById("js").style.visibility="hidden";
    
    // sind Cookies erlaubt?
    var doc = window.document;
	setCookie(doc,"Banger!Cookies","true");
	var c = getCookie(doc,"Banger!Cookies");
			
	if (! c || c.length == 0) {
	    document.getElementById("Info").style.visibility="visible";
		document.getElementById("cookie").style.visibility="visible";
	} else {
        // weiterleiten
		var uid = "" + document.location;
    	var pos = uid.indexOf("?");
    	if (pos > 0) {
    	   uid = uid.substr(pos + 1);
    	   document.location.replace('../BangerService?request=ep-login&' + uid + '&stylesheet=none');
    	}
    }
}

function getCookie(doc,name)
{
    if (! doc)
	doc = document;

    var c = new Object();
    var i = 0;
    var clen = doc.cookie.length;
    while (i < clen)
    {
         var endstr = doc.cookie.indexOf (";", i);
         if (endstr == -1) endstr = doc.cookie.length;

         var v = unescape(doc.cookie.substring(i, endstr));
         var key = v.substring(0, v.indexOf("=", 0));
         var val = v.substring(v.indexOf("=") + 1);
         c[key] = val;
         i = endstr + 2; // Leerzeichen nach ; überspringen
    }
    if(name) return c[name];
    return c;
}

function setCookie(doc,name, value, days)
{
    if (! doc)
	doc = document;

    var cookieStr = name + "=" + escape(value);

    if (days != null) {
	var expire = new Date();
	expire.setTime(expire.getTime() + 86400000 * days);
	cookieStr += "; expires=" + expire.toGMTString();
    }
    doc.cookie = cookieStr+ ";";
}

// <----------- EP

function set_focus() {
        // Setzt den Focus auf die Benutzereingabe
        document.inputForm.name.focus();
}
function set_login_focus() {
        // Setzt den Focus auf die Benutzereingabe
        document.loginForm.username.focus();
}
function set_fb_filter_focus() {
    // Setzt den Focus auf die Benutzereingabe
    document.inputForm.FBFilter.focus();
}
function set_hrz_filter_focus() {
    // Setzt den Focus auf die Benutzereingabe
    document.inputForm.HRZFilter.focus();
}
function starte_suche() {
        // Startet die Seite mit dem Suchergebnis
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 500;
        var y = 50;
        var win = open("","Ergebnisliste",
                    "width=380,height=500,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");

        with (win.document) {
            write("<html><head></head><body></body></html>");
        }

	win.focus();
        return true;
}
function starte_volleintrag() {
        // Startet die Seite fuer Volleintraege
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 400;
        var y = 50;
        var win = open("","Volleintrag",
                    "width=500,height=600,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");

        with (win.document) {
            write("<html><head></head><body></body></html>");
        }

        win.focus();
        return true;
}
function starte_export() {
        // Startet die Seite fuer Volleintraege
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 300;
        var y = 50;
        var win = open("","Export",
                    "width=700,height=580,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=no");

        with (win.document) {
            write("<html><head></head><body></body></html>");
        }

        win.focus();
        return true;
}
function starte_fachbereiche() {
        // Startet die Seite fuer Fachbereiche
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 400;
        var y = 50;
        var win = open("","Fachbereiche",
                    "width=500,height=580,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");

        with (win.document) {
            write("<html><head></head><body></body></html>");
        }
        document.inputForm.fbr.checked = true;

        win.focus();
        return true;
}
function starte_hauptreisezonen() {
        // Startet die Seite fuer Hauptreisezonen
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 400;
        var y = 50;
        var win = open("","Hauptreisezonen",
                    "width=500,height=580,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");

        with (win.document) {
            write("<html><head></head><body></body></html>");
        }
        document.inputForm.hrz.checked = true;

        win.focus();
        return true;
}
function oeffne_hilfe() {
        // Öffnet die Hilfeseiten und das Hotline-Formular
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 200;
        var y = 50;
        var win = open("","Hilfe",
                    "width=475,height=470,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");

        with (win.document) {
            write("<html><head></head><body></body></html>");
        }

        win.focus();
        return true;
}
function oeffne_konto() {
        // Öffnet das Konto-Fenster
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 200;
        var y = 50;
        var win = open("","Konto",
                    "width=640,height=480,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");

        with (win.document) {
            write("<html><head></head><body></body></html>");
        }

        win.focus();
        return true;
}
function oeffne_bestaetigung() {
        // Öffnet die Korrektur-Formulare
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 -600;
        var y = 50;
        var win = open("","Bestaetigung",
                    "width=600,height=580,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");

        with (win.document) {
            write("<html><head></head><body></body></html>");
        }

        win.focus();
        return true;
}
function oeffne_korrektur() {
        // Öffnet die Korrektur-Formulare
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 -400;
        var y = 50;
        var win = open("","Korrektur",
                    "width=600,height=580,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");

        with (win.document) {
            write("<html><head></head><body></body></html>");
        }

        win.focus();
        return true;
}
function check_avt() {
    // Falls die Checkbox "Angestellte Vertretungen" aktiviert wurde,
    // wird die Checkbox "Selstständige Vertretungen" deaktiviert.
    if (document.inputForm.avt.checked == true)
        document.inputForm.svt.checked = false;
}
function check_svt() {
    // Falls die Checkbox "Selststãndige Vertretungen" aktiviert wurde,
    // wird die Checkbox "Angestellte Vertretungen" deaktiviert.
    if (document.inputForm.svt.checked == true)
        document.inputForm.avt.checked = false;
}
function check_vlfa() {
    // Falls die Checkbox "mit Fremdauslieferungen" aktiviert wurde,
    // wird die Checkbox "ohne Fremdauslieferungen" deaktiviert.
    if (document.inputForm.vlfa.checked == true)
        document.inputForm.vlofa.checked = false;
}
function check_vlofa() {
    // Falls die Checkbox "ohne Fremdauslieferungen" aktiviert wurde,
    // wird die Checkbox "mit Fremdauslieferungen" deaktiviert.
    if (document.inputForm.vlofa.checked == true)
        document.inputForm.vlfa.checked = false;
}
function check_vlmv() {
    // Falls die Checkbox "mit Vertretungen" aktiviert wurde,
    // wird die Checkbox "ohne Vertretungen" deaktiviert.
    if (document.inputForm.vlmv.checked == true)
        document.inputForm.vlov.checked = false;
}
function check_vlov() {
    // Falls die Checkbox "ohne Vertretungen" aktiviert wurde,
    // wird die Checkbox "mit Vertretungen" deaktiviert.
    if (document.inputForm.vlov.checked == true)
        document.inputForm.vlmv.checked = false;
}
function check_us() {
    // Falls ein Umsatz angewählt wurde, so wird
    // auch der untergeordnete Schalter aktiviert

    if (document.inputForm.us1.checked == true ||
        document.inputForm.us2.checked == true ||
        document.inputForm.us3.checked == true ||
        document.inputForm.us4.checked == true)
            document.inputForm.vlmu.checked = true

    if (document.inputForm.us1.checked == false &&
        document.inputForm.us2.checked == false &&
        document.inputForm.us3.checked == false &&
        document.inputForm.us4.checked == false)
            document.inputForm.vlmu.checked = false
}
function highlight_row(cell) {
	// Aufhellen der aktuellen Zeile

        var row = cell.parentNode;
	if (row == null)
		return;
	for (var z=0; z < row.childNodes.length; z++){
		var a_cell = row.childNodes[z];
		if (a_cell != null && a_cell.style != null)
			a_cell.style.backgroundColor='#C5C5C5';
	}
}
function clear_row(cell) {
    // Aufhellen der aktuellen Zeile

        var row = cell.parentNode;
	if (row == null)
		return;
	for (var z=0; z < row.childNodes.length; z++){
		var a_cell = row.childNodes[z];
		if (a_cell != null && a_cell.style != null)
			a_cell.style.background='none';
	}
}
function enable_subitems() {
	// Aktivieren/Deaktivieren der Radiobuttons für den Volleintragsexport
	for (var i = 0; i <= 3; i++) {
		document.inputForm.listoptionen[i].disabled = !(document.inputForm.liste.checked);
 	}
}

