
/*
*** 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
*/

// first combo box

	data_1 = new Option("Calais", "$");
	data_2 = new Option("Normandy", "$$");
	data_3 = new Option("Paris", "$");
	data_4 = new Option("Loire", "$");
	data_5 = new Option("Aquitaine", "$");
	
// second combo box
    //Calais
	data_1_1 = new Option("Dunkerque", "-");
	data_1_2 = new Option("Wimereux", "-");
	data_1_3 = new Option("St Omer", "--");
	data_1_4 = new Option("Hardelot Dunes", "--");
	data_1_5 = new Option("Hardelot Pines", "--");
	data_1_6 = new Option("Le Touquet Foret", "--");
	data_1_7 = new Option("Le Touquet Mer", "--");
	data_1_8 = new Option("Arras", "-");
	data_1_9 = new Option("Belle Dune", "-");
	data_1_10 = new Option("Nampont Les Cygnes", "--");
	data_1_11 = new Option("Nampont Le Belvedere", "--");

	//Normandy
	data_2_1 = new Option("Dieppe Pourville", "--");
	data_2_2 = new Option("Etretat", "--");
	data_2_3 = new Option("Saint Saens", "--");
	data_2_4 = new Option("Champ de Bataille", "--");
	data_2_5 = new Option("Le Vaudreuil", "--");
	data_2_6 = new Option("Lery Poses", "--");
	data_2_7 = new Option("Le Golf Parc", "--");
	data_2_8 = new Option("Golf de Garcelles", "--");
	data_2_9 = new Option("Granville", "--");
	data_2_10 = new Option("Omaha Beach", "--");
	data_2_11 = new Option("Etretat", "--");
	data_2_12 = new Option("Saint Saens", "--");
	data_2_13 = new Option("Dieppe Pourville", "--");
	
	//Paris
	data_3_1 = new Option("Apremont", "--");
	data_3_2 = new Option("Raray", "--");
	data_3_3 = new Option("Dolce Chantilly", "--");
	data_3_4 = new Option("L'Isle de Adam", "--");
	data_3_5 = new Option("Paris International", "--");
	data_3_6 = new Option("Mont Griffon", "--");
	data_3_7 = new Option("Chantilly Club du Lys", "--");
	
	//Loire
    data_4_1 = new Option("Apremont", "--");
	data_4_2 = new Option("Raray", "--");
	data_4_3 = new Option("Dolce Chantilly", "--");
	data_4_4 = new Option("L'Isle de Adam", "--");
	data_4_5 = new Option("Paris International", "--");
	data_4_6 = new Option("Mont Griffon", "--");
	data_4_7 = new Option("Chantilly Club du Lys", "--");
	
	//Aquitaine
	data_5_1 = new Option("Gujan", "--");
	data_5_2 = new Option("Pressac", "--");
	data_5_3 = new Option("Cameyrac", "--");
	data_5_4 = new Option("Lacanau", "--");
	data_5_5 = new Option("Bordeaux Lac", "--");
	data_5_6 = new Option("Medoc", "--");
	data_5_7 = new Option("La Phare", "--");
	data_5_8 = new Option("Arcangues", "--");
	data_5_9 = new Option("Seignosse", "--");
	data_5_10 = new Option("Bassussary", "--");
	data_5_11 = new Option("Moilets", "--");

// other parameters
    displaywhenempty=""
    valuewhenempty=-1

    displaywhennotempty="-select-"
    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;
    }
}
