// ----------------------------------------------------------------------
//     Javascript-Bibliothek zur Steuerung des Carnificina Auftrittes
//     Copyright Rolf Schumann
//     Datum der letzten Änderung: 2006-01-08
// ----------------------------------------------------------------------
function ausketten(pointer)
{var vorg = pointer.vorg;
 var nachf = pointer.nachf;
 if (vorg == null)
 {parent.first = nachf;
 }
 else
 {vorg.nachf = nachf;
 }
 if (nachf == null)
 { parent.last = vorg;
 }
 else
 {nachf.vorg = vorg;
 }
 pointer.nachf = null;
 pointer.vorg = null;
}
function anfuegen(pointer)
{//am Ende der Kette anketten
 if (last == null)
 {parent.first = pointer;
  parent.last  = pointer;
 }
 else
 {parent.last.nachf = pointer;
  pointer.vorg = last;
  parent.last = pointer;
 }
}
function einketten(pointer,vor)
{//pointer soll in die Kette vor vor eingefügt werden
 vorg = vor.vorg;
 pointer.nachf = vor;
 vor.vorg = pointer;
 pointer.vorg = vorg;
 if (vorg == null)
 {parent.first = pointer;
 }
 else
 {vorg.nachf = pointer;
 }
}
function sort(k)
{ var lauf1=parent.first;
  while (lauf1 !=null)
  {  //suche die erste Stelle, die nicht korrekt einsortiert ist.
     
     var weiter = true;
     while (weiter)
     {  weiter = (lauf1.nachf !=null);
        if (weiter) {weiter = vergleiche (lauf1,lauf1.nachf, k);}
        if (weiter) {lauf1=lauf1.nachf;}
     }
     //jetzt ist entweder lauf1 am ende oder an einer Tauschposition
     
     if (lauf1.nachf != null)
     {  var pointer = lauf1.nachf;
        ausketten(pointer);
        var lauf2 = parent.first;
        while (vergleiche(lauf2,pointer,k)) {lauf2 = lauf2.nachf;}
        einketten(pointer,lauf2);
     }
     else {lauf1=lauf1.nachf;}
  }

//evt. hat sich das letzte Element geändert
parent.last = parent.first;
while (parent.last.nachf != null) {parent.last = parent.last.nachf;}
parent.CARNI_UNTEN.location='liste.htm';
}
function vergleiche (pointer1,pointer2,k)
{ switch (k)
  {case 1:{return (pointer1.nummer > pointer2.nummer);
           break;}
   case 2:{return (pointer1.datum <= pointer2.datum);
           break;}
   case 3:{return (pointer1.titel.toUpperCase() <= pointer2.titel.toUpperCase());
           break;}
   case 4:{return (pointer1.gruppe.toUpperCase() <= pointer2.gruppe.toUpperCase());
           break;}
  }
  return true; 
}
function set(k)
{var akt = parent.first;
 while (akt.nummer != k) {akt=akt.nachf;}
 parent.aktuell = akt;
 parent.CARNI_OBEN.location='oben.htm';
 parent.CARNI_UNTEN.location='liste.htm';

}

function dokument_ausgabe()
{ var col="Blue";

  //wegen der Einrückprobleme im Explorer wird hier eine Tabellenstruktur aufgebaut
  document.writeln('<TABLE ALIGN=LEFT BORDER=0 CELLPADDING=2 CELLSPACING=2 UNIT=PIXELS WIDTH=840 HSPACE=0 VSPACE=0 BGCOLOR=#FFFF00>');
  // diese dummy-Zeile wird fuer die Spaltentreue benötigt!!!

       {
        document.writeln('<TR><TD WIDTH=80 BGCOLOR=#FFFFEE align=center><FONT SIZE=3 COLOR=BLUE FACE="New Times Roman" >Auswahl</FONT></TD>');       

        document.write('<TD WIDTH=80 BGCOLOR=#FFFFEE><FONT SIZE=3 COLOR=BLUE FACE="New Times Roman" >');
document.writeln('<A HREF="javascript:sort(1);"><IMG SRC="_lib/grafik/sort_pf.gif" ALIGN=RIGHT border=0></A>lfd. Nr.</FONT>');       
        document.write('<TD WIDTH=250 BGCOLOR=#FFFFEE><FONT SIZE=3 COLOR=BLUE FACE="New Times Roman" >');
document.writeln('<A HREF="javascript:sort(3);"><IMG SRC="_lib/grafik/sort_pf.gif" ALIGN=RIGHT  border=0></A>Titel</FONT></TD>');       

        document.write('<TD WIDTH=80 BGCOLOR=#FFFFEE><FONT SIZE=3 COLOR=BLUE FACE="New Times Roman" >');
document.writeln('<A HREF="javascript:sort(2);"><IMG SRC="_lib/grafik/sort_pf.gif" ALIGN=RIGHT  border=0></A>Datum</FONT></TD>');       

        document.writeln('<TD WIDTH=300 BGCOLOR=#FFFFEE><FONT SIZE=3 COLOR=BLUE FACE="New Times Roman" >');
document.writeln('<A HREF="javascript:sort(4);"><IMG SRC="_lib/grafik/sort_pf.gif" ALIGN=RIGHT VALIGN=TOP border=0></A>Gruppe</FONT></TD></TR>');       

       } 

  //hole den Anfang der Dokumentliste, indem die aktuelle Wurzel geholt wird;
  lauf = parent.first;
  while (lauf != null)
  { //ausgabe des aktuellen Dokumentes
    document.write('<TR><TD WIDTH=80 BGCOLOR=#FFFFEE ALIGN=CENTER><A HREF="javascript:set(');
    document.write(lauf.nummer);
    document.write(');">');
    document.write('<IMG SRC="');
    if (lauf == parent.aktuell)
    {col="Blue";
     document.write('_lib/grafik/Haken_blau.gif');
    }
    else
    {
     col="Black";
     document.write('_lib/grafik/Haken_gruen.gif');
    }
     document.writeln('" border=0 ALIGN=CENTER></A></TD>');

        document.write('<TD WIDTH=80 BGCOLOR=#FFFFEE ALIGN=RIGHT><FONT SIZE=3 COLOR='+col+' FACE="New Times Roman">' + lauf.nummer + '</FONT></TD>');

        document.write('<TD WIDTH=250 BGCOLOR=#FFFFEE><FONT SIZE=3 COLOR='+col+' FACE="New Times Roman" >'+lauf.titel+'</FONT></TD>');
        document.write('<TD WIDTH=80 BGCOLOR=#FFFFEE><FONT SIZE=3 COLOR='+col+' FACE="New Times Roman" >'+lauf.datum+'</FONT></TD>');
        document.writeln('<TD WIDTH=300 BGCOLOR=#FFFFEE><FONT SIZE=3 COLOR='+col+' FACE="New Times Roman" >'+lauf.gruppe+'</FONT></TD></TR>');

    lauf = lauf.nachf;
  }
  document.writeln('</TABLE>');
}
//   Ende der Auskommentierung für die HTML-Anzeige   -->