vacations = new Array();
vacations[0] = new Array("Baden-Württemberg", 
"02.04.2007", "14.04.2007", "29.05.2007", "09.06.2007", "26.07.2007", "08.09.2007", "29.10.2007", "03.11.2007", "24.12.2007", "05.01.2008",
"17.03.2008", "28.03.2008", "13.05.2008", "23.05.2008", "24.07.2008", "06.09.2008", "27.10.2008", "30.10.2008", "22.12.2008", "10.01.2009",
"14.04.2009", "17.04.2009", "25.05.2009", "06.06.2009", "30.07.2009", "12.09.2009",  	
"03.10.2007", "03.10.2007", 
"01.01.2008","01.01.2008","06.01.2008","06.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","22.05.2008","22.05.2008","03.10.2008","03.10.2008","01.11.2008","01.11.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "06.01.2009", "06.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "11.06.2009", "11.06.2009", "03.10.2009", "03.10.2009", "01.11.2009", "01.11.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[1] = new Array("Bayern", 
"19.02.2007", "24.02.2007", "02.04.2007", "14.04.2007", "29.05.2007", "09.06.2007", "30.07.2007", "10.09.2007", "29.10.2007", "03.11.2007", "24.12.2007",  "05.01.2008",
"04.02.2008", "09.02.2008", "17.03.2008", "29.03.2008", "13.05.2008", "24.05.2008", "04.08.2008", "15.09.2008", "03.11.2008", "05.11.2008", "22.12.2008",  "05.01.2009",
"23.02.2009", "28.02.2009", "06.04.2009", "18.04.2009", "02.06.2009", "13.06.2009", "03.08.2009", "14.09.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","06.01.2008","06.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","22.05.2008","22.05.2008","15.08.2008","15.08.2008","03.10.2008","03.10.2008","01.11.2008","01.11.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "06.01.2009", "06.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "11.06.2009", "11.06.2009", "15.08.2009", "15.08.2009", "03.10.2009", "03.10.2009", "01.11.2009", "01.11.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[2] = new Array("Berlin", 
"05.02.2007", "10.02.2007", "02.04.2007", "13.04.2007", "30.04.2007", "30.04.2007", "18.05.2007", "18.05.2007", "12.07.2007", "25.08.2007", "15.10.2007", "27.10.2007", "24.12.2007", "12.01.2008",
"04.02.2008", "04.02.2008", "17.03.2008", "29.03.2008", "02.05.2008", "02.05.2008", "13.05.2008", "16.05.2008", "16.07.2008", "29.08.2008", "20.10.2008", "31.10.2008", "22.12.2008", "03.01.2009",
"02.02.2009", "07.02.2009", "06.04.2009", "18.04.2009", "22.05.2009", "22.05.2009", "16.07.2009", "28.08.2009", "15.07.2009", "15.07.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[3] = new Array("Brandenburg", 
"05.02.2007", "10.02.2007", "04.04.2007", "13.04.2007", "12.07.2007", "25.08.2007", "15.10.2007", "27.10.2007", "24.12.2007", "04.01.2008",
"04.02.2008", "04.02.2008", "19.03.2008", "28.03.2008", "13.05.2008", "16.05.2008", "17.07.2008", "30.08.2008", "20.10.2008", "30.10.2008", "22.12.2008", "03.01.2009",
"02.02.2009", "07.02.2009", "08.04.2009", "17.04.2009", "22.05.2009", "22.05.2009", "16.07.2009", "29.08.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","31.10.2008","31.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "31.10.2009", "	31.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[4] = new Array("Bremen", 
"01.02.2007", "02.02.2007", "26.03.2007", "10.04.2007", "29.05.2007","29.05.2007","19.07.2007", "29.08.2007", "22.10.2007", "03.11.2007", "24.12.2007", "05.01.2008",
"31.01.2008", "01.02.2008", "10.03.2008", "25.03.2008", "13.05.2008","16.05.2008","10.07.2008", "20.08.2008", "13.10.2008", "25.10.2008", "22.12.2008", "06.01.2009",
"02.02.2009", "02.02.2009", "30.03.2009", "14.04.2009", "02.06.2009", "02.06.2009", "25.06.2009", "05.08.2009", "20.05.2009", "24.05.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[5] = new Array("Hamburg", 
"02.02.2007", "02.02.2007", "05.03.2007", "17.03.2007", "30.04.2007", "30.04.2007", "14.05.2007", "18.05.2007", "12.07.2007", "22.08.2007", "15.10.2007", "27.10.2007", "21.12.2007", "05.01.2008",
"01.02.2008", "01.02.2008", "10.03.2008", "20.03.2008", "02.05.2008", "02.05.2008", "13.05.2008", "17.05.2008", "17.07.2008", "27.08.2008", "13.10.2008", "25.10.2008", "22.12.2008", "02.01.2009",
"30.01.2009", "30.01.2009", "09.03.2009", "21.03.2009", "18.05.2009", "23.05.2009", "16.07.2009", "26.08.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[6] = new Array("Hessen", 
"02.04.2007", "14.04.2007", "09.07.2007", "17.08.2007", "08.10.2007", "20.10.2007", "23.12.2007", "11.01.2008",
"25.03.2008", "05.04.2008", "23.06.2008", "01.08.2008", "06.10.2008", "18.10.2008", "22.12.2008", "10.01.2009",
"06.04.2009", "18.04.2009", "13.07.2009", "21.08.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","22.05.2008","22.05.2008","03.10.2008","03.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "11.06.2009", "11.06.2009", "03.10.2009", "03.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[7] = new Array("Mecklenburg-Vorpommern", 
"05.02.2007", "17.02.2007", "02.04.2007", "11.04.2007", "25.05.2007", "29.05.2007", "16.07.2007", "25.08.2007", "22.10.2007", "27.10.2007", "24.12.2007", "04.01.2008",
"04.02.2008", "16.02.2008", "17.03.2008", "26.03.2008", "09.05.2008", "13.05.2008", "21.07.2008", "30.08.2008", "27.10.2008", "30.08.2008", "22.12.2008", "03.01.2009",
"09.02.2009", "20.02.2009", "06.04.2009", "14.04.2009", "02.06.2009", "06.06.2009", "20.07.2009", "29.08.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","31.10.2008","31.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "31.10.2009", "	31.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[8] = new Array("Niedersachsen", 
"01.02.2007", "02.02.2007", "26.03.2007", "10.04.2007", "30.04.2007", "30.04.2007", "18.05.2007", "18.05.2007", "29.05.2007", "29.05.2007", "19.07.2007", "29.08.2007", "22.10.2007", "03.11.2007", "24.12.2007", "05.01.2008",
"31.01.2008", "01.02.2008", "10.03.2008", "26.03.2008", "02.05.2008", "02.05.2008", "13.05.2008", "13.05.2008", "10.07.2008", "20.08.2008", "13.10.2008", "25.10.2007", "22.12.2008", "06.01.2009",
"02.02.2009", "03.02.2009", "30.03.2009", "15.04.2009", "22.05.2009", "22.05.2009", "25.06.2009", "05.08.2009", "02.06.2009", "02.06.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[9] = new Array("Nordrhein-Westfalen", 
"02.04.2007", "14.04.2007", "29.05.2007", "29.05.2007", "21.06.2007", "03.08.2007", "24.09.2007", "06.10.2007", "20.12.2007", "04.01.2008",
"17.03.2008", "29.03.2008", "13.05.2008", "13.05.2008", "26.06.2008", "08.08.2008", "29.09.2008", "11.10.2008", "22.12.2008", "06.01.2009",
"06.04.2009", "18.04.2009", "02.06.2009", "02.06.2009", "02.07.2009", "14.08.2009", 
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","22.05.2008","22.05.2008","03.10.2008","03.10.2008","01.11.2008","01.11.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "11.06.2009", "11.06.2009", "03.10.2009", "03.10.2009", "01.11.2009", "01.11.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[10] = new Array("Rheinland-Pfalz", 
"28.03.2007", "13.04.2007", "09.07.2007", "17.08.2007", "08.10.2007", "19.10.2007", "24.12.2007", "08.01.2008",
"12.03.2008", "28.03.2008", "23.06.2008", "01.08.2008", "06.10.2008", "17.10.2008", "22.12.2008", "07.01.2009",
"01.04.2009", "17.04.2009", "13.07.2009", "21.08.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","22.05.2008","22.05.2008","03.10.2008","03.10.2008","01.11.2008","01.11.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "11.06.2009", "11.06.2009", "03.10.2009", "03.10.2009", "01.11.2009", "01.11.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[11] = new Array("Saarland", 
"15.02.2007", "21.02.2007", "02.04.2007", "14.04.2007", "09.07.2007", "18.08.2007", "08.10.2007", "20.10.2007", "19.12.2007", "05.01.2008",
"31.01.2008", "06.02.2008", "17.03.2008", "29.03.2008", "30.06.2008", "09.08.2008", "04.10.2008", "18.10.2008", "19.12.2008", "03.01.2009",
"19.02.2009", "25.02.2009", "06.04.2009", "18.04.2009", "13.07.2009", "22.08.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","22.05.2008","22.05.2008","15.08.2008","15.08.2008","03.10.2008","03.10.2008","01.11.2008","01.11.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "11.06.2009", "11.06.2009", "15.08.2009", "15.08.2009", "03.10.2009", "03.10.2009", "01.11.2009", "01.11.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[12] = new Array("Sachsen", 
"12.02.2007", "23.02.2007", "05.04.2007", "13.04.2007", "18.05.2007", "18.05.2007", "26.05.2007", "29.05.2007", "23.07.2007", "31.08.2007", "08.10.2007", "19.10.2007", "22.12.2007", "02.01.2008",
"04.02.2008", "15.02.2008", "20.03.2008", "28.03.2008", "02.05.2008", "02.05.2008", "10.05.2008", "13.05.2008", "14.07.2008", "22.08.2008", "20.10.2008", "30.10.2008", "22.12.2008", "02.01.2009",
"09.02.2009", "21.02.2009", "09.04.2009", "18.04.2009", "22.05.2009", "22.05.2009", "29.06.2009", "07.08.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","31.10.2008","31.10.2008","19.11.2008","19.11.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "31.10.2009", "31.10.2009", "18.11.2009", "18.11.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[13] = new Array("Sachsen-Anhalt", 
"01.02.2007", "10.02.2007", "31.03.2007", "05.04.2007", "18.05.2007", "25.05.2007", "19.07.2007", "29.08.2007", "15.10.2007", "20.10.2007", "21.12.2007", "04.01.2008",
"02.02.2008", "09.02.2008", "17.03.2008", "20.03.2008", "13.05.2008", "23.05.2008", "10.07.2008", "22.08.2008", "13.10.2008", "17.10.2008", "22.12.2008", "05.01.2009",
"02.02.2009", "10.02.2009", "06.04.2009", "18.04.2009", "22.05.2009", "29.05.2009", "25.06.2009", "05.08.2009", 
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","06.01.2008","06.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","31.10.2008","31.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "06.01.2009", "06.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "31.10.2009", "	31.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[14] = new Array("Schleswig-Holstein", 
"02.04.2007", "16.04.2007", "30.04.2007", "30.04.2007", "16.07.2007", "25.08.2007", "15.10.2007", "27.10.2007", "24.12.2007", "08.01.2008",
"20.03.2008", "05.04.2008", "21.07.2008", "30.08.2008", "13.10.2008", "25.10.2008", "22.12.2008", "07.01.2009",
"06.04.2009", "21.04.2009", "20.07.2009", "29.08.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);
vacations[15] = new Array("Thüringen", 
"05.02.2007", "10.02.2007", "02.04.2007", "13.04.2007", "26.05.2007", "29.05.2007", "19.07.2007", "29.08.2007", "15.10.2007", "26.10.2007", "22.12.2007", "05.01.2008",
"04.02.2008", "09.02.2008", "22.03.2008", "28.03.2008", "13.05.2008", "16.05.2008", "10.07.2008", "20.08.2008", "13.10.2008", "24.10.2008", "20.12.2008", "03.01.2009",
"02.01.2009", "07.02.2009", "06.04.2009", "17.04.2009", "25.06.2009", "05.08.2009",
"03.10.2007", "03.10.2007",
"01.01.2008","01.01.2008","21.03.2008","21.03.2008","24.03.2008","24.03.2008","01.05.2008","01.05.2008","01.05.2008","01.05.2008","12.05.2008","12.05.2008","03.10.2008","03.10.2008","31.10.2008","31.10.2008","25.12.2008","25.12.2008","26.12.2008","26.12.2008",
"01.01.2009", "01.01.2009", "10.04.2009", "10.04.2009", "13.04.2009", "13.04.2009", "01.05.2009", "01.05.2009", "21.05.2009", "21.05.2009", "01.06.2009", "01.06.2009", "03.10.2009", "03.10.2009", "31.10.2009", "	31.10.2009", "25.12.2009", "25.12.2009", "26.12.2009", "26.12.2009"
);

calendarDays = new Array("Mo", "Di", "Mi", "Do", "Fr", "Sa", "So");
calendarMonths = new Array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
calendarMonthPrevTitle = "vorheriger Monat";
calendarMonthNextTitle = "n&auml;chster Monat"
calendarTitle = "Kalender";
calendarHolidays = "Ferien";
calendarChooseArea = "Bundesland w&auml;hlen";
calendarInstruction = "Bitte klicken Sie auf das gew&uuml;nschte Datum";
calendarClose = "Fenster schlie&szlig;en";

calendarCss="/fileadmin/rob/templates/css/4_calendar.css";

/*
 * Returns the default calendar width.
 */
function getDefaultCalendarWidth() {
    return 310;
}

/*
 * Returns the default calendar height.
 */
function getDefaultCalendarHeight() {
    return 400;
}

function getDefaultToIncrease() {
    return 1;
}

/*
 * Spawns a calendar window that interacts with a single
 * input field containing a complete date.
 * myField: The input field
 * months: Number of months to display (starting with the current month)
 * pattern: The date pattern used in the input field. See parseDate for allowed patterns.
 * width: width of the popup window (optional; defaults to 310)
 * height: height of the popup window (optional; defaults to 400)
 * validateCalendar: (optional) Indicates whether to modify an additional
 *                   date field after changes in the calendar
 * otherField: (optional) only sensible when validateCalendar is true
 */
function spawnInputFieldCalendarFromTextfield(myField, months, pattern, width, height, validateCalendar, otherField) {
    spawnInputFieldCalendar(myField, months, pattern, width, height, validateCalendar, otherField);
}

/*
 * Spawns a calendar window that interacts with a single
 * input field containing a complete date.
 * myField: The input field
 * months: Number of months to display (starting with the current month)
 * pattern: The date pattern used in the input field. See parseDate for allowed patterns.
 * width: width of the popup window (optional; defaults to 310)
 * height: height of the popup window (optional; defaults to 400)
 * validateCalendar: (optional) Indicates whether to modify an additional
 *                   date field after changes in the calendar
 * otherField: (optional) only sensible when validateCalendar is true
 */
function spawnInputFieldCalendar(myField, months, pattern, width, height, validateCalendar, otherField) {
   var fields = new Array();
   if (otherField != null) {
      fields = new Array(myField.name , otherField.name);
   } else {
     fields = new Array(myField.name);
   }
   var ds = myField.value;
   var start = parseDate(pattern, myField.value);
   var w = width;
   var h = height;
   var numberOfMonths = 12;
   if (months != null) numberOfMonths = months;
   if (isNaN(w) || w == null) w = getDefaultCalendarWidth();
   if (isNaN(h) || h == null) h = getDefaultCalendarHeight();
   var calWin = window.open("", "calWindow", "width=" + w + ",height=" + h);
   if (validateCalendar) {
    generateCal(calWin, 0, myField.form.name, fields, start, start, numberOfMonths, validateCalendar, -1, pattern, false, true);
   } else {
    generateCal(calWin, 0, myField.form.name, fields, start, start, numberOfMonths, validateCalendar, -1, pattern, false, true);
   }
   calWin.focus();
}




/*
 * Spawns a calendar window that interacts with two comboboxes: one with
 * days and one with a month-year combination. Values are expected to be in the
 * format "1", "2", ... "31" and "1.2004", "12.2005", ... respectively.
 * dayField: The day combobox
 * monthField: The month combobox
 * months: The number of months to display (starting with the current month) (defaults to 12)
 * width: width of the popup window (optional; defaults to 310)
 * height: height of the popup window (optional; defaults to 400)
 * validateCalendar: (optional) Indicates whether to modify additional
 *                   date fields (day and month combobox) after changes in the calendar
 * isDeparture: (optional) Indicates whether dayField and monthField form a departure day or not.
 *              Only valid if validateCalendar is true.
 * otherDayField: (optional) The other day combobox. Only valid if validateCalendar is true.
 * otherMonthField: (optional) The other month combobox. Only valid if validateCalendar is true.
 */
function spawnDayAndMonthComboboxCalendar(
    dayField, monthField, months, width, height,
    validateCalendar, isDeparture, otherDayField, otherMonthField) {
    var numberOfMonths;
   var fields = new Array();
   if (otherDayField != null && otherMonthField != null) {
     fields = new Array(dayField.name, monthField.name, otherDayField.name, otherMonthField.name);
   } else {
      fields = new Array(dayField.name, monthField.name);
   }

   // 12 is default if month undefined or zero
   if ((!isNaN(months)) && (months > 0)) {
      numberOfMonths = months;
   } else {
      if (monthField.length > 0) {
         numberOfMonths = monthField.length;
      } else {
         numberOfMonths = 12;
      }
   }

   var w = width;
   var h = height;
   if (isNaN(w) || w == null) w = getDefaultCalendarWidth();
   if (isNaN(h) || h == null) h = getDefaultCalendarHeight();


   var elements = monthField.options[monthField.selectedIndex].value.split(".");
   var start = new Date(elements[1], elements[0]-1, dayField.options[dayField.selectedIndex].value);
   var calWin = window.open("", "calWindow", "width=" + w + ",height=" + h);
   var mode = 0;

   if (isDeparture) mode = 2; else mode=3;
   if (validateCalendar) {
       generateCal(calWin, mode, dayField.form.name, fields, start, start, numberOfMonths, validateCalendar, -1, '', false);
   } else {
       generateCal(calWin, mode, dayField.form.name, fields, start, start, numberOfMonths, validateCalendar, -1, '', false);
   }
   calWin.focus();
}

/*
 * Spawns a calendar window that interacts with a combobox containing
 * complete dates. Values are expected to be in the format
 * "dd.MM.yyyy". The Calendar will only contain the months for which dates are
 * available the combobox and only dates available in the combobox will be selectable.
 * dateField: The combobox
 * booleanSubmitForm
 * width: width of the popup window (optional; defaults to 310)
 * height: height of the popup window (optional; defaults to 400)
 */

function spawnDateComboboxCalendar(dateField, booleanSubmitForm, width, height) {
   var numberOfMonths;
   var start;
   var today = new Date();
   var dxe = parseDate('dd.MM.yyyy', dateField.options[dateField.length - 1].value);
   numberOfMonths =((dxe.getFullYear() - today.getFullYear()) * 12) + (dxe.getMonth() - today.getMonth()) + 1;

   if (dateField.selectedIndex == -1) {
      start = new Date();
   } else if (dateField.selectedIndex == 0) {
      start = parseDateInsecure('dd.MM.yyyy', dateField.options[0].value);
      if (start == null) {
        start = parseDate('dd.MM.yyyy', dateField.options[1].value);
      }
   } else {
      start = parseDate('dd.MM.yyyy', dateField.options[dateField.selectedIndex].value);
   }

   var w = width;
   var h = height;
   if (isNaN(w)) w = getDefaultCalendarWidth();
   if (isNaN(h)) h = getDefaultCalendarHeight();

   var calWin = window.open("", "calWindow", "width=" + w + ",height=" + h);
   var fields = new Array(dateField.name);
   generateCal(calWin, 1, dateField.form.name, fields, start, start, numberOfMonths, false, -1, '', booleanSubmitForm);
   calWin.focus();
}

/*
 * Change the selected month in the calendar window.
 * See generateCal for the params.
 */
function calendarChooseMonth(window, mode, formname, formelements, originalChosenTime, chosenTime, numberOfMonths, validateCalendar, selectedArea, pattern, submit) {

   var chosen = new Date();
   var originalChosen = new Date();
   originalChosen.setTime(originalChosenTime);
   chosen.setTime(chosenTime);
   chosen.setTime(window.document.calForm.monthBox.options[window.document.calForm.monthBox.selectedIndex].value);
   generateCal(window, mode, formname, formelements, originalChosen, chosen, numberOfMonths, validateCalendar, selectedArea, pattern, submit);
}

/*
 * Returns a String representing the given date using the given pattern.
 * See source for allowed patterns.
 * day: Day
 * month: Month
 * year: Year
 * pattern: The date pattern, e.g. "dd.MM.yyyy"
 */
function formatDate(day, month, year, pattern) {
   var dayString = day < 10 ? '0' + day : day;
   var monthString = (month+1) < 10 ? '0' + (month+1) : (month+1);

   if (pattern == 'dd.MM.yyyy') {
    return dayString + "." + monthString + "." + year;
   } else if (pattern == 'dd/MM/yyyy') {
    return dayString + "/" + monthString + "/" + year;
   } else if (pattern == 'MM/dd/yyyy') {
    return monthString + "/" + dayString + "/" + year;
   }
   return "";
}

/*
 * Sets the given date into the given input field after
 * formatting it using the given pattern.
 * See formatData for allowed patterns.
 */
function setDateToFreeTextField(formname, fieldName, day, month, year, pattern) {
    var field = document.forms[formname].elements[fieldName];
    field.value = formatDate(day, month, year, pattern);
}

/*
 * Sets the given date into the given day- and monthYear-combobox.
 */
function setDateToDayAndMonthYearCombobox(formname, dayComboName, monthyearComboName, day, month, year) {

    // There is a problem if the combobox days is filled appropriate to the months -
    // e.g. you cannot select the 31st if it is not in the list ...

    var dayCombo = document.forms[formname].elements[dayComboName];
    var monthYearCombo = document.forms[formname].elements[monthyearComboName];

    foundfield = 0;
    var dayOldIndex = -1;
    var dayNewIndex = -1;

    var monthyearOldIndex = -1;
    var monthyearNewIndex = -1;

    for (var index = 0; index < dayCombo.options.length; index++) {
        var opt = dayCombo.options[index];
        if (opt.selected == true) {
            dayOldIndex = index;
        }
        if (opt.value == day) {
            dayNewIndex = index;
        }
    }

    for (var index = 0; index < monthYearCombo.options.length; index++) {
        var opt = monthYearCombo.options[index];
        var vall = (month + 1) + "." + year;
        if (opt.selected == true) {
            monthyearOldIndex = index;
        }
        if (opt.value.indexOf(vall) == 0) {
            monthyearNewIndex = index;
        }
    }

    if ((dayNewIndex != -1) && (monthyearNewIndex != -1)) {
       dayCombo.options[dayOldIndex].selected = false;
       dayCombo.options[dayNewIndex].selected = true;
       monthYearCombo.options[monthyearOldIndex].selected = false;
       monthYearCombo.options[monthyearNewIndex].selected = true;
    }
}

/*
 * Selects an index in the given combobox.
 * formname: Name of the form of the combobox
 * comboname: Name of the combobox
 * index: Index to select
 */

function setDateToDateCombobox(formname, comboname, index) {
    var combo = document.forms[formname].elements[comboname];
    combo.options[combo.selectedIndex].selected = false;
    combo.options[index].selected = true;
}

/*
 * Checks whether a given combobox contains a given date.
 * Returns -1 if not, the index otherwise.
 * t: a Date
 * formname: name of a form
 * comboname: name of a combobox
 */
function comboboxContainsDay(t, formname, comboname) {
   var txd = "" + t.getDate();
   if (txd.length < 2) txd = "0" + txd;
   var txm = "" + (t.getMonth() + 1);
   if (txm.length < 2) txm = "0" + txm;
   var txy = "" + t.getFullYear();

   var combo = document.forms[formname].elements[comboname];

   for (i = 0; i < combo.options.length; i++) {
      if ((txd + "." + txm + "." + txy) == combo.options[i].value) {
         return i;
      }
   }

   return -1;
};

/*
 * Checks whether a given combobox (containing complete dates) contains the month
 * of the given date. Returns false if not, true otherwise.
 * t: a Date
 * formname: name of a form
 * comboname: name of a combobox
 * date pattern
 */
function comboboxContainsMonth(t, formname, comboname) {
   var txm = "" + (t.getMonth() + 1);
   if (txm.length < 2) txm = "0" + txm;
   var txy = "" + t.getFullYear();

   var combo = document.forms[formname].elements[comboname];

   for (i = 0; i < combo.options.length; i++) {
      if ((txm + "." + txy) == combo.options[i].value.substring(3)) {
         return true;
      }
   }
   return false;
};

/*
 * Parses a date string given in the parameter value
 * according to the given pattern.
 * Allowed patterns (in java.text.SimpleDateFormat syntax)
 * are "dd.MM.yyyy", "dd/MM/yyyy" and "MM/dd/yyyy".
 * The optional parameter allowPast indicates whether dates
 * in the past are allowed.
 * Returns a Date object representing the given date
 * or today if an error occured.
 * If the pattern is unrecognized, an alert-box is displayed.
 */

function parseDate(pattern, value, allowPast) {
    var d = parseDateInsecure(pattern, value, allowPast);
    if (d == null) d = new Date();
    return d;
}

/*
 * Parses a date string given in the parameter value
 * according to the given pattern.
 * Allowed patterns (in java.text.SimpleDateFormat syntax)
 * are "dd.MM.yyyy", "dd/MM/yyyy" and "MM/dd/yyyy".
 * The optional parameter allowPast indicates whether dates
 * in the past are allowed.
 * Returns a Date object representing the given date
 * or null if an error occured.
 * If the pattern is unrecognized, an alert-box is displayed.
 */
function parseDateInsecure(pattern, value, allowPast) {
    var pattern;
    var day;
    var month;
    var year;

    if (pattern=='dd.MM.yyyy') {
         pattern = /^(\d\d)\.(\d\d)\.(\d\d\d\d)$/;
         if (pattern.exec(value) != null) {
            year = RegExp.$3;
            month = RegExp.$2-1;
            day = RegExp.$1;
         } else {
            return null;
         }
    } else if (pattern=='dd/MM/yyyy') {
         pattern = /^(\d\d)\/(\d\d)\/(\d\d\d\d)$/;
         if (pattern.exec(value) != null) {
            year = RegExp.$3;
            month = RegExp.$2-1;
            day = RegExp.$1;
         } else {
            return null;
         }
    } else if (pattern=='MM/dd/yyyy') {
         pattern = /^(\d\d)\.(\d\d)\.(\d\d\d\d)$/;
         if (pattern.exec(value) != null) {
            year = RegExp.$3;
            month = RegExp.$1-1;
            day = RegExp.$2;
         } else {
            return null;
         }
    } else {
        alert("Unsupported pattern " + pattern);
        return null;
    }

    if (!allowPast) {
        var today = new Date();
        if (year < today.getFullYear()) return null;
        if (year == today.getFullYear()) {
            if (month < today.getMonth()) return null;
            if (month == today.getMonth()) {
                if (day < today.getDate()) return null;
            }
        }
    }

    if ((month >= -1)
            && (month<=11)
            && (day >= 1)
            && (day <= 31)) {
        return new Date(year, month, day);
    }

    return null;
}

/*
 * Fills the given combobox with entries for each day of the month.
 */
function setDays(combobox, month, year){
   var isLeapYear=false;
    var daysPerMonth = new Array ("31", "28", "31", "30", "31","30", "31", "31", "30", "31", "30", "31");

   isLeapYear = (((year % 4 == 0) && (year % 100 != 0)) || ( year % 400 == 0))

   if (isLeapYear)
       daysPerMonth[1] = 29;
  else
      daysPerMonth[1] = 28;
   with (combobox) {
        if (length > daysPerMonth[month]) {
            for(i = length-1; i >= daysPerMonth[month]; i--)
                options[i] = null;
        } else if (length < daysPerMonth[month]) {
            for(i=length; i < daysPerMonth[month]; i++)
                options[i] = new Option("" + (i + 1), "" + (i + 1), false, false);

        }
   }
  return true;
}

/*
 * Returns a date being toIncrease days later than the given date.
 * If toIncrease is not set, 1 is used.
 */
function increaseDay(templDate, toIncrease) {
  var retVal;
  retVal = new Date();
  if (toIncrease == null ) {
    //toIncrease = 1;
    toIncrease = getDefaultToIncrease();
  }
  retVal.setFullYear(templDate.getFullYear(), templDate.getMonth(), templDate.getDate() + toIncrease);

  return retVal;
}

/*
 * Returns a date being toDecrease days earlier than the given date.
 * If toDecrease is not set, 1 is used.
 */
function decreaseDay(templDate, toDecrease){
    if (toDecrease == null)
        return increaseDay(templDate, -1);
    else
        return increaseDay(templDate, -1 * toDecrease);
}

/*
 * Convenience method for the validateVacationDateDayAndMonthCombobox.
 * See there for parameters.
 * This method expects objects, while the next method expects elements names!
 */
function validateVacationDateDayAndMonthComboboxByFields(
    changed, depDay, depMonth, retDay, retMonth) {
        if ((retDay == null) || (retMonth == null)) {
            return;
        }
        validateVacationDateDayAndMonthCombobox(
            changed.form.name, changed.name,
            depDay.name, depMonth.name,
            retDay.name, retMonth.name);
}

/*
 * Returns the number of days that should be added to a start date in order
 * to propose a return date.
 */
function getValidateVacationDateReturnOffset() {
    return 1;
}


/*
 * Performs the magic of changing the values of a date input field
 * according to the new value of another date input field.
 * pattern: The date pattern used in the input field. See parseDate for allowed patterns.
 * formName: Name of the form containing the four comboboxes
 * changedElementName: Indicates which element was changed. Has to match one of the
 *                     two fields given in the next four parameters.
 * depField: Name of the departure date input field
 * retField: Name of the return date input field
 */
function validateVacationDateField(
    pattern, formName, changedElementName, depField, retField) {
  var theForm = document.forms[formName];
  var newDate;
  var changedDate;
  var selectedStartDate;
  var selectedEndDate;

  changedDate = parseDate(pattern, theForm.elements[changedElementName].value);
  if (changedElementName == depField) {
     previousDate = parseDateInsecure(pattern, theForm.elements[retField].value);
     if ((previousDate == null) || (previousDate.getTime() < changedDate.getTime())) {
        newDate = increaseDay(changedDate, getValidateVacationDateReturnOffset());
        theForm.elements[retField].value = formatDate(newDate.getDate(), newDate.getMonth(), newDate.getFullYear(), pattern);
     }
  } else {
     // nothing to do yet
  }
}

/*
 * Performs the magic of changing the values of a day/monthYear combobox combination
 * according to the new value of another day/monthYear combobox combination.
 * formName: Name of the form containing the four comboboxes
 * changedElementName: Indicates which element was changed. Has to match one of the
 *                     four comboboxes given in the next four parameters.
 * depDayName: Name of the departure day combobox
 * depMonthName: Name of the departure month-year combobox
 * retDayName: Name of the return combobox
 * retMonthName: Name of the return month-year combobox
 */
function validateVacationDateDayAndMonthCombobox(
    formName, changedElementName, depDayName, depMonthName, retDayName, retMonthName) {
  var theForm = document.forms[formName];
  var nowDate;
  var selectedStartDate;
  var selectedEndDate;

  var selStartMonthYear;
  var selEndMonthYear;

  var startOutput;
  var startChange = "";
  var endOutput;
  var endChange = "";

  nowDate = new Date();

    //parse choosen Dates
    var depMonth = theForm.elements[depMonthName];
    var retMonth = theForm.elements[retMonthName];
    var depDay = theForm.elements[depDayName];
    var retDay = theForm.elements[retDayName];

    if ((depMonth == null) || (retMonth == null)) {
        return;
    }

    selStartMonthYear = depMonth.options[depMonth.selectedIndex].value;
    selEndMonthYear = retMonth.options[retMonth.selectedIndex].value;

    var ix = selStartMonthYear.indexOf('.');
    var sm = selStartMonthYear.substring(0, ix);
    var sy = selStartMonthYear.substring(ix + 1, selStartMonthYear.length);

    ix = selEndMonthYear.indexOf('.');
    var em = selEndMonthYear.substring(0, ix);
    var ey = selEndMonthYear.substring(ix + 1, selEndMonthYear.length);

    selectedStartDate = new Date(sy, sm - 1, (depDay.options[depDay.selectedIndex].value));
    selectedEndDate = new Date(ey, em - 1, (retDay.options[retDay.selectedIndex].value));

    switch (changedElementName) {
        case depDayName:
        case depMonthName:
            if (selectedStartDate.getTime() < nowDate.getTime()) {
                selectedStartDate = nowDate;
            }
            if (selectedEndDate.getTime() <= selectedStartDate.getTime()){
                selectedEndDate = increaseDay(selectedStartDate);
            }

            if (selectedEndDate.getTime() <= nowDate.getTime()) {
                selectedStartDate = increaseDay(nowDate);
                selectedEndDate = increaseDay(selectedStartDate);
            }
            break;
        case retDayName:
        case retMonthName:
            if (selectedEndDate.getTime() <= increaseDay(selectedStartDate)) {
                //selectedStartDate = increaseDay(nowDate);
                selectedEndDate = increaseDay(selectedStartDate);
            }
            break;
    }
    //fill Days for Month
    setDays(depDay, selectedStartDate.getMonth(), selectedStartDate.getFullYear());
    setDays(retDay, selectedEndDate.getMonth(), selectedEndDate.getFullYear());
    //set Values for Selectboxes
    retDay.value = selectedEndDate.getDate();
    depDay.value = selectedStartDate.getDate();
    var valueEndMonth = (selectedEndDate.getMonth() + 1) + "." +  selectedEndDate.getFullYear();
    var valueStartMonth = (selectedStartDate.getMonth() + 1) + "." +  selectedStartDate.getFullYear();
    retMonth.value = valueEndMonth;
    depMonth.value = valueStartMonth;


  return true;
}

/**
 * This function can be called for the onBlur event of input fields
 * containing date information in order to bring the entered date
 * information into a defined format.
 * Default implementation is empty, overwrite it in the brand component
 * if necessary.
 */
function calendarFormatDateFieldFromTextfield(field) {
    // nothing to do by default
}

/*
 * Returns the default calendar width.
 */
function getDefaultCalendarWidth() {
    return 260;
}

/*
 * Returns the default calendar height.
 */
function getDefaultCalendarHeight() {
    return 250;
}

/*
 * Returns the number of days that should be added to a start date in order
 * to propose a return date.
 * Method getConcreteValidateVacationDateReturnOffset is defined
 * in common_extended.js but can be overwritten in module specific
 * js files like packagetour_extended.js.
 */
function getValidateVacationDateReturnOffset() {
    return getConcreteValidateVacationDateReturnOffset();
}

/*
 * Overwritten to do nothing when an input field for a date is clicked.
 */
function spawnInputFieldCalendarFromTextfield(myField, months, pattern, width, height, validateCalendar, otherField) {
}

/*
 * window: Window to use for displaying the calendar
 * mode: 0: Freetext complete date; 1: Combobox complete date; 2: Comboboxes Date, Month/Year (Departure Date)
 *       3: Comboboxes Date, Month/Year (Return Date)
 * formname: Name of form to reflect choices in the calendar
 * formelements: Array of names of form elements to reflect choices in the calendar
 *              if mode 0: one element (input field)
 *              if mode 1: one element (combobox)
 *              if mode 2 or 3: two elements (comboboxes in sequence date, month/year;
 *                           optional other comboboxes for calendar validation in sequence date, month, year)
 * originalChosen: date which was chosen on the original web page
 * chosen: date which defines the month to display
 * numberOfMonth: Number of months to display (starting with the current month)
 * validateCalendar: Indicates whether a service method is to include after a date was selected.
 *                   The service method can influence the contents of other form elements.
 * selectedArea: Index of the area currently selected
 * pattern: display pattern
 * submit: Indicates whether to submit the calendar launching form after a date was selected in the calendar.
 * alwaysOnTop (optional):  Indicates if the popup should alwyas be on top. If alwaysOnTop is true
 *							onblur="self.focus();opener.blur();" is added to the body tag
 */

function generateCal(
        window, mode, formname, formelements, originalChosen, chosen,
        numberOfMonths, validateCalendar, selectedArea, pattern, submit, alwaysOnTop) {
   var calDoc = window.document;
   calDoc.open();

   var selectedMonth;
   var selectedYear;

   var elements = formelements;

   // prepare holidays
   var vacationArray = new Array();

   if (selectedArea > - 1) {
      // Prepare holidays for the selected area
      for (var i = 1; i < vacations[selectedArea].length; i++) {
         var vacationDate = new String(vacations[selectedArea][i]);
         // Compute day
         var vacationDay = vacationDate.substring(0, vacationDate.indexOf('.'));
         // Compute month
         var vacationMonth = vacationDate.substring(vacationDate.indexOf('.') + 1, vacationDate.lastIndexOf('.'));
         // Compute year
         var vacationYear = vacationDate.substring(vacationDate.lastIndexOf('.') + 1);
         // if year has only 2 characters: prefix with "20"
         if (vacationYear < 100) {
            vacationYear = "20" + vacationYear;
         }
         // Create date
         vacationArray[i - 1] = new Date(vacationYear, vacationMonth - 1, vacationDay);
      }
   }

   var today = new Date();

   calDoc.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
   calDoc.writeln('<html>');
   calDoc.writeln('<head>');
   calDoc.writeln('	<title>' + calendarTitle + '</title>');
   calDoc.writeln('	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
   calDoc.writeln('	<link rel="stylesheet" href="' + calendarCss + '" type="text/css">');
   calDoc.writeln('</head>');
   calDoc.writeln('<body id="genCalPopupBody">');
   calDoc.writeln('<form name="calForm">');
   calDoc.writeln('	<div id="genCalPopup">');
   calDoc.writeln('		<div id="genCalPopupHeadline">' + calendarTitle + '</div>');

   calDoc.writeln('<script type="text/javascript" language="JavaScript">function submitMonthSel() {');
   calDoc.writeln('   var forms = new Array(' + formelements.length + ');');

   for (i = 0; i < formelements.length; i++) {
      calDoc.writeln('   forms[' + i + '] = \''  + formelements[i]+ '\';');
   }

   calDoc.writeln('    opener.calendarChooseMonth(self,' + mode + ',\'' + formname  + '\', forms,' + originalChosen.getTime() + ',document.calForm.monthBox.options[document.calForm.monthBox.selectedIndex].value,' + numberOfMonths + ',' + validateCalendar + ',document.calForm.areas.options[document.calForm.areas.selectedIndex].value,\'' + pattern + '\',' + submit + ');');
   calDoc.writeln('}</script>');
   // show selectbox with month and year
   calDoc.writeln('<div id="genCalPopupMonthSelCell"><div id="genCalPopupMonthPrev" title="' + calendarMonthPrevTitle + '" onclick="select = document.getElementById(\'genCalPopupMonthSel\'); if (select.selectedIndex > 0) { select.selectedIndex= select.selectedIndex-1; submitMonthSel()};"></div>');
   calDoc.writeln('<select name="monthBox" onchange="submitMonthSel()" id="genCalPopupMonthSel" class="genCalPopupSel">');

   var optionDate = new Date();
   // preset day to first day because of overrun of last days on some months:
   // starting with (today) 31.10 and after adding 1 month we get 31.11 (non-existant date), therefore
   // we get not november as month but dezember (bugs 42339, 45402)!!!
   optionDate.setDate(1);
   for (i = 0; i < numberOfMonths; i++) {
      selectedMonth = (today.getMonth() + i) % 12;
      optionDate.setMonth(selectedMonth);
      selectedYear = today.getFullYear() + (today.getMonth() + i)/12;
      optionDate.setYear(selectedYear);
      var optionDateString = "" + calendarMonths[optionDate.getMonth()] + " " + optionDate.getFullYear();
      if ((mode != 1)
            || ((mode == 1) && (comboboxContainsMonth(optionDate, formname, elements[0], pattern)))) {
         calDoc.write('<option value = "' + optionDate.getTime() + '"');
         if ((optionDate.getMonth() == chosen.getMonth()) && (optionDate.getFullYear() == chosen.getFullYear())) {
            calDoc.write(' selected');
         }
         calDoc.writeln('>' + optionDateString + '</option>');
      }
   }
   calDoc.writeln('</select>');
   calDoc.writeln('<div id="genCalPopupMonthNext" title="' + calendarMonthNextTitle + '" onclick="select = document.getElementById(\'genCalPopupMonthSel\'); if (select.selectedIndex < select.length-1) { select.selectedIndex=select.selectedIndex+1; submitMonthSel(); };"></div></div>');


   calDoc.writeln('<div id="genCalPopupCalendar">');

   calDoc.writeln('<div id="genCalPopupDayNames">');
   for (i = 0; i < calendarDays.length; i++) {
      calDoc.writeln('<div class="genCalPopupDayName">' + calendarDays[i] + '</div>');
   }
   calDoc.writeln('</div>');

   calDoc.writeln('<div id="genCalPopupDays"><div class="genCalPopupWeek">');

   var iter = new Date(chosen.getFullYear(), chosen.getMonth(), 1);
   var diff = iter.getDay();

   // Weeks start with monday
   if (diff > 0)
    iter = new Date(iter.getTime() - 86400000 * (diff - 1));
   else
    iter = new Date(iter.getTime() - 86400000 *(diff + 6));

   // create days
   for (i = 0; i < 42; i++) {
      var bgc = "genCalPopupDay";

      // check if special vacations are selected
      if (selectedArea > - 1) {
         // check all intervals
         for (var j = 0; j < vacationArray.length; j = j + 2) {
            if ((iter.getTime() >= vacationArray[j].getTime())
                    && (iter.getTime() < (vacationArray[j + 1].getTime() + 86400000))) {
               bgc = "genCalPopupVacationDay";
            }
         }
      }

      var isChosen = false;

      if ((originalChosen != null)
            && (iter.getFullYear() == originalChosen.getFullYear())
            && (iter.getMonth() == originalChosen.getMonth())
            && (iter.getDate() == originalChosen.getDate())) {
                isChosen = true;
      }

      var isToday = false;
      if ((iter.getFullYear() == today.getFullYear())
            && (iter.getMonth() == today.getMonth())
            && (iter.getDate() == today.getDate())) {
                isToday = true;
      }

      var id = '';
      if (isToday && isChosen) {
          id = ' id="genCalPopupDayTodayChosen"';
      } else if (isToday) {
          id = ' id="genCalPopupDayToday"';
      } else if (isChosen) {
          id = ' id="genCalPopupDayChosen"';
      }

      calDoc.writeln('<div class="' + bgc + '"' + id + '>');

      var call = null;
      var isInThePast = false;

      if ((iter.getFullYear() == today.getFullYear())
            && (iter.getMonth() == today.getMonth())
            && (iter.getDate() < today.getDate())) {
                isInThePast = true;
      }

      if (!isInThePast) {
          if (mode == 0) {
            if (iter.getMonth() == chosen.getMonth()) {
              var element = formelements[0];
                call = 'setDateToFreeTextField(\'' + formname + '\',\'' + element + '\',' + iter.getDate() + ',' + iter.getMonth() + ',' + iter.getFullYear() + ',\'' + pattern + '\', self);';
            }
          } else if (mode == 1) {
            var idx = comboboxContainsDay(iter, formname, elements[0], pattern);
            if (idx >= 0) {
                call = 'setDateToDateCombobox(\'' + formname + '\',\'' + elements[0] + '\',' + idx + ', self);';
             }
          } else if ((mode == 2) || (mode == 3)) {
             if (iter.getMonth() == chosen.getMonth()) {
                call = 'setDateToDayAndMonthYearCombobox(\'' + formname + '\',\'' + elements[0] + '\',\'' + elements[1] + '\',' + iter.getDate() + ',' + iter.getMonth() + ',' + iter.getFullYear() + ', self);';

            }
          }
      }

      if (call != null) {
        calDoc.write('<a class="genCalPopupDayLink" href="javascript:opener.' + call + ' window.close();');
        if (validateCalendar) {
            if (mode == 2) {
                calDoc.write('opener.validateVacationDateDayAndMonthCombobox(\''
                    + formname + '\',\''
                    + elements[0] + '\',\''
                    + elements[0] + '\',\''
                    + elements[1] + '\',\''
                    + elements[2] + '\',\''
                    + elements[3] + '\');');
            } else if (mode == 3) {
                calDoc.write('opener.validateVacationDateDayAndMonthCombobox(\''
                    + formname + '\',\''
                    + elements[0] + '\',\''
                    + elements[2] + '\',\''
                    + elements[3] + '\',\''
                    + elements[0] + '\',\''
                    + elements[1] + '\')');
            } else if (mode == 0) {
               calDoc.write('opener.validateVacationDateField(\''
                    + pattern + '\',\''
                    + formname + '\',\''
                    + elements[0] + '\',\''
                    + elements[0] + '\',\''
                    + elements[1] + '\')');
            }
        }
        if (submit) {
            calDoc.write('opener.document.forms[\'' + formname + '\'].submit();');
        }
        calDoc.write('">');
      }

      calDoc.write(iter.getDate());

      if (call != null) {
         calDoc.writeln('</a>');
      }

      calDoc.write('</div>');

      if (i % 7 == 6) {
         calDoc.writeln('</div><div class="genCalPopupWeek">');
      }
      iter.setDate(iter.getDate() + 1);
   }

   calDoc.writeln('</div></div></div>');
   calDoc.writeln('<div id="genCalPopupInstruction">' + calendarInstruction + '.</div>');
   calDoc.writeln('<div id="genCalPopupVacationCell">');
   calDoc.writeln('<div id="genCalPopupVacationLabel">' + calendarHolidays + ':</div>');

   // special areas
   calDoc.writeln('<select name="areas" onChange="submitMonthSel()" id="genCalPopupStateSel" class="genCalPopupSel">');
   calDoc.writeln('<option value = "-1">' + calendarChooseArea);
   for (var i = 0; i < vacations.length; i++) {
      calDoc.write('<option ');
      // selected area must be reselected upon regeneration
      if (i == selectedArea) {
         calDoc.write('selected ');
      }
      calDoc.writeln('value = "' + i + '"> ' + vacations[i][0]);
   }
   calDoc.writeln('</select>');
   calDoc.writeln('</div>');
   calDoc.writeln('<div id="genCalPopupWindowCloseCell"><a id="genCalPopupWindowClose" href="javascript:window.close()">' + calendarClose + '</a></div>');
   calDoc.writeln('</div>');
   calDoc.writeln('</form>');
   calDoc.writeln('</body>');
   calDoc.writeln('</html>');
   calDoc.close();
};