// JavaScript Document
// For page /climate/cdo/about/sitedata.shtml.  Last modified 2009 05 01

function getinfo(list) { 

 if (list.options[list.selectedIndex].value == 139 || list.options[list.selectedIndex].value == 149) {

        location.href="139.htm"

        } else if (list.options[list.selectedIndex].value == 3 || list.options[list.selectedIndex].value == 31

                 || list.options[list.selectedIndex].value == 122 || list.options[list.selectedIndex].value == 124)

        { location.href="3.htm"

        } else if (list.options[list.selectedIndex].value == 125 || list.options[list.selectedIndex].value == 126) 

        {location.href="125.htm"

        } else if (list.options[list.selectedIndex].value == 7 || list.options[list.selectedIndex].value == 128 

                || list.options[list.selectedIndex].value == 129 || list.options[list.selectedIndex].value == 131) 

        {location.href="7.htm"

        } else if (list.options[list.selectedIndex].value == 147 || list.options[list.selectedIndex].value == 144) 

        {location.href="144.htm"

        } else {

        location.href=list.options[list.selectedIndex].value+".htm"

        } 

}



function datalist(buttons,list,list2) {

        var address = "ftp://ftp.bom.gov.au/anon2/home/ncc/metadata/lists_by_element/"

        if (buttons[0].checked == true) {

                address = address + "alpha/alpha"

        } else {

                address = address + "numeric/num"

                }

        address = address + list2.options[list2.selectedIndex].value

        address = address + "_" + list.options[list.selectedIndex].value + ".txt"
		if (list.options[list.selectedIndex].value == 200)
		 {location.href="ftp://ftp.bom.gov.au/anon2/home/ncc/metadata/lists_by_element/alpha/alphaAUS_200.txt"}  // only one page for solar radiation
		 else
		 {location.href=address}

}

function getpdf(station) {

        var address = "/climate/cdo/metadata/pdf/metadata";
        address = address + station.value + ".pdf";
        location.href=address;
}

function validsitenum (sitenumber) {
    var theInput = sitenumber.value;
    theInput = theInput.replace(/^\s*/, "").replace(/\s*$/, "");    // remove leading & trailing whitespace
    if ( theInput.match(/\D/) ) {                                   // any non-digit characters?
        alert("The station number must consist only of digits,\n so '" + theInput + "' cannot be used.");
    } else if (theInput < 1000 || theInput >= 400000) {             // in range?
        alert("The station number must be between 001000 and 399999");
    } else {                                                        // all seems OK
        while (theInput.length < 6) {                               // pad out to 6 chars...
            theInput = "0" + theInput;                              // .. with leading zero
        }
        sitenumber.value = theInput;                                // save the modified version
        document.pdfmetadata.submit();                              // go get it
    }
}

function setimagesrc () {
var x;
var ilist = document.images;
var ilistlength = ilist.length;
var oldpath = "/z/";
var newpath = "/climate/cdo/images/";
for (var i=0; i<ilistlength; ++i) {
x=ilist[i].src;
document.images[i].src=x.replace(oldpath,newpath); 
}
}