/*
 * File: contacts.js
 *
 * This script is used to build tables in the contacts page.
 */

var officers =
[
    [ "caption", "Officers:" ],
    [ "row", "", "President", "&#x70;&#x72;&#101;&#115;&#105;&#100;&#101;&#x6e;&#x74;&#x40;&#x63;&#x77;&#100;&#116;&#99;&#x2e;&#x6f;&#x72;&#103;", "Kathy Miller" ],
    [ "row", "", "Vice President", "&#x76;&#105;&#x63;&#101;&#x5f;&#112;&#114;&#x65;&#x73;&#105;&#x64;&#x65;&#110;&#116;&#64;&#x63;&#x77;&#100;&#116;&#x63;&#x2e;&#x6f;&#x72;&#x67;", "Justine Espinoza" ],
    [ "row", "", "Treasurer", "&#x74;&#x72;&#101;&#x61;&#115;&#117;&#114;&#x65;&#x72;&#64;&#x63;&#119;&#x64;&#x74;&#x63;&#46;&#111;&#x72;&#x67;", "Jeff Moritz" ],
    [ "row", "", "Recording Secretary", "&#x72;&#x65;&#99;&#x6f;&#x72;&#x64;&#x69;&#110;&#x67;&#95;&#x73;&#101;&#99;&#x72;&#x65;&#116;&#97;&#114;&#x79;&#x40;&#x63;&#119;&#x64;&#116;&#x63;&#46;&#111;&#x72;&#x67;", "Sandra Moritz" ],
    [ "row", "", "Corresponding Secretary", "&#x63;&#111;&#x72;&#x72;&#101;&#115;&#x70;&#111;&#x6e;&#100;&#x69;&#x6e;&#103;&#x5f;&#x73;&#x65;&#99;&#x72;&#x65;&#x74;&#x61;&#x72;&#121;&#x40;&#99;&#x77;&#100;&#116;&#x63;&#46;&#111;&#114;&#x67;", "Nancy Pec" ]
];

var directors =
[
    [ "caption", "Board of Directors:" ],
    [ "row", "", "Director #1", "&#x64;&#x69;&#x72;&#101;&#x63;&#116;&#x6f;&#114;&#49;&#64;&#99;&#119;&#100;&#x74;&#99;&#x2e;&#x6f;&#114;&#x67;", "Janice McCarthy" ],
    [ "row", "", "Director #2", "&#x64;&#x69;&#x72;&#101;&#x63;&#x74;&#x6f;&#114;&#x32;&#x40;&#99;&#119;&#100;&#x74;&#99;&#46;&#111;&#x72;&#x67;", "Judy Neuhaus" ],
    [ "row", "", "Director #3", "&#100;&#105;&#x72;&#101;&#99;&#116;&#x6f;&#x72;&#x33;&#64;&#x63;&#x77;&#100;&#x74;&#99;&#46;&#x6f;&#x72;&#x67;", "TBD" ]
];

var trial_secretaries =
[
    [ "caption", "Trial Secretaries:" ],
    [ "row", "", "Obedience Trial Secretary", "&#111;&#x62;&#95;&#x74;&#114;&#x69;&#x61;&#x6c;&#95;&#115;&#101;&#99;&#x72;&#101;&#x74;&#97;&#x72;&#121;&#64;&#x63;&#x77;&#x64;&#116;&#x63;&#46;&#x6f;&#x72;&#103;", "Linda Hause" ],
    [ "row", "", "Agility Trial Secretary", "&#97;&#x67;&#x5f;&#x74;&#x72;&#105;&#x61;&#108;&#x5f;&#x73;&#101;&#99;&#114;&#x65;&#x74;&#x61;&#x72;&#121;&#64;&#x63;&#119;&#100;&#116;&#99;&#46;&#111;&#114;&#103;", "Debbie Stoner, Laurel Putnam" ]
];

var other =
[
    [ "caption", "Other:" ],
    [ "row", "", "Training Director", "&#x74;&#114;&#97;&#x69;&#x6e;&#x69;&#x6e;&#x67;&#95;&#x64;&#x69;&#114;&#101;&#99;&#x74;&#x6f;&#114;&#64;&#99;&#x77;&#100;&#116;&#x63;&#46;&#x6f;&#x72;&#x67;", "Linda Hause" ],
    [ "row", "", "Membership Director", "&#109;&#x65;&#109;&#x62;&#101;&#114;&#115;&#x68;&#x69;&#x70;&#x5f;&#100;&#x69;&#x72;&#101;&#x63;&#116;&#x6f;&#x72;&#x40;&#x63;&#119;&#100;&#116;&#99;&#46;&#111;&#x72;&#103;", "Jennifer Pauline" ],
    // [ "row", "", "Class Registration", "&#x72;&#x65;&#x67;&#105;&#x73;&#116;&#x72;&#97;&#114;&#x40;&#99;&#x77;&#x64;&#x74;&#x63;&#46;&#111;&#114;&#103;", "Jeff Moritz" ],
    // [ "row", "", "General Information", "&#105;&#110;&#x66;&#111;&#64;&#x63;&#x77;&#100;&#116;&#99;&#46;&#111;&#x72;&#x67;", "Jeff Moritz" ],
    [ "row", "", "CGC Evaluator", "&#x63;&#x67;&#99;&#x5f;&#101;&#x76;&#x61;&#x6c;&#x75;&#x61;&#116;&#x6f;&#114;&#64;&#x63;&#x77;&#100;&#116;&#x63;&#x2e;&#x6f;&#x72;&#103;", "Debbie Stoner" ],
    [ "row", "", "Webmaster", "&#119;&#x65;&#x62;&#x6d;&#97;&#x73;&#x74;&#101;&#114;&#64;&#x63;&#x77;&#100;&#x74;&#99;&#46;&#111;&#114;&#x67;", "Jeff Moritz" ]
];

function genContactsTableCaption(table_caption) {
    // alert ("Generating Caption: " + table_caption);
    str = "<caption class=\"contacts_table_caption\">" + table_caption + "</caption>";
    document.writeln(str);
}

// function genContactsTableHeader(table_title, table_name, col_1_header, col_2_header) {
function genContactsTableHeader(col_1_header, col_2_header) {
    // alert ("Generating Header: " + col_1_header + ", " + col_2_header);
    str = "<thead class=\"contacts_table\">";
    if (col_1_header && col_2_header) {
        str += "<tr class=\"contacts_table_header\">";
        str += "<td class=\"col_1_header\">" + col_1_header + "</td>";
        str += "<td class=\"col_2_header\">" + col_2_header + "</td>";
        str += "</tr>";
    }
    str += "</thead>";
    document.writeln(str);
}  // end: genContactsTableHeader()

function genContactsTableRow(rowspan, col_1_data, col_1_link, col_2_data) {
    // alert ("Generating Row: " + col_1_data + ", " + col_1_link + ", " + col_2_data);
    str = "<tr class=\"contacts_data_row\">";
    if (col_1_data) {
        str += "<td class=\"col_1_data\"";
        if (rowspan) {
            str += " rowspan=\"" + rowspan + "\"";
        }
        str += ">" + col_1_data + "</td>";
    }
    str += "<td class=\"col_2_data\">";
    str += "<a name=\"" + col_1_data + "\" href=\"mailto:" + col_2_data + " <" + col_1_link + ">\">" + col_2_data + "</a>";
    str += "</td>";
    str += "</tr>";    
    document.writeln(str);
}  // end: genContactsTableRow()

function genContactsTable(table_data) {
    genContactsTable(table_data, "");
}

function genContactsTable(table_data, table_class) {
    if (! table_class) {
        table_class = "contacts_table";
    }
    str = "<table class=\"" + table_class + "\">";
    document.writeln(str);
    var ii = 0;
    for (ii == 0; ii < table_data.length; ii++) {
        row = table_data[ii];
        type = row[0];
        if ("row" == type) {
            genContactsTableRow(row[1], row[2], row[3], row[4]);
        } else if ("caption" == type) {
            genContactsTableCaption(row[1]);
        } else if ("header" == type) {
            genContactsTableHeader(row[1], row[2]);
        }
    }
    document.writeln("</table>");
}  // end: genContactsTable()

function genContactsTables() {
    genContactsTable(officers);
    genContactsTable(directors);
    genContactsTable(trial_secretaries);
    genContactsTable(other);
}

