$(document).ready(
    function()
    {
        $(".sidebar div,#content div").each(function(){
            var blocId = $(this).attr("id");
            if(blocId != null && blocId != "")
            {
                if(blocId.indexOf("bloc_") != -1)
                {
                    blocId = parseInt(blocId.replace("bloc_",""));
                    $.ajax({
                        url:rootDir+"index/get_module/bloc/"+blocId,
                        dataType:"json",
                        success:function(data)
                        {
                            
                            if(data.success === true)
                            {
                                if(data.isText !== true)
                                {
                                    if(typeof(data.redirect_url) != "undefined")
                                    {
                                        $.ajax({
                                            dataType:"html",
                                            url:data.redirect_url,
                                            success:function(htmlData){
                                                $("#bloc_"+blocId).html(htmlData);
                                            }
                                        });
                                    }
                                }
                            }else
                            {
                                var newElem = document.createElement("H5");
                                $("#bloc_"+blocId).empty().append($(newElem).css("color","red").css("font-size","11px").css("font-weight","bold").css("text-align","center").text(data.message));
                            }
                        },
                        async:true
                    });
                }
            }
        });
    }
);


