//<--

//start new script code



// Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x

function isBrowserSupp() {

    // Get the version of the browser

    version =  parseFloat( navigator.appVersion );



    if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {

        return false;

    }

    else {

    return true;

    }



return true;

}



function isLeapYear(yrStr)

{

var leapYear=false;

var year = parseInt(yrStr, 10);

// every fourth year is a leap year

if (year%4 == 0)

    {

    leapYear=true;

    // unless it's a multiple of 100

    if (year%100 == 0)

        {

        leapYear=false;

        // unless it's a multiple of 400

        if (year%400 == 0)

            {

            leapYear=true;

            }

        }

    }

return leapYear;

}





function getDaysfrom_month(mthIdx, YrStr)

{

// all the rest have 31

var maxDays=31

// expect Feb. (of course)

if (mthIdx==1)

    {

    if (isLeapYear(YrStr))

        {

        maxDays=29;

        }

    else

        {

        maxDays=28;

        }

    }

// thirty days hath...

if (mthIdx==3 || mthIdx==5 || mthIdx==8 || mthIdx==10)

    {

    maxDays=30;

    }

return maxDays;

}





//the function which does some magic to the date fields

// return non-zero if it is the last day of the month

function adjustDate(mthIdx, Dt)

{

var value=0;



var today = new Date()

var theYear = parseInt(today.getYear(),10)



if (mthIdx < today.getMonth()) {

    theYear = (parseInt(today.getYear(), 10) + 1)

}

if(theYear<100){

    theYear = "19" + theYear

}

else{

    if((theYear-100) < 10){

        theYear = "0" + (theYear-100)

    }

    else{

        theYear = (theYear-100)+""

    }

    theYear = "20" + theYear

}





var numDays=getDaysfrom_month(mthIdx, theYear);



if (mthIdx==1)

    {

    if (Dt.options.selectedIndex + 1 < numDays)

        {

        return 0;

        }

    else

        {

        Dt.options.selectedIndex=numDays - 1;

        //check for leap year

        if (numDays==29)

            {

            return 99;

            }

        else

            {

            return 1;

            }

        }

    }

if (Dt.options.selectedIndex + 1 < numDays)

    {

    value=0;

    }

else

    {

    if (Dt.options.selectedIndex + 1 > numDays)

        {

        Dt.options.selectedIndex--;

        value=3;

        }

    else

        {

        //index is 31 or 30

        value=2;

        }

    }

return value;

}



//changes departure month when arrival month is changed

function amadChange(inM,inD,outM,outD)

{

if (!isBrowserSupp())

    {

    return;

    }



var res = adjustDate(inM.options.selectedIndex, inD);

if (res != 0)

    {

           outD.options.selectedIndex=0;

           if (outM.options.selectedIndex==11){

            outM.options.selectedIndex=0

           }

           else{

            outM.options.selectedIndex=inM.options.selectedIndex + 1;

           }

    }

else

    {

    outM.options.selectedIndex = inM.options.selectedIndex;

    outD.options.selectedIndex = inD.options.selectedIndex+1;

    }

return;

}



function dmddChange(outM,outD)

{

if (!isBrowserSupp())

    {

    return;

    }



adjustDate(outM.options.selectedIndex,outD);

return;

}



function setDates()

{

  // This will populate the date dropdowns with today and tomarrow's values.

  theForm = document.mainForm;

  //  now = new Date(); **** old version *** AYartsev

  now = new Date(new Date().valueOf() - (24*60*60*1000));

  yearOffset = parseInt(now.getYear());

  // getDate

  //  var tomorrow = new Date(new Date().valueOf() + (24*60*60*1000));  **** old version *** AYartsev

  var tomorrow = new Date();

  var from_month=tomorrow.getMonth();

  var from_day=tomorrow.getDate();

  var from_year=y2k(tomorrow.getYear());



  if(isLeapYear(from_year)) { var days = new Array(31,29,31,30,31,30,31,31,30,31,30,31); }

  else { var days = new Array(31,28,31,30,31,30,31,31,30,31,30,31); }



  to_month=from_month;

  to_day = from_day%days[from_month];

  to_year=from_year;

  if(to_day == 0) { to_month = (from_month + 1) % 12; }

  if(to_day == 0 && from_month == 11) { to_year++; }



  // Now set the select boxes to the appropriate dates:

  theForm.from_month.options[from_month].selected=true;

  theForm.from_day.options[(from_day-1)].selected=true;

  theForm.to_month.options[to_month].selected=true;

  theForm.to_day.options[to_day].selected=true;



}

// quadYear

function y2k(number){return (number < 1000) ? number + 1900 : number;}



function isLeapYear(yr)

{

  if (((yr % 4 == 0) && (yr % 100 != 0)) || (yr % 400 == 0)) { return true; }

  else { return false; }

}

  

function changeDates()

{

  theForm = document.mainForm;

  now = new Date();

  var from_month=parseInt(theForm.from_month.options[theForm.from_month.selectedIndex].value,10)-1;

  var from_year=parseInt(now.getYear(),10);



  if(isLeapYear(from_year)) { var days = new Array(31,29,31,30,31,30,31,31,30,31,30,31); }

  else { var days = new Array(31,28,31,30,31,30,31,31,30,31,30,31); }



  var from_day=parseInt(theForm.from_day.options[theForm.from_day.selectedIndex].value,10);



  if(from_day >= days[from_month]) { from_day = days[from_month]; }

  else { from_day = from_day%days[from_month]; }

  theForm.from_day.options[from_day-1].selected=true;



  to_month=from_month;

  to_day = from_day%days[from_month];

  to_year=from_year;

  if(to_day == 0) { to_month = (from_month + 1) % 12; }

  if(to_day == 0 && from_month == 11) { to_year++; }



  theForm.to_month.options[to_month].selected=true;

  theForm.to_day.options[to_day].selected=true;

}



function checkOutDate()

{

  theForm = document.mainForm;

  var to_month=parseInt(theForm.to_month.options[theForm.to_month.selectedIndex].value,10)-1;



  if(isLeapYear(to_year)) { var days = new Array(31,29,31,30,31,30,31,31,30,31,30,31); }

  else { var days = new Array(31,28,31,30,31,30,31,31,30,31,30,31); }



  var to_day=parseInt(theForm.to_day.options[theForm.to_day.selectedIndex].value,10);



  if(to_day >= days[to_month]) { to_day = days[to_month]; }

  else { to_day = to_day%days[to_month]; }

  theForm.to_day.options[to_day-1].selected=true;

}







	//-->