	
	var sdate = 0;
	var week = 1;
	var loaded = false;


	Event.observe(window, 'load', 
		function (e) {
			Event.observe($('details'), 'submit', 
			function (e) {
//
			}, false);
			Event.stop (e);
		}, false);
	
function startLoading() {
  loaded = false;
  window.setTimeout('showLoadingImage()', 1000);
}

function showLoadingImage() {
  var el = $("loading");
  if (el && !loaded) {
      el.innerHTML = '<img src="./images/load.gif" width="16" height="16" />';
		el.style.display = 'block';
      new Effect.Appear('loading');
  }
}
   function stopLoading() {
  Element.hide('loading');
	$('loading').style.display = 'hidden';
  loaded = true;
}

   Ajax.Responders.register({
  onCreate : startLoading,
  onComplete : stopLoading
});
	function highlightCalendarCell(element) {
		$(element).style.border = '1px dashed #000';
		$(element).style.cursor = 'pointer';
	}

	function resetCalendarCell(element, color) {
		$(element).style.border = '1px solid #000';
		$(element).style.cursor = 'default';
	}
	
	function selectCalendarCell(date) {
		week = $F('weekz');
		sdate = date;
		$('h_date').value = date;
		$('h_week').value = week;
		new Ajax.Updater('calculateCost', 'app.php', {method: 'post', postBody: 'action=calcCost&date='+date+'&week='+week+''});
	}
	
	function startCalendar(month, year) {
		new Ajax.Updater('calendarInternal', 'app.php', {method: 'post', postBody: 'action=startCalendar&month='+month+'&year='+year+''});
	}
			
	function doGoogle(type) {		
		new Ajax.Updater('content', 'app.php', {method: 'post', postBody: 'action=doGoogle&type='+type+''});
	}
	
	function doCheque(type) {		
		new Ajax.Updater('content', 'app.php', {method: 'post', postBody: 'action=doCheque&type='+type+''});
	}
	function setDates() {		
		new Ajax.Updater('content', 'app.php', {method: 'post', postBody: 'action=setDates'});
	}
	function toggleCB(el) {
		if(el.disabled) {
			el.enable();
		} else {
			el.disable();
		}
	}
