// JavaScript Document
<!--
/*
*** Multiple dynamic combo boxes
*** by Mirko Elviro, 9 Mar 2005
*** Script featured and available on JavaScript Kit (http://www.javascriptkit.com)
***
***Please do not remove this comment
*/
// This script supports an unlimited number of linked combo boxed
// Their id must be "combo_0", "combo_1", "combo_2" etc.
// Here you have to put the data that will fill the combo boxes
// ie. data_2_1 will be the first option in the second combo box
// when the first combo box has the second option selected

// first combo box
	data_1 = new Option("Theos Flickenbär", "Theos Flickenbär");
	data_2 = new Option("Liliane Susenwind - Mit Elefanten spricht man nicht", "Liliane Susenwind - Mit Elefanten spricht man nicht");
	data_3 = new Option("Der 7. Sonntag im August", "Der 7. Sonntag im August");
	data_4 = new Option("Hilfe, ich habe meine Leherin geschrumpft", "Hilfe, ich habe meine Leherin geschrumpft");
	data_5 = new Option("Geschichten im Fluss", "Geschichten im Fluss");
	data_6 = new Option("Herz im Gepäck", "Herz im Gepäck");
	data_7 = new Option("Jeansgröße 0", "Jeansgröße 0");

	
	
// second combo box
	data_1_1 = new Option("Montag, 1. Dez. 2008 um 9 Uhr", "Montag, 1. Dez. 2008 um 9 Uhr");
	data_1_2 = new Option("Montag, 1. Dez. 2008 um 11 Uhr", "Montag, 1. Dez. 2008 um 11 Uhr");
	data_2_1 = new Option("Donnerstag, 4. Dez. 2008 um 9 Uhr", "Donnerstag, 4. Dez. 2008 um 9 Uhr");
	data_2_2 = new Option("Donnerstag, 4. Dez. 2008 um 11 Uhr", "Donnerstag, 4. Dez. 2008 um 11 Uhr");
	data_2_3 = new Option("Freitag, 5. Dez. 2008 um 9 Uhr", "Freitag, 5. Dez. 2008 um 9 Uhr");
	data_2_4 = new Option("Freitag, 5. Dez. 2008 um 11 Uhr", "Freitag, 5. Dez. 2008 um 11 Uhr");
	data_3_1 = new Option("Dienstag, 2. Dez. 2008 um 9 Uhr", "Dienstag, 2. Dez. 2008 um 9 Uhr");
	data_4_1 = new Option("Dienstag, 2. Dez. 2008 um 11 Uhr", "Dienstag, 2. Dez. 2008 um 11 Uhr");
	data_5_1 = new Option("Dienstag, 2. Dezember 2008 von 9 Uhr bis 13 Uhr", "Dienstag, 2. Dez. 2008 von 9 Uhr bis 13 Uhr");
	data_6_1 = new Option("Mittwoch, 3. Dez. 2008 um 9 Uhr", "Mittwoch, 3. Dez. 2008 um 9 Uhr");
	data_7_1 = new Option("Mittwoch, 3. Dez. 2008 um 11 Uhr", "Mittwoch, 3. Dez. 2008 um 11 Uhr");
	
	
// other parameters
    displaywhenempty=""
    valuewhenempty=-1
    displaywhennotempty="-bitte Termin auswählen-"
    valuewhennotempty=0

function change(currentbox) {
	numb = currentbox.id.split("_");
	currentbox = numb[1];
    i=parseInt(currentbox)+1
// I empty all combo boxes following the current one
    while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
           (document.getElementById("combo_"+i)!=null)) {
         son = document.getElementById("combo_"+i);
	     // I empty all options except the first one (it isn't allowed)
	     for (m=son.options.length-1;m>0;m--) son.options[m]=null;
	     // I reset the first option
	     son.options[0]=new Option(displaywhenempty,valuewhenempty)
	     i=i+1
    }

// now I create the string with the "base" name ("stringa"), ie. "data_1_0"
// to which I'll add _0,_1,_2,_3 etc to obtain the name of the combo box to fill
    stringa='data'
    i=0
    while ((eval("typeof(document.getElementById(\"combo_"+i+"\"))!='undefined'")) &&
           (document.getElementById("combo_"+i)!=null)) {
           eval("stringa=stringa+'_'+document.getElementById(\"combo_"+i+"\").selectedIndex")
           if (i==currentbox) break;
           i=i+1
    }

// filling the "son" combo (if exists)
    following=parseInt(currentbox)+1
    if ((eval("typeof(document.getElementById(\"combo_"+following+"\"))!='undefined'")) &&
       (document.getElementById("combo_"+following)!=null)) {
       son = document.getElementById("combo_"+following);
       stringa=stringa+"_"
       i=0
       while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) {
       // if there are no options, I empty the first option of the "son" combo
	   // otherwise I put "-select-" in it
	   	  if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
	   	      if (eval("typeof("+stringa+"1)=='undefined'"))
	   	         eval("son.options[0]=new Option(displaywhenempty,valuewhenempty)")
	   	      else
	             eval("son.options[0]=new Option(displaywhennotempty,valuewhennotempty)")
	      else
              eval("son.options["+i+"]=new Option("+stringa+i+".text,"+stringa+i+".value)")
	      i=i+1
	   }
       //son.focus()
       i=1
       combostatus=''
       cstatus=stringa.split("_")
       while (cstatus[i]!=null) {
          combostatus=combostatus+cstatus[i]
          i=i+1
          }
       return combostatus;
    }
}
//-->
