<!--

// SE DECLARAN FUERA DEL JS PARA QUE COJA EL IDIOMA
//var month_names = new Array("ENE","FEB","MAR","ABR","MAY","JUN","JUL","AGO","SEP","OCT","NOV","DIC");
//var week_names = new Array("L","M","X","J","V","S","D");

var days_in_month  = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var days_order  = new Array(1, 2, 3, 4, 5, 6, 0); //l,m,x,j,v,s,d
var this_date = new Date();
var this_day = this_date.getDate(); // 1-31
var this_month = this_date.getMonth(); // 0-11 
var this_year = y2K(this_date.getYear());
/*-----------------------------------*/
var fechas_ocupadas = ''; //" 12-3-2005 13-3-2005 14-3-2005 21-6-2005 22-6-2005 23-6-2005 24-6-2005"
var mes_procesado = '';
var salida = '';

function IncluirFechaEnSuCampo(Fecha)
	{
	if (document.getElementById('fecha_inicio').value == '')
		{ document.getElementById('fecha_inicio').value = Fecha; }
	else
		{
		if (document.getElementById('fecha_salida').value == '')
			{ document.getElementById('fecha_salida').value = Fecha; }
		else
			{
			document.getElementById('fecha_inicio').value = Fecha;
			document.getElementById('fecha_salida').value = '';
			}
		}
	}

function makeCalendar(the_month, the_year)
	{
	first_of_month = new Date(the_year, the_month, 1);
    day_of_week = first_of_month.getDay(); // 0-6

	if  (((the_year % 4 == 0) && (the_year % 100 != 0)) || (the_year % 400 == 0))
	// it's a leap year so change # days in Feb in array
		{ days_in_month[1] = 29; }
    else
	// not leap year - future use if multi year calendar built
		{ days_in_month[1] = 28; }

    salida += "<TABLE CALLSPACING=0 CELLPADDING=0";
    salida += "<TR><TH COLSPAN=7>" + month_names[the_month] + " " + the_year;
    salida += "<TR BGCOLOR='#EBEBEB'><TH>" + week_names[0] + "</TH><TH>" + week_names[1] + "</TH><TH>" + week_names[2] + "</TH><TH>" + week_names[3] + "</TH><TH>" + week_names[4] + "</TH><TH>" + week_names[5] + "</TH><TH>" + week_names[6] + "</TH></TR>";
    salida += "<TR ALIGN=RIGHT>";

	var column = 0;
	
	for (i=0; i<=6; i++) {
		if (days_order[i] != day_of_week)
			{ salida += "<TD> </TD>"; column++; }
		else
			{ break; }
	}

	for (i=1; i<=days_in_month[the_month]; i++) {
//		var StringABuscar= new RegExp(' '+i+'-'+(the_month+1)+'-'+the_year);
		
		if  ((i < this_day) && (the_month == this_month) && (the_year == this_year))
			// DIAS ANTES DE HOY
			{ salida += "<TD BGCOLOR='#F4F4F4' align='center' width='14' id='" + i + "-" + (the_month+1) + "-" + this_year + "'>-</TD>"; }
		
		else if  ((i == this_day)  && (the_month == this_month) && (the_year == this_year))
			// HOY
			{ salida += "<TD BGCOLOR='#F7941C' align='center' width='14' id='" + i + "-" + (the_month+1) + "-" + this_year + "'><font color='#FFFFFF'>" + i + "</font></TD>"; }
//		/*else if (fechas_ocupadas.search(StringABuscar) != -1)
//			// OCUPADOS (LO COMENTO PORQUE ES MUUUUUUY LENTO Y LO HAGO DE OTRA MANERA
//			{ salida += "<TD BGCOLOR='#F7941C' align='center' width='14'>" + i + "</TD>"; }*/
		else
			// RESTO
			{ salida += "<TD BGCOLOR='#F4F4F4' align='center' width='14' id='" + i + "-" + (the_month+1) + "-" + this_year + "'><a href='javascript:void(0)' onclick='IncluirFechaEnSuCampo("+'"'+i+'-'+(the_month+1)+'-'+the_year+'"'+")'>" + i + "</a></TD>"; }

		column++;
		// start next row of dates for month
		if  (column == 7)
			{ salida += "</TR><TR ALIGN=RIGHT>"; column = 0; }
	}

	salida += "</TR></TABLE>"; // month complete - close table
}
    
/* if year < 2000 javascript gives only 2 digits for year */
function y2K(number)
	{ return (number < 1000) ? number + 1900 : number; }
 
function MesProcesado()
	{
	if (mes_procesado == '')
		{ mes_procesado = this_month + 1; }
	else
		{
		if (mes_procesado == 12)
			{ mes_procesado = 0; this_year = this_year + 1; }
		
		mes_procesado = mes_procesado + 1;
		}
	
	return mes_procesado - 1;
	}

function PrintAvailabilityCalendar()
	{
	this_date = new Date();
	this_day = this_date.getDate();
	this_month = this_date.getMonth();
	this_year = y2K(this_date.getYear());

	mes_procesado = '';
	salida = '';
	salida += "<TABLE BORDER='0'><TR VALIGN=TOP><TD>";
	makeCalendar(MesProcesado(), this_year);
	salida += "</TD><TD>";
	makeCalendar(MesProcesado(), this_year);
	salida += "</TD><TD>";
	makeCalendar(MesProcesado(), this_year);
	salida += "</TD><TD>";
	makeCalendar(MesProcesado(), this_year);
//	salida += "</TD></TR><TR VALIGN=TOP><TD>";
//	makeCalendar(MesProcesado(), this_year);
//	salida += "</TD><TD>";
//	makeCalendar(MesProcesado(), this_year);
//	salida += "</TD><TD>";
//	makeCalendar(MesProcesado(), this_year);
//	salida += "</TD><TD>";
//	makeCalendar(MesProcesado(), this_year);
//	salida += "</TD></TR><TR VALIGN=TOP><TD>";
//	makeCalendar(MesProcesado(), this_year);
//	salida += "</TD><TD>";
//	makeCalendar(MesProcesado(), this_year);
//	salida += "</TD><TD>";
//	makeCalendar(MesProcesado(), this_year);
//	salida += "</TD><TD>";
//	makeCalendar(MesProcesado(), this_year);
	salida += "</TD></TR></TABLE>";
	return salida;
	}
// -->