﻿function en_today()
{

en_label = document.getElementById("Today_EN");

if (typeof today_en_is != "undefined")

	{

		en_label.innerHTML = today_en_is;
	}
	
	else 
		
		{
		
			en_label.innerHTML = "";
			
		}		
		
}

//end function en_today

function show_en_list()

{

EN_HOL_label = document.getElementById("EN_HOL");

var en_list="";

// sort on date array

BubbleSortAscend(en_hol_list_b,en_hol_list_a,en_hol_list_length)

for (var i=0; i<en_hol_list_length; i++)

{

which_year_array=en_hol_list_b[i].split("-");

get_ddd()

which_day_ddd = day_en[which_day_dd];

en_h_name =  "<tr>" + "<td align=\"right\">" + en_hol_list_a[i] + ",&nbsp;</td>";

en_h_day = "<td align=\"right\">" + which_day_ddd + ",&nbsp;</td>";

en_h_date = "<td>" + en_hol_list_b[i] + "</td>" + "</tr>";

en_list = en_list + en_h_name + en_h_day + en_h_date;

}

EN_HOL_label.innerHTML = "<table summary=\"layout\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" >" +
"<tr>" + "<td>" + en_list  + "</td>" +  "</tr>" + "</table>";

}

//end function show_en_list

function de_today()
{

de_label = document.getElementById("Today_DE");

if (typeof today_de_is != "undefined")

	{

		de_label.innerHTML = today_de_is;
	}
	
	else 
		
		{
		
			de_label.innerHTML = "";
			
		}		
		
}

//end function de_today

function show_de_list()

{

DE_HOL_label = document.getElementById("DE_HOL");

var de_list="";

// sort on date array

BubbleSortAscend(de_hol_list_b,de_hol_list_a,de_hol_list_length)

for (var i=0; i<de_hol_list_length; i++)
{

which_year_array=de_hol_list_b[i].split("-");

get_ddd()

which_day_ddd = day_de[which_day_dd];

de_h_name =  "<tr>" + "<td align=\"right\">" + de_hol_list_a[i] + ",&nbsp;</td>";

de_h_day = "<td align=\"right\">" + which_day_ddd + ",&nbsp;</td>";

de_h_date = "<td>" + de_hol_list_b[i] + "</td>" + "</tr>";

de_list = de_list + de_h_name + de_h_day + de_h_date;

}

DE_HOL_label.innerHTML = "<table summary=\"layout\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" >" +
"<tr>" + "<td>" + de_list  + "</td>" +  "</tr>" + "</table>";

}

//end function show_de_list

// dates

de_hol_list_full_a = new Array();
de_hol_list_full_b = new Array();
de_hol_list_a = new Array();
de_hol_list_b = new Array();

en_hol_list_full_a = new Array();
en_hol_list_full_b = new Array();
en_hol_list_a = new Array();
en_hol_list_b = new Array();

day24 = 86400000;
month30 = day24 * 30;

time_in_30_days = new Date();

time_in_30_days.setTime(time_in_30_days.getTime() + month30);

this_year_in_30_days=time_in_30_days.getFullYear();
this_month_in_30_days=time_in_30_days.getMonth() + 1;
this_date_in_30_days=time_in_30_days.getDate();

if (this_month_in_30_days < 10)

	{
		this_month_in_30_days="0" + this_month_in_30_days;
	}

if (this_date_in_30_days < 10)

	{
		this_date_in_30_days="0" + this_date_in_30_days;
	}

iso_today_in_30_days = this_year_in_30_days + "-" + this_month_in_30_days + "-" + this_date_in_30_days;

 anc_start_de="<a href=\"calendar.asp\" alt=\"Kalender\" title=\"Kalender\" >";
 
 anc_start_en="<a href=\"calendar.asp\" alt=\"Calendar\" title=\"Calendar\" >";
 
 anc_end="</a><br />";

 today = new Date();

 this_year=today.getFullYear();
 this_month=today.getMonth() + 1;
 this_date=today.getDate();


if (this_month < 10)

	{
		this_month="0" + this_month;
	}

if (this_date < 10)

	{
		this_date="0" + this_date;
	}

 iso_today = this_year + "-" + this_month + "-" + this_date;

 day_en = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

 day_de = new Array ("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");

 day_num = today.getDay();

 this_day_en = day_en[day_num];

 this_day_de = day_de[day_num];

function get_ddd()

	{
	
		which_year = 1 * which_year_array[0];
		which_month = (1 * which_year_array[1]) - 1;
		which_day_mm = 1 * which_year_array[2];

		 which_date = new Date();

		which_date.setFullYear(which_year, which_month, which_day_mm);

		which_day_dd = which_date.getDay();

	}
	
//end function get_ddd

//XMLHttpRequest version 2006-11-25, ??? keep the DOM stuff as it might still work with older browsers ???

// get the German dates

function hol_de()

	{

		objNodeList_de_a = xmlDoc_de.getElementsByTagName("n");
		objNodeList_de_b = xmlDoc_de.getElementsByTagName("d");

// make the assumption that both are of equal length, if not the xml file is incorrect

		 today_is = "";

    	for (i=0; i<objNodeList_de_a.length; i++) 

    		{ 
 
				if	(iso_today == objNodeList_de_b.item(i).firstChild.nodeValue)

// .text instead of .firstChild.nodeValue only works with IE
 
					{	today_is = objNodeList_de_a.item(i).firstChild.nodeValue;

    				}
    		}

    			if (today_is == "")

					{	

						today_is_de = anc_start_de + this_day_de + anc_end;
	
					}

				else

					{

						today_is_de = anc_start_de + today_is + anc_end;

					}
				
today_de_is = today_is_de;
	
//get the German list of dates 30 days ahead

de_list_length = objNodeList_de_a.length;

	j=0;
	
	for ( i=0; i<de_list_length; i++) 

    {
    	de_hol_list_full_a[i] = objNodeList_de_a.item(i).firstChild.nodeValue;
    	de_hol_list_full_b[i] = objNodeList_de_b.item(i).firstChild.nodeValue;

// .text instead of .firstChild.nodeValue only works with IE

	if (de_hol_list_full_b[i] >= iso_today && de_hol_list_full_b[i] <= iso_today_in_30_days)
	
	{
	
		de_hol_list_a[j] = de_hol_list_full_a[i];
		de_hol_list_b[j] = de_hol_list_full_b[i];

		j++;

	}

    }

	de_hol_list_length = j;

			}

//end function hol_de

// get the English dates

function hol_en()

	{

		objNodeList_en_a = xmlDoc_en.getElementsByTagName("n");
		objNodeList_en_b = xmlDoc_en.getElementsByTagName("d");

// make the assumption that both are of equal length, if not the xml file is incorrect

		 today_is = "";

		for (i=0; i<objNodeList_en_a.length; i++) 

			{
 
				if	(iso_today == objNodeList_en_b.item(i).firstChild.nodeValue)
 
					{
					
						today_is = objNodeList_en_a.item(i).firstChild.nodeValue;

					}
			}

				if (today_is == "")

					{	

						today_is_en = anc_start_en + this_day_en + anc_end;

					}

   				else

					{

						today_is_en = anc_start_en + today_is + anc_end;

					}

today_en_is = today_is_en;

// get the English of dates 30 days ahead

en_list_length = objNodeList_en_a.length;

	 j=0;

   for ( i=0; i<en_list_length; i++) 

    {
 
    en_hol_list_full_a[i] = objNodeList_en_a.item(i).firstChild.nodeValue;
    en_hol_list_full_b[i] = objNodeList_en_b.item(i).firstChild.nodeValue;

// .text instead of .firstChild.nodeValue only works with IE
 
	if (en_hol_list_full_b[i] >= iso_today && en_hol_list_full_b[i] <= iso_today_in_30_days)
	{
	 en_hol_list_a[j] = en_hol_list_full_a[i];
	 en_hol_list_b[j] = en_hol_list_full_b[i];

	 j++;

	}

    }

	en_hol_list_length = j;

}

//end function hol_en

function BubbleSortAscend(arrayName_a,arrayName_b,length) 
{ 
    for ( i=0; i<(length-1); i++) 
    { 
        for ( b=i+1; b<length; b++) 
{ 
            if (arrayName_a[b] < arrayName_a[i]) 
    { 

	// swap them for array being tested

		temp_a = arrayName_a[i]; 
		arrayName_a[i] = arrayName_a[b]; 
		arrayName_a[b] = temp_a;

	// swap them for companion of array being tested

		temp_b = arrayName_b[i]; 
		arrayName_b[i] = arrayName_b[b]; 
		arrayName_b[b] = temp_b;
		
    } 
        } 
    } 

}

// end function BubbleSortAscend

function state_Change_en()

{

// if xmlDoc_en shows "loaded"

		if	(xmlDoc_en.readyState==4)
		
			{
			
// if "OK"
				if (xmlDoc_en.status==200)
		
					{
			
    // ...some code here...

						xmlDoc_en = xmlDoc_en.responseXML;
				
						hol_en();
						
						en_today();
	
if (document.title == "Calendar / Kalender")

					{	
						show_en_list();
						
					}
			}

				else
			
					{

						alert("Problem retrieving XML data");
					
					}
				
			}
}

// end function state_Change_en

function state_Change_de()

{

// if xmlDoc_de shows "loaded"

	if (xmlDoc_de.readyState==4)
	
		{
		
// if "OK"
			if (xmlDoc_de.status==200)
			
				{
				
// ...some code here...

					xmlDoc_de = xmlDoc_de.responseXML;

					hol_de();

					de_today();
					
if (document.title == "Calendar / Kalender")

					{	
						show_de_list();
						
					}

//

		}
				
			else
			
				{
				
					alert("Problem retrieving XML data");
					
				}
				
		}
		
}

// end function state_Change_de

function get_de_xml()

{

	url="de_hol.xml";

	xmlDoc_de=null;

// code for Mozilla, IE, etc.

	if (window.XMLHttpRequest)
	
		{
		
			xmlDoc_de=new XMLHttpRequest();
			
		}
		
// code for old IE

	else if (window.ActiveXObject)
	
		{
		
			xmlDoc_de=new ActiveXObject("Microsoft.XMLHTTP");
			

		}

	if (xmlDoc_de!==null)

		{
		
			xmlDoc_de.onreadystatechange=state_Change_de;
		
			xmlDoc_de.open("GET",url,true);
			
			xmlDoc_de.send(null);
			
		}

	else
	
		{
		
			alert("Your browser does not support XMLHttpRequest.");
			
		}

}

// end function get_de_xml


// ************************************

function get_en_xml()

{

	 url="en_hol.xml";

	xmlDoc_en=null;
	
// code for Mozilla, etc.

	if	(window.XMLHttpRequest)
	
		{
		
			xmlDoc_en=new XMLHttpRequest();
			
		}
		
// code for IE

	else if (window.ActiveXObject)
	
			{
						
				xmlDoc_en=new ActiveXObject("Microsoft.XMLHTTP");

			}

	if (xmlDoc_en!=null)
	
			{
			
				xmlDoc_en.open("GET",url,true);
				
				xmlDoc_en.onreadystatechange=state_Change_en;
				
				xmlDoc_en.send(null);
				
			}

	else
	
			{
					
				alert("Your browser does not support XMLHttpRequest.");
				
			}

}

//end function get_en_xml

// *************************************************

function today_de()

{
if (typeof today_de_is != "undefined")

{
document.write( today_de_is );

}

}

//end function today_de

function today_en()

{
if (typeof today_en_is != "undefined")
{

document.write( today_en_is );

}

}

// Copyright © Mark Plews 2002 - 2011

