function typeStr(file) {
    if (file == "ruc00hr_lvl_frzg.gif") {
        typestr = "Latest analysis";
    } else if (file == "ruc03hr_lvl_frzg.gif") {
        typestr = "3 hour forecast";
    } else if (file == "ruc06hr_lvl_frzg.gif") {
        typestr = "6 hour forecast";
    } else if (file == "ruc09hr_lvl_frzg.gif") {
        typestr = "9 hour forecast";
    } else if (file == "ruc12hr_lvl_frzg.gif") {
        typestr = "12 hour forecast";
    }

    return typestr;
}

function changeIt() {
    var file = document.frzgnav.valid.options[document.frzgnav.valid.selectedIndex].value;
    var pos  = 1 + document.content.src.lastIndexOf('/');
    var curr = document.content.src.substring(pos);
    if (file != curr) {
        document.printing.alt_text.value = typeStr(file);
        document.printing.image_source.value = "/data/icing/" + file;

		document.content.src = document.printing.image_source.value
		document.content.title = document.printing.alt_text.value;
		document.content.alt = document.printing.alt_text.value;
    }
}

function nextTime(dir) {
    var sel = document.frzgnav.valid.selectedIndex;
    if (dir < 0) {
        if (sel > 0) {
            document.frzgnav.valid.selectedIndex = sel - 1;
            changeIt();
        }
    } else {
        var total = document.frzgnav.valid.length - 1;
        if (sel < total) {
            document.frzgnav.valid.selectedIndex = sel + 1;
            changeIt();
        }
    }
}

// It has to be in a function or the prevLoad variable will
// cause infinite recursion
function addChangeIt() {
    var prevLoad = window.onload;
    window.onload = function() {
    if (prevLoad) {
        prevLoad();
        }
        changeIt();
    }
}
addChangeIt();
