    //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 getDaysInMonth( 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( monthObj, dayObj, yearObj ) {
        var value = 0;
        var mthIdx = monthObj.options.selectedIndex;
        var Dt = dayObj;
        var theYear = yearObj.options[yearObj.options.selectedIndex].value;

        var numDays = getDaysInMonth( mthIdx, theYear );

        if( mthIdx == 1 ) {
            if( Dt.options.selectedIndex + 2 < numDays ) {
                return 0;
            } else {
                if( Dt.options.selectedIndex + 1 > numDays) {
                    Dt.options.selectedIndex=numDays - 1;
                }
                //check for leap year
                if( (Dt.options.selectedIndex + 1) == numDays ) {
                    return 1;
                } else {
                    return 4;
                }
            }
        }

        if( Dt.options.selectedIndex + 2 < numDays ) {
            value = 0;
        } else {
            if ( Dt.options.selectedIndex + 1 > numDays ) {
                Dt.options.selectedIndex--;
                value = 3;
            } else if ( Dt.options.selectedIndex + 1 == numDays ) {
                //index is 31 or 30
                value = 2;
            } else {
                value = 4;
            }
        }
        return value;
    }

    //changes departure month when arrival month is changed
    //changes departure month when arrival month is changed
    function amadChange(inM, inD, inY, outM, outD, outY) {
        if ( !isBrowserSupp() ) {
            return;
        }
        adjustDate(inM, inD, inY);

        var mthIdx = inM.options.selectedIndex;
        var theYear = inY.options[inY.options.selectedIndex].value;


        var numDays = getDaysInMonth(mthIdx,theYear);
        outD.options.selectedIndex = inD.options.selectedIndex + 2;
        outM.options.selectedIndex = inM.options.selectedIndex;
        outY.options.selectedIndex = inY.options.selectedIndex;

        var diffValue = ((inD.options.selectedIndex + 2) - numDays);

        if (diffValue >= 0){
            outD.options.selectedIndex = diffValue;
            outM.options.selectedIndex = inM.options.selectedIndex + 1;
            if (inM.options.selectedIndex + 1 == 12){
               outM.options.selectedIndex = 0;
               outY.options.selectedIndex = inY.options.selectedIndex + 1;
            }
        }
        adjustDate( outM, outD, outY);
        return;
    }

    function dmddChange( outM, outD, outY ) {
        if ( !isBrowserSupp() ) {
            return;
        }

        adjustDate( outM.options.selectedIndex, outD, outY.options[outY.options.selectedIndex].value );
        return;
    }

