<!--
var basinName="Brahma";

var rootDir="http://cfab2.eas.gatech.edu/";
var rootDirCFAN="http://cfab2.eas.gatech.edu/";

var satelliteDir="imagesShortTerm";

var rootLarge = rootDir + satelliteDir + "/";
var rootSmall = rootDir + satelliteDir + "/";

var rootLargeCFAN = rootDirCFAN + satelliteDir + "/";
var rootSmallCFAN = rootDirCFAN + satelliteDir + "/";

var otherDisplay=false

var year,month,day,fcst

var firstY,firstM,firstD
var lastY,lastM,lastD

var defaultYearIdx

var NumberRiskVars

var yearEnd = yearEnd_nrt
var monthEnd = monthEnd_nrt
var dayEnd = dayEnd_nrt
var fcstIni=1

year=yearEnd; month=monthEnd; day=dayEnd; fcst=fcstIni;

firstY = yearStart; firstM = monthStart; firstD = dayStart;
lastY = yearEnd; lastM = monthEnd; lastD = dayEnd;

defaultYearIdx = yearEnd - yearStart + 1;

function fcst_options() {
        options = "<OPTION>Day"
        for (var i=1; i<=10; ++i) {
                options += "<OPTION"
                if (i == fcst) options += " selected>"
                else options += ">"	
		if (i < 10) options += "0"
                options += i
        }
        return options
}

function year_options() {
        options = "<OPTION VALUE=" + year + ">Year"
        for (var i=yearStart; i<=yearEnd; ++i) {
                options += "<OPTION VALUE=" + i
                if (year == i) options += " selected>"
                else options += ">"
                options += i
        }
        return options
}


function month_options() {
        options = "<OPTION>Month"
        for (var i=1; i<=12; ++i) {
                options += "<OPTION"
                if (i ==monthEnd) options += " selected>"
                else options += ">"
                options += month_names[i]
                <!-- options += i
        }
        return options
}

function day_options() {
        options = "<OPTION>Day"
        for (var i=1; i<=31; ++i) {
                options += "<OPTION"
                if (i == dayEnd) options += " selected>"
                else options += ">"
                if (i < 10) options += "0"
                options += i
        }
        return options
}


function range(num, beginMonth, beginDay, beginYear, endMonth, endDay, endYear) {
        this.num = num;
        this.beginMonth = beginMonth;
        this.beginDay = beginDay;
        this.beginYear = beginYear;
        this.endMonth = endMonth;
        this.endDay = endDay;
        this.endYear = endYear;
}


function valid_day(inDay) {
        if (month == 2) {
                if (inDay > get_Feb_length()) return false;
        }
        else if (inDay > month_lengths[month]) return false;
        return true;
}

function reset_index() {

        form = document.forms["select_date"];
        form.year.options[defaultYearIdx].selected = true;
        form.month.options[monthEnd].selected = true;
        form.day.options[dayEnd].selected = true;

	form2 = document.forms["select_lead"];
	form2.fcst.options[fcstIni].selected = true;
	


}

function within_range() {

        if ((year == yearStart) && (month == monthStart) && (day < dayStart)) return false;
        if ((year == yearStart) && (month <  monthStart)) return false;
        if ((year <  yearStart)) return false;

        if ((year == yearEnd) && (month== monthEnd) && (day > dayEnd)) return false
        if ((year == yearEnd) && (month > monthEnd)) return false;
        if ((year >  yearEnd)) return false
        return true;
}

     
function set_year() {
        form = document.forms["select_date"];
        ySI = form.year.selectedIndex
        if (ySI == 0) { form.year.options[defaultYearIdx-(yearEnd-year)].selected = true; }
        else year = parseInt(form.year.options[ySI].value);
}

function set_month() {
        form = document.forms["select_date"];
        mSI = form.month.selectedIndex;
        if (mSI == 0) { form.month.options[month].selected = true; }
        else month = mSI
}

function set_day() {
        form = document.forms["select_date"];
        dSI = form.day.selectedIndex;
        if (dSI == 0) { form.day.options[day].selected = true; }
        else day = dSI
}

function set_fcst() {
        form2 = document.forms["select_lead"];
        fSI = form2.fcst.selectedIndex;
        if (fSI == 0) { form2.fcst.options[fcst].selected = true; }
        else fcst = fSI
}


function valid_select() {
	if ( !exist_data()) {
		rangeMsg = "Data only available\n";
		rangeMsg += " From " + monthStart + "/"
		rangeMsg += dayStart + "/" + yearStart + " to " + monthEnd + "/" + dayEnd + "/" + yearEnd +".\n";
		alert(rangeMsg);
		return false
	}
	return true
}


function convert(inStr) {
	if (inStr < 10) return ("0" + inStr);
	return inStr;
}


function get_gif(par) {
	gifName = par +"/"+ par+"_" + year + convert(month) + convert(day) + ".gif";
	return gifName;
}

function get_gifFcstH(par) {
	gifName = par + "/"+ par+"_" + year + convert(month) + convert(day) + "_"+fcst+".gif";
	return gifName;
}

function get_gif_big(par) {
        gifName = par + "/"+par+"_" + year + convert(month) + convert(day) + "BIG.gif";
        return gifName;
}

function get_gif_bigFcstH(par) {
        gifName = par + "/"+par+"_" + year + convert(month) + convert(day) + "_"+fcst+ "BIG.gif";
        return gifName;
}


function display_image() {
	form = document.forms["select_date"];

	if (otherDisplay || valid_select()) {
		outputText = year + "/" + convert(month) + "/" + convert(day);
//		form.output.value = outputText;

        document.images["VAR"].alt = rootSmall + get_gif(basinName);
	//document.all["VARlink"].href = rootLarge + get_gif_big(basinName);
	document.getElementById('VARlink').href=rootLarge + get_gif_big(basinName);
		document.images["VAR"].src = rootSmall + get_gif(basinName);
		otherDisplay = false 
	}
	
	display_imageFcts()
	
}


function display_imageFcts() {
	form = document.forms["select_date"];

	if (otherDisplay || valid_select()) {
		outputText = year + "/" + convert(month) + "/" + convert(day);
//		form.output.value = outputText;

        document.images["VARfcstH"].alt = rootSmall + get_gifFcstH(basinName);
	//document.all["VARlinkFcstH"].href = rootLarge + get_gif_bigFcstH(basinName);
	document.getElementById("VARlinkFcstH").href = rootLarge + get_gif_bigFcstH(basinName);
	document.images["VARfcstH"].src = rootSmall + get_gifFcstH(basinName);
        
}
}


function set_basin(pvar) {

	basinName = pvar;
	display_image();

}

function display_next() {
	otherDisplay = true
	form = document.forms["select_date"]
	day++

	if (!valid_day(day)) {day = 1; month++}
	if (month == 13) {year++; month = 1}

	if (!exist_data()) {
		if ((year > lastY) || (year == lastY && month > lastM) || (year == lastY && month==lastM && day > lastD)) {
			msg ="Data not available"
			msg +=" after "+ lastM + "/" + lastD + "/" + lastY + ".\n"
			alert(msg)
			display_last()
		}
		else if ((year < firstY) || (year == firstY && month < firstM)) display_first()
	}

	else {
		form.year.options[year-yearStart+1].selected = true
		form.month.options[month].selected = true
		form.day.options[day].selected = true
		display_image()
	
	}
	display_imageFcts()
}


function display_prev() {
	otherDisplay = true
	form = document.forms["select_date"];
	day--

	if(day == 0) {
		month--
		if (month == 0) {year--; month = 12}
		if (month == 2) {day = get_Feb_length()}
		else {day = month_lengths[month]}
	}

	if (!exist_data()) {
		if ((year < firstY) || (year == firstY && month < firstM) || (year == firstY && month == firstM && day <firstD)) {
			msg ="Sorry. Data are not available"
			msg +=" before "+ firstM + "/" + firstD + "/" + firstY + ".\n"
			msg += "Images for " + firstM + "/" +firstD +"/" +firstY + " will be displayed"
			alert(msg)
			display_first()
		}
		else if ((year > lastY) || (year == lastY && month > lastM)) display_last()
	}

	else {
		form.year.options[year-yearStart+1].selected = true
		form.month.options[month].selected = true
		form.day.options[day].selected = true
		display_image()
	}
	display_imageFcts()
}

function data_may_need_refreshing() {
	return(0);
}

function display_nextFcst() {
	otherDisplay = true
	form2 = document.forms["select_lead"]
	fcst++

	if(fcst == 11) {
		fcst--
			msg ="Forecasts are available from Day 1 to Day 10tr		"
			alert(msg)
	}

	form2.fcst.options[fcst].selected = true
	display_imageFcts()
		
}

function display_prevFcst() {
	otherDisplay = true
	form2 = document.forms["select_lead"]
	fcst--

	if(fcst == 00) {
		fcst++
			msg ="Forecasts are available from Day 1 to Day 15"
			alert(msg)
	}

	form2.fcst.options[fcst].selected = true
	display_imageFcts()
		
}



function display_first() {
        year = firstY
        form.year.options[year-yearStart+1].selected = true
        month = firstM
        form.month.options[month].selected = true
        day = firstD
        form.day.options[day].selected = true

}


function display_last() {
        year = lastY
        form.year.options[year-yearStart+1].selected = true
        month = lastM
        form.month.options[month].selected = true
        day = lastD
        form.day.options[day].selected = true

}



// -->
