﻿			function highlightCalendarCell(element) {
				$(element).style.border = '1px solid #999999';
			}
			function resetCalendarCell(element) {
				$(element).style.border = '1px solid #000000';
			}
			function startCalendar(month, year) {
				new Ajax.Updater('calendarInternal', 'rpc.php', {method: 'post', postBody: 'action=startCalendar&month='+month+'&year='+year+''});
			}
			function startCalendar2(month, year) {
				new Ajax.Updater('calendarInternal2', 'rpc2.php', {method: 'post', postBody: 'action=startCalendar&month='+month+'&year='+year+''});
			}

			function showEventForm(day) {
				$('evtDay').value = day;
				$('evtMonth').value = $F('ccMonth');
				$('evtYear').value = $F('ccYear');
				$('evtTitle').value = '';
				$('evtTime').value = '';
				
				displayEvents(day, $F('ccMonth'), $F('ccYear'));
				
				if(Element.visible('addEventForm')) {
					// do nothing.
				} else {
					Element.show('addEventForm');
				}
			}
			function displayEvents(day, month, year) {
				new Ajax.Updater('eventList', 'rpc.php', {method: 'post', postBody: 'action=listEvents&&d='+day+'&m='+month+'&y='+year+''});
				if(Element.visible('eventList')) {
					// do nothing, its already visble.
				} else {
					setTimeout("Element.show('eventList')", 300);
				}
			}

			function addEvent(day, month, year, title, time, location, body) {
				if(day && month && year && title && time && location && body) {
					// alert('Add Event\nDay: '+day+'\nMonth: '+month+'\nYear: '+year+'\nBody: '+body);
					new Ajax.Request('rpc.php', {method: 'post', postBody: 'action=addEvent&d='+day+'&m='+month+'&y='+year+'&title='+title+'&time='+time+'&location='+location+'&body='+body+'', onSuccess: highlightEvent(day)});
					$('evtBody').value = '';
				} else {
					alert('There was an unexpected script error.\nPlease ensure that you have not altered parts of it.');
				}
				// highlightEvent(day);
			} // addEvent.
			function highlightEvent(day) {
				Element.hide('addEventForm');
				$('calendarDay_'+day+'').style.background = '#<?= $eventColor ?>';
			}
			function showLoginBox() {
				Element.show('loginBox');
			}
			function showCP() {
				Element.show('cpBox');
			}
			function deleteEvent(eid) {
				confirmation = confirm('Are you sure you wish to delete this event?\n\nOnce the event is deleted, it is gone forever!');
				if(confirmation == true) {
					new Ajax.Request('rpc.php', {method: 'post', postBody: 'action=deleteEvent&eid='+eid+'', onSuccess: Element.hide('event_'+eid+'')});
				} else {
					// Do not delete it!.
				}
			}

// kill line 

function showAddress(address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        alert(address + " not found");
      } else {
        map.setCenter(point, 13);
        var marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(address);
      }
    }
  );
}