﻿$.ajaxSetup({
    global: true,
    cache: false,
    async: true,
    dataType: "html",
    type: "GET"
});

function execAjax(page, divid, data) {
    if (divid != "div_new_mailq" && divid != "divFlash") {
        $("#dialog").dialog('open');
    }
    $.ajax({
        url: page,
        data: data,
        success: function(data) {
            if (divid != "dlgHtml" && divid != "div_new_mailq") { $("#dialog").dialog('close'); }
            if (data == "Logout") { document.location = "default.aspx" }
            else { $("[id*='" + divid + "']").html(data); }
        },
        fail: function() {
            if (divid != "dlgHtml" && divid != "div_new_mailq") { $("#dialog").dialog('close'); }
            $("[id*='" + divid + "']").html("Error getting data! Please try again.");
        }
    });
}
function execAjaxXml(page, params) {
    var retXML;
    $.ajax({
        cache: false,
        async: false,
        dataType: "xml",
        type: "POST",
        data: params,
        url: page,
        success: function(xml) {
            retXML = xml;
        },
        fail: function() {
            retXML = '<?xml version="1.0" encoding="utf-8" ?><Error><Code>-1<Code><Descr>Failed to load XML</Descr></Error>';
        }
    });
    return retXML;
}