function popup_onAjaxSuccess(popupElementId, textPrefix, transport)
{
    var response = transport.responseText || "Fejl i systemet: Artikel ikke fundet.";
    $(popupElementId).style.visibility = 'visible';
    $(popupElementId).down().innerHTML = textPrefix + response;
}

function popup_onAjaxFailure(popupElementId)
{
    alert ("Fejl i systemet: Kunne ikke hente artikel.");
}

// Show message directly
function popup_showMessage(message, popupElementId)
{
    $(popupElementId).style.visibility = 'visible';
    $(popupElementId).down().innerHTML = message;
}

// The 'pathToPage' is the absolute path (starting from /) to the page to be loaded dynamically
function popup_openPage(pathToPage, popupElementId, textPrefix)
{
    if (! textPrefix)
        textPrefix = '';

    new Ajax.Request(pathToPage,
    {
        method: 'get',
        encoding: 'UTF-8',
        onSuccess: new Function("transport", "popup_onAjaxSuccess('"+popupElementId+"', '" + textPrefix + "', transport);"),
        onFailure: new Function("",          "popup_onAjaxFailure('"+popupElementId+"');")
    } )
}

function popup_closePage(popupElementId)
{
    $(popupElementId).style.visibility = 'hidden';
}


