
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}




<!--
// Original code created by Michael P. Scholtis (mpscho@planetx.bloomu.edu)
// All rights reserved.  January 13, 1996
// You may use this JavaScript example as you see fit, as long as the
// information within this comment above is included in your script.
// Modified October 16, 1998 by Dave Gramenz (dgramenz@ixl.com)
// Modified October 28, 1998 by Grant Prellwitz (gprellwitz@ixl.com)
// Modified December 5, 1998 by Grant Prellwitz (gprellwitz@ixl.com)
//
// Interface:
//    new_calendar(form, box, month, day, year, imageloc)
//     e.g.
//
//         <a href="javascript:void();"
//             onclick="new_calendar('query_parms',
//                                   'txt_to_date_opened',
//                                   now.getMonth()+1,
//                                   now.getDate(),
//                                   now.getYear(),
//                                   'images/');
//                                   return false;">
//         <img src="images/Date_icon.gif" border=0 width=14 height=14 alt="Calendar"></a>
//
//    CheckDate(form, box)
// e.g.
//    if (CheckDate(myform, 'date_opened') == true) {
//       ErrString += "The date opened is invalid.";
//    }
//Modificacion 6/11/2001
//Nuevo parametro. devuelve el tiempo en segundos en el campo box si se pone  new_calendar(form, box, month, day, year, imageloc,1)
//como último parametro
//Modificacion 7/06/2002
//Devuelve la fecha en ambos formatos (d-m-año y en segundos en un campo hidden) si se añade el último parámetro
//El campo hidden se ha de llamar como el campo de texto acabandolo en '_sec'
//
var now=new Date();

function return_date(FormName, BoxName, send_month, send_day, send_year) {

   //modificacion 6/11/2001
        setCookie('ULTd',send_day);
        setCookie('ULTm',send_month);
        setCookie('ULTy',send_year);


        var return_value = true;
        if (send_day != ""){
             eval("if (document."+FormName+"."+BoxName+"_month != null) {var field_name_month = document."+FormName+"."+BoxName+"_month;var field_name_day = document."+FormName+"."+BoxName+"_day;var field_name_year = document."+FormName+"."+BoxName+"_year;field_name_month.value=send_month;field_name_day.value=send_day;field_name_year.value=send_year; }");
             if ( !set_segundos){
                  eval("if (document."+FormName+"."+BoxName+" != null) {var field_name = document."+FormName+"."+BoxName+";field_name.value = send_day + '-' + send_month + '-' + send_year;}");
             }else {
             	  eval("if (document."+FormName+"."+BoxName+" != null) {var field_name = document."+FormName+"."+BoxName+";field_name.value = send_day + '-' + send_month + '-' + send_year;}");
                  fecha= new Date(send_year, send_month-1, send_day);
                  eval("if (document."+FormName+"."+BoxName+" != null) {var field_name = document."+FormName+"."+BoxName+"_sec;field_name.value = fecha.getTime()/1000}");
             //calculo de segundos
             }
           return_value = true;
                }
      return return_value;
 }

function calendar(mform, mbox, mmonth, mdate, myear, mImage_location, s)
{
   set_form = mform;
   set_box = mbox;
   set_date = mdate;
   set_month= mmonth;
   set_year = myear;
   
   if ((typeof(s)!="undefined") && (s.toLowerCase()=="s"))
     set_segundos = true;
   else
     set_segundos = false;
 
   set_Image_location = mImage_location;
        back_img_location = set_Image_location + "Date_Larr.gif";
   for_img_location = set_Image_location + "Date_Rarr.gif";
        if (br == "four") {
   calwin.document.writeln("<html><head><title>Calendario<\/title>");
   calwin.document.writeln("<STYLE>td,th {font-size:11px;color:#00202B;text-decoration:none;background-color:#EEEEEE; font-family: Verdana, Arial, Helvetica, sans-serif} select {FONT-FAMILY: Verdana;FONT-SIZE: 8pt;COLOR: BLACK;} table {font-family:verdana, sans-serif;font-size:11px;color:#000000;text-decoration:none;background-color:#E7EEF6;} :hover {FONT-FAMILY: Verdana;FONT-SIZE: 11px;COLOR: white; BACKGROUND-COLOR: #009896; text-decoration : none;}.normal {FONT-FAMILY: Verdana;FONT-SIZE: 11px;COLOR: BLACK;text-decoration : none;} .normal:hover {FONT-FAMILY: Verdana;FONT-SIZE: 11px;COLOR: white; BACKGROUND-COLOR: #009896;text-decoration : none;} .dia{FONT-FAMILY: Verdana;FONT-SIZE: 11px;COLOR: white; BACKGROUND-COLOR: #009896;text-decoration : none;}<\/STYLE>");
   calwin.document.writeln("<script language='JavaScript'>");

   calwin.document.writeln("\nfunction ret_date(send_day, send_month, send_year) {");
   calwin.document.writeln("opener.return_date(set_form, set_box, send_month, send_day, send_year);");
   calwin.document.writeln("  self.close();");
   calwin.document.writeln("  return false;");
   calwin.document.writeln("}");

   calwin.document.writeln("        var this_date = new Date();");
   calwin.document.writeln("        var set_form = opener.set_form;");
   calwin.document.writeln("        var set_box = opener.set_box;");

   calwin.document.writeln("        var set_Image_location = opener.set_Image_location;");
   calwin.document.writeln("        if (opener.set_date) {");
   calwin.document.writeln("                var set_year = opener.set_year;");
   calwin.document.writeln("                var set_month = opener.set_month;");
   calwin.document.writeln("                var set_date = opener.set_date;");
   calwin.document.writeln("                var base_date = new Date(set_year, set_month, set_date);");
   calwin.document.writeln("        } else {");
   calwin.document.writeln("                var base_date = this_date;");
   calwin.document.writeln("                var set_date = base_date.getDate();");
   calwin.document.writeln("                var set_month = base_date.getMonth();");
   calwin.document.writeln("                var set_year = base_date.getYear();");
   calwin.document.writeln("        }");

   calwin.document.writeln("  bdyear = base_date.getYear();");
   calwin.document.writeln("        if (bdyear < 1000)");
   calwin.document.writeln("                bdyear += 1900;");
   calwin.document.writeln("        var monthNames = 'EneFebMarAbrMayJunJulAgoSepOctNovDic';");
   calwin.document.writeln("        var monthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);");
   calwin.document.writeln("        if (((bdyear % 4 == 0) && (bdyear % 100 != 0)) || (bdyear % 400 == 0))");
   calwin.document.writeln("          monthDays[1] = 29;");
   calwin.document.writeln("        nDays = monthDays[base_date.getMonth()];");

        // determine whether we are showing the current month
   calwin.document.writeln("        var cur_month = true;");
   calwin.document.writeln("        if (((this_date.getMonth()) != base_date.getMonth())");
   calwin.document.writeln("        || (this_date.getYear() != base_date.getYear()))");
   calwin.document.writeln("                cur_month = false;");
   calwin.document.writeln("        var CurDay = this_date.getDate();");

   calwin.document.writeln("        firstDay = base_date;");
   calwin.document.writeln("        firstDay.setDate(1);");   // works fine for most systems
   calwin.document.writeln("        testMe = firstDay.getDate();");
   calwin.document.writeln("        if (testMe == 2)");
   calwin.document.writeln("          firstDay.setDate(0);");
   calwin.document.writeln("        startDay = firstDay.getDay();");
   calwin.document.writeln("        document.writeln('\\n<CENTER><TABLE BORDER=0 cellspacing=1 cellpadding=2>');");

   // Create the month name row
   calwin.document.writeln("document.write('\\n<TR><TD align=center valign=middle><a class=normal href=\"#\" onClick=\"opener.calendar(set_form, set_box, --set_month, 1, set_year, set_Image_location, \\'s\\');return false;\"><<</a></TD><TH COLSPAN=5 align=center valign=middle>');");
   calwin.document.writeln("document.write(monthNames.substring(base_date.getMonth() * 3, (base_date.getMonth() + 1) * 3));");
   calwin.document.writeln("document.write((base_date.getMonth() != 4)?'. ':'  ');"); // don't put period after May
   calwin.document.writeln("document.write(bdyear);");
   calwin.document.writeln("document.write('</TH>');");
   calwin.document.writeln("document.write('\\n<td  align=center valign=middle><a class=normal href=\"#\" onClick=\"opener.calendar(set_form, set_box, ++set_month, 1, set_year, set_Image_location, \\'s\\');return false;\">>></a></TD>');");
   calwin.document.writeln("document.write('</TR>\\n');");

   // Create the day name row
   calwin.document.writeln("document.write('\\n<TR><TH>Lun</TH><TH>Mar</TH><TH>Mie</TH><TH>Jue</TH><TH>Vie</TH><TH>Sab</TH><TH>Dom</TH></TR>\\n');");

   // Create the days
   calwin.document.writeln("document.write('\\n<TR>');");
   calwin.document.writeln("column = 0;");
   calwin.document.writeln("if (startDay==0) startDay=7;");
   calwin.document.writeln("for (i=0; i<startDay-1; i++) {");
   calwin.document.writeln("  document.write('\\n\\t<TD>&nbsp;</TD>');");
   calwin.document.writeln("  column++;");
   calwin.document.writeln("}");
   calwin.document.writeln("        var ret_month=(base_date.getMonth()+1);");
   calwin.document.writeln("for (i=1; i<=nDays; i++) {");
   calwin.document.writeln("  if ((i == CurDay) && (cur_month)) {");

   calwin.document.writeln("    document.write('\\n\\t<TD align=center class=dia>');");
   calwin.document.writeln("    document.write('<a class=dia href=\"#\" onClick=\"return(ret_date('+i+','+ret_month+','+bdyear+'));\">' + i + '</a>');");
   calwin.document.writeln("    document.write('');");
   calwin.document.writeln("  } else { ");
   calwin.document.writeln("    document.write('\\n\\t<TD align=center>');");
   calwin.document.writeln("    document.write('<a class=normal href=\"#\" onClick=\"return(ret_date('+i+','+ret_month+','+bdyear+'));\">' + i + '</a>');");
   calwin.document.writeln("  }");
   calwin.document.writeln("  document.write('</TD>');");
   calwin.document.writeln("  if (++column == 7) {");
   calwin.document.writeln("    document.write('</TR>'); ");
   calwin.document.writeln("    if (i < nDays) document.write('\\n<TR>'); ");
   calwin.document.writeln("    column = 0;");
   calwin.document.writeln("  }");
   calwin.document.writeln("}");
   calwin.document.writeln("if (column > 0) {");
   calwin.document.writeln("   for (;column < 7;column++) {");
   calwin.document.writeln("      document.write('</TD>\\n\\t<TD>&nbsp;'); }");
   calwin.document.writeln("   document.write('</TD></TR>'); ");
   calwin.document.writeln("}");

   calwin.document.writeln("document.write('</TABLE></CENTER>');");

   calwin.document.writeln("<\/script><\/head>");
   calwin.document.writeln("<body bgcolor='white' link='black' alink='black' vlink='black'><\/body><\/html>");
   calwin.document.close();
   }
   return false;
}

if (parseInt(navigator.appVersion) >= 4) br="four";
else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 3) br="n3";
else br="unsupported";

var set_form;
var set_box;
var set_month;
var set_month;
var set_year;
var set_Image_location;
var back_img_location;
var for_img_location;

function new_calendar(f, b, m, d, y, i, s) {
   //modificacion 6/11/2001
   if (getCookie('ULTd')!=null)
         {
         m=getCookie('ULTm');
         d=getCookie('ULTd');
         y=getCookie('ULTy');
         }

   set_form=f; //nombre formulario
   set_box=b;  //nombre campo
   if (y < 1000)
      y += 1900;
        if (br == "four") {
                calwin = window.open("","newwin","status=0,width=230,height=170,scrollbars=no,menubar=no");
                calendar(f, b, m-1, d, y, i, s);
        } else {
      set_Image_location = i;
            back_img_location = i + "Date_Larr.gif";
      for_img_location = i + "Date_Rarr.gif";
             calwin = window.open("calendar_client.html"
                                ,"newwin"
                                ,"status=0,width=275,height=260,scrollbars=no,menubar=yes");
        }
}

function CheckDate(myform, box) {
   rc = false;
   eval("   if ((myform."+box+"_month.value == '')   && (myform."+box+"_day.value == '')   && (myform."+box+"_year.value == '')) {  if (myform."+box+" != null){ myform."+box+".value =''; }  rc = false; } else {      if (IsValidDate(myform."+box+"_month.value, myform."+box+"_day.value,myform."+box+"_year.value)) {if (myform."+box+" != null){myform."+box+".value =myform."+box+"_month.value+ '/'+myform."+box+"_day.value+ '/'+myform."+box+"_year.value;}rc = false;} else {rc = true;}}");
   return rc;
}


function IsValidDate(month, day, year) {
   var err=0

   if (month<1 || month>12) err = 1
   if (day<1 || day>31) err = 1
   if (year<1980 || year>2050) err = 1
   if (isNaN(parseInt(month))) err = 1;
   if (isNaN(parseInt(day))) err = 1;
   if (isNaN(parseInt(year))) err = 1;
   if (month==4 || month==6 || month==9 || month==11) {
      if (day==31) err=1
   }

   if (month==2){
      if (isNaN(parseInt(year/4))) err=1;
      if (day > 29) err=1;
      if (day == 29 && !IsLeapYear(year)) err=1;
   }

   return (err == 0);
}

function IsLeapYear(year)
{
   // leap years are divisible by 4 but not by 100 unless also divisible by 400.
   if ((year/4) != parseInt(year/4)) return false;

   if (((year/100) == parseInt(year/100)) && ((year/400) != parseInt(year/400)))
      return false;

   return true;
}

function DateSeg(){
 var fecha=new date(  )

}

//-->
