// <!--

// var yrSelect = getObject("YearSelect") ;
var yrSelect = document.forms[1].YearSelect ;
// var monSelect = getObject("MonthSelect") ;
var monSelect = document.forms[1].MonthSelect ;
var optinx = 0 ;

for (var iyr = beg_yr ;  iyr < end_yr ;  ++iyr) {
    var iyrstr = iyr.toString() ;
//    yrSelect.add(new Option(iyr+"", iyr+"", false, false) ;
    yrSelect.options[optinx++] = new Option(iyrstr, iyrstr, false, false) ;
}

var eyrstr = end_yr.toString() ;
// yrSelect.add(new Option(end_yr+"", end_yr+"", true, true), null) ;
yrSelect.options[optinx] = new Option(eyrstr, eyrstr, true, true) ;
// yrSelect.remove(0) ;   // remove the dummy initial element
monSelect.options[end_mon - 1].selected = true ;

for (var imon = end_mon ;  imon < 12 ;  ++imon) {
    monSelect.options[imon].disabled = true ;
}

if (end_mon < 10) {
    var path = new String("months_BAO_Tower/month_" + end_yr + "0" + end_mon + ".html") ;
} else {
    var path = new String("months_BAO_Tower/month_" + end_yr + end_mon + ".html") ;
}

curr_yr = Math.round(end_yr) ;
curr_mon = Math.round(end_mon) ;
curr_day = Math.round(end_day) ;

// var tsiframe = getObject("currTabSet") ;
// if (tsiframe == null) {
//     alert("The tsiframe is null in global_code.") ;
// } else {
//     currTabSetName = "Meas" ;
//     try {
//         tsiframe.src = "MeasTabSet.html" ;
//     } catch(er) {
//         alert("Setting tsiframe.src bollixes:\n" + er) ;
//     }
// } // end if
if (!dataparam.load() || !dataparam.field || !dataparam.date) {
// Never true here because of outside-of-any-fcn code that sets it
    dataparam.field = 400 ;
    //    dataparam.date = 20050804;
    dataparam.date = currdate_YYYYMMDD ;
    dataparam.lvl = "Combined" ;
    goDaily() ; // Includes a dataparam.store() call, as well as setting tf
    var ifcal = getObject("currMonth") ;
    try {
        ifcal.src = path ;
    } catch (er) {
        alert("Web page is in need of repairs.  Please try again later.\n") ;
    }
// alert("currdate_YYYYMMDD(no old cookie found)=" + currdate_YYYYMMDD + ";") ;
    change_field(1400) ;  // will do the correct change_date call at end, I believe
} else {
// alert("dataparam.date=" + dataparam.date + ";") ;
// If cookie exists from earlier in session...
    curr_day = Math.round(Math.round(dataparam.date) % 100) ;
    curr_month = Math.round((((Math.round(dataparam.date) - curr_day) % 10000))/100) ;
    curr_yr = Math.round(Math.round(dataparam.date - 
                           ((curr_month * 100) + curr_day)) / 10000) ;
// alert("(old cookie found)curr_yr="+curr_yr+"; curr_month="+curr_month+"; curr_day="+curr_day+";") ;
    currdate_YYYYMMDD = Math.round(dataparam.date) ;
// alert("currdate_YYYYMMDD(old cookie found)=" + currdate_YYYYMMDD + ";") ;
    if (dataparam.tf == "daily") {
// alert("Got a cookie and calling goDaily in global code.") ;
        goDaily() ;
        var ifcal = getObject("currMonth") ;
        try {
            ifcal.src = path ;
        } catch (er) {
            alert("Web page is in need of repairs.  Please try again later.\n") ;
        }
// alert("Got a cookie and calling change_field with the arg (add 1000) "+dataparam.field+".") ;
        change_field(1000 + Math.round(dataparam.field)) ;
    } else if (dataparam.tf == "monthly") {
// alert("Got a cookie and calling goMonthly in global code.") ;
        goMonthly() ;
// alert("Got a cookie and calling change_field with the arg (add 1000) "+dataparam.field+".") ;
        change_field(1000 + Math.round(dataparam.field)) ;
    }
// Don't I want to call change_date first?  -- Nope; change_field calls it
} // end if - no cookie; else - cookie
// change_date(latest_numdate) ; // change_field calls this anyway.


