﻿var bulletItem = new Image();
var bulletItem_MO = new Image();
var bulletItem_Selected = new Image();

// this routine allows setting the url that will be used in loading
// images for the bullets
function setBulletImages(itemUrl, moUrl, selectedUrl) {
    bulletItem.src = itemUrl;
    bulletItem_MO.src = moUrl;
    bulletItem_Selected.src = selectedUrl;
}

// this routine is called whenever the users runs his/her mouse over
// one of the results items that may be selected for viewing
function resultsItem_MouseOver(id)
{
    var img = document.getElementById(id);
    var td = img.parentElement != null ? img.parentElement : img.parentNode;
    if (img.src != bulletItem_Selected.src)
    {
        td.className = 'ResultsWeekLink ResultsWeekLinkMO';
        img.src = bulletItem_MO.src;
    }
}

// this routine is called whenever the user runs his/her mouse out
// from over a result item link
function resultsItem_MouseOut(id)
{
    var img = document.getElementById(id);
    var td = img.parentElement != null ? img.parentElement : img.parentNode;
    if (img.src != bulletItem_Selected.src)
    {
        td.className = 'ResultsWeekLink';
        img.src = bulletItem.src;
    }
}

function resultsItem_ItemClicked(id)
{
    var tdClickedCell = document.getElementById(id);
    var tbl = tdClickedCell.parentElement != null ? tdClickedCell.parentElement.parentElement : tdClickedCell.parentNode.parentNode;
    
    for (var i = 0; i < tbl.rows.length; ++i )
    {
       if (tbl.rows[i].cells[0].className == 'ResultsWeekLinkSelected' )
       {
            // switch this over to the "normal" view in both CSS and image
            tbl.rows[i].cells[0].className = 'ResultsWeekLink';
            tbl.rows[i].cells[0].childNodes[0].src = bulletItem.src;
            
            var divCurrentlyShowingResultsId = '';
            if (tbl.rows[i].cells[0].associatedResultsId != null)
                divCurrentlyShowingResultsId = tbl.rows[i].cells[0].associatedResultsId;
            else if (tbl.rows[i].cells[0].getAttribute != null)
                divCurrentlyShowingResultsId = tbl.rows[i].cells[0].getAttribute('associatedResultsId');

            if (divCurrentlyShowingResultsId != '')
                document.getElementById(divCurrentlyShowingResultsId).style.display = 'none';
       }
    }
    
    tdClickedCell.className = 'ResultsWeekLinkSelected';
    tdClickedCell.childNodes[0].src = bulletItem_Selected.src;
    
    var divNewResultsId = '';
    if (tdClickedCell.associatedResultsId != null)
        divNewResultsId = tdClickedCell.associatedResultsId;
    else if (tdClickedCell.getAttribute != null)
        divNewResultsId = tdClickedCell.getAttribute('associatedResultsId');
    document.getElementById(divNewResultsId).style.display = '';
}
