var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

var today = new Date();
var year = today.getYear();
if (year < 1900) {
    year += 1900;
}
var month = today.getMonth();
var date = today.getDate();
var hours = today.getHours();
var minutes = today.getMinutes();
if (minutes < 10) {
    minutes = "0" + minutes;
}

var events = [
    [1, 20, "Birthday of HRH The Countess of Wessex"],
    [2, 6, "Her Majesty's Accession"],
    [2, 19, "Birthday of HRH The Duke of York"],
    [3, 8, "Commonwealth Day"],
    [3, 10, "Birthday of HRH The Earl of Wessex"],
    [4, 21,  "Birthday of Her Majesty the Queen"],
    [4, 23, "Saint George's Day"],
    [4, 25, "Anzac Day"],
    [5, 9, "Europe Day"],
    [6, 2, "Coronation Day"],
    [6, 10, "Birthday of HRH The Duke of Edinburgh"],
    [6, 13, "Official celebration of Her Majesty\'s Birthday"],
    [7, 15, "Saint Swithun\'s Day"],
    [7, 17, "Birthday of HRH The Duchess of Cornwall"],
    [8, 15, "Birthday of The Princess Royal"],
    [9, 0, ""],
    [10, 0, ""],
    [11, 8, "Remembrance Day"],
    [11, 11, "Armistice Day"],
    [11, 14, "Birthday of HRH The Prince of Wales"],
    [11, 20, "Her Majesty\'s Wedding Day"],
    [12, 0, ""]
];

function makeEventsList() {

    var ee = '';
    var i, j, fred;
    var noEvents = '<tr><td width=120px>&nbsp;</td><td>No flag days this month</td></tr>';

    for (i = 0; i < 12; i++) { //i is order of display, starting with system month
        j = i + month;
        if (j > 11) {
            j -= 12;
        } //j is calendar month, 0 to 11
        ee += '<h3>' +  months[j] + '</h3><table>';
        for (fred in events) {
            if (events[fred][0] - 1 === j) {
                ee += (events[fred][1] === 0) ? noEvents : '<tr><td width=120px>' + events[fred][1] + '</td><td>' + events[fred][2] + '</td></tr>';
            }
        }
        ee += '</table>';
    }

    return ee;
}

function link(url, text, footer, tgt) {
    var txt, targ, ff;
	if (!text) {
		txt = '<font size="2">Top</font>';
		footer = "Top of page";
	} else {
		txt = text;
	}
	footer = (!footer) ? text : footer;
    targ = (!tgt) ? "_self" : "_blank";
	ff = '<A CLASS="leftmenu" TARGET="' + targ + '" HREF="' + url + '" ';
	ff += 'onmouseover="status = \'' + footer + '\'; return true;" ';
	ff += 'onmouseout="status = \'The Kennington Village Website\'; return true;">';
	ff += txt;
	ff += '</A><br>';

    return ff;
}

//menu='<td WIDTH="180" class=leftmenu>';

var menu = '<table width="180" cellpadding=0 cellspacing=0><tr><td>';
menu += '<h2>Kennington Village</h2>';

menu += '<h3 class=menu>Home section</h3>';
menu += link("default.htm", "Home page");
//link("news.htm","News and coming events");
menu += link("location.htm", "Location", "See a map of the district");
menu += link("gallery.htm", "Photo Galleries");
menu += link("website.htm", "About the website", "How was Kennington&acute;s website born?");

menu += '<h3 class=menu>Parish Council</h3>';
menu += link("foia2000.htm", "Freedom of information");
menu += link("pcmeetings.htm", "Dates of meetings");
menu += link("minutes/planningagenda.pdf", "Planning Comm. agenda", "", "1");
menu += link("pcminutes.htm", "Parish council minutes");
menu += link("clerk february 10.htm", "Clerk\'s report");
menu += link("pcmembers.htm", "Parish council members");
menu += link("government.htm", "Government", "Local and regional government, including Parish Council");


menu += '<h3 class=menu>About town</h3>';
menu += link("history.htm", "History", "Find out Kennington#039;s past");
menu += link("streetnames.htm", "The street where you live");
menu += link("adtts.htm", "Abingdon Twin Towns");
menu += link("flagdays.htm", "Flag days", "High days and holidays");

menu += '<h3 class=menu>Services</h3>';
menu += link("churches.htm", "Churches", "Details of the church communities in Kennington");
menu += link("http://www.kenningtonhealthcentre.co.uk/", "Health", "The Kennington Health Centre and other resources", 1);
menu += link("education.htm", "Education", "Schools, colleges and other institutions");
menu += link("http://www.oxfordshire.gov.uk/wps/portal/publicsite/councilservices?WCM_GLOBAL_CONTEXT=http://apps.oxfordshire.gov.uk/wps/wcm/connect/occ/Internet/Council+Services/Leisure+and+culture/Libraries/Your+local+library/LC+-+L+-+YLL+-+Kennington", "Library", "Details of the Library Service", 1);
menu += link("http://www.kenningtonchronicle.org.uk/", "Kennington Chronicle", "The village magazine, delivered to every home", 1);

menu += '<h3 class=menu>Leisure</h3>';
menu += link("leisure.htm", "Local clubs and societies", "Get involved in your sport or pastime");

menu += '<h3 class=menu>Businesses</h3>';
menu += link("businesses.htm", "Kennington and district", "Find details of local businesses");

menu += '<h3 class=menu>Links</h3>';
menu += link("links.htm", "Useful info", "Links to national and local websites");

menu += '<h3 class=menu>Diary</h3>';

var kk = months[today.getMonth()].toLowerCase() + 'diary.htm';

menu += link(kk, "What\'s on?", "Events to note in Kennington");

menu += '<p class=time>' + days[today.getDay()] + ' '  + date + ' ' + months[month] + ' ' + year;

menu += '<br>' + hours + ':' + minutes;

for (var ii in events) {
    if ((events[ii][0] - 1 === month) && (events[ii][1] === today.getDate())) {
	    menu += '<br><span style="color:#000;">Flag day:</span> ' + events[ii][2];
    }

}


menu += '</td></tr></table>';


//menu += '</TD>';// end of left hand menu panel

//alert(menu);
document.write(menu);


