﻿
function openFixedPopup(url, title, articleLink) {
    var link = url + "?Title=" + title + "&ArticleLink=" + articleLink;
    var width = 500;
    var height = 500;
    var top = (screen.height - height) / 2;
    var left = (screen.width - width) / 2;
    window.open(link, '', 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',resizable=no,scrollbars=no', false);
}

function OpenPrintWindow(theURL, winName, features) {
    window.open(theURL, winName, features);
}
function printandclosewindow() {
    window.print();
    window.close();
}
var newwindow;
function poptastic(url) {
    newwindow = window.open(url, 'name', 'height=400,width=200');
    if (window.focus) { newwindow.focus() }
}
var previousArticleID = '1';


AGBB.ArticleDetail =
{    
    //Load chi tiet tin tuc cac bai tin tiep theo
    LoadNextArticle: function(ArticleID, path, ModuleID) {
        var ArticleSearch = "#ArticleSearch" + ModuleID;
        var ArticlePaging = "#ArticleIndex" + ModuleID;
        var ArticleList = "#ArticleList" + ModuleID;
        $(ArticleSearch).html('');
        $(ArticlePaging).html('');
        $(ArticleList).html('');
        var Content = '';
        var loading = "var loading = \"<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src='" + ImageInfo.Loading + "'  style='height:30px;'/>";
        $(ArticleList).html(loading);
        var m_path = AGBB.App.XmlDetail + path + ".xml?t=" + DateUtils.GetDateTimeNow();
        try {
            $.ajax({
                type: "GET",
                url: m_path,
                dataType: "xml",
                success: function(XML) {
                    if ($(XML).find('Title').text().length == 0) {
                        Content = "<div style=\"color:red;\">" + Warning.FileNotFound + "</div>";
                    }
                    else {
                        var strContent = $(XML).find('Content').text();

                        //Title
                        Content += '<p>';
                        Content += "<div class='M_AD_Title'>";
                        Content += $(XML).find('Title').text() + "<i>&nbsp;(" + ArticleDetailInfo.Source + ": " + $(XML).find('Source').text() + ")</i>";
                        Content += "</div>";
                        Content += '</p><br /><br />';
                        //Anh
                        Content += '<span>';
                        if ($(XML).find("Image").text().length > 0) {
                            Content += "<img width='170px' src=\"/Portals/0/";
                            Content += $(XML).find("Image").text();
                            Content += "\" class='DNews_Image'></img>";
                            if ($(XML).find("ImgNote").text().length > 0) {
                                Content += "<br/><div class='DNews_ImageNote'><i>";
                                Content += $(XML).find("ImgNote").text(); ;
                                Content += "</i></div>";
                            }
                        }
                        Content += '</span>';
                        //Lead
                        Content += '<div class="M_AD_Lead">';
                        Content += $(XML).find('Lead').text();
                        Content += '</div><br />';
                        //Content
                        Content += '<div class="M_AD_Content">';
                        Content += Encoder.htmlDecode(strContent);
                        Content += '</div>';
                        Content += '<div class="AD_Count" Id="Count' + ModuleID + '"></div>';
                        Content += '<div style="clear: both;"/>';
                        Content += '<div class="AD_LastUpdate" Id="LastUpdate' + ModuleID + '"></div>';
                        Content += '<div class="lineSeperate"/>';
                        Content += '<div class="M_AD_NextList" Id="NextArticle1' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_NextList" Id="NextArticle2' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_Bottom" Id="Bottom' + ModuleID + '"></div>';
                        // alert(Content);
                        $(ArticleList).html(Content);
                        AGBB.ArticleDetail.LoadCountAndUpdate(ArticleID, ModuleID);
                    }
                },
                error: function displayError(request, errorType, errorThrown) {
                    try {
                        if (errorType == 'timeout') {

                        }
                        if (errorType == 'error') {
                        }
                    }
                    catch (err) {
                    }
                }
            });

        }
        catch (Error) {
        }
    },

    Detail5Older: '/DesktopModules/AG.Article/App/Handler/Detail5Older.ashx',
    Detail5Newer: '/DesktopModules/AG.Article/App/Handler/Detail5Newer.ashx',
    //Load chi tiet tin cac tin truoc va cac tin sau
    LoadNextAndAferArticle: function(ArticleID, path, ModuleID) {
        var ArticleSearch = "#ArticleSearch" + ModuleID;
        var ArticlePaging = "#ArticleIndex" + ModuleID;
        var ArticleList = "#ArticleList" + ModuleID;
        $(ArticleSearch).html('');
        $(ArticlePaging).html('');
        $(ArticleList).html('');
        //  alert("ModuletID" + ModuleID + "ArtilceId" + ArticleID + "Path:" + path);
        var Content = '';
        var loading = "<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src='" + ImageInfo.Loading + "'  style='height:30px;'/>";
        $(ArticleList).html(loading);
        var m_path = AGBB.App.XmlDetail + path + ".xml?t=" + DateUtils.GetDateTimeNow();
        try {
            $.ajax({
                type: "GET",
                url: m_path,
                dataType: "xml",
                success: function(XML) {
                    if ($(XML).find('Title').text().length == 0) {
                        Content = "<div style=\"color:red;\">" + Warning.FileNotFound + "</div>";
                    }
                    else {
                        var strContent = $(XML).find('Content').text();

                        //Title

                        Content += "<div class='M_AD_Title'>";
                        // Content += $(XML).find('Title').text() + "<i>&nbsp;(" + ArticleDetailInfo.Source + ": " + $(XML).find('Source').text() + ")</i>";
                        var date = new Date($(XML).find('Date').text());

                        Content += $(XML).find('Title').text() + "<i style='font-weight:normal;'>&nbsp;(" + DateUtils.ConvertStringToDayMonthYear(date) + ")</i>";
                        //
                        Content += "</div>";

                        //Lead
                        if ($(XML).find('Lead').text().length > 0) {
                            Content += '</br></br><div class="M_AD_Lead">';
                            Content += $(XML).find('Lead').text();
                            Content += '</div>';
                        }
                        //Anh
//                        Content += '<span>';
//                        if ($(XML).find("Image").text().length > 0) {
//                            Content += "<img width='170px' src=\"/Portals/0/";
//                            Content += $(XML).find("Image").text();
//                            Content += "\" class='M_News_Image'></img>";
//                            if ($(XML).find("ImgNote").text().length > 0) {
//                                Content += "<br/><div class='M_News_ImageNote'><i>";
//                                Content += $(XML).find("ImgNote").text(); ;
//                                Content += "</i></div>";
//                            }
//                        }
//                        Content += '</span>';
                        //Content
                        Content += '<div class="M_AD_Content">';
                        Content += Encoder.htmlDecode(strContent);
                        Content += '</div>';
                        Content += '<div class="M_AD_LastUpdate">';
                        Content += '<span Id="Count' + ModuleID + '"></span>';
                        Content += '<span  Id="LastUpdate' + ModuleID + '"></span>';
                        //Content += '<div style="clear:both;"></div>';
                        Content += '</div>';
                        Content += '<div class="lineSeperate"/>';
                        Content += '<div class="M_AD_NextList" Id="NextArticle1' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_NextList" Id="NextArticle2' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_Bottom" Id="Bottom' + ModuleID + '"></div>';
                        // alert("1" + Content);
                        $(ArticleList).html(Content);
                        AGBB.ArticleDetail.LoadCountAndUpdate(ArticleID, ModuleID);
                        //                        AGBB.ArticleDetail.LoadArticleList(ArticleID, AGBB.ArticleDetail.Detail5Older, '5', ArticleDetailInfo.AfterList, '2', ModuleID);
                        //                        AGBB.ArticleDetail.LoadArticleList(ArticleID, AGBB.ArticleDetail.Detail5Newer, '5', ArticleDetailInfo.NextList, '1', ModuleID);

                        AGBB.ArticleDetail.LoadBottomGoHome(ModuleID);
                    }

                },
                error: function displayError(request, errorType, errorThrown) {
                    try {
                        if (errorType == 'timeout') {

                        }
                        if (errorType == 'error') {

                        }

                    }
                    catch (err) {
                    }
                }
            });

        }
        catch (Error) {
        }
    },
    //Danh sach cac bai tin khac co phan trang
    LoadArticleDetailOtherPaging: function(ArticleID, path, ModuleID) {
        var ArticleSearch = "#ArticleSearch" + ModuleID;
        var ArticlePaging = "#ArticleIndex" + ModuleID;
        var ArticleList = "#ArticleList" + ModuleID;
        $(ArticleSearch).html('');
        $(ArticlePaging).html('');
        $(ArticleList).html('');
        //  alert("ModuletID" + ModuleID + "ArtilceId" + ArticleID + "Path:" + path);
        var Content = '';
        var loading = "<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src='" + ImageInfo.Loading + "'  style='height:30px;'/>";
        $(ArticleList).html(loading);
        var m_path = AGBB.App.XmlDetail + path + ".xml?t=" + DateUtils.GetDateTimeNow();
        try {
            $.ajax({
                type: "GET",
                url: m_path,
                dataType: "xml",
                success: function(XML) {
                    if ($(XML).find('Title').text().length == 0) {
                        Content = "<div style=\"color:red;\">" + Warning.FileNotFound + "</div>";
                    }
                    else {
                        var strContent = $(XML).find('Content').text();
                        //Title
                        Content += "<div class='M_AD_Title'>";
                        // Content += $(XML).find('Title').text() + "<i>&nbsp;(" + ArticleDetailInfo.Source + ": " + $(XML).find('Source').text() + ")</i>";
                        var date = new Date($(XML).find('Date').text());
                        Content += $(XML).find('Title').text() + "<i>&nbsp;(" + DateUtils.ConvertStringToDayMonthYear(date) + ")</i>";
                        //
                        Content += "</div>";

                        //Lead
                        if ($(XML).find('Lead').text().length > 0) {
                            Content += '</br></br><div class="M_AD_Lead">';
                            Content += $(XML).find('Lead').text();
                            Content += '</div>';
                        }


                        //Anh
                        Content += '<span>';
                        if ($(XML).find("Image").text().length > 0) {
                            Content += "<img width='170px' src=\"/Portals/0/";
                            Content += $(XML).find("Image").text();
                            Content += "\" class='M_News_Image'></img>";
                            if ($(XML).find("ImgNote").text().length > 0) {
                                Content += "<br/><div class='M_News_ImageNote'><i>";
                                Content += $(XML).find("ImgNote").text(); ;
                                Content += "</i></div>";
                            }
                        }

                        Content += '</span>';
                        //Content
                        Content += '<div class="M_AD_Content">';
                        Content += Encoder.htmlDecode(strContent);
                        Content += '</div>';
                        Content += '<div class="M_AD_LastUpdate" Id="LastUpdate' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_Count" Id="Count' + ModuleID + '"></div>';
                        Content += '<div class="lineSeperate"/>';
                        Content += '<div class="M_AD_NextList" Id="NextArticle1' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_NextList" Id="NextArticle2' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_Bottom" Id="Bottom' + ModuleID + '"></div>';
                        // alert("1" + Content);
                        //Them doan danh sach bai tin khac
                        var ModuleIdOther = parseInt(ModuleID) + 1000;
                        Content += '<div class="clear" style="padding-top:20px;"/><div class="M_AD_Title">Các sự kiện khác</div><div class="M_AD_Line"/><div ID="ArticleList' + ModuleIdOther + '"></div><div ID="ArticleIndex' + ModuleIdOther + '"></div>';
                        $(ArticleList).html(Content);
                        AGBB.ArticleDetail.LoadCountAndUpdate(ArticleID, ModuleID);

                        AGBB.ArticleDetail.LoadBottomGoHomeSendMail(ModuleID);
                        AGBB.Search.SearchAD(ModuleID, '2');
                    }
                },
                error: function displayError(request, errorType, errorThrown) {
                    try {
                        if (errorType == 'timeout') {

                        }
                        if (errorType == 'error') {

                        }

                    }
                    catch (err) {
                    }
                }
            });

        }
        catch (Error) {
        }
    },
    LoadCountAndUpdate: function(ArtilceID, ModuleId) {
        var urlhander = '/DesktopModules/AG.Article/App/Handler/GetCountAndDate.ashx?ArticleID=' + ArtilceID;
        $.ajax({
            type: "GET",
            url: urlhander,
            dataType: "xml",
            success: function(result) {
                var NgayThangNam;

                if (DateInfo.Lang == 'EN') {
                    // alert("!");
                    NgayThangNam = DateUtils.ConvertStringToMonthDayYear($(result).find('DATE').text());
                }
                else {

                    NgayThangNam = DateUtils.ConvertStringToDayMonthYear($(result).find('DATE').text());
                }
                // var GioPhutGiay = DateUtils.ConvertStringToHourMinusSecond($(result).find('DATE').text());
                // var displayDate = NgayThangNam + " : " + GioPhutGiay
                var displayDate = NgayThangNam;
                if ($(result).find('COUNT').text().length > 0) {
                    $("#Count" + ModuleId).html(ArticleDetailInfo.ReadNumber + $(result).find('COUNT').text() + " - ");
                }
                if ($(result).find('DATE').text().length > 0) {
                    $("#LastUpdate" + ModuleId).html(ArticleDetailInfo.LastUpdate + displayDate);
                }
            },
            error: function displayError(request, errorType, errorThrown) {
                try {
                    if (errorType == 'timeout') {

                    }
                    if (errorType == 'error') {

                    }

                }
                catch (err) {
                }
            }
        });
    },
    LoadBottom: function(ModuleID) {
        var ContentBottom = '<div style="clear: both"></div><div align="right" class="DNews_GoTop">';
        // ContentBottom += '<a href="javascript:scroll(0,0)" title="Lên đầu trang">';
        // ContentBottom += '<img border="0" alt="Lên đầu trang" src="/Portals/0/Images/Icon_lendautrang.gif" /></a>&#160';
        ContentBottom += '<a href="javascript:scroll(0,0)" title="Lên đầu trang" style="color:#FFCC00;">Lên đầu </a>&#160';
        ContentBottom += '<a href="javascript:window.history.back(-1);"';
        ContentBottom += 'title="Quay về trang màn hình trước khi mở trang này" class="DNews_LGoTop">';
        ContentBottom += '<img border="0" alt="" src="/Portals/0/Images/Icon_vetrangtruoc.gif" />';
        ContentBottom += 'Về trang trước</a>&#160; &#160;<span id="inSpan' + ModuleID + '"></span> <span style="font-family: Arial;"> &#160; <a title="Gửi Email" href="mailto:support@cscj.vn">';
        ContentBottom += '<img border="0" src="/Portals/0/Images/Icon-guimail.gif" alt="" />&#160; </a>';
        ContentBottom += '<a title="Gửi Email" href="mailto:support@cscj.vn" style=" color:#FFCC00">Email </a></span></div>';
        // alert(ContentBottom);
        $('#Bottom' + ModuleID).html('');
        $('#Bottom' + ModuleID).html(ContentBottom);
        AGBB.ArticleDetail.LoadPrint(ModuleID);
    },
    LoadBottomGoHome: function(ModuleID) {
        var ContentBottom = '<div style="clear: both"/><div align="right" class="AD_LBGH_Div">';
        //  ContentBottom += '<a href="javascript:scroll(0,0)" title="' + ArticleDetailInfo.GoHome + '">';
        //ContentBottom += '<img border="0" alt="' + ArticleDetailInfo.GoHome + '" src="/DeskTopModules/AG.Article/App/Images/S_ToTop.gif" /></a>';
        //ContentBottom += '<a href="javascript:scroll(0,0)" title="' + ArticleDetailInfo.GoHome + '"> ' + ArticleDetailInfo.GoHome + ' </a>';
        ContentBottom += '<span id="BackSpan' + ModuleID + '">';
        ContentBottom += '<a href="javascript:window.history.back(-1);"';
        ContentBottom += 'title="' + ArticleDetailInfo.GoBack + '" class="AD_LBGH_A"><img border="0" alt="" src="/DeskTopModules/AG.Article/App/Images/S_ToBack.jpg" /> ';
        ContentBottom += ArticleDetailInfo.Back;
        ContentBottom += '</a>';
        ContentBottom += '</span>';
        ContentBottom += '<span id="inSpan' + ModuleID + '"></span> <span style="font-family: Arial;"> &#160;<a title="' + ArticleDetailInfo.SendMail + '" href="mailto:' + ArticleDetailInfo.Mail + '">';
        ContentBottom += '<img border="0" src="/DeskTopModules/AG.Article/App/Images/S_News_Email.gif" alt="" />&#160; </a>';
        ContentBottom += '<a class="AD_LBGH_A" title="' + ArticleDetailInfo.SendMail + '" href="mailto:' + ArticleDetailInfo.Mail + '">' + ArticleDetailInfo.Email + '</a></span></div>';

        // alert(ContentBottom);
        $('#Bottom' + ModuleID).html('');
        $('#Bottom' + ModuleID).html(ContentBottom);
        AGBB.ArticleDetail.LoadPrint(ModuleID);
    },
    LoadBottomGoHomeSendMail: function(ModuleID) {
        var ContentBottom = '<div style="clear: both"/><div align="right" class="AD_LBGH_Div">';
        //  ContentBottom += '<a href="javascript:scroll(0,0)" title="' + ArticleDetailInfo.GoHome + '">';
        //ContentBottom += '<img border="0" alt="' + ArticleDetailInfo.GoHome + '" src="/DeskTopModules/AG.Article/App/Images/S_ToTop.gif" /></a>';
        //ContentBottom += '<a href="javascript:scroll(0,0)" title="' + ArticleDetailInfo.GoHome + '"> ' + ArticleDetailInfo.GoHome + ' </a>';
        ContentBottom += '<span id="BackSpan' + ModuleID + '">';
        ContentBottom += '<a href="javascript:window.history.back(-1);"';
        ContentBottom += 'title="' + ArticleDetailInfo.GoBack + '" class="AD_LBGH_A"><img border="0" alt="" src="/DeskTopModules/AG.Article/App/Images/S_ToBack.jpg" /> ';
        ContentBottom += ArticleDetailInfo.Back;
        ContentBottom += '</a>';
        ContentBottom += '</span>';
        ContentBottom += '<span id="inSpan' + ModuleID + '"></span>';
        ContentBottom += '<span id="MailSpan' + ModuleID + '"></span>';
        //  ContentBottom +=' <span style="font-family: Arial;"> &#160;<a title="' + ArticleDetailInfo.SendMail + '" href="mailto:' + ArticleDetailInfo.Mail + '">';
        // ContentBottom += '<img border="0" src="/DeskTopModules/AG.Article/App/Images/S_News_Email.gif" alt="" />&#160; </a>';
        // ContentBottom += '<a class="AD_LBGH_A" title="' + ArticleDetailInfo.SendMail + '" href="mailto:' + ArticleDetailInfo.Mail + '">' + ArticleDetailInfo.Email + '</a></span>';
        ContentBottom += '</div>';

        // alert(ContentBottom);
        $('#Bottom' + ModuleID).html('');
        $('#Bottom' + ModuleID).html(ContentBottom);
        AGBB.ArticleDetail.LoadPrint(ModuleID);
        AGBB.ArticleDetail.LoadSendMail(ModuleID);

    },
    LoadSendMail: function(ModuleID) {
        var temp = location.hash.replace('#', '');
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var urlFilePath = ModuleUtils.GetXmlDetail(CollectionParam);
        // var contentMail = '<span style="font-family: Arial;"> &#160; <a title="Gửi Email" href="mailto:support@jsi.vn">';
        var contentMail = ' <span style="font-family: Arial;"> &#160;<a title="' + ArticleDetailInfo.SendMail + '" href="mailto:' + ArticleDetailInfo.Mail + '">';

        contentMail += '<img border="0" src="/DeskTopModules/AG.Article/App/Images/S_News_Email.gif" alt="" />&#160; </a>';
        var title = '';
        var m_path = AGBB.App.XmlDetail + urlFilePath + ".xml?t=" + DateUtils.GetDateTimeNow();
        $.ajax({
            type: "GET",
            url: m_path,
            dataType: "xml",
            async: false,
            success: function(XML) {
                title = $(XML).find('Title').text();
            },
            error: function displayError(request, errorType, errorThrown) {
                try {
                    if (errorType == 'timeout') {

                    }
                    if (errorType == 'error') {

                    }

                }
                catch (err) {
                }
            }
        });
        // contentMail += '<a title="Gửi Email" href="mailto:support@jsi.vn" style=" color:#FFCC00">Email </a>
        contentMail += ' <span style="font-family: Arial;"> &#160;<a title="' + ArticleDetailInfo.SendMail + '" href="mailto:' + ArticleDetailInfo.Mail + '">';
        //openFixedPopup(url, title, articleLink)
        var articleLink = document.location.href;
        // contentMail += '<a onclick="OpenPrintWindow(\'/DesktopModules/AG.ArticleManagement/SendEmail.aspx?title=' + title + '\',\'scrollbars=yes,width=645,height=455\')" style="font-family: Arial; font-size: 12px; color: rgb(0, 0, 0);" href="javascript:" title="Gửi bài này cho bạn bè">Email </a>';
        contentMail += '<a onclick="openFixedPopup(\'/DesktopModules/AG.Article/App/SendEmail.aspx\',\'' + title + '\',\'' + articleLink + '\')" style="font-family: Arial; font-size: 12px; color: rgb(0, 0, 0);" href="javascript:" title="Gửi bài này cho bạn bè">Email </a>';
        contentMail += '</span>';
        $('#MailSpan' + ModuleID).html(contentMail);
    },
    LoadPrint: function(ModuleID) {
        var temp = location.hash.replace('#', '');
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var urlFilePath = ModuleUtils.GetXmlDetail(CollectionParam);
        var contentIN = "<a LoadPrint title=\"" + ArticleDetailInfo.OpenPrint + "\" href=\"#" + temp + "\" onclick=\"OpenPrintWindow('/DesktopModules/AG.Article/App/region/In/in.htm?path=" + urlFilePath + "','','scrollbars=yes,width=545,height=255')\">";
        contentIN += " <img border=\"0\" src=\"/DeskTopModules/AG.Article/App/Images/S_News_Print.gif\" alt=\"\" />&nbsp;&nbsp;" + ArticleDetailInfo.Print + "</a>&nbsp;"
        //alert(contentIN);
        $('#inSpan' + ModuleID).html(contentIN);
    },
    //Load cac bai tin tiep theo
    LoadNextArticle: function(articleID, ModuleID) {
        var contentDiv = '';
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var Category = ModuleUtils.GetCategory(CollectionParam);
        var urlhander = '/DesktopModules/AG.Article/App/Handler/Detail5Older.ashx?ArticleID=' + articleID + "&SetOfCategory=" + Category;
        $.ajax({
            type: "GET",
            url: urlhander,
            dataType: "xml",
            success: function(XML) {
                numberOfItem = $(XML).find('It').length;
                var j = 0;
                var countfor = 5;
                if (numberOfItem < countfor) {
                    countfor = numberOfItem;
                };
                if ($(XML).find("It[id=\"0\"]").find("T").text().length > 0) {
                    contentDiv += "<div class=\"\"><span class='AD_NextList_Title'>Các tin tiếp theo</span></div> <div class=\"clear\">";
                }
                for (j = 0; j < countfor; j++) {
                    var date = new Date($(XML).find("It[id=\"" + j + "\"]").find("D").text());
                    contentDiv += '<div class="M_N_CKTN"><div class="M_N_C"><div class="M_N_D" style="width:260px; text-align:left;">';
                    contentDiv += DateUtils.ConvertStringToDayMonthYear(date) + '&nbsp;|&nbsp;' + DateUtils.ConvertStringToHourMinus(date);
                    contentDiv += '<div style="font-weight:bold">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
                    contentDiv += $(XML).find("It[id=\"" + j + "\"]").find("S").text();
                    contentDiv += '</div>'
                    contentDiv += '</div>';
                    contentDiv += '<div class="M_N_T">';
                    contentDiv += '<a href="javascript:AGBB.App.setTemplateDetail(\'';
                    contentDiv += $(XML).find("It[id=\"" + j + "\"]").find("Id").text();
                    contentDiv += "','";
                    contentDiv += $(XML).find("It[id=\"" + j + "\"]").find("P").text();
                    contentDiv += "','";
                    contentDiv += ModuleID;
                    contentDiv += "')\">";
                    contentDiv += StringUtils.SubString($(XML).find("It[id=\"" + j + "\"]").find("T").text(), 90);
                    contentDiv += "</a></div><div style='clear:both;'></div></div>";

                };
                if ($(XML).find("It[id=\"0\"]").find("T").text().length > 0) {
                    contentDiv += "</div>";
                }
                alert(contentDiv);
                $("#NextArticle" + ModuleID).html('');
                $("#NextArticle" + ModuleID).html(contentDiv);

            },
            error: function displayError(request, errorType, errorThrown) {
                try {
                    if (errorType == 'timeout') {
                    }
                    if (errorType == 'error') {

                    }

                }
                catch (err) {
                }
            }
        });

    },
    //Load cac bai tin tiep theo
    LoadArticleList: function(articleID, Url, NumberOfItem, Title, ID, ModuleID) {
        var contentDiv = '';
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var Category = ModuleUtils.GetCategory(CollectionParam);
        var urlhander = Url + '?ArticleID=' + articleID + "&SetOfCategory=" + Category;
        $.ajax({
            type: "GET",
            url: urlhander,
            dataType: "xml",
            success: function(XML) {
                var countfor = $(XML).find('It').length;
                var j = 0;
                if (countfor > parseInt(NumberOfItem)) {
                    countfor = parseInt(NumberOfItem)
                }
                if ($(XML).find("It[id=\"0\"]").find("T").text().length > 0) {
                    contentDiv += "<div class=\"paddingTitleNews\"><img src=\"/Portals/0/Skins/APSI/Images/Icon/title.png\" /><span class=\"titleOtherNews\">" + Title + "</span></div> <div class=\"clear\">";
                }
                for (j = 0; j < countfor; j++) {
                    var date = new Date($(XML).find("It[id=\"" + j + "\"]").find("D").text());
                    contentDiv += "<div class='AL_NoSource_Dot'>";
                    contentDiv += "<div class=\"AD_Date_Div\">";
                    contentDiv += DateUtils.ConvertStringToDayMonthYear(date);
                    contentDiv += "</div>";
                    contentDiv += "<div class='AD_HourMinus'>";
                    contentDiv += DateUtils.ConvertStringToHourMinus(date);
                    contentDiv += "</div>";
                    contentDiv += "<div class='AD_NoSource_Title_Div'>";
                    contentDiv += '<a class="AD_LAL_A" href="javascript:AGBB.App.setTemplateDetail(\'';
                    contentDiv += $(XML).find("It[id=\"" + j + "\"]").find("Id").text();
                    contentDiv += "','";
                    contentDiv += $(XML).find("It[id=\"" + j + "\"]").find("P").text();
                    contentDiv += "','";
                    contentDiv += ModuleID;
                    contentDiv += "')\">";
                    contentDiv += StringUtils.SubString($(XML).find("It[id=\"" + j + "\"]").find("T").text(), 76);
                    contentDiv += "</a></div></div>";
                };
                if ($(XML).find("It[id=\"0\"]").find("T").text().length > 0) {
                    contentDiv += "</div>";
                }
                //  alert(contentDiv);
                $("#NextArticle" + ID + ModuleID).html('');
                $("#NextArticle" + ID + ModuleID).html(contentDiv);

            },
            error: function displayError(request, errorType, errorThrown) {
                try {
                    if (errorType == 'timeout') {
                    }
                    if (errorType == 'error') {

                    }

                }
                catch (err) {
                }
            }
        });

    },


    LoadScoll: function(Url, articleid) {

        var url = '/ArticleFiles/Portal0/' + Url + '.xml';

        $.ajax({
            type: "GET",
            url: url,
            dataType: "xml",
            success: function(XML) {

                if ($(XML).find('Title').text().length == 0) {
                    strContent = "<div style=\"color:red;\">Không tìm thấy file này</div>";
                }
                else {
                    var strContent = $(XML).find('Content').text();
                    var divName = "#GioiThieu_CongTy_Div" + articleid;
                    var priviousDiv = "#GioiThieu_CongTy_Div" + previousArticleID;
                    $(priviousDiv).html('');
                    if (priviousDiv != divName)
                        $(priviousDiv).hide();
                    $(divName).html(Encoder.htmlDecode("<div style='padding-right:10px;'>" + strContent + "</div>"));
                    $(divName).toggle("slow ");
                    previousArticleID = articleid;
                }

            },
            error: function displayError(request, errorType, errorThrown) {

            }
        });

    },
    LoadScollTD: function(Url, articleid) {

        var url = '/ArticleFiles/Portal0/' + Url + '.xml';

        $.ajax({
            type: "GET",
            url: url,
            dataType: "xml",
            success: function(XML) {

                if ($(XML).find('Title').text().length == 0) {
                    strContent = "<div style=\"color:red;\">Không tìm thấy file này</div>";
                }
                else {
                    var strContent = $(XML).find('Content').text();
                    var divName = "#GioiThieu_CongTy_Div" + articleid;
                    var priviousDiv = "#GioiThieu_CongTy_Div" + previousArticleID;
                    $(priviousDiv).html('');
                    if (priviousDiv != divName)
                        $(priviousDiv).hide();
                    $(divName).html(Encoder.htmlDecode("<div style='padding-right:10px;'>" + strContent + "</div><div style='text-align:left;padding-top:10px;padding-bottom:2px;'><a href='/tabid/313/default.aspx'><img style='border:0px;' src='/DesktopModules/AG.Article/App/Images/UngTuyenTrucTuyen.gif'/></a></div>"));
                    $(divName).toggle("slow ");
                    previousArticleID = articleid;
                }

            },
            error: function displayError(request, errorType, errorThrown) {

            }
        });

    },
    
    LoadArticleLSKDetail: function(ArticleID, path, ModuleID) {
        var ArticleSearch = "#ArticleSearch" + ModuleID;
        var ArticlePaging = "#ArticleIndex" + ModuleID;
        var ArticleList = "#ArticleList" + ModuleID;
        $(ArticleSearch).html('');
        $(ArticlePaging).html('');
        $(ArticleList).html('');
        //  alert("ModuletID" + ModuleID + "ArtilceId" + ArticleID + "Path:" + path);
        var Content = '';
        var loading = "<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src='" + ImageInfo.Loading + "'  style='height:30px;'/>";
        $(ArticleList).html(loading);
        var m_path = "/DesktopModules/AG.Article/App/Handler/MarketCalendar_GetDetailByID_Hander.ashx?ID="+ArticleID+"&t=" + DateUtils.GetDateTimeNow();
        try {
            $.ajax({
                type: "GET",
                url: m_path,
                dataType: "xml",
                success: function(XML) {
                    if ($(XML).find('Title').text().length == 0) {
                        Content = "<div style=\"color:red;\">" + Warning.FileNotFound + "</div>";
                    }
                    else {
                        var strContent = $(XML).find('Detail').text();
                        //Title
                        Content += "<div class='M_AD_Title'>";
                        var date = new Date($(XML).find('CreateDate').text());
                        Content += $(XML).find('Title').text() + "<i>&nbsp;(" + DateUtils.ConvertStringToDayMonthYear(date) + ")</i>";
                        Content += "</div>";
                        //Content
                        Content += '<div class="M_AD_Content">';
                        Content += Encoder.htmlDecode(strContent);
                        Content += '</div>';
                        Content += '<div class="M_AD_Source"> Theo: ';
                        Content += $(XML).find('Source').text();
                        Content += '</div>';
                        
                        Content += '<div class="M_AD_LastUpdate" Id="LastUpdate' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_Count" Id="Count' + ModuleID + '"></div>';
                        Content += '<div class="lineSeperate"/>';
                        Content += '<div class="M_AD_NextList" Id="NextArticle1' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_NextList" Id="NextArticle2' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_Bottom" Id="Bottom' + ModuleID + '"></div>';
                        // alert("1" + Content);
                        //Them doan danh sach bai tin khac
//                        var ModuleIdOther = parseInt(ModuleID) + 1000;
//                        Content += '<div class="clear" style="padding-top:20px;"/><div class="M_AD_Title">Các sự kiện khác</div><div class="M_AD_Line"/><div ID="ArticleList' + ModuleIdOther + '"></div><div ID="ArticleIndex' + ModuleIdOther + '"></div>';
                        $(ArticleList).html(Content);
//                        AGBB.ArticleDetail.LoadCountAndUpdate(ArticleID, ModuleID);

                        AGBB.ArticleDetail.LoadBottomGoHomeSendMail(ModuleID);
//                        AGBB.Search.SearchAD(ModuleID, '2');
                    }
                },
                error: function displayError(request, errorType, errorThrown) {
                    try {
                        if (errorType == 'timeout') {

                        }
                        if (errorType == 'error') {

                        }

                    }
                    catch (err) {
                    }
                }
            });

        }
        catch (Error) {
        }
    }


}
