
	/* SuckerFish focus method on tds, only slightly modified
	--------------------------------------------------------------*/
	attachHover = function ()
	{
		// List of tags to add hover and focus to
		var elmnts = new Array ('td', 'input', 'textarea', 'li');

		// Do it up!
		for (var i = 0; i < elmnts.length; i++)
		{
			var elmPntrs = document.getElementsByTagName (elmnts[i]);
			for (var j = 0; j < elmPntrs.length; j++)
			{
				// Hover
				elmPntrs[j].onmouseover = function () { this.className += ' hover'; }
				elmPntrs[j].onmouseout = function () { this.className = this.className.replace (' hover', ''); }

				// Focus
				elmPntrs[j].onfocus = function () { this.className += ' focus'; }
				elmPntrs[j].onblur = function () { this.className = this.className.replace (' focus', ''); }
			}
		}
	}

	if (window.attachEvent) window.attachEvent('onload', attachHover);

	// Adds an event listener to target. Ex:
	// addHandler (window, 'load', functionToCall);
	function addHandler (target, event_name, handler_name)
	{
		if (typeof target.attachEvent != 'undefined')
		{
			target.attachEvent ('on' + event_name, handler_name);
		}
		else if (typeof window.addEventListener != 'undefined')
		{
			target.addEventListener (event_name, handler_name, false);
		}
		else if (typeof document.addEventListener != 'undefined')
		{
			document.addEventListener (event, handler_name, false);
		}
	}

	addHandler (window, 'load', setupLoginForm);

	function setupLoginForm ()
	{
		user = document.getElementById ('login_username');
		pass = document.getElementById ('login_password');

		if (user.value == '')
		{
			user.value = 'Username';
		}
		if (pass.value == '')
		{
			pass.value = 'Password';
			pass.type = 'text';
		}

		user.onfocus = function ()
		{
			if (this.value == 'Username')
			{
				this.value = '';
			}
		}
		user.onblur = function ()
		{
			if (this.value == '')
			{
				this.value = 'Username';
			}
		}
		pass.onfocus = function ()
		{
			if (this.value == 'Password')
			{
				this.type = 'password';
				this.value = '';
			}
		}
		pass.onblur = function ()
		{
			if (this.value == '')
			{
				this.type = 'text';
				this.value = 'Password';
			}
		}
	}

	/* Calendar event popups
	--------------------------------------------------------------*/
	var delay = 150;
	var posX = 0;
	var posY = 0;
	var offset = 5;
	var eventTimer = new Array();

	function getMouseXY (e)
	{
		if (navigator.appName == 'Netscape')
		{
			posX = e.pageX;
			posY = e.pageY;
		}
		else
		{
			posX = event.clientX + document.body.scrollLeft;
			posY = event.clientY + document.body.scrollTop;
		}

		if (posX < 0) posX = 0;
		if (posY < 0) posY = 0;

		posX += offset;
		posY += offset;

		return true;
	}
	window.document.onmousemove = getMouseXY;

	function showEvents (cal, day)
	{
		// A timer thread for this calendar should be created only if it doesn't exist
		if (typeof eventTimer[cal] != 'object') eventTimer[cal] = new Array ();

		eventDL = document.getElementById ('events_' + cal + '_' + day);

		// Kill any pending request to hide the object
		clearTimeout (eventTimer[cal][day]);

		// Hide all open tooltips, except this one
		for (var i in eventTimer)
		{
			// Go through days in that calendar
			for (var j in eventTimer[i])
			{
				if ((i == cal && j != day) || i != cal)
				{
					// Hide it
					document.getElementById ('events_' + i + '_' + j).style.display = 'none';

					// Free its pending timeout
					clearTimeout (eventTimer[i][j]);

					// Delete it from the array
					delete eventTimer[i][j];
				}
			}
		}

		// Display the box on the proper side of the mouse
		if (posX < document.body.clientWidth - 220)
			eventDL.style.left = posX + 'px';
		else
			eventDL.style.left = (posX - 200) + 'px';

		/*if (posY + getElementHeight ('events_' + day) < document.body.clientHeight)
			eventDL.style.top = posY + 'px';
		else
			eventDL.style.top = (posY - getElementHeight ('events_' + day)) + 'px';*/
		eventDL.style.top = posY + 'px';

		// Show it
		eventDL.style.display = 'block';

		// Attatch a function to the onMouseOver event to prevent the events from hiding
		eventDL.onmouseover = function () { clearTimeout (eventTimer[cal][day]); }
		// Attatch a function to the onMouseOut event to hide the events after they're read.
		eventDL.onmouseout = function () { hideEvents (cal, day); }
	}

	// Set a timeout to kill the object in 'delay' milliseconds
	function hideEvents (cal, day)
	{
		eventTimer[cal][day] = setTimeout ('document.getElementById (\'events_' + cal + '_' + day + '\').style.display = \'none\'', delay);
	}

	var op5 = navigator.userAgent.indexOf ('Opera 5') != -1 || navigator.userAgent.indexOf ('Opera/5') != -1;
	function getElementHeight(Elem)
	{
		if (document.getElementById)
			var elem = document.getElementById (Elem);
		else if (document.all)
			var elem = document.all[Elem];

		if (op5)
			xPos = elem.style.pixelHeight;
		else
			xPos = elem.offsetHeight;

		return xPos;
	}

	/* Date Field Manager
	--------------------------------------------------------*/
	daysInMonth = new Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	function valiDate (set)
	{
		objMonth = document.getElementById (set + 'Month');
		objDay	 = document.getElementById (set + 'Day');
		objYear	= document.getElementById (set + 'Year');

		// Save the selected day. Save as the end of the month if that's what's selected
		if (objDay.selectedIndex == objDay.options.length - 1 && objDay.options.length != 0) // Last day selected
			var selectedDay = daysInMonth[objMonth.selectedIndex - 1];
		else
			var selectedDay = objDay.selectedIndex;

		// Empty the day object
		for (var i = objDay.options.length; i >= 0; i--)
			objDay.options[i] = null;

		// Get the days in this month
		var daysInThisMonth = daysInMonth[objMonth.selectedIndex - 1];

		// Leap year, and it's February? 29 days then!
		if (objYear.selectedIndex > 0 && objYear.options[objYear.selectedIndex].value % 4 == 0 && objMonth.selectedIndex == 2) daysInThisMonth = 29;

		// Add the proper number of days
		for (var i = 1; i <= daysInThisMonth; i++)
			objDay.options[i - 1] = new Option (i, i);

		// Select the last-selected date, or the last item in the list if this month is shorter
		objDay.selectedIndex = Math.min (objDay.options.length - 1, selectedDay);
	}