function calendar_init() 
{
	var timeout_varsec = 4000;
	var the_timeout='';
  
	function getScroll() 
	{
  		if (document.body.scrollTop != undefined) 								// IE model
  		{	
  			var ieBox = document.compatMode != "CSS1Compat";
  			var cont = ieBox ? document.body : document.documentElement;
      		return {x : cont.scrollLeft, y : cont.scrollTop};
  		} 
  		else 
  		{
  			return {x : window.pageXOffset, y : window.pageYOffset};
  		}
	}
  
    function showNote(e) 
    {
    	if (!e)
	    	e = event;
	    var objTip = document.getElementById('tooltip');
    	if(objTip) 
		{
    		var scroll = getScroll();
   			objTip.style.left = e.clientX + scroll.x;
   			objTip.style.top  = e.clientY + scroll.y + 5;
    		
   			theTip = this.getElementsByTagName('span');							// get hidden span content
    		objTip.innerHTML = theTip[0].innerHTML;
    		objTip.style.visibility = 'visible';
		}
	}
  
	function hideNote() 
	{
    	if(document.getElementById('tooltip')) 
    	{
      		clearTimeout(the_timeout);
      		the_timeout=setTimeout(function(){document.getElementById('tooltip').style.visibility = 'hidden';  }, timeout_varsec);
    	}
	}
  
	function hideSelf()
	{
    	if(document.getElementById('tooltip')) 
    	{
      		document.getElementById('tooltip').style.visibility = 'hidden';
  		}
	}
  
	function createCookie() 
	{
		var date = new Date();
		date.setTime(date.getTime()+(24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
				
		var scroll = getScroll();
		var value = scroll.y + '';
		document.cookie = "my_calendar_scroll="+value+expires+"; path=/";
		
		hideSelf();
	}
	
	function readCookie() 
	{
	
		var ca = document.cookie.split(';');
		for (var i = 0; i < ca.length; i++) 
		{
			var c = ca[i];
			while (c.charAt(0) == ' ') 
				c = c.substring(1, c.length);
			if (c.indexOf("my_calendar_scroll=") == 0) 
				return c.substring("my_calendar_scroll=".length, c.length);
		}
		return null;
	}

	function eraseCookie() 
	{
		var date = new Date();
		date.setTime(date.getTime()+((-1)*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
				
		document.cookie = "my_calendar_scroll="+expires+"; path=/";
	}


	function setScroll(my_scroll)
	{
  		if(my_scroll)
    		window.scrollTo(0, my_scroll);
	}
	
	function init() 									// create a dynamic layer and attach it to the HTML document. 
	{
    	
		objBody = document.getElementsByTagName("body").item(0);
  		objContainer = document.createElement('div');
  		objContainer.setAttribute('id', 'tooltip');
  		objBody.appendChild(objContainer);
   		objTag = document.getElementById('calendar').getElementsByTagName('a');
  		for (i=0; i<objTag.length; i++) 
  		{
  			objTag[i].setAttribute('id','link'+i);
			if (i<2) 
			{
				objTag[i].onmouseover = hideSelf; 		// first two links are month nav arrows
				objTag[i].onclick = createCookie;	  
			}
			else
			{
  				objTag[i].onmouseover = showNote;
			}
			objTag[i].onmouseout = hideNote;
		}
        objTag = document.getElementById('calendar').getElementsByTagName('th');
  		for (i=0; i<objTag.length; i++) 
  		{
        	objTag[i].onmouseover = hideSelf;			// mouse over weekday names 	 
		}
		objTd = document.getElementById('calendar').getElementsByTagName('td');
		for (i=2; i<objTd.length; i++) 
		{
			objTd[i].onclick = hideSelf;
  		}
	}

	setScroll(parseInt(readCookie()));
	eraseCookie();
	init();
}