function thisMonth() 
{
  dt = new Date();
  mnth  = dt.getMonth(); /* 0-11*/
  dayOfMnth = dt.getDate(); /* 1-31*/
  dayOfWeek = dt.getDay(); /*0-6*/
  yr = dt.getFullYear(); /*4-digit year*/
  document.f.mymon.options[mnth].selected=true;
  document.f.myyear.value = yr;
  document.form.arr_date.value = (mnth+1)+"/"+dayOfMnth+"/"+yr;

  document.fs1.mymons1.options[mnth].selected=true;
  document.fs1.myyears1.value = yr;
  document.form.dep_date.value = (mnth+1)+"/"+dayOfMnth+"/"+yr;

  document.fs.mymons.options[mnth].selected=true;
  document.fs.myyears.value = yr;
  document.form.tour_date.value = (mnth+1)+"/"+dayOfMnth+"/"+yr;

  startStr = (mnth+1)+"/1/"+yr;
  dt1 = new Date(startStr);
  dayOfWeek1 = dt1.getDay(); /*0-6*/

  noOfDaysInMnth = getNoOfDaysInMnth(mnth+1,yr);
  fillDates(dayOfWeek1+1,noOfDaysInMnth);
  fillDates1(dayOfWeek1+1,noOfDaysInMnth);
  fillDates2(dayOfWeek1+1,noOfDaysInMnth);
}//thisMonth()

function setDate(str) {
if (str<1) {
  return;
 }
 var mnth = parseInt(document.f.mymon.value);
 var year = document.f.myyear.value;
 mnth++;
 dateStr = mnth+"/"+str+"/"+year;
 dateStr = trim(dateStr);
document.form.arr_date.value = dateStr;
test.style.visibility="hidden";
}//setDate()

function setDates(str) {
if (str<1) {
  return;
 }
 var mnth = parseInt(document.fs.mymons.value);
 var year = document.fs.myyears.value;
 mnth++;
 dateStr = mnth+"/"+str+"/"+year;
 dateStr = trim(dateStr);

document.form.dep_date.value = dateStr;


tests.style.visibility="hidden";
}//setDates()

function setDates1(str) {
if (str<1) {
  return;
 }
 var mnth = parseInt(document.fs1.mymons1.value);
 var year = document.fs1.myyears1.value;
 mnth++;
 dateStr = mnth+"/"+str+"/"+year;
 dateStr = trim(dateStr);
document.form.tour_date.value = dateStr;
tests1.style.visibility="hidden";
}//setDates1()

/**
 * 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()
 



/**
 * 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 = "s"+i;
   document.f.elements[str].value="    ";
 }


 startSlotIndx = dayOfWeek1;
 slotIndx = startSlotIndx;

 for(var i=1; i<(noOfDaysInmnth+1); i++) {
  slotName = "s"+slotIndx;

  val="";
  if (i<10) {
    val = " "+i+" ";
  } else {
    val = i;
  }

  document.f.elements[slotName].value = val;
  slotIndx++;
 }
  
}//fillDates()

function fillDates1(dayOfWeek1,noOfDaysInmnth) {

 for(var i=1; i<43; i++) {
   str = "s"+i;
   //document.fs.elements[str].value="    ";
 }


 startSlotIndx = dayOfWeek1;
 slotIndx = startSlotIndx;

 for(var i=1; i<(noOfDaysInmnth+1); i++) {
  slotName = "s"+slotIndx;

  val="";
  if (i<10) {
    val = " "+i+" ";
  } else {
    val = i;
  }

  document.fs.elements[slotName].value = val;
  slotIndx++;
 }
  
}//fillDates1()

function fillDates2(dayOfWeek1,noOfDaysInmnth) {

 for(var i=1; i<43; i++) {
   str = "s"+i;
   document.fs1.elements[str].value="    ";
 }


 startSlotIndx = dayOfWeek1;
 slotIndx = startSlotIndx;

 for(var i=1; i<(noOfDaysInmnth+1); i++) {
  slotName = "s"+slotIndx;

  val="";
  if (i<10) {
    val = " "+i+" ";
  } else {
    val = i;
  }

  document.fs1.elements[slotName].value = val;
  slotIndx++;
 }
  
}//fillDates2()

function selMonth() {
 var currMnth = parseInt(document.f.mymon.value);
 var currYr = document.f.myyear.value;
 noOfDays = getNoOfDaysInMnth(currMnth+1,currYr)
 currMnth=currMnth+1;
 str = currMnth+"/1/"+currYr;
 dt = new Date(str);
 dayOfWeek = dt.getDay();
 fillDates(dayOfWeek+1,noOfDays);

}//selMonth()

function selMonths() {
 var currMnth = parseInt(document.fs.mymons.value);
 var currYr = document.fs.myyears.value;
 noOfDays = getNoOfDaysInMnth(currMnth+1,currYr)
 currMnth=currMnth+1;
 str = currMnth+"/1/"+currYr;
 dt = new Date(str);
 dayOfWeek = dt.getDay();
 fillDates1(dayOfWeek+1,noOfDays);

}//selMonths()

function selMonths1() {
 var currMnth = parseInt(document.fs1.mymons1.value);
 var currYr = document.fs1.myyears1.value;
 noOfDays = getNoOfDaysInMnth(currMnth+1,currYr)
 currMnth=currMnth+1;
 str = currMnth+"/1/"+currYr;
 dt = new Date(str);
 dayOfWeek = dt.getDay();
 fillDates2(dayOfWeek+1,noOfDays);

}//selMonths1()

function go1() 
{
test.style.visibility="visible";
}
function go2() 
{
tests.style.visibility="visible";
}
function go3() 
{
tests1.style.visibility="visible";
}

