<% 


%>

<SCRIPT LANGUAGE=javascript>
<!--


//Form button calendar (author unknown)
//For this script and more
//Visit http://javascriptkit.com

function setDate(num_casilla) {

	var nom_casilla = "f"+num_casilla

	str= document.all.item(nom_casilla).innerText

	if (str == " ") {
		return;
	}

	mnth1 = document.form_cal.month.value;
	mnth = mnth1;
	year = document.form_cal.year.value;
	dateStr = str+"/"+mnth+"/"+year;

	dateStr = trim(dateStr);
 
	document.form_cal.dateField.value = dateStr;

	document.all.item("fecha_sel").value= dateStr;
	document.all.item("estilo_str").value= 1;
	
	filtro()


}//setDate()

/**
 * The function removes spaces from the selected date.
 */

function trim(str) {

 res="";

 for(var i=0; i< str.length; i++) {
   if (str.charAt(i) != " ") {
     res +=str.charAt(i);
  }
 }
   
 return res;

}//trim()
 
/**
 * The method to get the Month name given the Month number of the year.
 */

function getMonthName(mnth) {

 if (mnth == 0) {
  name = "Enero";
 }else if(mnth==1) {
  name = "Febrero";
 }else if(mnth==2) {
  name = "Marzo";
 }else if(mnth==3) {
  name = "Abril";
 }else if(mnth==4) {
  name = "Mayo";
 } else if(mnth==5) {
  name = "Junio";
 } else if(mnth==6) {
  name = "Julio";
 } else if(mnth==7) {
  name = "Agosto";
 } else if(mnth==8) {
  name = "Septiembre";
 } else if(mnth==9) {
  name = "Octubre";
 } else if(mnth==10) {
  name = "Noviembre";
 } else if(mnth==11) {
  name = "Diciembre";
 }

 return name;

}//getMonthName()


function getDayName(dia) {

 if (dia == 0) {
  name = "Domingo";
 }else if(dia==1) {
  name = "Lunes";
 }else if(dia==2) {
  name = "Martes";
 }else if(dia==3) {
  name = "Miércoles";
 }else if(dia==4) {
  name = "Jueves";
 } else if(dia==5) {
  name = "Viernes";
 } else if(dia==6) {
  name = "Sábado";
 }

 return name;

}//getMonthName()

/**
 * Get the number of days in the month based on the year.
 */

function getNoOfDaysInMnth(mnth,yr) {
 
 rem = yr % 4;

 if(rem ==0) {
   leap = 1;
 } else {
  leap = 0;
 }

 noDays=0;

 if ( (mnth == 1) || (mnth == 3) || (mnth == 5) ||
      (mnth == 7) || (mnth == 8) || (mnth == 10) ||
      (mnth == 12)) {
  noDays=31;
 } else if (mnth == 2) {
           noDays=28+leap;
        } else {
           noDays=30;
 }

 //alert(noDays);
 return noDays;
 
      
}//getNoOfDaysInMnth()
  
/**
 * The function to reset the date values in the buttons of the 
 * slots.
 */

function fillDates(dayOfWeek1,noOfDaysInmnth) {

 for(var i=1; i<43; i++) {
   str = "f"+i;
   var str_cas = "s"+i;
	document.all.item(str).innerText=" ";
	document.all.item(str).style.visibility="hidden";	
	document.all.item(str_cas).bgColor="White";		
}


	startSlotIndx = dayOfWeek1;
	slotIndx = startSlotIndx;

 for(var i=1; i<(noOfDaysInmnth+1); i++) {
  slotName = "f"+slotIndx;
  slotName_c = "s"+slotIndx;

  val="";
  if (i<10) {
    val = " "+i+" ";
  } else {
    val = i;
  }

document.all.item(slotName).style.visibility="visible";	
  document.all.item(slotName).innerText=val;
	document.all.item(slotName_c).bgColor="WhiteSmoke";		
  slotIndx++;
 }
  
}//fillDates()
 

/**
 * The function that is called at the time of loading the page.
 * This function displays Today's date and also displays the 
 * the calendar of the current month.
 */

function thisMonth() {

	dia = document.form_cal.dia.value
	mes = document.form_cal.month.value
	year = document.form_cal.year.value
	 var dt = new  Date(year, mes-1,dia);

	dayOfMnth = dt.getDate(); /* 1-31*/
	mnth  = dt.getMonth()+1; /* 0-11*/
	dayOfWeek = dt.getDay(); /*0-6*/
	yr = dt.getFullYear(); /*4-digit year*/
  
	//alert("month:"+(mnth+1)+":dayofMnth:"+dayOfMnth+":dayofweek:"+dayOfWeek+":year:"+yr);

	mnthName = getMonthName(mnth-1);
	document.form_cal.month.value = mnth;
	document.form_cal.year.value = yr;
	document.form_cal.currMonth.value = mnth;
	document.form_cal.currYear.value = yr;
  
	document.all.item("monthYear").innerText= mnthName+" "+yr;
	document.form_cal.dateField.value = (mnth)+"/"+dayOfMnth+"/"+yr;

	startStr = (mnth)+"/1/"+yr;
	dt1 = new Date(startStr);
	dayOfWeek1 = dt1.getDay(); /*0-6*/

	noOfDaysInMnth = getNoOfDaysInMnth(mnth,yr);
	fillDates(dayOfWeek1+1,noOfDaysInMnth);
  
	//var strestilo = document.form_cal.estilo.value
	
	//var str_seleccion= ""

	//if (strestilo=="1") {
	//	str_seleccion =	getDayName(dayOfWeek)+"\n"+dayOfMnth+" de "+mnthName+" del "+yr;
	//}else if (strestilo=="7"){
	//	str_seleccion = "Mes: "+mnth+"\n"+mnthName+" del "+yr;

	//}else if (strestilo=="31"){
	//	str_seleccion = "Mes: "+mnth+"\n"+mnthName+" del "+yr;
	//}

	//document.all.item("fecha_sel").innerText = str_seleccion
 

}//thisMonth()

/**
 * The function that will be used to display the calendar of the next month.
 */

function nextMonth() {

 var currMnth = document.form_cal.month.value;
 currYr = document.form_cal.year.value;

 if (currMnth == "12") {
    nextMnth = 1;
    nextYr = currYr;
    nextYr++;
 } else {
   nextMnth=currMnth;
   nextMnth++;
   nextYr = currYr;
 }

 mnthName = getMonthName(nextMnth-1);
 document.form_cal.month.value=nextMnth;
 document.form_cal.year.value=nextYr;
 document.all.item("monthYear").innerText= mnthName+" "+nextYr;
 
 str = (nextMnth)+"/1/"+nextYr;
 dt = new Date(str);
 dayOfWeek = dt.getDay();

 noOfDays = getNoOfDaysInMnth(nextMnth,nextYr);

 fillDates(dayOfWeek+1,noOfDays);

}//nextMonth()

/**
 * The method to display the calendar of the previous month.
 */

function prevMonth() {

 var currMnth = document.form_cal.month.value;
 currYr = document.form_cal.year.value;

 if (currMnth == "1") {
    prevMnth = 12;
    prevYr = currYr;
    prevYr--;
 } else {
   prevMnth=currMnth;
   prevMnth--;
   prevYr = currYr;
 }

 str = (prevMnth)+"/1/"+prevYr;
 dt = new Date(str);
 dayOfWeek = dt.getDay();

 /***********************************************
  * Remove the comment if do not want the user to 
  * go to any previous month than this current month.
  ***********************************************/

 /*

 runningMonth = document.forms[0].currMonth.value;
 rMonth=runningMonth;
 rMonth++;
 runningYear = document.forms[0].currYear.value;
 rYear=runningYear;

 str = (rMonth)+"/1/"+rYear;
 dt1 = new Date(str);
 
 if (dt.valueOf() < dt1.valueOf()) {
   alert('Cannot Go Before Current Month');
   return;
 }
 
 */

 /**************************************************
 * End of comment
 **************************************************/

 mnthName = getMonthName(prevMnth-1);
 document.form_cal.month.value=prevMnth;
 document.form_cal.year.value=prevYr;
 document.all.item("monthYear").innerText=  mnthName+" "+prevYr;

 noOfDays = getNoOfDaysInMnth(prevMnth,prevYr);
 fillDates(dayOfWeek+1,noOfDays);
 
}//prevMonth()

function cambia_cursor(casilla,str_numero)
{

var str_casilla="s" + str_numero;

var num_guardado = document.all.item(str_casilla).innerText;

	if (num_guardado != " ") {

		casilla.style.cursor="hand";
		document.all.item(str_casilla).bgColor="LightGrey";		
		return;
	}
	
		casilla.style.cursor="auto";
	
}

function desactiva_cursor(str_numero)
{

var str_casilla="s" + str_numero;

	if (document.all.item(str_casilla).bgColor=="#d3d3d3") 
	{	
		document.all.item(str_casilla).bgColor="WhiteSmoke";		
	}
	
}

//-->
</SCRIPT>


<table height="50" width="170" border=1 bgcolor="whitesmoke" align=center background="" borderColorDark=white borderColorLight=gray cellpadding="0" cellspacing="0">
	<tr>
		<td>
				<table bgcolor="white" align=center border="1" cellpadding="0" cellspacing="0" width="170">
			        <tr>
					    <td align="middle" width="35" nowrap name="prev" id="prev" onclick="prevMonth()" style="CURSOR: hand" bgColor=gainsboro borderColorDark=silver borderColorLight=#333333><font class="eti_ari_12_b">&lt;&lt;</font></td>
					    <td align="middle" width="150%" nowrap  bgColor=azure><b><font class="eti_azul_10" name="monthYear" id="monthYear">Enero 2003</font></b></td>
					    <td align="middle" width="35" nowrap name="next" id="next" onclick="nextMonth()" style="CURSOR: hand" bgColor=gainsboro borderColorDark=silver borderColorLight=#333333><font class="eti_ari_12_b">&gt;&gt;</font></td>
					</tr>
				</table>
				<table bgcolor="white" align=center border="0" cellpadding="0" cellspacing="2" width="100%">
			        <tr >
					    <td align="middle" width="20" nowrap><font class="eti_azul_10">Dom</font></td>
					    <td align="middle" width="20" nowrap><font class="eti_azul_10">Lun</font></td>
					    <td align="middle" width="20" nowrap><font class="eti_azul_10">Mar</font></td>
					    <td align="middle" width="20" nowrap><font class="eti_azul_10">Mie</font></td>
					    <td align="middle" width="20" nowrap><font class="eti_azul_10">Jue</font></td>
					    <td align="middle" width="20" nowrap><font class="eti_azul_10">Vie</font></td>
					    <td align="middle" width="20" nowrap><font class="eti_azul_10">Sab</font></td>
					</tr>
				    <tr>
						<td align="middle" name="s1" id="s1" onclick="setDate(1);" onmouseover="cambia_cursor(this,1)" onmouseout="desactiva_cursor(1)"><font class="eti_ari_10" name="f1" id="f1">1</font></td>
			            <td align="middle" name="s2" id="s2" onclick="setDate(2);" onmouseover="cambia_cursor(this,2)" onmouseout="desactiva_cursor(2)"><font class="eti_ari_10" name="f2" id="f2">2</font></td>
			            <td align="middle" name="s3" id="s3" onclick="setDate(3);" onmouseover="cambia_cursor(this,3)" onmouseout="desactiva_cursor(3)"><font class="eti_ari_10" name="f3" id="f3">3</font></td>
						<td align="middle" name="s4" id="s4" onclick="setDate(4);" onmouseover="cambia_cursor(this,4)" onmouseout="desactiva_cursor(4)"><font class="eti_ari_10" name="f4" id="f4">4</font></td>
						<td align="middle" name="s5" id="s5" onclick="setDate(5);" onmouseover="cambia_cursor(this,5)" onmouseout="desactiva_cursor(5)"><font class="eti_ari_10" name="f5" id="f5">5</font></td>
						<td align="middle" name="s6" id="s6" onclick="setDate(6);" onmouseover="cambia_cursor(this,6)" onmouseout="desactiva_cursor(6)"><font class="eti_ari_10" name="f6" id="f6">6</font></td>
						<td align="middle" name="s7" id="s7" onclick="setDate(7);" onmouseover="cambia_cursor(this,7)" onmouseout="desactiva_cursor(7)"><font class="eti_ari_10" name="f7" id="f7">7</font></td>
					</tr>
					<tr>
						<td align="middle" name="s8" id="s8" onclick="setDate(8);" onmouseover="cambia_cursor(this,8)" onmouseout="desactiva_cursor(8)"><font class="eti_ari_10" name="f8" id="f8">8</font></td>
			            <td align="middle" name="s9" id="s9" onclick="setDate(9);" onmouseover="cambia_cursor(this,9)" onmouseout="desactiva_cursor(9)"><font class="eti_ari_10" name="f9" id="f9">9</font></td>
			            <td align="middle" name="s10" id="s10" onclick="setDate(10);" onmouseover="cambia_cursor(this,10)" onmouseout="desactiva_cursor(10)"><font class="eti_ari_10" name="f10" id="f10">10</font></td>
						<td align="middle" name="s11" id="s11" onclick="setDate(11);" onmouseover="cambia_cursor(this,11)" onmouseout="desactiva_cursor(11)"><font class="eti_ari_10" name="f11" id="f11">11</font></td>
						<td align="middle" name="s12" id="s12" onclick="setDate(12);" onmouseover="cambia_cursor(this,12)" onmouseout="desactiva_cursor(12)"><font class="eti_ari_10" name="f12" id="f12">12</font></td>
						<td align="middle" name="s13" id="s13" onclick="setDate(13);" onmouseover="cambia_cursor(this,13)" onmouseout="desactiva_cursor(13)"><font class="eti_ari_10" name="f13" id="f13">13</font></td>
						<td align="middle" name="s14" id="s14" onclick="setDate(14);" onmouseover="cambia_cursor(this,14)" onmouseout="desactiva_cursor(14)"><font class="eti_ari_10" name="f14" id="f14">14</font></td>
					</tr>
					<tr>
						<td align="middle" name="s15" id="s15" onclick="setDate(15);" onmouseover="cambia_cursor(this,15)" onmouseout="desactiva_cursor(15)"><font class="eti_ari_10" name="f15" id="f15">15</font></td>
			            <td align="middle" name="s16" id="s16" onclick="setDate(16);" onmouseover="cambia_cursor(this,16)" onmouseout="desactiva_cursor(16)"><font class="eti_ari_10" name="f16" id="f16">16</font></td>
			            <td align="middle" name="s17" id="s17" onclick="setDate(17);" onmouseover="cambia_cursor(this,17)" onmouseout="desactiva_cursor(17)"><font class="eti_ari_10" name="f17" id="f17">17</font></td>
						<td align="middle" name="s18" id="s18" onclick="setDate(18);" onmouseover="cambia_cursor(this,18)" onmouseout="desactiva_cursor(18)"><font class="eti_ari_10" name="f18" id="f18">18</font></td>
						<td align="middle" name="s19" id="s19" onclick="setDate(19);" onmouseover="cambia_cursor(this,19)" onmouseout="desactiva_cursor(19)"><font class="eti_ari_10" name="f19" id="f19">19</font></td>
						<td align="middle" name="s20" id="s20" onclick="setDate(20);" onmouseover="cambia_cursor(this,20)" onmouseout="desactiva_cursor(20)"><font class="eti_ari_10" name="f20" id="f20">20</font></td>
						<td align="middle" name="s21" id="s21" onclick="setDate(21);" onmouseover="cambia_cursor(this,21)" onmouseout="desactiva_cursor(21)"><font class="eti_ari_10" name="f21" id="f21">21</font></td>
					</tr>
					<tr>
						<td align="middle" name="s22" id="s22" onclick="setDate(22);" onmouseover="cambia_cursor(this,22)" onmouseout="desactiva_cursor(22)"><font class="eti_ari_10" name="f22" id="f22">22</font></td>
			            <td align="middle" name="s23" id="s23" onclick="setDate(23);" onmouseover="cambia_cursor(this,23)" onmouseout="desactiva_cursor(23)"><font class="eti_ari_10" name="f23" id="f23">23</font></td>
			            <td align="middle" name="s24" id="s24" onclick="setDate(24);" onmouseover="cambia_cursor(this,24)" onmouseout="desactiva_cursor(24)"><font class="eti_ari_10" name="f24" id="f24">24</font></td>
						<td align="middle" name="s25" id="s25" onclick="setDate(25);" onmouseover="cambia_cursor(this,25)" onmouseout="desactiva_cursor(25)"><font class="eti_ari_10" name="f25" id="f25">25</font></td>
						<td align="middle" name="s26" id="s26" onclick="setDate(26);" onmouseover="cambia_cursor(this,26)" onmouseout="desactiva_cursor(26)"><font class="eti_ari_10" name="f26" id="f26">26</font></td>
						<td align="middle" name="s27" id="s27" onclick="setDate(27);" onmouseover="cambia_cursor(this,27)" onmouseout="desactiva_cursor(27)"><font class="eti_ari_10" name="f27" id="f27">27</font></td>
						<td align="middle" name="s28" id="s28" onclick="setDate(28);" onmouseover="cambia_cursor(this,28)" onmouseout="desactiva_cursor(28)"><font class="eti_ari_10" name="f28" id="f28">28</font></td>
					</tr>
					<tr>
						<td align="middle" name="s29" id="s29" onclick="setDate(29);" onmouseover="cambia_cursor(this,29)" onmouseout="desactiva_cursor(29)"><font class="eti_ari_10" name="f29" id="f29">29</font></td>
			            <td align="middle" name="s30" id="s30" onclick="setDate(30);" onmouseover="cambia_cursor(this,30)" onmouseout="desactiva_cursor(30)"><font class="eti_ari_10" name="f30" id="f30">30</font></td>
			            <td align="middle" name="s31" id="s31" onclick="setDate(31);" onmouseover="cambia_cursor(this,31)" onmouseout="desactiva_cursor(31)"><font class="eti_ari_10" name="f31" id="f31">31</font></td>
						<td align="middle" name="s32" id="s32" onclick="setDate(32);" onmouseover="cambia_cursor(this,32)" onmouseout="desactiva_cursor(32)"><font class="eti_ari_10" name="f32" id="f32">&nbsp;</font></td>
						<td align="middle" name="s33" id="s33" onclick="setDate(33);" onmouseover="cambia_cursor(this,33)" onmouseout="desactiva_cursor(33)"><font class="eti_ari_10" name="f33" id="f33">&nbsp;</font></td>
						<td align="middle" name="s34" id="s34" onclick="setDate(34);" onmouseover="cambia_cursor(this,34)" onmouseout="desactiva_cursor(34)"><font class="eti_ari_10" name="f34" id="f34">&nbsp;</font></td>
						<td align="middle" name="s35" id="s35" onclick="setDate(35);" onmouseover="cambia_cursor(this,35)" onmouseout="desactiva_cursor(35)"><font class="eti_ari_10" name="f35" id="f35">&nbsp;</font></td>
					</tr>
					<tr>
						<td align="middle" name="s36" id="s36" onclick="setDate(36);" onmouseover="cambia_cursor(this,36)" onmouseout="desactiva_cursor(36)"><font class="eti_ari_10" name="f36" id="f36">&nbsp;</font></td>
			            <td align="middle" name="s37" id="s37" onclick="setDate(37);" onmouseover="cambia_cursor(this,37)" onmouseout="desactiva_cursor(37)"><font class="eti_ari_10" name="f37" id="f37">&nbsp;</font></td>
			            <td align="middle" name="s38" id="s38" onclick="setDate(38);" onmouseover="cambia_cursor(this,38)" onmouseout="desactiva_cursor(38)"><font class="eti_ari_10" name="f38" id="f38">&nbsp;</font></td>
						<td align="middle" name="s39" id="s39" onclick="setDate(39);" onmouseover="cambia_cursor(this,39)" onmouseout="desactiva_cursor(39)"><font class="eti_ari_10" name="f39" id="f39">&nbsp;</font></td>
						<td align="middle" name="s40" id="s40" onclick="setDate(40);" onmouseover="cambia_cursor(this,40)" onmouseout="desactiva_cursor(40)"><font class="eti_ari_10" name="f40" id="f40">&nbsp;</font></td>
						<td align="middle" name="s41" id="s41" onclick="setDate(41);" onmouseover="cambia_cursor(this,41)" onmouseout="desactiva_cursor(41)"><font class="eti_ari_10" name="f41" id="f41">&nbsp;</font></td>
						<td align="middle" name="s42" id="s42" onclick="setDate(42);" onmouseover="cambia_cursor(this,42)" onmouseout="desactiva_cursor(42)"><font class="eti_ari_10" name="f42" id="f42">&nbsp;</font></td>
					</tr>
				</table>
		</td>
	</tr>
</table>
<form id=form_cal name=form_cal>
	<!-- Hidden fields --->
    <input type=hidden name=dia value=<%=int_dia%>>
    <input type=hidden name=month value=<%=int_mes%>>
	<input type=hidden name=year value=<%=int_year%>>
	<input type=hidden name=currMonth >
	<input type=hidden name=currYear > 
	<input type=hidden name=dateField > 
	<!-- End of Hidden fields --->
</form>
