// 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
        if (document.inputForm.name != null)
            document.inputForm.name.focus();
}
function set_zeit_focus() {
        // Setzt den Focus auf die Benutzereingabe
        if (document.inputForm.titel != null)
            document.inputForm.titel.focus();
}
function set_login_focus() {
        // Setzt den Focus auf die Benutzereingabe
        if (document.loginForm.username != null)
            document.loginForm.username.focus();
}
function set_sg_filter_focus() {
    // Setzt den Focus auf die Benutzereingabe
    if (document.inputForm.SGFilter != null)
        document.inputForm.SGFilter.focus();
}
function set_hrz_filter_focus() {
    // Setzt den Focus auf die Benutzereingabe
    if (document.inputForm.HRZFilter != null)
        document.inputForm.HRZFilter.focus();
}
function starte_themenwelten()
{
  var win = open("", "Themenwelt");
  win.focus();
  return true;
}
function starte_suche() {
        // Startet die Seite mit dem Suchergebnis
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 400;
        var y = 50;
        var win = open("","Ergebnisliste",
                    "width=450,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 oeffne_bestaetigung() {
        // Öffnet die Bestaetigungs-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 starte_volleintrag() {
        // Startet die Seite fuer Volleintraege
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 300;
        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_sachgebietsuche() {
        // Startet die Seite fuer Volleintraege
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 200;
        var y = 50;
        var win = open("","Sachgebietsuche",
                    "width=700,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>");
        }
        win.focus();
        return true;
}
function starte_export() {
        // Startet die Seite fuer Volleintraege
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 200;
        var y = 50;
        var win = open("","Export",
                    "width=700,height=680,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_pdf() {
        // Startet die Seite fuer Volleintraege
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 200;
        var y = 50;
        var win = window.open("","pdf",
                    "width=700,height=580,directories=no,location=no," +
                    "left=" + x + ",top=" + y + "," +
                    "screenX=" + x + ",screenY=" + y + "," +
                    "menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no");

        try {
            with (win.document) {
                write("<html><head></head><body></body></html>");
            }
            win.focus();
        } catch (err) {}

        return true;
}
function starte_bildansicht() {
        // Startet die Seite fuer Volleintraege
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 200;
        var y = 50;
        var win = open("","Bildansicht",
                    "width=450,height=610,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_sachgebiete() {
        // Startet die Seite fuer Fachbereiche
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 400;
        var y = 50;
        var win = open("","Sachgebiete",
                    "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.sgb.checked = true;

        win.focus();
        return true;
}
function starte_verwaltung() {
        // Startet die Seite fuer Themenweltzuordnungen
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 400;
        var y = 50;
        var win = open("","Verwaltung",
                    "width=400,height=400,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_import() {
        // Startet die Seite fuer Mediadatenimporte
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 400;
        var y = 50;
        var win = open("","Import",
                    "width=400,height=400,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>');
            write('<table width="100%" height="100%" border="0">');
            write('<tr><td><div align="center"><span class="text2Bold">');
            write('Der Import von Mediadaten wurde gestartet. Bitte haben Sie einige Minuten Geduld...<br><br>');
            write('<img src="../images/working.gif" width="112" height="16"> </span></div>');
            write('</td></tr></table></body></html>');
        }

        win.focus();
        return true;
}
function starte_verzeichnisauswahl(sid) {
        // Startet die Seite fuer die Verzeichnisauswahl
        var w = screen.availWidth;
        var h = screen.availHeight;
        var x = w/2 - 400;
        var y = 50;
        var win = open("","directories",
                    "width=480,height=480,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();

        var dir = document.getElementById("directory").value;
        win.document.location.href="dir_selection.jsp?sid=" + sid + "&directory=" + dir;
        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_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=1200,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ã­¤ige Vertretungen" deaktiviert.
    if (document.inputForm.avt.checked == true)
        document.inputForm.svt.checked = false;
}
function check_svt() {
    // Falls die Checkbox "Selststã­¤ige 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ã§¬t wurde, so wird
    // auch der ï¿½ordnete 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='#e9e9e9';
	}
}
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 loeschen_bestaetigen() {
    // Rückfrage, ob etwas gelöscht werden soll
    var erg = confirm("Wollen Sie die Datei wirklich löschen?");
    return erg;
}

function ScrollToAnchor(doc, ancName)
{
    // srollt zu dem Anchor ancName
    if (ancName == '0') {
        doc.scrollTo(0.0);
        return;    
    }
    
    var anc = doc.document.getElementsByName(ancName);
    if (anc != null) {
        doc.scrollTo(anc[0].offsetLeft, anc[0].offsetTop - 5);
    } else {
        doc.scrollTo(0, 0);
    }
}

function load_list_of_titles(doc, url)
{
    doc.location = url.replace('navigation.xsl','titelliste.xsl');
}

