/*

Mike's Calendar script popup thingifier. Make's link mouseover popups work in browsers that do not support toggling
the display or visibility property of element x (for example) in a css statement such as: *:hover x{}

*/

function enableCalPopups(){

	if(document.getElementById){
		x=document.getElementsByTagName('DIV');
		for(var i=0; i < x.length; i++){
			if(x[i].className == 'cal_event_bubble'){
				x[i].parentNode.parentNode.onmouseover=function(){//targets the TD
					for(j=0;j<this.childNodes.length;j++){
						if(this.childNodes[j].tagName == 'DIV' && this.childNodes[j].className == 'cal_iefix'){
							var parent=this.childNodes[j];
							break;
						}
					}
					for(k=0;k<parent.childNodes.length;k++){
						if(parent.childNodes[k].tagName == 'DIV' && parent.childNodes[k].className == 'cal_event_bubble'){
							var bubble=parent.childNodes[k];
							bubble.style.visibility='visible';
						}
					}
				}
				x[i].parentNode.parentNode.onmouseout=function(){//targets the TD
					for(j=0;j<this.childNodes.length;j++){
						if(this.childNodes[j].tagName == 'DIV' && this.childNodes[j].className == 'cal_iefix'){
							var parent=this.childNodes[j];
							break;
						}
					}
					for(k=0;k<parent.childNodes.length;k++){
						if(parent.childNodes[k].tagName == 'DIV' && parent.childNodes[k].className == 'cal_event_bubble'){
							var bubble=parent.childNodes[k];
							bubble.style.visibility='hidden';
						}
					}
				}
					//moves popups up if they would otherwise extend below the bottom of the page, increasing the height.
				bubble=x[i];
				pageOffset=document.getElementById('wrapper').offsetHeight;
				if(!bubble.style.top)
					var top=0;
				else
					var top=bubble.style.top;
				if((getOffsetTop(bubble.parentNode)+bubble.offsetHeight-pageOffset) > 0)
					bubble.style.top=top-(getOffsetTop(bubble.parentNode)+bubble.offsetHeight-pageOffset+10)+'px';
			}
		}
	}
}

function getOffsetTop (el){
	var ot = el.offsetTop;
	while ( ( el = el.offsetParent ) != null )	{
		ot += el.offsetTop;
	}
	return ot;
}