// Function Get_URL_Last_Modified(url,
//                                setter)
//    This function calls the setter (function) with the string value of
//    the URL's last modified date/time as it's only (string) parameter.
//
//    If the date/time is zero, or cannot be determined, the last modified
//    parameter value passed to the "setter" function will be a null.
//

function Get_URL_Last_Modified(url,
                               setter) {
    var xmlhttp = null;

// Create xmlhttp Object
    try {
        // Firefox, Opera 8.0+, Safari
        xmlhttp = new XMLHttpRequest();
    } catch (e) {
        try {
            // Internet Explorer
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
            }
        }
    }

    if (xmlhttp == null) {
        if (setter != null) {
            setter(last_modified);
        }
    } else {
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4) {
                var last_modified = xmlhttp.getResponseHeader("Last-Modified");
                if ((last_modified == null) || (Date.parse(last_modified) == 0)) {               // unknown date (or January 1, 1970 GMT)
                    if (setter != null) {
                        setter(null);
                    }
                } else {               // unknown date (or January 1, 1970 GMT)
                    if (setter != null) {
                        setter(last_modified);
                    }
                }
            }
        }

        try {
            xmlhttp.open("HEAD", url, true);
            xmlhttp.send();
        } catch (e) {
            if (setter != null) {
                setter(last_modified);
            }
        }
    }
}

