function prepRollOvers () {
	var houses
	if (houses = document.getElementsByTagName("div")) {
		for(i=0; i<houses.length; i++) {
			if (houses[i].getAttribute("id") == "ac" ||
					   houses[i].getAttribute("id") == "bg" ||
					   houses[i].getAttribute("id") == "p" ||
					   houses[i].getAttribute("id") == "m") {
				
				houses[i].onmouseover = function () {
					showBlurb(this)
				}
				
				houses[i].onmouseout = function () {
					hideBlurb(this)
				}
			}
		}
	}
}

window.onload = function () {
	prepRollOvers()
	setCalendarLink()
}

function showBlurb(targ) {
	var blurbName = targ.getAttribute('id')+"_over"
	var blurb
	if (blurb = document.getElementById(blurbName)) {
		blurb.style.display = "block"
	}
}
function hideBlurb(targ) {
	var blurbName =targ.getAttribute('id')+"_over"
	var blurb
	if (blurb = document.getElementById(blurbName)) {
		blurb.style.display = "none" 
	}
}


function setCalendarLink () {
	var cal
	if (cal = document.getElementById("calendarLink")) {
		cal.onclick = function () {
			return toggleCalendar()
		}
	}
	var cal2
	if (cal2 = document.getElementById("calendar")) {
		cal2.style.height = "55px"
		cal2.setAttribute("open", 0)
	}
}
function toggleCalendar () {
	var cal
	if (cal = document.getElementById('calendar')) {
		if (cal.getAttribute('open') == 1) {
			closeCalendar()
			return false
		} else {
			expandCalendar()
			return false
		}
	}
}
function expandCalendar () {
	var cal
	if (cal = document.getElementById('calendar')) {
		if (parseInt(cal.style.height) < 485) {
			cal.style.height = Math.ceil(parseInt(cal.style.height)+ (486-parseInt(cal.style.height))/4)+"px";
			setTimeout("expandCalendar()", 40);
		} else {
			cal.setAttribute("open", 1);
			updateCalendar(cal)
		}
		
	}
}
function closeCalendar () {
	var cal
	if (cal = document.getElementById('calendar')) {
		if (cal.getAttribute("open") == 1) {
			cal.setAttribute("open", 0);
			updateCalendar(cal)
		}
		
		if (parseInt(cal.style.height) > 55) {
			cal.style.height = Math.floor(parseInt(cal.style.height) + (54-parseInt(cal.style.height))/4)+"px";
			setTimeout("closeCalendar()", 40);
		}		
	}
}

function updateCalendar  (cal) {
		
	if (cal.getAttribute("open") == 1) {
		var span = cal.getElementsByTagName("span")[0];
		span.innerHTML = "-";
		
		var calBody;
		if (calBody = document.getElementById("calBody")) {
			calBody.style.display = "block";
			cal.style.zIndex = 999;
			
		}
		
	} else {
		
		var span = cal.getElementsByTagName("span")[0];
		span.innerHTML = "+";
		
		
		var calBody;
		if (calBody = document.getElementById("calBody")) {
			calBody.style.display = "none";
			cal.style.zIndex = 50;
		}
		
	}

}