<!--
if (typeof boolPeople == "undefined") boolPeople = "False";

function selectAll() {
    var frm = document.formPOST;
    for (i = 0; i < frm.elements.length; i++) {
        if (frm.elements[i].type == 'checkbox') {
            if (boolPeople == "True") {
                if (frm.elements[i].name == 'per_id')
                    frm.elements[i].checked = true;
            }
            else {
                if (frm.elements[i].name == 'comp_id')
                    frm.elements[i].checked = true;
            }
        }
    }
}

function deselectAll() {
    var frm = document.formPOST;
    for (i = 0; i < frm.elements.length; i++) {
        if (frm.elements[i].type == 'checkbox') {
            if (boolPeople == "True") {
                if (frm.elements[i].name == 'per_id')
                    frm.elements[i].checked = false;
            }
            else {
                if (frm.elements[i].name == 'comp_id')
                    frm.elements[i].checked = false;
            }
        }
    }
}

function downloadSelections() {
    var frm = document.formPOST;
    if (boolTrial == "True") {
        alert("Downloads are not available to free trial users.");
    }
    else {
        if (verifySelections() == true) {
            var address;
            if (boolPeople == "True")
                address = "/subscriber/downloadPersonnel.asp";
            else
                address = "/subscriber/downloadForm.asp";
            frm.action = address;
            frm.submit();
        }
    }
}

function countSelections() {
    var frm = document.formPOST;
    var count = 0;
    if (frm.per_id) {
        // count people
        for (var x = 0; x < frm.per_id.length; x++) {
            if (frm.per_id[x].checked == true)
                count++;
        }
        if (!frm.per_id.length) {
            // there's only one per_id (it's not an array)
            if (frm.per_id.checked) {
                count++;
            }
        }
    }
    if (frm.comp_id) {
        // count people
        for (var x = 0; x < frm.comp_id.length; x++) {
            if (frm.comp_id[x].checked == true)
                count++;
        }
        if (!frm.comp_id.length) {
            // there's only one comp_id (it's not an array)
            if (frm.comp_id.checked) {
                count++;
            }
        }
    }
    return count;
}

function concatenateAlertSelections(groupDelim, delim) {
    var frm = document.formPOST;
    var str = '';
    if (frm.per_id) {
        // return people
        for (var x = 0; x < frm.per_id.length; x++) {
            if (frm.per_id[x].checked == true) {
                if (str.length > 0)
                    str += delim;
                str += frm.per_id[x].value;
            }
        }
        if (!frm.per_id.length) {
            // there's only one per_id (it's not an array)
            if (frm.per_id.checked) {
                if (str.length > 0)
                    str += delim;
                str += frm.per_id.value;
            }
        }
    }
    str += groupDelim;
    if (frm.comp_id) {
        // return companies
        var first = true;
        for (var x = 0; x < frm.comp_id.length; x++) {
            if (frm.comp_id[x].checked == true) {
                if (!first)
                    str += delim;
                str += frm.comp_id[x].value;
                first = false;
            }
        }
        if (!frm.comp_id.length) {
            // there's only one comp_id (it's not an array)
            if (frm.comp_id.checked) {
                if (!first)
                    str += delim;
                str += frm.comp_id.value;
                first = false;
            }
        }
    }
    return str;
}

function concatenateSelections(alertType, delim) {
    var frm = document.formPOST;
    var x, str = '';

    if ((alertType == 'C') && frm.comp_id) {
        // return companies
        if (frm.comp_id.length) {
            for (x = 0; x < frm.comp_id.length; x++) {
                if (frm.comp_id[x].checked == true) {
                    if (str.length > 0)
                        str += delim;
                    str += frm.comp_id[x].value;
                }
            }
        }
        else {
		    // there's only one comp_id (it's not an array)
		    if (frm.comp_id.checked) {
                if (str.length > 0)
                    str += delim;
                str += frm.comp_id.value;
                first = false;
		    }
	    }
    }
    else if ((alertType == 'P') && frm.per_id) {
        // return people
        if (frm.per_id.length) {
            for (x = 0; x < frm.per_id.length; x++) {
                if (frm.per_id[x].checked == true) {
                    if (str.length > 0)
                        str += delim;
                    str += frm.per_id[x].value;
                }
            }
        }
        else {
		    // there's only one per_id (it's not an array)
		    if (frm.per_id.checked) {
                if (str.length > 0)
                    str += delim;
                str += frm.per_id.value;
		    }
	    }
    }
    return str;
}

function concatenateLabels(alertType, delim) {
    var frm = document.formPOST;
    var x, str = '';

    if ((alertType == 'C') && frm.comp_id) {
        // return companies
        if (frm.comp_id.length) {
            for (x = 0; x < frm.comp_id.length; x++) {
                if (frm.comp_id[x].checked == true) {
                    if (str.length > 0)
                        str += delim;
                    str += frm.comp_id[x].title;
                }
            }
        }
        else {
		    // there's only one comp_id (it's not an array)
		    if (frm.comp_id.checked) {
                if (str.length > 0)
                    str += delim;
                str += frm.comp_id.title;
                first = false;
		    }
	    }

    } else if ((alertType == 'P') && frm.per_id) {
        // return people
        if (frm.per_id.length) {
            for (x = 0; x < frm.per_id.length; x++) {
                if (frm.per_id[x].checked == true) {
                    if (str.length > 0)
                        str += delim;
                    str += frm.per_id[x].title;
                }
            }
        }
        else {
		    // there's only one per_id (it's not an array)
		    if (frm.per_id.checked) {
                if (str.length > 0)
                    str += delim;
                str += frm.per_id.title;
		    }
	    }
    }
    return str;
}

function verifySelections() {
    if (countSelections() == 0) {
        alert("Please make a selection before continuing.");
        return false;
    }
    return true;
}

function addToAlertsCart() {
    var frm = document.formPOST;
    if (countSelections() == 0) {
        alert("No selections were found - no records were added to \"My Alerts\".\nPlease make a selection and try again.")
        return; // return false;
    }
    var url = '';
    var strCompIds = concatenateSelections('C', ',');
    var strPersIds = concatenateSelections('P', ',');
    var strCompLabels = concatenateLabels('C', '|');
    var strPersLabels = concatenateLabels('P', '|');

    if (strCompIds.length > 0)
        url += '&cidlist=' + escape(strCompIds) + '&clabellist=' + escape(strCompLabels);
    if (strPersIds.length > 0)
        url += '&pidlist=' + escape(strPersIds) + '&plabellist=' + escape(strPersLabels);
    url = '/Subscriber/Child/addToAlertsCart.asp?' + url.substr(1);

    var winattribs = "toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, copyhistory=no, scrollbars=no"
    
    popup(url, 'addToCart', 400, 150, winattribs)
}

function deleteFromCart() {
    var strCompIds, strPersIds, url = '';
    var frm = document.formPOST;
    if (countSelections() == 0) {
        alert("No selections were found - no records were deleted from \"My Alerts\".\nPlease make a selection and try again.")
        return;
    }
    if (frm.comp_id) {
        strCompIds = concatenateSelections('C', '.');
        if (strCompIds.length > 0)
            url += '&cidlist=' + escape(strCompIds);
    }
    if (frm.per_id) {
        strPersIds = concatenateSelections('P', '.');
        if (strPersIds.length > 0)
            url += '&pidlist=' + escape(strPersIds);
    }
    url = '/Subscriber/Child/deleteFromCart.asp?' + url.substr(1);
    popup(url, 'deleteFromCart', 640, 480);
    reloadPage();
}

function createAdvancedAlert() {
    navigate('/subscriber/advancedAlert.asp');
}

function editAdvancedAlert(alertId) {
    url = "advancedAlert.asp?alert_id=" + alertId + '&action=edit';
    navigate(url);
}

function verifyEmail() {
    var frm = document.formPOST;
    var email = Trim(frm.email.value);
    if (email.length == 0) {
        alert("Please specify the Email Address.");
        return false;
    }

    if (!checkEmail(email)) {
        alert("Email Address is not valid.");
        return false;
    }

    return true;
}
//-->
