<!--

var dateListElementId = 'datesList';
var datesElementId = 'dates';
var currentDateItemId = null;
;
function initDates() {
	var dateButtonHash = document.location.hash;
	
	var dateListContainer = document.getElementById(dateListElementId);
	var dateList = dateListContainer.getElementsByTagName('ul')[0];
	
	
	var childN = dateList.childNodes;
	var theNode;
	var firstLi = 0;

	for(var i=0; i< childN.length; i++) { // LOOP THROUGH ALL CHILD NODES OF MAIN MENU LIST
		theNode = childN[i].nodeName;
		if(theNode == 'LI') {
			
			linkObj = childN[i].getElementsByTagName('a')[0];
			
				
			// SET ON CLICK HANDLER FOR THE LINK WITHIN EACH MAIN LIST ITEM
			
			
			linkObj.onclick = hiliteDate;
			if(linkObj.hash == dateButtonHash) {
				
				setDateDisplay(linkObj);
				
			}
			
		}
													
	}
	
 
}

function getSubStringSplit (str,delim,arrayPos) {
	
	var mySubStr = str.split(delim)[arrayPos];
	if(mySubStr == "undefined") {
		alert("ERROR");
		return false;
		
	}
	return mySubStr;
	
}


function hiliteDate (obj) {
	var li = this.parentNode;

	//var itemID = li.getAttribute('id');
	
	var linkTag =li.getElementsByTagName('a')[0];
	setDateDisplay (linkTag);
}

function setDateDisplay (linkTag) {
	var shortRef = getSubStringSplit (linkTag.href, "#",1);
	/*if(shortRef == false) {
		alert("ERROR");
		return;
		
	}*/
	linkTag.style.color = "#000";
	linkTag.style.backgroundColor = "#cccc99";
	linkTag.onmouseover = function () {
		this.style.color = "#000";
	}
	linkTag.onmouseout = function () {
		this.style.color = "#000";
	}
	
	//var dateId = "day-" + itemID;
	var dateId = shortRef;
	
	var dateContainer = document.getElementById(dateId);
	
	dateContainer.style.border = "solid 1px #80714b";
	dateContainer.style.backgroundColor = "white";
	unHiliteDates(dateContainer,dateId);
	unhiliteButtons (linkTag)
	return true;
}

function unHiliteDates(currentObj,dateId) {
	
	var datesContainer = document.getElementById(datesElementId);
	var childN = datesContainer.childNodes;
	var theNode;
	var theId
	for(var i=0; i< childN.length; i++) { // LOOP THROUGH ALL CHILD NODES OF MAIN MENU LIST
		theNode = childN[i].nodeName;
		if(theNode == 'DIV') {
			theObj = childN[i]
			theId = childN[i].getAttribute('id');
			if(theId != dateId) {
				theObj.style.border = "solid 1px #edecdd";
				theObj.style.backgroundColor = "#edecdd";
				
				
			}
		}
													
	}
}

function unhiliteButtons (dateButton) {
	
	var dateButtonsContainer = document.getElementById(dateListElementId);
	var dateButtonsList = dateButtonsContainer.getElementsByTagName('ul')[0];
	var childN = dateButtonsList.childNodes;
	var theNode;
	var theId;
	var buttonObj;
	for(var i=0; i< childN.length; i++) { // LOOP THROUGH ALL CHILD NODES OF MAIN MENU LIST
		theNode = childN[i].nodeName;
		
		if(theNode == 'LI') {
		
			buttonObj = childN[i].getElementsByTagName('a')[0];
			
			if(buttonObj != dateButton) {
				buttonObj.style.color = "#CCA635";
				buttonObj.style.backgroundColor = "#000";
				buttonObj.onmouseover = function () {
					this.style.color = "#fff";
				}
				
				buttonObj.onmouseout = function () {
					this.style.color = "#CCA635";
				}
				
			}
		}
													
	}
}

function rollDate () {
	alert("BOB");
	//this.style.color = "#fff";
}

function rollDate () {
	this.style.backgroundColor = "#000";
}


if (window.attachEvent) window.attachEvent("onload", initDates);
if (window.addEventListener) window.addEventListener( "load", initDates, false );
//-->

