
// Detección de navegador
var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;
   
var aMonthNames = new Array('JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY',	'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER');
var aMonthDisplay = new Array('01', '02', '03', '04', '05', '06', '07',	'08', '09', '10', '11', '12');	
var aMonthDays = new Array(/* Jan */ 31, /* Feb */ 28, /* Mar */ 31, /* Apr */ 30, /* May */ 31, /* Jun */ 30, /* Jul */ 31, /* Aug */ 31, /* Sep */ 30, /* Oct */ 31, /* Nov */ 30, /* Dec */ 31);
var days = new Array(42);

// Función que rellena la tabla con los días del mes y año especificado.
		  
function daylayerdisplay(b,a,c)
{
	/*
	  b = Año en formato YYYY.
	  a = Meses en formato numérico.
	  c = Dia en formato numérico.
	*/
	
	monthreduction=a;
	monthincrease=a;
	
	if (b%4 == 0 || b%100 ==0)
	{
		aMonthDays[1]=29;
	}
	else
	{
		aMonthDays[1]=28;
	}
	
	var oDateNow = new Date();	
	var oDate = new Date(aMonthNames[a] +  1 + "," + b);
	
	dayofweek=oDate.getDay();
      
	var count=0;
	var count1;
	var end=aMonthDays[a]+(dayofweek) - 1;
	
	for (s=1;s<=42;s++)
	{
		document.getElementById("day"+s).childNodes[0].innerHTML="&nbsp;";
	}
	
	if (dayofweek == 0)
	{
		dayofweek = 7
		end = end + 7
	}
	
	for (s=(dayofweek);s<=end;s++)
	{
		count=count+1;
		document.getElementById("day"+s).childNodes[0].innerHTML=count;
		if (count<=9)
		{
			count1=0+""+count;
		}
		else
		{
			count1=count;
		}
		document.getElementById("day"+s).childNodes[0].id=count1;
	}
	
	if (end<36)
	{
	    document.getElementById("LastWeek").style.visibility = 'hidden';
	}
	else
	{
	    document.getElementById("LastWeek").style.visibility = 'visible';
	}
}

function reducemonths()
{ 
	monthreduction= +monthreduction - 1;
	if (monthreduction==-1)
	{
		monthreduction=11;
		document.all.calendarform.year.value=
		parseFloat(document.all.calendarform.year.value)-1;
	} 
	
	document.all.calendarform.month[monthreduction].selected = "1";
	submitform();
}
		
function increasemonths()
{ 
	monthincrease= +monthincrease + 1;
	if (monthincrease==12)
	{
		monthincrease=0;
		document.all.calendarform.year.value=
		parseFloat(document.all.calendarform.year.value)+1;
	 }
	 
	 document.all.calendarform.month[monthincrease].selected = "1";
	 submitform();
}

function submitform()
{
    document.all.calendarform.action = 'Agenda.asp?month=' + document.all.calendarform.month.value + '&year=' + document.all.calendarform.year.value;
	document.all.calendarform.submit();
}
