﻿// JScript File
function changeDiv(id, content) {
    document.getElementById(id).innerHTML = content;
}

var indPic = '<img src="images/images/indicator.gif" border="0" />&nbsp;&nbsp;&nbsp;Loading...';

function beginAJAX(url, divID) {
    var ai = new AJAX(url, divID);
    ai.setTimer(6000);
    ai.doGet();
}
function afterAJAX(divID, content) {
    changeDiv(divID, content);
}
var getErrors = 0;
function errorAJAX(divID) {
    getErrors++;
    if (getErrors > 2) {
        location.href = "messagesold.aspx?Date="+globID;
    }
}
function noAJAX() {
    location.href = "messagesold.aspx?Date="+globID;
}

function displayMessage(id) {
    if (id != globID) {
        if (globID != todayID) {
            var td1 = document.getElementById(globID);
            td1.style.backgroundColor = "White";
            td1.firstChild.style.color = "#3791E9";
        }
        if (id != todayID) {
            var td2 = document.getElementById(id);
            td2.style.backgroundColor = "LightBlue";
            td2.firstChild.style.color = "White";
        }
        globID = id;
        changeDiv("message", indPic);
        beginAJAX("messages.aspx?AJAX=" + id, "message");
    }
}