/*comment1 starts
Author: Badrinath Chebbi
Date: 01-04-2002
comment1 ends*/

//Browser detection code
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;
//Browser detection code ends here

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);

/* This Function populates the table with the dates for a particular month in a year. */
/* b año, a mes, c */
function daylayerdisplay (b,a,c) {
  monthreduction=a;
  monthincrease=a;
  // Determina si es año bisisesto
  if (b%4 == 0 || b%100 ==0){ aMonthDays[1]=29; } else { aMonthDays[1]=28; }
  var oDateNow = new Date();                           // Fecha actual	
  var oDate = new Date(aMonthNames[a] +  1 + "," + b); // Primer día del mes a desplegar
  dayofweek = oDate.getDay();                          // Día en que cae el primero de mes
  //Input values in td's
  var count=0;
  var count1;
  var end = aMonthDays[a]+(dayofweek);                   // Calcula la última celda donde se colocará información
  for (s=1; s<=42; s++) { // recorre cada una de las celdas de la cuadrícula HTML para los días del mes
    // Limpia el contenido
    document.getElementById("day"+s).childNodes[0].innerHTML = "";
  }
  for (s = (dayofweek+1); s <= end; s++){
    count = count + 1;
    document.getElementById("day"+s).childNodes[0].innerHTML = count;
    // coloca el identificador de la celda en formato de dos dígitos
    if (count <= 9) { count1 = 0 + "" + count; } else { count1 = count; }
    document.getElementById("day"+s).childNodes[0].id = count1;
  }
}
				
/*Comment4 starts
This function sends the value back to the form object of the window
which called it*/

function sendvalue (y, m, d) {
  // var TargetForm = parent.document.forma;
  
  if (y == 1) {
	todayobj= new Date();
    // today=todayobj.getFullYear()+todayobj.getMonth()+todayobj.getDate();
    year=todayobj.getFullYear();
    if (todayobj.getDate() <= 9) {
      var todayday=0+""+todayobj.getDate(); }
    else { 
      var todayday=todayobj.getDate();
    }
  //parent.document.callingform.receivedate.value=aMonthDisplay[todayobj.getMonth()]+ "/" + todayday + "/" + year;
    document.calendarform.tgField.value = todayday+"/"+aMonthDisplay[todayobj.getMonth()]+"/"+year;	
  }
  else { 
  //parent.document.callingform.receivedate.value= aMonthDisplay[m]+"/"+d+"/"+y;//y + m + d;
    document.calendarform.tgField.value= d+"/"+aMonthDisplay[m]+"/"+y;//y + m + d;
  }	
  hideLayer("msCalendarFrame");
}
/*Comment4 ends here*/

/*Comment5 starts
  This function reduces the month by one everytime prev.gif is clicked*/

function reducemonths() { 
  monthreduction= +monthreduction - 1;
  if (monthreduction==-1) {
    monthreduction=11;
    document.calendarform.year.value = parseFloat(document.calendarform.year.value)-1;
  }
  document.calendarform.month[monthreduction].selected = "1";
  daylayerdisplay(document.calendarform.year.value,monthreduction,101);
}
/*Comment5 ends here*/
				 
/*Comment6 starts
This function Increases the month by one everytime next.gif is clicked*/

function increasemonths() { 
  monthincrease= +monthincrease + 1;
  if (monthincrease==12) {
    monthincrease=0;
    document.calendarform.year.value= parseFloat(document.calendarform.year.value)+1;
  }
  document.calendarform.month[monthincrease].selected = "1";
  daylayerdisplay(document.calendarform.year.value,monthincrease,101);
}
/*Comment6 ends here*/				 
