   function openWindow(k,j,i){
       var f="width="+j+",height="+i+",";
       f+="resizable=yes,scrollbars=yes,status=yes,";
       f+="menubar=yes,toolbar=yes,location=no,directories=no";
       var h=window.open(k,'newWin',f);
       h.focus();
       }

   function moDa(e){
       if(typeof arrival=="undefined")calcDate();
       arrival.setTime(arrival.getTime()+e*86400000+4320000);
       depart.setTime(depart.getTime()+e*86400000+4320000);
       changeDate();
       calcDate();
       }
   function moNi(e){
       if(typeof arrival=="undefined")calcDate();
       document.fechas.noches.value=parseInt(document.fechas.noches.value)+e;
       calcDepart();
       }
   dow=new Array("Do","Lu","Ma","Mi","Ju","Vi","Sa");
   function calcDate(g){
       var noches=document.fechas.noches.value;
       arrival=new Date(document.fechas.ano_i.options[document.fechas.ano_i.selectedIndex].value,document.fechas.mes_i.selectedIndex,document.fechas.dia_i.selectedIndex+1);
       document.fechas.mes_i.selectedIndex=arrival.getMonth();
       document.fechas.dia_i.selectedIndex=arrival.getDate()-1;
       document.fechas.dow_i.value=dow[arrival.getDay()];
       depart=new Date(document.fechas.ano_f.options[document.fechas.ano_f.selectedIndex].value,document.fechas.mes_f.selectedIndex,document.fechas.dia_f.selectedIndex+1);
       document.fechas.mes_f.selectedIndex=depart.getMonth();
       document.fechas.dia_f.selectedIndex=depart.getDate()-1;
       document.fechas.dow_f.value=dow[depart.getDay()];
       document.fechas.noches.value=Math.round((depart-arrival)/86400000);
       if(g>0&&noches>0){
           if(g<10)document.fechas.noches.value=noches;
           else if(document.fechas.noches.value<=0)document.fechas.noches.value=1;calcDepart();
           }
       }


   function changeDate(){
       var b,a;
       var d,c;
       d=new Date(document.fechas.ano_i.options[0].text,0,1);
       c=new Date(document.fechas.ano_i.options[document.fechas.ano_i.length-1].text,11,31);
       if(arrival<d)arrival=d;
       else if(arrival>c)arrival=c;
       if(depart<d)depart=d;
       else if(depart>c)depart=c;
       if(depart<arrival)depart=arrival;
       document.fechas.mes_i.selectedIndex=arrival.getMonth();
       document.fechas.dia_i.selectedIndex=arrival.getDate()-1;
       b=arrival.getYear();
       if(b<1000)b=b+1900;
       for(a=0;a<document.fechas.ano_i.length;a++)
       if(b==document.fechas.ano_i.options[a].value)document.fechas.ano_i.options[a].selected=true;
       document.fechas.mes_f.selectedIndex=depart.getMonth();
       document.fechas.dia_f.selectedIndex=depart.getDate()-1;
       b=depart.getYear();
       if(b<1000)b=b+1900;
       for(a=0;a<document.fechas.ano_f.length;a++)
       if(b==document.fechas.ano_f.options[a].value)document.fechas.ano_f.options[a].selected=true;
       }
   function calcDepart(){
       arrival=new Date(document.fechas.ano_i.options[document.fechas.ano_i.selectedIndex].value,document.fechas.mes_i.selectedIndex,document.fechas.dia_i.selectedIndex+1);
       depart=new Date(document.fechas.ano_f.options[document.fechas.ano_f.selectedIndex].value,document.fechas.mes_f.selectedIndex,document.fechas.dia_f.selectedIndex+1);
       depart.setTime(arrival.getTime()+86400000*parseInt(document.fechas.noches.value)+18000000);
       changeDate();
       calcDate(0);
       }

   function E(){
       var D=parseFloat(navigator.appVersion);
       if(D>=2.0&&D<2.1&&navigator.appName.indexOf("Netscape")!=-1)return false;
       else return true;
       }
   function Q(P){
       var b=parseInt(P,10);return!(b%4)&&(!(b%400)||(b%100));
       }
   function O(a,b){
       if(a==2)return Q(b)?29:28;
       if(a==4||a==6||a==9||a==11)return 30;
       else return 31;
       }
   function C(b,B){
       for(var d=0;d<B.length;d++)if(b==B.options[d].text)return d;return 0;
       }
   function m(a,u){
       return((a+11+u)%12)+1;
       }
   function j(a,b,u){
       return b+((a+11+u)-(a+11+u)%12)/12-1;
       }

   function CalCreate(a,b,g,p){
       if(!E()){alert("Feature not supported.");return;}
       var l;
       k=-1;
       h=1;
       f=h-k+1;
       if(navigator.appVersion.indexOf("Mac",0)!=-1)l=window.open("","Calendar"+g,"width="+(18+f*200)+",height=255,resizable=no,scrollbars=no");
       else l=window.open("","Calendar"+g,"width="+(18+f*200)+",height=235,resizable=no,scrollbars=no");
       l.focus();
       if(g=="A")winA=l;else winD=l;
       CalCalc(l,a.options.selectedIndex+1,b.options[b.options.selectedIndex].text,b.options[0].text,b.options[b.options.length-1].text,g,p);
       }
   function CalCalc(y,N,M,t,s,g,p){
       if(!E())return;
       var x=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
       var a=parseInt(N);
       var b=parseInt(M,10);
       while(j(a,b,k)<t)a++;
       while(j(a,b,h)>s)a--;
       var c="";
       var r=0;
       var e,d;
       y.document.open();
       c+="<html><head><title>"+p+"</title></head><body bgcolor=ffffff link='#000000' alink='#000000' vlink='#000000' topmargin='6' leftmargin='0' marginheight='0' marginwidth='0'>"+"<div align=center><center></center>";
       c+="<font face=Arial size=1><table border=0 cellspacing=0 cellpadding=3 width="+200*f+">";
       c+="<tr valign=top>";
       for(e=k;e<=h;e++){
           c+="<td colspan=7 align=center bgcolor=#86A88E>"+"<b><font face='Arial' color=#ffffff>"+x[m(a,e)-1]+" "+j(a,b,e)+"</font></b></td>";
           c+="<td></td>";
           }
       c+="</tr>";
       L=new Array("Do","Lu","Ma","Mi","Ju","Vi","Sa");
       c+="<tr align=right>";
       for(e=k;e<=h;e++){
           for(d=1;d<=7;d++)c+="<td><font face='Verdana' size=1 color='"+(((d+r)%7||6)==6?"#ff0000":"#000000")+"'><b>"+L[(d+r)%7]+"</b></font></td>";
           if(e<h)c+="<td></td>";
           }
       c+="</tr>";
       var A=0,q,i,z;
       var o=0;
       var n,w;
       while(A<f&&o<10){
           c+="<tr>";
           for(e=k;e<=h;e++){
               i=m(a,e);
               q=j(a,b,e);
               z=new Date(i+"/01/"+q);
               n=(z.getDay()+13-r)%7;
               w=O(i,q)+n;
               for(d=o*7+1;d<(o+1)*7+1;d++){
                   if(d<=n||d>w)c+="<td>&nbsp;</td>";
                   else{if(d==w)A++;c+="<td "+(((d+r)%7||6)==6?"bgcolor='#ffffff'":"")+" align=right>&nbsp;<font face='Verdana' size=1><b><a href='JavaScript:self.close();opener.C"+g+"("+(d-n)+","+i+","+q+")'>"+(d-n)+"</a></b></font></td>";}
                   }
               if(e<h)c+="<td></td>";
               }
           o++;
           c+="</tr>";
           }
       if(o<6)c+="<tr><td>&nbsp;</td></tr>";
       var K=m(a,-1);
       var J=m(a,+1);
       var I=j(a,b,1);
       var H=j(a,b,-1);
       var G=j(a,b,h+1);
       var F=j(a,b,k-1);
       c+="<form action='javascript:return;'><tr><td align=left colspan="+((f==1)?3:7)+" bgcolor=#cccccc>";
       if(F<t)c+="&nbsp;";
       else c+="<input type=button value=' < "+((f==1)?"":x[m(a,k-1)-1]+" ")+"'"+"onClick='document.clear();opener.CalCalc(opener.win"+g+","+K+","+H+","+t+","+s+",\""+g+"\",\""+p+"\")'>";
       c+="</td>"+"<td align=center colspan="+((f==1)?8*f-7:8*f-15)+" bgcolor=#cccccc>&nbsp;</td><td align=right colspan="+((f==1)?3:7)+" bgcolor=#cccccc>";
       if(G>s)c+="&nbsp;";
       else c+="<input type=button value='"+((f==1)?"":x[m(a,h+1)-1])+" > '"+"onClick='document.clear();opener.CalCalc(opener.win"+g+","+J+","+I+","+t+","+s+",\""+g+"\",\""+p+"\")'>";c+="</td></tr></form>";
       c+="</table></font></div></body></html>";y.document.write(c);y.document.close();
       }
   function CA(v,i,b){
       document.fechas.dia_i.options.selectedIndex=parseInt(v)-1;
       document.fechas.mes_i.options.selectedIndex=parseInt(i)-1;
       document.fechas.ano_i.options.selectedIndex=C(b,document.fechas.ano_i);
       calcDate(4);
       }
   function CD(v,i,b){
       document.fechas.dia_f.options.selectedIndex=parseInt(v)-1;
       document.fechas.mes_f.options.selectedIndex=parseInt(i)-1;
       document.fechas.ano_f.options.selectedIndex=C(b,document.fechas.ano_f);calcDate(14);
       }
