﻿$(function () {

    $.each($(".AsyncWidgetLoader"), function (index, item) {
        var widgetContent = this;
        $(widgetContent).html("<center><img src=\"/Images/loading.gif\"/></center>");

        var WidgetId = $(widgetContent).attr("WidgetId");
        var ViewMode = $(widgetContent).attr("ViewMode");
        var PageId = $(widgetContent).attr("PageId");

        var uri = "/AsyncLoadWidget/" + WidgetId + "/" + PageId + "/" + ViewMode + "/Get.aspx";

        if (document.location.toString().indexOf("?") == -1) {
            uri = uri + "?" + new Date().getTime();
        }
        else {
            uri = uri + "?" + document.location.toString().split("?")[1] + "&" + new Date().getTime();
        }

        $.ajax({
            url: uri,
            success: function (data) {

                $(widgetContent).html(data);

                //$(widgetContent).find(".scripts").html("");
            }
        });

    });

});
