/*
 * File: links_table.js
 *
 * This script is used to build a table in the links page.
 */

function genLinksTableCaption(table_caption) {
    // alert ("Generating Caption: " + table_caption);
    str = "<caption class=\"links_table_caption\">" + table_caption + "</caption>";
    document.writeln(str);
}

// function genLinksTableHeader(table_title, table_name, col_1_header, col_2_header) {
function genLinksTableHeader(col_1_header, col_2_header) {
    // alert ("Generating Header: " + col_1_header + ", " + col_2_header);
    str = "<thead class=\"links_table\">";
    if (col_1_header && col_2_header) {
        str += "<tr class=\"links_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: genLinksTableHeader()

function genLinksTableRow(rowspan, col_1_data, col_2_data, col_3_data) {
    // alert ("Generating Row: " + col_1_data + ", " + col_2_data);
    str = "<tr class=\"link_data_row\">";
    if (col_1_data) {
        str += "<td class=\"col_1_data\"";
        if (rowspan) {
            str += " rowspan=\"" + rowspan + "\"";
        }
        str += ">" + col_1_data + "</td>";
    }
    if (col_3_data) {
        str += "<td class=\"col_2_data\"><a name=\"" + col_1_data + "\" href=\"" + col_2_data + "\">" + col_3_data + "</a></td>";
    } else {
        str += "<td class=\"col_2_data\"><a name=\"" + col_1_data + "\" href=\"" + col_2_data + "\">" + col_2_data + "</a></td>";
    }
    str += "</tr>";    
    document.writeln(str);
}  // end: genLinksTableRow()

function genLinksTable(table_data) {
    genLinksTable(table_data, "");
}

function genLinksTable(table_data, table_class) {
    if (! table_class) {
        table_class = "links_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) {
            genLinksTableRow(row[1], row[2], row[3], row[4]);
        } else if ("caption" == type) {
            genLinksTableCaption(row[1]);
        } else if ("header" == type) {
            genLinksTableHeader(row[1], row[2]);
        }
    }
    document.writeln("</table>");
}  // end: genLinksTable()

function genLinksTables() {
    genLinksTable(agility);
    genLinksTable(boarding);
    genLinksTable(breeds, "bordered");
    genLinksTable(conformation);
    genLinksTable(health);
    genLinksTable(kennel_clubs);
    genLinksTable(obedience);
    genLinksTable(supplies);
}

var agility =
[
    [ "caption", "Agility:" ],
    // [ "row", "", "The Dog Agility Page", "http://www.dogpatch.org/agility" ],
    [ "row", "", "Flygility", "http://homepages.ihug.co.nz/~mbutler/hurric.htm" ],
    [ "row", "", "The North American Dog Agility Council", "http://www.nadac.com" ],
    [ "row", "", "South West Agility Calendar", "http://agilek9s.net/calendar" ]
];

var boarding =
[
    [ "caption", "Boarding / Day Care:" ],
    [ "row", "", "Fit'n'Furry", "http://www.fitnfurry.com" ]
];

var breeds =
[
    [ "caption", "Breed Sites:"],
    [ "header", "Breed", "Organization" ],
    [ "row", "", "Bull Terrier", "http://www.barbarycoastbullterrierclub.org" ],
    [ "row", "", "Dachshund", "http://www.geocities.com/northerncaliforniadachshundclub" ],
    [ "row", "", "German Shepherd Dog", "http://www.gsdca.org" ],
    [ "row", "4", "Keeshond", "http://www.norcalkees.org" ],
    // [ "row", "", "", "http://www.keeshondonline.com" ],
    [ "row", "", "", "http://www.keeshondrescue.org" ],
    [ "row", "", "", "http://www.keeshondenmagazine.com" ],
    [ "row", "", "", "http://www.sierrakeeshondclub.org" ],
    [ "row", "2", "Labrador Retriever", "http://www.gglrc.org" ],
    [ "row", "", "", "http://www.labrescue.org" ],
    // [ "row", "", "Pembroke Welsh Corgi", "http://www.arf-net.com/pwc.htm" ],
    [ "row", "", "Portuguese Water Dog", "http://www.pwdcnc.org" ],
    [ "row", "", "Shetland Sheepdog", "http://www.norcalshelties.org" ],
    [ "row", "2", "Siberian Husky", "http://ncshc.com" ],
    [ "row", "", "", "http://shca.org" ]
];

var conformation =
[
    [ "caption", "Conformation:" ],
    [ "row", "", "AKC Show Schedule of Events", "http://www.akc.org/events/conformation/index.cfm" ],
    [ "row", "", "Jack Bradshaw, Superintendent", "http://www.jbradshaw.com" ],
    [ "row", "", "MB-F, Superintendent", "http://www.infodog.com/visit_mbf.htm" ],
    [ "row", "", "Onofrio, Superintendent", "http://www.onofrio.com" ],
    // [ "row", "", "Virtual Dog Show", "http://www.dogshow.com/fall97/catalog" ],
    [ "row", "", "Virtual Dog Show", "http://www.infodog.com/vds/default.htm" ]
];

var health =
[
    [ "caption", "Health:" ],
    [ "row", "", "American Animal Hospital Assoc", "http://www.aahanet.org" ],
    [ "row", "", "American Veterinary Medical Assoc", "http://www.avma.org" ],
    [ "row", "", "Finding the Right Vet", "http://www.specialneedspets.org/vetseek.htm" ],
    [ "row", "", "Merck Veterinarian Manual", "http://www.merckvetmanual.com/mvm/index.jsp" ]
];

var kennel_clubs =
[
    [ "caption", "Kennel Clubs:" ],
    [ "row", "", "American Kennel Club", "http://www.akc.org" ]
];

var obedience =
[
    [ "caption", "Obedience:" ],
    [ "row", "", "American Dog Trainers Network", "http://www.inch.com/~dogs/training.html" ],
    // [ "row", "", "All Ways for Dog Lovers", "http://www.thuntek.net/dogtrain" ],
    [ "row", "", "Associated Obedience Clubs of Northern California (AOCNC)", "http://www.aocnc.org" ],
    [ "row", "", "Association of Pet Dog Trainers", "http://www.apdt.com" ]
];

var supplies =
[
    [ "caption", "Supplies:" ],
    [ "row", "", "Cherrybrook", "http://www.cherrybrook.com" ],
    [ "row", "", "Dancing Paws", "http://www.dancingpaws.com" ],
    [ "row", "", "Doggone Good!", "http://www.doggonegood.com" ],
    [ "row", "", "Drs. Foster and Smith", "http://www.drsfosterandsmith.com" ],
    [ "row", "", "Groomer's Mall", "http://www.groomersmall.com" ],
    [ "row", "", "J &amp; J supplies", "http://www.jjdog.com" ],
    [ "row", "", "National Pet &amp; Animal Health (Cotati, CA)", "http://www.Hoofs2Paws.com" ],
    [ "row", "", "Max 200", "http://www.max200.com" ],
    [ "row", "", "Petco", "http://www.petco.com" ],
    [ "row", "", "PetEdge", "http://www.petedge.com" ],
    [ "row", "", "PetSmart", "http://www.petsmart.com" ],
    [ "row", "", "Revival Animal Health", "http://revivalanimal.com" ]
    // [ "row", "", "Show supplies", "http://www.arf-net.com" ],
];

