/*	-- -- -- -- -- -- --	mezzoblue v6 archives javascript	last edit: 31 dec 08	-- -- -- -- -- -- --	File Contents:	Functions to add UI finishing touches to the archive selectors	*/function getSelected(obj) {	if (obj.hasChildNodes()) {		var children = obj.childNodes;		for (i = 0; i < children.length; i++) {			if (children[i].nodeName == "OPTION") {				if (children[i].selected) {					return children[i].getAttribute("value");				}			}		}	}}function adjustMonths() {	var year = document.getElementById("archive-year");	var month = document.getElementById("archive-month");	var monthsel = document.getElementById("selected-month");	var selectedMonth = monthsel.getAttribute("value");	var d = new Date();	var skip = false;	var monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");	// loop variables	var children, newMonth, monthValue, i, txt;	// find the currently selected year	var selectedYear = getSelected(year);	// rebuild the monthly menu	if (month.hasChildNodes()) {		children = month.childNodes;		// clear the menu		while (month.firstChild) {			month.removeChild(month.firstChild);		}		// rewrite the menu		for (i = 0; i < monthNames.length; i++) {			skip = false;			// I only have archives for nov/dec 2002			if (selectedYear == "2002") {				if (i < 10) {					skip = true;				}			}			// and lets get rid of anything past the current month			if (selectedYear == (d.getFullYear())) {				if (i > d.getMonth()) {					skip = true;				}			}			if (skip == false) {				newMonth = document.createElement("option");				monthValue = String(i + 1);				if (monthValue.length == 1) {					monthValue = "0" + monthValue;				}				newMonth.setAttribute("value", monthValue);				if (i == (selectedMonth - 1)) {					newMonth.setAttribute("selected", "selected");				}				// newMonth.text = monthNames[i];				txt = document.createTextNode(monthNames[i]);				newMonth.appendChild(txt);				month.appendChild(newMonth);			}		}	}}function adjustAction() {	var formObj = document.getElementById("archive-form");	var year = document.getElementById("archive-year");	var month = document.getElementById("archive-month");	// find the currently selected year	var selectedYear = getSelected(year);	// find the currently selected year	var selectedMonth = getSelected(month);	formObj.setAttribute("action", "/archives/" + String(selectedYear) + "/" + String(selectedMonth) + "/");}window.onload = function() {	// Test if DOM is available	if(!document.getElementById || !document.createElement || !document.appendChild){return;}	adjustMonths();	adjustAction();	var year = document.getElementById("archive-year");	year.onchange = function() {		adjustMonths();		adjustAction();	}	var month = document.getElementById("archive-month");	month.onchange = function() {		adjustAction();	}}