﻿function setDescriptionTooltip($element, show)
{
    if (show) 
    {
        tooltipText = description;
    } 
    else 
    {
        tooltipText = "";
    }
    $element.attr('title', tooltipText);
    $element.attr('alt', tooltipText);
}

function setupDescription() {

    if (description == "") {
        return;
    }

    // We only slice the description for Archives.    
    if (type == 'Live')
        return;

    $("#DescriptionText").expander({
        expandText: '(' + more_info_str + ')',
        userCollapseText: '(' + less_info_str + ')',
        afterExpand: function($thisElement) {
            setDescriptionTooltip($thisElement, false);
        },
        onCollapse: function($thisElement, byUser) {
            setDescriptionTooltip($thisElement, true);
        }
    });

    // This is a bit of a hack to see if the expander plugin has
    // sliced the description in two. In cases where it does, it
    // puts in a <span> with class="details", which holds holds
    // the second part of the description.
    if ($("#DescriptionText > .details").length > 0)
        setDescriptionTooltip($("#DescriptionText"), true);

}

$(document).ready(function() {

    setupDescription();

});