<!-- Begin
// external JavaScript file

/**
 * Coded by Michael R. Brundin
 * Created in March 2005
 * Last revised in October 2008
 */

// variable to contain the message
var message = "Please read the "
        + "<a href=\"terms.html\">Terms&nbsp;of&nbsp;Use</a> "
        + "before downloading resources."
        + "<br /><br />"
        + "A list of resources recently added to the DRR "
        + "can be viewed from the "
        + "<a href=\"../whatsnew.html#new_resources\">What's "
        + "New</a> page on our main Web site.";
     
// variable to contain the black dash
var dash = "------------------------";

// variable to contain the copyright statement
var now = new Date();
var year = now.getYear();
if (year < 2000) {
    year = year + 1900;
}
var copyright = '&copy; ' + year
        + ' <a href=".." ' + 'class="copyright">CAM in UME Project</a>';

// variable to contain the processing form statement
var processing = '<p id="hideProcessing">'
        + '<span class="processing">'
        + 'Your TLR submission form is now being processed ...'
        + '</span><br />'
        + '<img src="2-bar.gif" name="bar" width="362" height="8"'
        + 'border="0" alt="" />'
        + '</p>';

// function to open a new browser window for resources (CAMpods and TLRs) links
function popUp(URL)
{
    var day = new Date();
    var id = day.getTime();
    if (window.open) {
        window.open(URL, id,'width=900,height=650,left=112,'
                + 'top=84, directories=yes,location=yes,menubar=yes,'
                + 'scrollbars=yes,status=yes,toolbar=yes,resizable=yes');
    }
}

// function to check limitType
function checkLimitType(form)
{
    if (form.limitType.value == "All resources"
            || form.limitType.value == "CAMpods") {
        form.limitTLRcategory.value = "All TLR categories";
    }
}

// function to check limitTLRcategory
function checkLimitTLRcategory(form)
{
    if (form.limitTLRcategory.selectedIndex != 0) {
        form.limitType.value = "TLRs";
    }
}

/* functions to display and rehide the CAMpod abstracts */

function displayAbs(abstract)
{
    if (document.getElementById) {
        document.getElementById(abstract).style.display = "block";
    }
}

function hideAbs(abstract)
{
    if (document.getElementById) {
        document.getElementById(abstract).style.display = "none";
    }
}

/* function to check TLR submission form data */

function checkTLR(tlr_form)
{

// check if required form fields have been filled out
    if ((tlr_form.new_revised[0].checked == false
            && tlr_form.new_revised[1].checked == false)
            || tlr_form.author.value == ""
            || tlr_form.position.value == ""
            || tlr_form.email.value == ""
            || tlr_form.uploadedfile.value == ""
            || tlr_form.date.value == "") {
        var warning = "Please provide information on:\n\n";
        if (tlr_form.new_revised[0].checked == false && 
                tlr_form.new_revised[1].checked == false) {
            var warning = warning + "* if a new TLR or a revised TLR\n";
        }
        if (tlr_form.author.value == "") {
            var warning = warning + "* the author\'s name\n";
        }
        if (tlr_form.position.value == "") {
            var warning = warning + "* the author\'s position/credentials\n";
        }
        if (tlr_form.email.value == "") {
            var warning = warning + "* the author\'s e-mail address\n";
        }
        if (tlr_form.uploadedfile.value == "") {
            var warning = warning + "* the TLR file to upload\n";
        }
        if (tlr_form.date.value == "") {
            var warning = warning + "* the TLR creation/revison date\n";
        }
        alert(warning);
        if (tlr_form.new_revised[0].checked == false
                && tlr_form.new_revised[1].checked == false) {
            parent.location = "#new_revised";
        }
        else if (tlr_form.author.value == "") {
            parent.location = "#author";
            tlr_form.author.focus();
        }
        else if (tlr_form.position.value == "") {
            parent.location = "#position";
            tlr_form.position.focus();
        }
        else if (tlr_form.email.value == "") {
            parent.location = "#email";
            tlr_form.email.focus();
        }
        else if (tlr_form.uploadedfile.value == "") {
            parent.location = "#uploadedfile";
            tlr_form.uploadedfile.focus();
        }
        else if (tlr_form.date.value == "") {
            parent.location = "#date";
            tlr_form.date.focus();
        }
        return false;
    }

// check for properly-formed drive letter if client is Windows OS
    if ((window.RegExp) && (navigator.appVersion.indexOf("Win") != -1)) {
        var regexp1 = /^[a-zA-Z]:/;
        var drive_letter = tlr_form.uploadedfile.value.substring(0,2);
        if (!regexp1.test(drive_letter)) {
            alert("The filename path of the TLR file to be uploaded\n"
                    + "does not begin with a properly-formed drive letter,\n"
                    + "i.e., \"[a-zA-Z]:\".");
            parent.location = "#uploadedfile";
            tlr_form.uploadedfile.focus();
            return false;
        }
    }

// check for a valid file extension
    if (window.RegExp) {
        var filename = tlr_form.uploadedfile.value;
        var filename_array = filename.split(".");
        var file_ext = filename_array[filename_array.length-1];
        var regexp2 = /doc|htm|html|jpg|pdf|png|ppt|rtf|shw|txt|wpd/i;
        if (!regexp2.test(file_ext)) {
            alert("The TLR file to be uploaded does not have a valid file extension.\n"
                    + "Valid file extensions include the following: .doc, .htm,\n"
                    + ".html, .jpg, .pdf, .png, .ppt, .rtf, .shw, .txt, and .wpd.");
            parent.location = "#uploadedfile";
            tlr_form.uploadedfile.focus();
            return false;
        }
    }

// display processing text and animated GIF if required form fields pass checks
    if (document.getElementById) {
        document.getElementById('hideProcessing').style.display = "block";
        document.images['bar'].src = "2-bar.gif"; // workaround for IE, to restart animated GIF
        setTimeout('document.images["bar"].src = "2-bar.gif"', 200);
        return true;
    }

// end function checkTLR
}

// End -->
