

	function changeDay(event) {

		e = event.element();
		eid = e.id;
		thisday = eid.substring(3);

		e.stopObserving('click');
		showValue = e.innerHTML;
		showValue = showValue.replace(/\<br *\/?\>/g, "\n");
		e.update('<textarea id="editor_'+eid+'" class="inplaceEditor">'+showValue+'</textarea>');
		$('editor_'+eid).select();
		Event.observe($('editor_'+eid), 'blur', function() {
			newValue = $('editor_'+eid).value;
			newValue = newValue.replace(/\n/g,'<br\/>');

			// FIXME - this will be a problem if the month changes without a page reload
			datecode = dayPrefix+pad(thisday);
			url = 'http://iamyoga.ca/cal/cal-service.php?date='+datecode+'&text='+encodeURI(newValue);
			new Ajax.Request(url, {method: 'get'});
			
			e.update(newValue);
			if (e.innerHTML == "") {
				e.update("empty");
			}
			Event.observe(e, 'click', changeDay);
		});
	}

	function pad(n) {
		if (n < 10) {
			return "0" + n;
		} else {
			return n;
		}
		
	}