/*
Cogumelo v0.1 - INNOTO
Copyright (C) 2009 Innoto Gestión para el Desarrollo Social S.L. <mapinfo@innoto.es>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
USA.
*/

var showdate = null;
var showrangestart = null;
var showrangeend = null;

//
//	Page events
//

// page init
//Event.observe(window, "load", initWeekCalendar, false);




function initWeekCalendar()
{			
	new Ajax.Updater('calendario', 'index.php', {
	  method: 'get',
	  parameters: {q: 'weekcalendar' },
	  onComplete:function(){
			showdate=null;
			shorangestart=$('calstart').innerHTML;
			showrangeend=$('calend').innerHTML;
			//alert(shorangestart+'-'+showrangeend);
			
			initIndexMap();
          }
	  });
}


function setWeek(timestamp)
{	

	new Ajax.Updater('calendario', 'index.php', {
	  method: 'get',
	  parameters: {q: 'weekcalendar', cmd:'setweek', date:timestamp },
	  onComplete:function(){
							showdate=null;
							shorangestart=$('calstart').innerHTML;
							showrangeend=$('calend').innerHTML;
							//alert(shorangestart+'-'+showrangeend);
							
							refreshMap();
	                        }
	  });	
	

}


function setToday()
{	
	initWeekCalendar();	
}


function setCalendar(cell, date)
{	
	$('ThisWeekoff').hide();
	$('ThisWeek').show();
	$('weekcalendarrange').innerHTML='Mostrando o día '+date;
	for(i=0;i<=6;++i)		
	    if(i != cell) 
	    	 {  $('calday'+i).removeClassName("weekday");
	    	    $('calday'+i).removeClassName("weekend");
	    	    $('calday'+i).removeClassName("hiddencal");
	    	    $('calday'+i).addClassName("calhidden");
	    	 }
		$('calday'+cell).removeClassName("calhidden");
		$('calday'+cell).addClassName("weekday");
		
		showdate=date;
		shorangestart=null;
		showrangeend=null;
		//alert(showdate);
		
		refreshMap();
}


