var stop = 0;     //The variable "stop" controls whether or not the window containing the full day's events should be popped-up

function calendar() {

	var days = document.getElementsByTagName("td");     //Create an array with all instances of "td"
	
	for (var i=0; i<days.length; i++) {     //Cycle through all tds    	
		if (days[i].className == "event") {     //Check to see if the td has any events associated with it

			var events = days[i].getElementsByTagName("a");     //Create an array of all instances of anchor tags inside the current td
			
			for (var j=0; j<events.length; j++) {     //Cycle through all anchors 
				events[j].date = events[j].href;     //Gives every anchor in the "events" array a variable called "date" and sets that variable to the href of the anchor
				events[j].onmouseover = mouseOverLink;
				events[j].onclick = function () 
					{
						return userClick(this.date);
						changeStop();
					}
				events[j].onmouseout = mouseOutLink;
			}
	
			days[i].date = events[0].href;     //Gives every td in the "days" array a variable called "date" and sets that variable to the href of the first anchor in that td
			days[i].onmouseover = mouseOverDay;
			days[i].onmouseout = mouseOutDay;
			days[i].onclick = function () 
				{
					if (stop == 0) {     //If the user is hovering on an anchor in the td, this window will not pop-up
						return userClick(this.date);
					}
				}
		}
	}
}

	function mouseOverLink() {
		stop = 1;
	}

	function mouseOutLink () {
		stop = 0;
	}

	function mouseOverDay() {
		this.className = "eventOver pointer";
	}

	function mouseOutDay() {
		this.className = "event";
	}

	function userClick(date) {
		window.open(date,"Window1","menubar=no,width=430,height=360,scrollbars=yes,toolbar=no");     //Open a new window using the href of whichever element is calling this function
		return false;
	}