/*
Code added by Terry Fussell to prompt the user when leaving the website. 
Modified by Larry Meyer to include dynamically generated (i.e. menu) links
and to display additional messages 
*/

/*
Code by Terry Fussell to prompt the user when leaving the website. 
Modified by Larry Meyer to include dynamically generated (i.e. menu) links
and to display additional messages 
*/

var nonDantesMsg = 'The web page you are about to visit is not part of the DANTES website. The site is not under DANTES control, and DANTES is not responsible for the information or links you may find. DANTES is providing this link only as a convenience. The presence of the link is not intended to imply DANTES endorsement. ';
var pdfMsg = 'The document you are about to view on the DANTES website may contain links to external sites. If so, DANTES is not responsible and does not endorse the information or links you may find at the external site. ';
var nonGovMsg = "The appearance of hyperlinks does not constitute endorsement by the (Department of Defense/the U.S. Army/the U.S. Navy/the U.S. Air Force/the U.S. Marine Corps, etc.) of this Web site or the information, products or services contained therein. For other than authorized activities such as military exchanges and Morale, Welfare and Recreation sites, the (Department of Defense/the U.S. Army/the U.S. Navy/the U.S. Air Force/the U.S. Marine Corps, etc.) does not exercise any editorial control over the information you may find at these locations. Such links are provided consistent with the stated purpose of this DoD Web site."
document.onclick = function(e) {

    e = e || window.event;

    var t = e.target || e.srcElement;
    var t = e.target || e.srcElement;
    if (
        (t.parentNode.toString().indexOf("mailto") >= 0) || (t.nodeName == "A" && t.href.indexOf("mailto") >= 0) ||
        (t.parentNode.toString().indexOf("javascript:__doPostBack(") >= 0) || (t.nodeName == "A" && t.href.indexOf("javascript:__doPostBack(") >= 0)) {
        return true;
    }

    if (t.parentNode.toString().indexOf("http") >= 0 || t.nodeName == "A") {
        if (
           (
            t.nodeName == "A" ? t.href.indexOf(".mil") < 0 : t.parentNode.toString().indexOf(".mil") < 0
            )
            &&
            (
            t.nodeName == "A" ? t.href.indexOf(".gov") < 0 : t.parentNode.toString().indexOf(".gov") < 0
            )
            ) {
            if (confirm(nonGovMsg)) {
                return true;
            }
            else {
                return false;
            }
        }
        else {
            if (t.parentNode.toString().indexOf(".doded.mil") < 0 && t.href.indexOf(".doded.mil") < 0) {
                if (confirm(nonDantesMsg)) {
                    return true;
                }
                else {
                    return false;
                }
            }
            if (t.parentNode.toString().indexOf(".pdf") > 0 || t.href.indexOf(".pdf") > 0) {
                // Code by Thomas Morris to check if the PDF prompt should be shown.
                // You can turn off the PDF alert message by adding a attribute of 
                // showalert. (e.g. <a href="myfile.pdf" showalert="false">)
                if (t.showalert !== "false") {
                    alert(pdfMsg);
                }
            }
        }
    }
}
