﻿function openFixedPopup(url, articleLink) {
    var link = url + "?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 =
{
    Content: '',
    //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 = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + ArticleID;
        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='M_AD_CountUpdate'>";
                        Content += '<div class="M_AD_Count" Id="Count' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_LastUpdate" Id="LastUpdate' + ModuleID + '"></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>';

                        // Chuỗi Content dùng để in
                        AGBB.ArticleDetail.Content = 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) {
        }
    },
    //Load chi tiet tin cac tin truoc va cac tin sau TuanDX1
    LoadNextAndAferArticle: 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 = "<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src='" + ImageInfo.Loading + "'  style='height:30px;'/>";
        $(ArticleList).html(loading);
        var m_path = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + ArticleID;
        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();
                        strContent = strContent.replace("Tahoma", "Arial");
                        //Title
                        Content += "<div class='M_AD_Title'>";
                        var 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>';
                        }
                        Content += '<div class="M_AD_Content">';
                        Content += Encoder.htmlDecode(strContent);
                        Content += '</div>';
                        Content += "<div class='M_AD_CountUpdate'>";
                        Content += '<div class="M_AD_Count" Id="Count' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_LastUpdate" Id="LastUpdate' + ModuleID + '"></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>";

                        // Chuỗi Content dùng để in
                        AGBB.ArticleDetail.Content = Content;


                        var ModuleIdOther = parseInt(ModuleID) + 1000;
                        Content += "<div class='M_Clear' style='padding-top:20px;'><div class='M_AD_Title'>" + ArticleDetailInfo.OtherArticles + "</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, ArticleID);
                        AGBB.Search.SearchAD(ModuleID, '1');
                    }
                },
                error: function displayError(request, errorType, errorThrown) {
                    try {
                        if (errorType == 'timeout') {
                        }
                        if (errorType == 'error') {
                        }
                    }
                    catch (err) {
                    }
                }
            });
        }
        catch (Error) {
        }
    },
    LoadArticleCompany: 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 = "<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src='" + ImageInfo.Loading + "'  style='height:30px;'/>";
        $(ArticleList).html(loading);
        var m_path = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + ArticleID;
        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();
                        strContent = strContent.replace("Tahoma", "Arial");
                        //Title
                        Content += "<div class='M_AD_Title'>";
                        var 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>';
                        }
                        //Content
                        Content += '<div class="M_AD_Content">';
                        Content += Encoder.htmlDecode(strContent);
                        Content += '</div>';
                        Content += "<div class='M_AD_CountUpdate'>";
                        Content += '<div class="M_AD_Count" Id="Count' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_LastUpdate" Id="LastUpdate' + ModuleID + '"></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 + "'>";

                        // Chuỗi Content dùng để in
                        AGBB.ArticleDetail.Content = Content;

                        Content += '<div style="clear: both"/><div align="right" class="AD_LBGH_Div">';
                        Content += '<a href="/tabid/80/Default.aspx"';
                        Content += 'title="' + ArticleDetailInfo.GoBack + '" class="AD_LBGH_A"><img border="0" alt="" src="/DeskTopModules/AG.Article/App/Images/S_ToBack.jpg" /> ';
                        Content += ArticleDetailInfo.Back;
                        Content += '</a>';
                        Content += "</div>";
                        var ModuleIdOther = parseInt(ModuleID) + 1000;
                        $(ArticleList).html(Content);
                    }
                },
                error: function displayError(request, errorType, errorThrown) {
                    try {
                        if (errorType == 'timeout') {
                        }
                        if (errorType == 'error') {
                        }
                    }
                    catch (err) {
                    }
                }
            });
        }
        catch (Error) {
        }
    },
    LoadArticleFullTextDetail: 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 = "<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src='" + ImageInfo.Loading + "'  style='height:30px;'/>";
        $(ArticleList).html(loading);
        var m_path = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + ArticleID;
        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();
                        strContent = strContent.replace("Tahoma", "Arial");
                        //Title
                        Content += "<div class='M_AD_Title'>";
                        var 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>';
                        }
                        Content += '<div class="M_AD_Content">';
                        Content += Encoder.htmlDecode(strContent);
                        Content += '</div>';
                        Content += "<div class='M_AD_CountUpdate'>";
                        Content += '<div class="M_AD_Count" Id="Count' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_LastUpdate" Id="LastUpdate' + ModuleID + '"></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>";

                        // Chuỗi Content dùng để in
                        AGBB.ArticleDetail.Content = Content;

                        var ModuleIdOther = parseInt(ModuleID) + 1000;
                        $(ArticleList).html(Content);
                        AGBB.Search.SearchAD(ModuleID, '2');
                    }
                },
                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('');
        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 = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + ArticleID;
        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'>";
                        var 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_CountUpdate'>";
                        Content += '<div class="M_AD_Count" Id="Count' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_LastUpdate" Id="LastUpdate' + ModuleID + '"></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>';
                        //Them doan danh sach bai tin khac

                        // Chuỗi Content dùng để in
                        AGBB.ArticleDetail.Content = Content;

                        var ModuleIdOther = parseInt(ModuleID) + 1000;
                        Content += '<div class="clear" style="padding-top:20px;"/><div class="M_List_VDSC">Các sự kiện khác</div><div class="M_List_VDSC_Row"/><div ID="ArticleList' + ModuleIdOther + '"></div><div ID="ArticleIndex' + ModuleIdOther + '"></div>';
                        $(ArticleList).html(Content);
                        AGBB.ArticleDetail.LoadCountAndUpdate(ArticleID, ModuleID);
                        AGBB.ArticleDetail.LoadBottomGoHomeSendMail(ModuleID, ArticleID);
                        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 = '/Handler/AG.News/GetCountAndDate.ashx?ArticleID=' + ArtilceID;
        $.ajax({
            type: "GET",
            url: urlhander,
            dataType: "xml",
            success: function (result) {
                var NgayThangNam;
                if (DateInfo.Lang == 'EN') {
                    NgayThangNam = DateUtils.ConvertStringToMonthDayYear($(result).find('DATE').text());
                }
                else {
                    NgayThangNam = DateUtils.ConvertStringToDayMonthYear($(result).find('DATE').text());
                }
                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" 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>';
        $('#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 class="AD_LBGH_A" onclick="AGBB.ArticleDetail.GoBackList(\'' + ModuleID + '\')" style="cursor:pointer;">';
        ContentBottom += '<img border="0" alt="" src="/DeskTopModules/AG.Article/App/Images/S_ToBack.jpg" /> ';
        ContentBottom += ArticleDetailInfo.Back;
        ContentBottom += '</a>';
        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>';
        $('#Bottom' + ModuleID).html('');
        $('#Bottom' + ModuleID).html(ContentBottom);
        AGBB.ArticleDetail.LoadPrint(ModuleID);
    },
    LoadBottomGoHomeSendMail: function (ModuleID, ArticleID) {
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var TabLink = ModuleUtils.GetTabLink(CollectionParam);
        var ContentBottom = '<div style="clear: both"/><div align="right" class="AD_LBGH_Div">';
        ContentBottom += '<a onclick="AGBB.ArticleDetail.GoBackList(\'' + ModuleID + '\')" style="cursor:pointer;" ';
        ContentBottom += 'title="' + ArticleDetailInfo.GoBack + '" class="AD_LBGH_A"><img border="0" alt="" src="/DeskTopModules/AG.Article/App/Images/S_ToBack.gif" /> ';
        ContentBottom += ArticleDetailInfo.Back;
        ContentBottom += '</a>';
        ContentBottom += '<span id="inSpan' + ModuleID + '"></span>';
        ContentBottom += '<span id="MailSpan' + ModuleID + '"></span>';
        $('#Bottom' + ModuleID).html('');
        $('#Bottom' + ModuleID).html(ContentBottom);
        AGBB.ArticleDetail.LoadPrint(ModuleID, ArticleID);
        AGBB.ArticleDetail.LoadSendMail(ModuleID, ArticleID);
    },
    LoadSendMail: function (ModuleID, ArticleID) {
        var temp = location.hash.replace('#', '');
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var urlFilePath = ModuleUtils.GetXmlDetail(CollectionParam);

        var title = '';
        var m_path = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + ArticleID;
        $.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 += ' <span style="font-family: Arial;"> &#160;<a title="' + ArticleDetailInfo.SendMail + '" >';
        var articleLink = document.location.href;
        var contentMail = ' <span style="font-family: Arial;"> &#160;<a title="' + ArticleDetailInfo.SendMail + '" style="cursor:pointer;" onclick="openFixedPopup(\'/DesktopModules/AG.Article/App/SendMail-Print/SendMail.aspx\',\'' + articleLink + '\')" >';
        contentMail += '<img border="0" src="/DeskTopModules/AG.Article/App/Images/S_News_Email.gif" alt="" />&#160; </a>';
        contentMail += '<a style="cursor:pointer;"  onclick="openFixedPopup(\'/DesktopModules/AG.Article/App/SendMail-Print/SendMail.aspx\',\'' + articleLink + '\')" style="font-family: Arial; font-size: 12px; color: rgb(0, 0, 0);" >Email </a>';
        contentMail += '</span>';
        $('#MailSpan' + ModuleID).html(contentMail);
    },

    TempPrint: function (ArticleId) {
        AGBB.Printf(AGBB.ArticleDetail.Content, ArticleId);
    },

    LoadPrint: function (ModuleID, ArticleID) {
        var temp = location.hash.replace('#', '');
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var urlFilePath = ModuleUtils.GetXmlDetail(CollectionParam);

        var contentIN = "<a onclick='AGBB.ArticleDetail.TempPrint(" + ArticleID + ")' style='cursor:pointer;' >";
        contentIN += " <img border=\"0\" src=\"/DesktopModules/AG.Article/App/Images/S_News_Print.gif\" alt=\"\" />&nbsp;&nbsp;" + ArticleDetailInfo.Print + "</a>&nbsp;"
        $('#inSpan' + ModuleID).html(contentIN);
    },
    //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 = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + articleID;
        $.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 = $(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>";
                }
                $("#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 = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + articleid;
        $.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) {
            }
        });
    },
    LoadArticleDetailCompany: function (articleID, path, ModuleID) {
        var ArticleSearch = "#ArticleSearch" + ModuleID;
        var ArticlePaging = "#ArticleIndex" + ModuleID;
        var ArticleList = "#ArticleList" + ModuleID;
        $(ArticleSearch).html('');
        $(ArticlePaging).html('');
        $(ArticleList).html('');
        var contentDiv = '';
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var Category = ModuleUtils.GetCategory(CollectionParam);
        var loading = "<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src='" + ImageInfo.Loading + "'  style='height:30px;'/>";
        var m_path = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + articleID;
        $(ArticleList).html(loading);
        $.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 = "";
                    strContent += '<div class="M_AD_Left">';
                    strContent += Encoder.htmlDecode($(XML).find('Content').text());
                    strContent += '</div>';
                    strContent += '<div class="M_AD_Right">';
                    strContent += '<span>';
                    if ($(XML).find("Image").text().length > 0) {
                        strContent += "<img width='150px' src=\"/Portals/0/";
                        strContent += $(XML).find("Image").text();
                        strContent += "\" class='M_News_Image'></img>";
                        if ($(XML).find("ImgNote").text().length > 0) {
                            strContent += "<br/><div class='M_News_ImageNote'><i>";
                            strContent += $(XML).find("ImgNote").text(); ;
                            strContent += "</i></div>";
                        }
                    }
                    strContent += '</span>';
                    strContent += '</div>';
                    var ModuleIdOther = parseInt(ModuleID) + 1000;
                    var arSymbol = ($(XML).find("Lead").text()).split('@');
                    var Symbol = arSymbol[1];
                    strContent += '<div class="clear" style="padding-top:20px;"/><div class="M_AD_Bottom" Id="Bottom' + ModuleID + '" >';
                    strContent += '<div style="clear: both"/><div align="right" class="AD_LBGH_Div">';
                    strContent += '<a class="AD_LBGH_A" onclick="AGBB.ArticleDetail.GoBackList(\'' + ModuleID + '\')" style="cursor:pointer;">';
                    strContent += '<img border="0" alt="" src="/DeskTopModules/AG.Article/App/Images/S_ToBack.jpg" /> ';
                    strContent += ArticleDetailInfo.Back;
                    strContent += '</a>';
                    strContent += '</div>';
                    $(ArticleList).html(strContent);
                }
            }
        });
    },
    GoBackList: function (ModuleID) {
        var temp = location.hash.replace('#', '');
        location.hash = '#AL,' + ModuleID;
    },
    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('');
        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 = "/Handler/AG.News/MarketCalendar_GetDetailByID_Hander.ashx?ID=" + ArticleID + "&t=" + DateUtils.GetDateTimeNow();
        try {
            $.ajax({
                type: "GET",
                url: m_path,
                dataType: "xml",
                success: function (XML) {
                    $(ArticleSearch).html('');
                    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'>";
                        var 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 style="height:30px;"> </div>';
                        Content += "<div class='M_AD_CountUpdate'>";
                        Content += '<div class="M_AD_Count" Id="Count' + ModuleID + '"></div>';
                        Content += '<div class="M_AD_LastUpdate" Id="LastUpdate' + ModuleID + '"></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>';
                        $(ArticleList).html(Content);
                        AGBB.ArticleDetail.LoadCountAndUpdate(ArticleID, ModuleID);
                        AGBB.ArticleDetail.LoadBottomGoHomeSendMail(ModuleID, ArticleID);
                    }
                },
                error: function displayError(request, errorType, errorThrown) {
                    try {
                        if (errorType == 'timeout') {
                        }
                        if (errorType == 'error') {
                        }
                    }
                    catch (err) {
                    }
                }
            });
        }
        catch (Error) {
        }
    },
    ShowDetail: function (ModuleID, ArticleID, Position, TotalFor, Path) {
        var DivDetail = "#m_LoadListAndDetail_Detail_" + ModuleID + "_" + Position;
        // Hiển thị ảnh loading
        var loading = "<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src=\"" + ImageInfo.Loading + "\" style=\" height:30px\"/></div>";
        $(DivDetail).html('');
        $(DivDetail).html(loading);
        // Lấy đường dẫn đến file XML chi tiết bài tin
        var FullPath = "/Handler/AG.News/GetDetailArticles.ashx?ArticleID=" + ArticleID;
        var Content = '';
        // Đóng hết các phần chi tiết bài tin đang mở
        for (var i = 0; i < TotalFor; i++) {
            $("#m_LoadListAndDetail_Detail_" + ModuleID + "_" + i).html('');
            document.getElementById("m_LoadListAndDetail_Detail_" + ModuleID + "_" + i).style.lineHeight = "0px";
        }
        document.getElementById("m_LoadListAndDetail_Detail_" + ModuleID + "_" + Position).style.lineHeight = "15px";
        // Hiển thị chi tiết bài tin dưới title được click
        $.ajax({
            type: "GET",
            url: FullPath,
            dataType: "xml",
            async: false,
            success: function (result) {

                Content = Encoder.htmlDecode($(result).find("Content").text());
                $(DivDetail).html(Content);
            },
            error: function displayError(request, errorType, errorThrown) {
                AGBB.ALProcessData.ProcessError();
            }
        });
    },
    /********** VuLM - Create: 14/10/2010 - Description: function ShowContent for template LoadFinancialReport (VDSC - Báo cáo tài chính) **********/
    ShowContent: function (ModuleID, Position, TotalFor, Year) {
        var DivDetail = "#m_FinancialReport_Detail_" + ModuleID + "_" + Position;
        // Hiển thị ảnh loading
        var loading = "<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src=\"" + ImageInfo.Loading + "\" style=\" height:30px\"/></div>";
        $(DivDetail).html('');
        $(DivDetail).html(loading);
        var Content = '';
        // Đóng hết các phần tóm tắt bài tin đang mở
        for (var i = 0; i < TotalFor; i++) {
            if (document.getElementById("m_LoadFinancialReport_Img_" + ModuleID + "_" + i) != null) {
                $("#m_FinancialReport_Detail_" + ModuleID + "_" + i).html('');
                // Hiển thị dấu cộng ở đầu dòng
                document.getElementById("m_LoadFinancialReport_Img_" + ModuleID + "_" + i).className = "m_LoadFinancialReport_ImgCong";
                document.getElementById("m_FinancialReport_Detail_" + ModuleID + "_" + i).style.lineHeight = "0px";
            }
        }
        document.getElementById("m_FinancialReport_Detail_" + ModuleID + "_" + Position).style.lineHeight = "25px";
        document.getElementById("m_LoadFinancialReport_Img_" + ModuleID + "_" + Position).className = "m_LoadFinancialReport_ImgTru";
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var SetOfCategoryID = ModuleUtils.GetCategory(CollectionParam);
        var Order = ModuleUtils.GetOrder(CollectionParam);
        var OrderBy = ModuleUtils.GetOrderBy(CollectionParam);
        var t = DateUtils.GetDateTimeNow();
        var Url = "/Handler/AG.News/AL_GetByCategoryAndYear.ashx";
        var FullUrl = Url + "?SetOfCategoryID=" + SetOfCategoryID + "&Year=" + Year + "&Order=" + Order + "&OrderBy=" + OrderBy + "&NumberOfRecord=-1&Page=1&t=" + t;
        // Hiển thị tiêu đề các báo cáo dưới năm được click
        $.ajax({
            type: "GET",
            url: FullUrl,
            dataType: "xml",
            async: false,
            success: function (result) {
                var TotalLoop = $(result).find('It').length;
                for (var i = 0; i < TotalLoop; i++) {
                    //if ($(result).find("It[id=\"" + i + "\"]").find("T").text().match('[\\w\\W]*?' + Year + '[\\w\\W]*?') != null) {
                    var ArticleID = $(result).find("It[id=\"" + i + "\"]").find("Id").text();
                    var Path = $(result).find("It[id=\"" + i + "\"]").find("P").text();
                    var date = $(result).find("It[id=\"" + i + "\"]").find("D").text();
                    Content += "<div class=\"m_FinancialReport_TitleReport\" onclick=\"javascript:AGBB.App.setTemplateDetail('" + ModuleID + "','" + ArticleID + "','" + Path + "')\">";
                    Content += "<a onclick=\"javascript:AGBB.App.setTemplateDetail('" + ModuleID + "','" + ArticleID + "','" + Path + "')\">";
                    Content += StringUtils.SubString($(result).find("It[id=" + i + "]").find("T").text(), 70);
                    Content += "&nbsp;&nbsp;(" + DateUtils.ConvertStringToDayMonthYear(date) + ")";
                    Content += "</a>";
                    Content += "</div>";
                    Content += "<div class=\"Clear\"></div>";
                    //}
                }
                // Đẩy nội dung html vào div chứa detail
                $(DivDetail).html(Content);
            },
            error: function displayError(request, errorType, errorThrown) {
                AGBB.ALProcessData.ProcessError();
            }
        });
    }
}
