﻿function DisplayEventProgressIndication() {
    // Store the height of the content area of the table.
    var height = $('#EventTable tbody').height();

    // Replace the entire content area with a single row/cell.
    $('#EventTable tbody').html('<tr><td colspan="2"></td></tr>');

    // Set that row's height to be the same as previous.
    $('#EventTable tbody tr').height(height);

    // Add our centered progress indicator animation to it.
    $('#EventTable tbody td').addClass('loading');
}
function BuildEventTable(msg) {
    //var table = '<table cellspacing="0" cellpadding="5" border="0"><thead><tr><th>Date</th><th>Title/Exerpt</th></thead><tbody>';
    var table = '<table cellspacing="0" cellpadding="0" border="0" id="EventTable"><tbody>';
    if (msg.length > 0) {
        for (var post in msg) {
            var row = '<tr>';
            var datearray = msg[post].ArtDate.split("/");
            row += '<td valign="top"><div style="padding: 0px 0px 5px 15px;"><a href="/Article/' + msg[post].CatPath + '/' + datearray[2] + datearray[0] + datearray[1] + '/' + msg[post].SeoTitle + '">' + msg[post].Title + ' &raquo;</a></div></td>';

            row += '</tr>';

            table += row;
        }
    } else {
        table += '<tr><td>No events found</td></tr>';
    }

    table += '</tbody></table>';

    $('#EventContainer').html(table);
}

function DisplayEventTable() {
    var myDate = $("#ctl00_RightContent_module_Events_hidEventDate").val();
    //alert("Getting Events: " + myDate);
    $.ajax({
        type: "GET",
        url: "/EventXML.ashx",
        //data: "{'searchinput': '" + myTerms + "', 'Count':'" + pageSize + "', 'Page': '" + thisPage + "'}",
        data: "searchdate=" + myDate,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        processData: false,
        success: function (msg) {
            //alert(msg.d);
            BuildEventTable(msg);
            //ApplyTemplate(msg);
        },
        error: function (myRequest, myStatus, myError) {
            //alert("Error getting search results: " + myRequest.statusText);
            $('#EventContainer').html("<p>No events found</p>");
        }
    });
}
