var curTailElement = null;
var loadingDivText = '<div class="LoadingDiv">Loading&hellip;</div>';

function OnTailClick(newsID, htmlElement) {                
    if (!TestimonialsCallback.InCallback() && !IsCurrentNews(htmlElement)) {
        curTailElement = htmlElement;
        ShowPopup(htmlElement, loadingDivText);
        TestimonialsCallback.SendCallback(newsID);        
    }
}

function OnCallbackComplete(result) {
    if (GetPopupControl().IsVisible())
        ShowPopup(curTailElement, result);
}

function OnNewsControlBeginCallback() {
    GetPopupControl().Hide();
}

function IsCurrentNews(htmlElement) {
    return (curTailElement == htmlElement) && GetPopupControl().IsVisible();
}

function GetPopupControl() {
    return ASPxClientControl.GetControlCollection().Get(popupControlID);
} 
       
function ShowPopup(element, contentText) {            
    GetPopupControl().Hide();
    GetPopupControl().SetContentHTML(contentText);
    GetPopupControl().ShowAtElement(element);
}
