// JavaScript Document
var posy = new Array (0,0,0,0,0,0,0,0,0);

var lg = "dt";

var inh_kurz = new Array('t',    'c',     'd',          'p',       'a',      'm',          'y',   'l',   'i');
var inh_dt   = new Array('text','kunden','auftraggeber','projekte','bereiche','personen','jahr','links','bilder');
var title_dt = new Array('text','kunde','auftraggeber','projekt','bereich','person','jahr','links','bilder');
var inh_en   = new Array('text','customers','orderd','projects','areas','persons','years','links','images');
var title_en = new Array('text','customers','orderd','projects','areas','persons','years','links','images');

var backList = new Array();

var wahl;
var wahl_id;

var calNr;

var play;

function addSplit(old,addText,resultType) {
    if (old == null) old = "";
    if (typeof(old) == "object") {
        oldList = old;
    } else {
        if (old == "") {
            oldList = new Array();
            // alert("new Array "+oldList.length);
        } else {
            oldList = old.split(",");
        }
    }

    addList = addText.split(",");
    for (a=0;a<addList.length;a++) {
        addValue = addList[a];
       // alert("addText "+addText+" a= "+a+" addValue= "+addValue);
        if (addValue.length > 0) {
            found = 0;

            // check if is in oldList
            for (i=0;i<oldList.length;i++) {
                cont = oldList[i];
                if (cont == addValue) found = 1;
            }
            if (found == 0) {
                // not in List
               // alert("Add To List"+addValue);
                oldList.push(addValue);
            }
        }
    }

    if (resultType == null) resultType = "text";

    if (resultType == "list") {
        return oldList;
    }

    if (resultType == "text") {
        add = "";
       // alert ("addSplit("+addText+" / "+oldList);

        for (i=0;i<oldList.length;i++) {
            cont = oldList[i];
            if (add != "") add = add + ",";
            add = add + cont;
        }

        return add;

    }
}


function get_project() {
    if (lg == "en") proLi = proj_en;
    if (lg == "dt") proLi = proj_dt;
    return proLi;
}

function get_person() {
    if (lg == "en") perLi = pers_en;
    if (lg == "dt") perLi = pers_dt;
    return perLi;
}

function get_personTitle(pNr) {
    p_List = get_person();
    if (pNr < 0) return "wrong pNr";
    if (pNr > p_List.length) return "wrong pNr";
    return p_List[pNr][0];
}


function get_area() {
    if (lg == "en") arLi = area_en;
    if (lg == "dt") arLi = area_dt;
    return arLi;
}

function get_customer() {
    if (lg == "en") cuLi = cust_en;
    if (lg == "dt") cuLi = cust_dt;
    return cuLi;
}

function get_custTitle(cNr) {
    c_List = get_customer();
    if (cNr < 0) return "wrong CNr";
    if (cNr > c_List.length) return "wrong CNr";
    return c_List[cNr][0];
}

function get_dealer() {
    if (lg == "en") li = dealer_en;
    if (lg == "dt") li = dealer_dt;
    return li;
}

function get_dealerTitle(dNr) {
    d_List = get_dealer();
    if (dNr < 0) return "wrong dNr";
    if (dNr > d_List.length) return "wrong dNr";
    return d_List[dNr][0];
}

function get_Years() {
    pList = proj_dt;
    findId = get_FieldId("y");
    //add = "";
    yearList = new Array();
    for (p=0;p<pList.length;p++) {
        t = pList[p][findId];
        //add = add + t + "<br>";

        //alert(pList[p][0] + " ---------" + t );
        if (t != null) {
            if (t != "") {
            // add = add + t;
                    yearList = addSplit(yearList,t,"list");
            }
        }

    }

    //alert ("yearList " + yearList );
    yearList.sort();
    //alert ("yearList after sort" + yearList );
    return yearList;
}

function NrCode(nr) {
    //var inh_kurz = new Array('t','k','a','p','b','m','j','l');
    erg = null;
    if (nr == 0) erg = 't';
    if (nr == 1) erg = 'c';
    if (nr == 4) erg = 'a';
    if (nr == 3) erg = 'p';
    if (nr == 2) erg = 'd';
    if (nr == 5) erg = 'm';
    if (nr == 6) erg = 'y';
    if (nr == 7) erg = 'l';
    if (nr == 8) erg = 'd';
    return erg;
}

function CodeNr(code) {
    //var inh_kurz = new Array('t','k','a','p','b','m','j','l');
    erg = null;
    if (code == 't') erg = 0;
    if (code == 'c') erg = 1;
    if (code == 'a') erg = 4;
    if (code == 'p') erg = 3;
    if (code == 'd') erg = 2;
    if (code == 'm') erg = 5;
    if (code == 'y') erg = 6;
    if (code == 'l') erg = 7;
    //if (code == 'd') erg = 8;
    return erg;
}

function tab_start(rl) {
    return "";
	if (rl == "l") return "<table width=100% border='0'><tr><td align='left' valign='top'>";
	else return "<table width=100% border='0'><tr><td align='right' valign='top'>";
}

function tab_ende() {
    return "";
	return "</td></tr></table>";
}

function help_show(t) {
	setlayer('help',t,null,null,t);
}


////////////////////////////////////////////////////////////////
// RETURN the Title of the Left Side                          //
function getTitle(showMain) {
    res = "Unkown ";
    code = CodeNr(wahl);
    mainText = "häh "+wahl;
    if (lg == "dt") {
        mainText  = title_dt[code]; // Einzahl
        titelText = inh_dt[code]; // Mehrzahl
    }
    if (lg == "en") mainText = inh_en[code];


    if (wahl_id == null) {
        res = "<span class='headLine'>" + titelText + "</span>";
    } else {
        li = new Array();
        if (wahl == 'c') li = get_customer();
        if (wahl == 'd') li = get_dealer()
        if (wahl == 'm') li = get_person();
        if (wahl == "p") li = get_project();
        if (wahl == 'a') li = get_area();

        if (wahl == "y") sT = wahl_id;
        else sT = li[wahl_id][0];

        res = "";
        if (showMain == 1) {
            nu = null;
            if (useHtml == 1) res = "<a href='index.php?wahl="+wahl+"&nr=null' class='menu_link'>"+mainText+"</a>";// | ";
            else res = "<a href='#' onclick=javascript:goPage('" +wahl+ "',"+nu+"); class='menu_link'>"+mainText+"</a>";// | ";
        }
        // Add Aktuelle Auswahl
        //res = res + "<br>";
        res = res + " | ";
        res = res + "<span class='headLine'>"+ sT + "</span>";
    }

    if ( backList.length > 1 ) res = "<a href='#' onclick=javascript:back_goBack(); alt='zurück' class='menu_link'><</a> " + res;
    //res = res + backList.length;
    return res;
}
////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////
// RETURN the List of subRollover of the Left Side            //
function getList() {
    if (wahl_id == null) {
        shortList = 0;
        sortList  = 1;
        li = null;
        if (wahl == 'm') { li = get_person(); sortList = 0;}
        if (wahl == 'p') li = get_project(); 

        if (wahl == 'a') li = get_area();
        if (wahl == 'y') { li = get_Years(); shortList = 1; }
        if (wahl == 'c') li = get_customer();
        if (wahl == 'd') li = get_dealer();
       
        resList = "";
        if (li == null) {
                resList = "unkown in getList - " + wahl;
                return resList;
        }

        if (shortList == 1) {
           // alert("yearList"+li);
            for (i=0;i<li.length;i++) {
                if (useHtml == 1) resList = resList + "<a href='index.php?wahl="+wahl+"&nr="+li[i]+"' class='inhalt_link'>"+li[i]+"</a>";
                else resList = resList + "<a href='#' onclick=javascript:goPage('" +wahl+ "',"+li[i]+"); class='inhalt_link'>"+li[i]+"</a>";
                if (i==0)  resList = resList + "<span class='headline'>&nbsp;</span><br>"; //macht Zeilehöhe Korrekt
                if (i!=0) resList = resList + "<br>";
            }
        } else {
            if (sortList == 0) {
                for (i=0;i<li.length;i++) {
                    name = li[i][0];
                    id = i;
                    if (useHtml == 1) resList = resList + "<a href='index.php?wahl="+wahl+"&nr="+id+"' class='inhalt_link'>"+name+"</a>";
                    else resList = resList + "<a href='#' onclick=javascript:goPage('" +wahl+ "',"+id+"); class='inhalt_link'>"+name+"</a>";
                    if (i==0) resList = resList + "<span class='headline'>&nbsp;</span><br>"; //macht Zeilehöhe Korrekt
                    if (i!=0) resList = resList + "<br>";
                }
            } else {
                sortList = new Array();
                for (i=0;i<li.length;i++) {
                    name = li[i][0];
                    id = i;
                    sortList.push(new Array(name.toUpperCase(),name,id));

                   // resList = resList + "<a href='#' onclick=javascript:goPage('" +wahl+ "',"+i+"); class='inhalt_link'>"+li[i][0]+"</a>&nbsp;<br>";
                }
                sortList.sort();

                for (s=0;s<sortList.length;s++) {
                    name = sortList[s][1];
                    id = sortList[s][2];
                    if (useHtml == 1) resList = resList + "<a href='index.php?wahl="+wahl+"&nr="+id+"' class='inhalt_link'>"+name+"</a>";
                    else resList = resList + "<a href='#' onclick=javascript:goPage('" +wahl+ "',"+id+"); class='inhalt_link'>"+name+"</a>";
                    if (s==0) resList = resList + "<span class='headline'>&nbsp;</span><br>"; //macht Zeilehöhe Korrekt
                    if (s!=0) resList = resList + "<br>";
            
                }
            }
        }
    } else {
        
        resList = "Show SubMenu for " + wahl;
        // 0 'text'
        // 1 'kunden'
        // 2 'auftraggeber'
        // 3 'projekte'
        // 4 'bereich'
        // 5 'mitarbeiter'
        // 6 'jahr'
        // 7 'links'

        //help_show("WAHL = "+wahl);
        showli = new Array();
        if (wahl == 't') showli = new Array();
        if (wahl == 'c') showli = new Array(0,3,4,5,6,7);
        if (wahl == 'd') showli = new Array(3,4,5,6,7);
        if (wahl == 'a') showli = new Array(0,3,1,2,5,6); // AREA
        if (wahl == 'p') showli = new Array(0,1,8,2,4,5,6,7);
        if (wahl == 'b') showli = new Array(0,3,5);
        if (wahl == 'm') showli = new Array(0,1,3,4,6,7);
        if (wahl == 'y') showli = new Array(1,3,4,5);
        if (wahl == 'l') showli = new Array();


        if (lg == "dt") text = inh_dt;
        if (lg == "en") text = inh_en;
        if (lg == "dt") titleLi = title_dt;
        if (lg == "en") titleLi = title_en;
        resList = "";
        lineNr = 0;


        for (il=0;il<showli.length;il++) {
            nr = showli[il];
            kurz = inh_kurz[nr];
            trans = text[nr];
            titleName = titleLi[nr];
            //// onMouseOut='javascript:hideRoll();' // javascript:showRoll(m,"+i+");

            // alert("getInhalt "+kurz );
            rollText = getInhalt(kurz);
            // alert("getInhalt "+kurz + "\n rollText="+rollText);
            if (rollText.length > 0 ) {
                anz = rollText.split(",").length - 1;
                if (anz == 1 ) use = titleName;
                else use = trans;


                resList = resList + "<a href='#' onMouseOver=javascript:showRoll('"+kurz+"',"+lineNr+");  class='menu_link'>"+use+"</a><br>";
                lineNr++;
            }
        }
        //alert("Hier");
        //	alert(res);
        //res = "not Null " + wahl_id + " / " + wahl;

    }
    return resList
}
////////////////////////////////////////////////////////////////

function showTopic() {
    // 0 = t , 1 = k , 2 = a , 3 = p , 4 = b , 5 = m , 6 = j , 7 = l
    showMain = 1;
    title = getTitle(showMain);
    // alert ("ShowTopic <br> title="+title);
    list = getList();
    // alert ("ShowTopic <br> list="+list);
    t = title + "<br>";

    if (wahl_id == null) {
        t =  title + "<br>";
        setlayer('topic',t,null,null,1);

        t = list ;
        setlayer('inhalt',t,null,null,1);
    } else {
        t = title + "<br>";
        t = t + list ;
        setlayer('topic',t,null,null,1);
    }

    //inh = "inhalt";
    //inh = tab_start('l') + inh + tab_ende();
    //setlayer('inhalt',"123",null,null,1);
	
}

function get_FieldId(typ) {
	//if (typ == "") return 0 -
    if (typ == "n") return 0; // - title
    if (typ == "h") return 1; // - headLine - h
    if (typ == "t") return 2; // - text - t
    if (typ == "a") return 3; // - area -
    if (typ == "m") return 4; // - person
    if (typ == "d") return 5; // - dealer
    if (typ == "y") return 6; // - year
    if (typ == "c") return 7; // - customer
    if (typ == "w") return 8; // - link
    if (typ == "l") return 9; // linktext
    if (typ == "p") return 10; // - project
    if (typ == "i") return 11; // - project
    alert("unkown typ in  get_FieldId (" + typ);
}

function get_projectList(inh,makeLink) {
    if (inh.length == 0) return "no project";
    sli = get_project();
    prList = inh.split(",");
    res = "";
    getId = get_FieldId("n")
    //alert("Get ProjeczÖost");
    sortList = new Array();

    for (p=0;p<prList.length;p++) {       
        projId = parseInt( prList[p],0)-1;
        projName = sli[projId][getId];
        sortList.push(new Array(projName.toUpperCase(),projName,projId));       
    }

    sortList.sort();
    // res = "trulla<br>";
    for (s=0;s<sortList.length;s++) {
        if (s >= 1) res = res + "<br>";
        projId = sortList[s][2];
        projName = sortList[s][1];
        if (makeLink == 1) {
            if (useHtml == 1)  res = res + "<a href='index.php?wahl=p&nr="+projId+"&play=0' class='inhalt_link'>";
            else res = res + "<a href='#' onClick=javascript:goPage('p',"+projId+");  class='inhalt_link'>";
        }
        res = res + projName;
        if (makeLink == 1) res = res + "</a>";
    }
    return res;
}

function get_personList(inh,makeLink) {
    if (inh.length == 0) return "no persons";
    if (typeof(inh) != "string") return "no personString";
    sli = get_person();
    prList = inh.split(",");
    res = "";
    getId = get_FieldId("n")
    sortList = new Array();
    for (p=0;p<prList.length;p++) {
        if (p >= 1) res = res + "<br>";
        persId = parseInt( prList[p],0) - 1;
        if (persId > sli.length) return "error in personlist";
        persName = sli[persId][getId];
        sortList.push(new Array(persName.toUpperCase(),persName,persId));
    }

    sortList.sort();
    res = "";//get_personList<br>";
    for (s=0;s<sortList.length;s++) {
        if (s >= 1) res = res + "<br>";
        persId = sortList[s][2];
        persName = sortList[s][1];
        if (makeLink == 1) {
            if (useHtml == 1)  res = res + "<a href='index.php?wahl=m&nr="+persId+"&play=0' class='inhalt_link'>";
            else res = res + "<a href='#' onClick=javascript:goPage('m',"+persId+");  class='inhalt_link'>";
        }
        res = res + persName;
        if (makeLink == 1) res = res + "</a>";
    }
    return res;
}
function get_areaTitle(nr) {
	liAr = get_area();
	if (nr > liAr.length) return "wrong nr";
	if (nr < 0) return "wrong nr";
	
	area = liAr[nr][0];
	return area;
}
	
function get_areaList(inh,makeLink) {
    if (typeof(inh) == "number") inh = "" + inh;
    if (typeof(inh) != "string") return "no areaString is " + typeof(inh) + " - " + inh + "<br>";
    sli = get_area();
    if (inh.length == 0) return "no area";
    arList = inh.split(",");
    // if (inh.length == 0) return "fehler no inhalt";
    resGet = "";
    getId = get_FieldId("n")
    for (p=0;p<arList.length;p++) {
            if (p >= 1) resGet = resGet + "<br>";
            areaId = parseInt( arList[p],0) - 1;
            //if (areaId < 0) alert( "error in arealist " + areaId + " / " + li.length);
            // if (areaId > li.length) alert( "error in arealist " + areaId + " / " + li.length);
            areaName = sli[areaId][getId];
            if (makeLink == 1) {
                if (useHtml == 1) resGet = resGet + "<a href='index.php?wahl=a&nr="+areaId+"&play=0' class='inhalt_link'>";
                else resGet = resGet + "<a href='#' onClick=javascript:goPage('a',"+areaId+");  class='inhalt_link'>";
            }
            resGet = resGet + areaName;//+ "a / " + areaId;
            if (makeLink == 1) resGet = resGet + "</a>";
    }
    return resGet;
}


function get_customerList(inh,makeLink) {
    if (typeof(inh) == "number") inh = "" + inh;
    if (typeof(inh) != "string") return "no customerString is " + typeof(inh) + " - " + inh + "<br>";
    if (inh.length == 0) return "";
    liCust = get_customer();

    cuList = inh.split(",");
    res = "";
    getId = get_FieldId("n")
    sortList = new Array();
    //alert(cuList);
    for (p=0;p<cuList.length;p++) {
        if (p >= 1) res = res + "<br>";
        custId = parseInt( cuList[p],0) - 1;
        if ((custId >= 0) && (custId <  liCust.length)) {
            //alert(custId);
            custName = liCust[custId][getId];
            sortList.push(new Array(custName.toUpperCase(),custName,custId));
        } else {
            // alert ("Wrong custId "+inh+" , custId "+custId);
        }
    }

   sortList.sort();
    res = "";//get_customerList<br>";
    for (s=0;s<sortList.length;s++) {
        if (s >= 1) res = res + "<br>";
        custId = sortList[s][2];
        custName = sortList[s][1];
        if (makeLink == 1) {
            if (useHtml == 1)  res = res + "<a href='index.php?wahl=c&nr="+custId+"&play=0' class='inhalt_link'>";
            else res = res + "<a href='#' onClick=javascript:goPage('c',"+custId+");  class='inhalt_link'>";
        }
        res = res + custName;
        if (makeLink == 1) res = res + "</a>";
    }
    return res;
}

function get_DealerList(inh,makeLink) {
    if (typeof(inh) == "number") inh = "" + inh;
    if (typeof(inh) != "string") return "no dealerstring is " + typeof(inh) + " - " + inh + "<br>";
    if (inh.length == 0) return "no dealer";
    sli = get_dealer();

    dealList = inh.split(",");
    res = "";
    getId = get_FieldId("n");
    sortList = new Array();
    for (p=0;p<dealList.length;p++) {
        if (p >= 1) res = res + "<br>";
        dealId = parseInt( dealList[p],0) - 1;
        if (dealId >= 0) {
            dealName = sli[dealId][getId];
            sortList.push(new Array(dealName.toUpperCase(),dealName,dealId));
        } else {
           // alert("No Dealerid "+dealId);
        }
    }

    sortList.sort();
    res = "";//get_dealerList<br>";
    for (s=0;s<sortList.length;s++) {
        if (s >= 1) res = res + "<br>";
        persId = sortList[s][2];
        persName = sortList[s][1];
        if (makeLink == 1) {
            if (useHtml == 1)  res = res + "<a href='index.php?wahl=d&nr="+persId+"&play=0' class='inhalt_link'>";
            else res = res + "<a href='#' onClick=javascript:goPage('d',"+persId+");  class='inhalt_link'>";
        }
        res = res + persName;
        if (makeLink == 1) res = res + "</a>";
    }
    return res;

}

function get_projectContent(findId,cont,showType,makeLink) {
   // alert("get_projectContent("+findId+","+cont+","+showType+","+makeLink);
    //alert("found cont "+cont+" showType "+showType);
    sli = get_project();
    res = "";
    out = "";
    if (showType == "p") showType = "n";
    showId = get_FieldId(showType);
    // if (showType == "c") alert("find in Project where findId " + findId + " is " + cont + " and ShowType = " + showType + " and ShowId = " + showId);
   // res = res + "find in Project where findId " + findId + " is " + cont + " and ShowType = " + showType + " and ShowId = " + showId ;

    add = "";
    if (showType == "y") add = new Array();
    if (makeLink == null) makeLink = 1;
    for (p=0;p<sli.length;p++) {
        t = sli[p][findId];
         out = out + " t = " + t+"<br>";
        //alert("t= " + sli[p][findId] + " findId " + findId);
        if (t != null) {
            found = 0;
            contList = t.split(",");
            for (c=0;c<contList.length;c++) {
                if (contList[c] == cont) found = 1;
            }
            if (found == 1) {
                if (res != "") res = res + "<br>";
                showText = sli[p][showId];
                out = out + "<br> found "+findId+" in "+t+" showText="+showText +"<br>";
                if (showText != 0) {
                   out = out + "<br> found "+findId+" in "+t+" showText="+showText +"<br>";
                    //alert("t= " + sli[p][findId] + " findId " + findId+ "showText "+ showText);
                    if (showType == "m") add = addSplit(add,showText,"text");
                    if (showType == "a") add = addSplit(add,showText,"text");
                    if (showType == "d") add = addSplit(add,showText,"text");
                    if (showType == "c") add = addSplit(add,showText,"text");
                    if (showType == "y") {

                      add = addSplit(add,showText,"list");

                      //help_show("showtext = "+showText+"<br>yearList = "+yearList);
                    }

                    if (add == "") {
                        st = showType;
                        if (st == "n") st = "p";
                        if (makeLink == 1) {
                            if (useHtml == 1) res = res + "<a href='index.php?wahl="+st+"&nr="+p+"&play=0' class='inhalt_link'>";
                            else res = res + "<a href='#' onClick=javascript:goPage('"+st+"',"+p+");  class='inhalt_link'>";
                        }
                        res = res + showText ;
                        if (makeLink == 1) res = res + "</a>";
                    }
                }
            }
        }
    }
    //alert(out);
    //return out;
    if (add != "") {
        res = "";
        if (showType == "m") res = get_personList(add,makeLink);
        if (showType == "a") res = get_areaList(add,makeLink);
        if (showType == "c") res = get_customerList(add,makeLink);
        if (showType == "d") res = get_DealerList(add,makeLink);
        if (showType == "y") {
            add.sort();
            for (c=0;c<add.length;c++) {
                if (makeLink == 1) {
                    if (useHtml == 1) res = res + "<a href='index.php?wahl=y&nr="+add[c]+"&play=0' class='inhalt_link'>";
                    else res = res + "<a href='#' onClick=javascript:goPage('y',"+add[c]+");  class='inhalt_link'>";
                }
                res = res + add[c];
                if (makeLink == 1) res = res + "</a><br>";
            }

        }
    }
    return res;
}

function getInhalt(showType) {
    // help_show("getInhalt wahl="+wahl+" wahl_id="+wahl_id+" showType ="+showType);

    li = null;
    if (wahl == "m") gli = get_person();
    if (wahl == "p") gli = get_project();
    if (wahl == "a") gli = get_area();
    if (wahl == "c") gli = get_customer();
    if (wahl == "d") gli = get_dealer();

    if (wahl ==  "y") {
        findId = get_FieldId("y");
        //help_show("getInhalt wahl="+wahl+" wahl_id="+wahl_id+" showType ="+showType);
        go = parseInt(wahl_id);
        res = get_projectContent(findId,go,showType,1);
        //help_show("getInhalt yahr ="+res);
        // res = res + findId + "/" + wahl_id + "/" + showType
        return res;
    }


    if (gli == null) {
            res = "unkown " + " wahl = " + wahl + " showType = " + showType;
            return res;
    }

    getId = get_FieldId(showType);

    // alert(li[wahl_id] + "      " + getId);
    inh = gli[wahl_id][getId];
    res = showType + " - " + inh;

    if (showType == "t") {
        getId_head = get_FieldId("h");
        head = gli[wahl_id][getId_head];
        res = "";
        if (head == "") {
                if (inh == "") return res;
        }
        //res = res + "<b class='menu_leer'>";
        if (typeof(head) == "string") {
            //alert("Eingegebene Zeichen: " + head.length);
            if (head.length > 0) res = res + "<strong>" + head + "</strong>"+"<br>";
        }

        if (typeof(inh)  == "string") res = res + inh ;
            //es = res + "</b>";
    }

    if (showType == "d") {
        if (wahl == "a") {
            // sucht im FeldNr aus Projekte, nach Vorkommen, gibt aus, mit /ohne Link
            go = parseInt(wahl_id) + 1;
            res =  get_projectContent(3,go,"d",1);
           // help_show("wahl_id= "+wahl_id+" res= "+t);

        } else {

            if (inh != "") {
                    res = get_DealerList(inh,1);
                    // alert("dealerList "+inh+" "+1);
                   // res = "";
            } else {
                    res = "";
            }
        }
    }

    if (showType == "i") {
        res = "Images" + inh;
        cnt = parseInt(inh);
        if (typeof(cnt) == "number") {
                res = "";
                for (z=1;z<=cnt;z++) {
                    go = parseInt(wahl_id) + 1;
                    img = "<img src='img/" + go + "/thumb/" + z + ".jpg' border='0' height='20'>"; // height='20'>";
                    res = res + "<a href='#'; onMouseOver=javascript:showProjectImage("+wahl_id+","+z+"); ";
                    if (rollImg == 1) res = res + "onMouseOut=javascript:hideProjectImage();";
                    res = res + "class='inhalt_link'>"+img+"&nbsp;</a>";
                }
        } else {
                res = ""; //Images " + inh + "/"+ typeof(cnt);
        }
    }

    if (showType == "y") {
        res = "";
        if (wahl == "m") { // YEARS FOR PERSON
            go = parseInt(wahl_id) + 1;
            res = get_projectContent(4,go,"y",1);
            //alert("res = "+res);
        }
        if (wahl == "a") { // YEARS FOR AREA
            go = parseInt(wahl_id) + 1;
            res = get_projectContent(3,go,"y",1);
        }
        if (res == "") {
            te = inh.split(",");

            for (i=0;i<te.length;i++) {
                if (i > 0) res = res + "<br>";
                t = te[i];
                if (useHtml == 1) res = res + "<a href='index.php?wahl=y&nr="+t+"&play=0' class='inhalt_link'>"+t+"</a>";
                else res = res + "<a href='#' onclick=javascript:goPage('y',t); class='inhalt_link'>"+t+"</a>";
            }
        }
    }

    if (showType == "c") {
            if (wahl == "a") {
            //	res = "show kunden with area " + "a" + "/" + wahl_id + " showType " + showType;
            //	res = res + "<br>";
                    findId = get_FieldId("a");
                    go = parseInt(wahl_id) + 1;
                    res = get_projectContent(findId,go,showType,1);
                    // res = "Halo"+findId+" wahlId " + wahl_id;
            } else {
                    res = get_customerList(inh,1);
            }
    }

    if (showType == "l") {
        getId_www = get_FieldId("w");
        www = gli[wahl_id][getId_www];
        if (www + inh == "") return "";
        inhList = inh.split(",");
        wwwList = www.split(",");
        if (inhList.length == wwwList.length) {
            res = "";
            for (w=0;w<inhList.length;w++) {
                //res = res + " / " + gli[wahl_id][getId_www];
                res = res + "<a href='" + wwwList[w] + "' target='sklink' class='inhalt_link'>"+inhList[w]+"</a>";
                if (w < inhList.length) res = res + "<br>";
            }
       } else {
          res = "LinkError";
       }


    }

    if (showType == "p") res = get_projectList(inh,1);
    if (showType == "m") res = get_personList(inh,1);
    if (showType == "a") res = get_areaList(inh,1);

   // res = res + "<br>" + showType;
    return res
}

function showRoll(showType,lineNr) {
  //  tShow = getTitle() + "<br>"; //"";
    tShow = "<span class='headLine'>"+ "&nbsp;" + "<br></span>";
    //tShow = tShow + tab_start('l') + ""  + "<br>";
    // Leer Zeilen
    if (rollImg != 1) hideProjectImage();

    for (i=0;i<lineNr;i++) {
        tShow = tShow + "<span class='menu_leer'>&nbsp;</span><br>";
    }
    inh = getInhalt(showType);
    tShow = tShow + inh;
    tShow = tShow + tab_ende();
    setlayer('inhalt',tShow,null,null,1);


}

function hideRoll() {
    setlayer('inhalt','',null,null,0);
}
	


function navLine() {
    t = "";
    t = t + "<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0' bordercolor='#666600' >";
    t = t + "	<tr>";
    t = t + "		<td valign='middle' align='left' border='0' width='270px'>";
    if (lg == 'dt') {
        t = t + "			&nbsp;";
        if (useHtml == 1) {
            t = t + "			<a href='index.php?wahl=c&nr=null&play=0' class='menu_link'>kunden</a> | ";
            t = t + "			<a href='index.php?wahl=p&nr=null&play=0' class='menu_link'>projekte</a> | ";
            t = t + "			<a href='index.php?wahl=a&nr=null&play=0' class='menu_link'>bereiche</a> | ";
            t = t + "			<a href='index.php?wahl=m&nr=null&play=0' class='menu_link'>personen</a> |";
            t = t + "			<a href='index.php?wahl=y&nr=null&play=0' class='menu_link'>jahr</a>";
        } else {
            t = t + "			<a href='#' onClick=javascript:goPage('c',null); class='menu_link'>kunden</a> | ";
            t = t + "			<a href='#' onClick=javascript:goPage('p',null); class='menu_link'>projekte</a> | ";
            t = t + "			<a href='#' onClick=javascript:goPage('a',null); class='menu_link'>bereiche</a> | ";
            t = t + "			<a href='#' onClick=javascript:goPage('m',null); class='menu_link'>personen</a> |";
            t = t + "			<a href='#' onClick=javascript:goPage('y',null); class='menu_link'>jahr</a>";
        }
    } else {
        t = t + "			&nbsp;";
        t = t + "			<a href='#' onClick=javascript:goPage('c',null); class='menu_link'>kunden</a> | ";
        t = t + "			<a href='#' onClick=javascript:goPage('p',null); class='menu_link'>projects</a> | ";
        t = t + "			<a href='#' onClick=javascript:goPage('a',null); class='menu_link'>areas</a> | ";
        t = t + "			<a href='#' onClick=javascript:goPage('m',null); class='menu_link'>workers</a> |";
        t = t + "			<a href='#' onClick=javascript:goPage('y',null); class='menu_link'>years</a>";
    }
    t = t + "		</td>";

    // Mittlere Navigation
  //  t = t + "		<td valign='middle' align='center' border='0' >";
    //t = t + "<table width='400px' height='100%' border='0' cellspacing='0' cellpadding='0' bordercolor='#666600' bgcolor:'#777700'>";
    //t = t + "<tr><td valign='middle' align='center' bgcolor='#666600'>";
    if (play == 1) {
        t = t + "		<td valign='middle' align='center' border='0' >";
        t = t + "<table width='360px' height='100%' border='0' cellspacing='0' cellpadding='0' bordercolor='#666600' bgcolor:'#666600'>";
        t = t + "<tr><td valign='middle' align='center' bgcolor='#666600'>";

        // SPIELEN
       if (playPause == 0) { // läuft
            t = t + "<a href='#' onClick=javascript:doPause(); class='menuMitte_link'>pause</a>";
            t = t + "<span class='navTextLine'> | </span><span class='navText'>langsam </span>";
            t = t + speedNav()
            t = t + "<span class='navText'> schnell </span><span class='navTextLine'>| </span>";
            // navText = navText + speedNav();
       } else {
            t = t + "<a href='#' onClick=javascript:goBack(); class='menuMitte_link'>letztes bild</a>";
            t = t + " | ";
            t = t + "<a href='#' onClick=javascript:doPlay(); class='menuMitte_link'>weiter spielen</a>";
            t = t + " | ";
            t = t + "<a href='#' onClick=javascript:goFor(); class='menuMitte_link'>nächstes bild</a>";
            t = t + " | ";
        }
      //  t = t + naxText;
        t = t + "<a href='#' onClick=javascript:StopPlay(); class='menuMitte_link'>spielen beenden</a>";
        t = t + "</td></tr></table>";
        t = t + "</td>";

    } else {
         t = t + "		<td valign='middle' align='center' border='0' >";
        // NORMAL
        t = t + "<a href='#' onClick=javascript:StartPlay(); class='menuMitte_link'>spielen</a>";
        t = t + "</td>";
    }
    

    t = t + "		<td valign='middle' align='right' width='158px'>";
    t = t + "			|&nbsp;||&nbsp; ";
    if (lg == 'dt') {
        //t = t + "				<a href='#' onClick=javascript:goPage('m',0); class='menu_link'>start</a>&nbsp|&nbsp;";
        //if (play == 1) {
        //	t = t + "				<a href='#' onClick=javascript:StopPlay(); class='menu_link'>normal</a>&nbsp|&nbsp;";
        //} else {
        //	t = t + "				<a href='#' onClick=javascript:StartPlay(); class='menu_link'>diashow</a>&nbsp|&nbsp;";
        // }
        t = t + "				<a href='#' onClick=javascript:contact(); class='menu_link'>kontakt</a>&nbsp|&nbsp;";
        t = t + "				<a href='#' onClick=javascript:impress(); class='menu_link'>impressum</a>";//&nbsp|&nbsp;";
        //t = t + "				<a href='#' onClick=javascript:setLanguage('en'); class='menu_link'>english</a>&nbsp";

    } else {
        t = t + "				<a href='#' onClick=javascript:goPage('m',0); class='menu_link'>home</a>&nbsp|&nbsp;";
        t = t + "				<a href='#' onClick=javascript:contact(); class='menu_link'>contakt</a>&nbsp|&nbsp;";
        t = t + "				<a href='#' onClick=javascript:impress(); class='menu_link'>about</a>&nbsp|&nbsp;";
        t = t + "				<a href='#' onClick=javascript:setLanguage('dt'); class='menu_link'>deutsch</a>&nbsp";
    }
    t = t + "&nbsp;&nbsp;";
    t = t + "		</td>";
    t = t + "	</tr>";
    t = t + "</table>";
    setlayer('navLine',t,null,null,1);
}

function contact() {
    if (play == 1) StopPlay();
    if (lg == "en") trans = "contact";
    if (lg == "dt") trans = "kontakt";
    t = tab_start('r') + trans + "<br>" + tab_ende();

    t2 = tab_start('l');
    t2 = t2 + "<b class='menu_leer'>";
    t2 = t2 + "Stefan Kölmel</b>&nbsp;<b class='menu_leer'><br>";
    t2 = t2 + "Fasanenstraße 17<br>";
    t2 = t2 + "76131 Karlsruhe<br>";
    t2 = t2 + "&nbsp;<br>";
    t2 = t2 + "tel +49 721 93517.20<br>";
    t2 = t2 + "fax +49 721 93517.29<br>";
    t2 = t2 + "email sk@stefan-koelmel.de<br>";
    t2 = t2 + "</b>";
    t2 = t2 + tab_ende();

    setlayer('topic',t,null,null,1);
    setlayer('inhalt',t2,null,null,1);
}

function showProjectImage (pr,nr) {
    t = "";
    //t = t + "<img src='img/"+(pr+1)+"/"+nr+".jpg' height='400'  alt=''  >";
    t = t + "<img src='img/"+(pr+1)+"/"+nr+".jpg'  alt=''  >";
    // height='75%'
    setlayer('prImg',t,null,null,1);	//prImg
	
}

function hideProjectImage () {

    setlayer('prImg',"",null,null,0);	//prImg
	
}

function  impress_text() {
    imp = "";
    imp = imp + "<strong>Angaben gemäß § 5 TMG:</strong><br>";
    imp = imp + "Stefan Kölmel<br>";
    imp = imp + "Büro für Gestaltung<br>";
    imp = imp + "Fasanenstraße 17<br>";
    imp = imp + "76131 Karlsruhe<br>";
    imp = imp + "&nbsp;<br>";
    imp = imp + "<strong>Kontakt:</strong><br>";
    imp = imp + "Telefon: 0721 93517-20<br>";
    imp = imp + "Telefax: 0721 93517-29<br>";
    imp = imp + "eMail: info@stefan-koelmel.com<br>";
    imp = imp + "&nbsp;<br>";
    imp = imp + "<strong>Umsatzsteuer-ID:</strong><br>";
    imp = imp + "Umsatzsteuer-Identifikationsnummer gemäß<br>";
    imp = imp + "§27 a Umsatzsteuergesetz:<br>";
    imp = imp + "35110/08717<br>";
    imp = imp + "&nbsp;<br>";
    imp = imp + "<strong>Konzeption und Programmierung</strong><br>";
    imp = imp + "<a href='http://www.stefan-koelmel.com' class='inhalt_link' target='sklink' >Stefan Kölmel | Konzept und Medien</a>";

    return imp; //"Hier kommt das Impessum hin";
}

function impress() {
    if (play == 1) StopPlay();
    if (lg == "en") trans = "about";
    if (lg == "dt") trans = "impressum";
    t = tab_start('r') + trans + "<br>" + tab_ende();

    t2 = tab_start('l');

    t2 = t2 + "<b class='menu_leer'>";
    t2 = t2 + impress_text();

    t2 = t2 + tab_ende();
    setlayer('topic',t,null,null,1);
    setlayer('inhalt',t2,null,null,1);
}

function setLanguage(setLg) {
	lg = setLg;
	navLine();
	goPage(wahl,wahl_id);		
}

function back_add(type,nr) {
    // aktuelle Seite hinten an BackList anhängen
    backList.push(type+","+nr);
    // erstes Element Löschen wenn max erreicht
    max = 10;
    if (backList.length > max) backList.shift();

   // help_show(backList);
}

function back_goBack() {

    backList.pop();
    anz = backList.length;

    if (anz >= 1) {
        goStr = backList[anz-1];
        goList = goStr.split(",");

        goWahl = goList[0];
        goNr = goList[1];
        if (goNr == "null") goNr = null;
        else goNr = parseInt( goNr);
        //help_show("go back to "+goWahl+" Nr is "+goNr);
        goPage(goWahl,goNr,1); //
    } else {
        //help_show("no Go Back");
    }  
}


function goPage(type,nr,dontBack) {
    if (dontBack != 1) back_add(type,nr);

    if (play == 1) StopPlay();
    wahl = type;
    wahl_id = nr;
    hideProjectImage ();
    hideRoll();
    // alert("go Page " + type + " / " +  nr);
    showTopic();
}





function navStart(setTyp,setNr,setPlay) { // START
    play = 1;
    if (setPlay != null) play=setPlay;
    useHtml = 0;
    rollImg = 0;
    
    wahl = "m";
    wahl_id = 0;
    if (setTyp != null) { 
       // alert(setTyp);
        wahl = setTyp;
    }
    if (setNr == "null") wahl_id = null;
    else if (setNr != null) wahl_id = setNr;
    
    if (lg == null) {
        setLanguage('dt');
    }

    if (play == 1) {
        StartPlay();
    } else {
        navLine();
        goPage(wahl,wahl_id);
    }
   
    //if (play == 1)
        


    // sucht im FeldNr aus Projekte, nach Vorkommen, gibt aus, mit /ohne Link
   // t =  get_projectContent("6","2010","m",1);
   // help_show(t);
    
    //goPage("m",null);
}

