﻿var SPECIAL_DAYS = {};
AGBB.ALProcessData = {
    //dung khoi tao truoc khi search
    InnitData: function(Url, ModuleID) {
        var executeContentJS = "<script> var loading = \"<div style='clear:both;'/><div class='AL_Loading_Div' ><img  src='" + ImageInfo.Loading + "'  style='height:30px;'/></div>\";";
        executeContentJS += "$('#ArticleList" + ModuleID + "').html(loading);";
        executeContentJS += "var ObjectModuleName = '#ObjectModuleID " + ModuleID + "';";
        executeContentJS += " var CollectionParam = $(ObjectModuleName).text();";
        executeContentJS += "var ArticleList = '#ArticleList" + ModuleID + "';";
        executeContentJS += "var ArticleIndex = '#ArticleIndex" + ModuleID + "';";
        executeContentJS += "var TabLink = ModuleUtils.GetTabLink(CollectionParam);";
        executeContentJS += "var NumberRecordFirstPage = ModuleUtils.GetNumberOfRecordFirstPage(CollectionParam);";
        executeContentJS += " var NumberOfRecordPerPage = ModuleUtils.GetNumberOfRecordPerPage(CollectionParam);";
        executeContentJS += "var DetailModule = ModuleUtils.GetDetailModule(CollectionParam);";
        executeContentJS += "var TypeLoad = ModuleUtils.GetDisplayType(CollectionParam);";
        executeContentJS += "var Floor = ModuleUtils.GetFloorID(CollectionParam);";
        executeContentJS += "var Category = ModuleUtils.GetCategory(CollectionParam);";
        executeContentJS += " var content = '';";
        executeContentJS += " var UrlPath = '';";
        executeContentJS += " if (FileUtils.IsXmlFile('" + Url + "' )) {";
        executeContentJS += " UrlPath ='" + Url + "?t=" + DateUtils.GetDateTimeNow() + "';";
        executeContentJS += " }";
        executeContentJS += " else {";
        executeContentJS += "  UrlPath = '" + Url + "&?t=" + DateUtils.GetDateTimeNow() + "';";
        executeContentJS += " }</script>";
        $('#InnitArticleList').html(executeContentJS);
    },
    //dung de fill du lieu theo moduleId
    FillDataToID: function(ModuleID, NumberOfItem,content) {
        var executeContentJS = "<script>";
        executeContentJS += " $('#ArticleList').html('');";
        executeContentJS += "$('#ArticleList').html("+content+");";
        //executeContentJS += " var NumberOfItem = eval(parseInt($(result).find('TotalCount').text()));";
        executeContentJS += "var func = \"AGBB.Paging.SetCurrentPage('" + ModuleID + "',\";";
        executeContentJS += "$(ArticleIndex).html('');";
        executeContentJS += " $(ArticleIndex).html(PagingUtils.DrawPaging(CurrentPage, NumberOfRecordPerPage," +  NumberOfItem +", func));</script>";
        $('#FillDataToID').html(executeContentJS);
    },
    //Dung de su ly loi
    ProcessError: function(Id) {
        var executeContentJS = "<script>";
        executeContentJS += 'var temp = "<div class=\'AL_UD\'>" + ArticleListInfo.UpdateData + "...</div>";';
        executeContentJS += "$(ArticleIndex).html('');";
        executeContentJS += "$(ArticleList).html(temp);}</script>";
        $('#ProcessError').html(executeContentJS);
    }
}
AGBB.URL = {
    SymbolList: '/ArticleFiles/Portal0/Category/MaCongTyNiemYet.xml',
    CategoryList: '/ArticleFiles/Portal0/Category/CategoryList.xml',
    //Lay Url tu ngay den ngay
    GetUrlFullText: function (Page) {
        url = document.location.href;
        var indexkey = url.indexOf("keyword");
        var key = url.substring(indexkey + 8, url.length - 8);
        return '/Handler/AG.News/AL_SearchFullText.ashx?page=' + Page + "&Key=" + key;
    },
    GetUrlByBeginDateEndDate: function (pageNumber, ModuleID) {
        DateUtils.GetBeginEndDateByModuleID(ModuleID);
        var strURL = '/Handler/AG.News/ALD.ashx?page=' + pageNumber + '&CategoryID=' + SetOfCategoryID + '&NumberOfItemPerPage=' + NumberOfItemPerPage + '&BeginDate=' + dBegin + '&Enddate=' + dEnd;
        return strURL;
    },
    //Lay Url theo source
    GetUrlBySource: function (pageNumber, ModuleID) {
        DateUtils.GetBeginEndDateByModuleID(ModuleID);
        var obj_Source = document.getElementById('AL_Source_Dll' + ModuleID);
        var Source = obj_Source.value;
        var strURL = '/Handler/AG.News/ALD_Source.ashx?page=' + pageNumber + '&CategoryID=' + SetOfCategoryID + '&NumberOfItemPerPage=' + NumberOfItemPerPage + '&BeginDate=' + dBegin + '&Enddate=' + dEnd + '&Source=' + Source;
        return strURL;
    },
    //Lay Url theo ma chung khoan
    GetUrlBySymbol: function (pageNumber, ModuleID) {
        DateUtils.GetBeginEndDateByModuleID(ModuleID);
        var obj_Symbol = document.getElementById('AL_Symbol_Dll' + ModuleID);
        var Symbol = obj_Symbol.value;
        var strURL = '/Handler/AG.News/ALD_Symbol.ashx?page=' + pageNumber + '&CategoryID=' + SetOfCategoryID + '&NumberOfItemPerPage=' + NumberOfItemPerPage + '&BeginDate=' + dBegin + '&Enddate=' + dEnd + '&Symbol=' + Symbol;
        return strURL;
    },
    //Lay Url cua tim kiem nang cao
    GetUrlSearchAdvanced: function (pageNumber, ModuleID) {
        DateUtils.GetBeginEndDateByModuleID(ModuleID);
        var obj_Symbol = document.getElementById('AL_Symbol_Dll' + ModuleID);
        var obj_KeyWord = document.getElementById('SearchArticle_KeyWord' + ModuleID);
        var obj_Category = document.getElementById('SearchArticle_Categoryddl' + ModuleID);
        var Symbol = obj_Symbol.value;
        var tukhoa = obj_KeyWord.value;
        var isTitle = $("#SearchArticle_IsTitle" + ModuleID + ":checked").val();
        if (isTitle != null)
            isTitle = 1;
        else
            isTitle = 0;
        var isContent = $("#SearchArticle_IsContent" + ModuleID + ":checked").val();
        if (isContent != null)
            isContent = 1;
        else
            isContent = 0;
        var key = encodeURI(tukhoa);

        var strURL = '/Handler/AG.News/SearchAdvance.ashx?page=' + pageNumber + '&CategoryID=' + obj_Category.value + '&NumberOfItemPerPage=' + NumberOfItemPerPage + '&BeginDate=' + dBegin + '&Enddate=' + dEnd + '&Symbol=' + Symbol + "&IsTilte=" + isTitle + "&IsContent=" + isContent;
        if (key != '')
            strURL += "&KeyWord=" + key;
        return strURL;
    },
    //Lay url tim kiem lichj su kien co khoa
    GetUrlSearchMarketCalendar: function (pageNumber, ModuleID) {
        var obj_Symbol = document.getElementById('AL_Symbol_Dll' + ModuleID);
        var obj_KeyWord = document.getElementById('SearchArticle_KeyWord' + ModuleID);
        var obj_EventType = document.getElementById('Search_EventType_DDL' + ModuleID);
        var obj_PageSize = document.getElementById('SearchArticle_PageSize' + ModuleID);
        var Symbol = obj_Symbol.value;
        DateUtils.GetBeginEndDateByModuleID(ModuleID);
        var dKey = obj_KeyWord.value;
        if (dKey == '') {
            dKey = '-1';
        }
        else {
            dKey = encodeURI(dKey);
        }
        var dNumberOfRecord = obj_PageSize.value;
        if (dNumberOfRecord == '') {
            dNumberOfRecord = NumberOfItemPerPage;
        }
        var dMaCK = obj_Symbol.value;
        if (dMaCK == '') {
            dMaCK = '-1';
        }
        var EventType = encodeURI(obj_EventType.value);
        var strURL = '/Handler/AG.News/MarketCalendar_Search.ashx?page=' + pageNumber + '&Type=' + EventType + '&Symbol=' + dMaCK + '&BeginDate=' + dBegin + '&Enddate=' + dEnd + '&Key=' + dKey + '&NumberOfRecord=' + dNumberOfRecord + '&Category=' + SetOfCategoryID;
        return strURL;
    },
    //Lay url cua tim kiem lich su kien
    GetUrlMarketCalendar: function (pageNumber, ModuleID) {
        DateUtils.GetBeginEndDateByModuleID(ModuleID);
        var obj_Symbol = document.getElementById('AL_Symbol_Dll' + ModuleID);
        var obj_EventType = document.getElementById('Search_EventType_DDL' + ModuleID);
        var Symbol = obj_Symbol.value;
        var dMaCK = obj_Symbol.value;
        if (dMaCK == '') {
            dMaCK = '-1';
        }
        var Language = "";
        if (agLanguageName == "vi-VN") {
            Language = "0";
        }
        else if (agLanguageName == "en-US") {
            Language = "2";
        }
        var EventType = encodeURI(obj_EventType.value);

        // Format "Từ ngày" "Đến ngày" về 1 kiểu dd/mm/yyyy dùng cho handler
        if (agLanguageName == "en-US") {
            if (dBegin != "") {
                var temp = dBegin.split('/');
                dBegin = temp[0] + "/" + temp[1] + "/" + temp[2];
            }
            if (dEnd != "") {
                var temp = dEnd.split('/');
                dEnd = temp[0] + "/" + temp[1] + "/" + temp[2];
            }
        }

        var strURL = '/Handler/AG.News/MarketCalendar_SearchType.ashx?page=' + pageNumber + '&Type=' + EventType + '&Symbol=' + dMaCK + '&BeginDate=' + dBegin + '&Enddate=' + dEnd + '&NumberOfRecord=' + NumberOfItemPerPage + '&language=' + Language;
        return strURL;
    },
    //Lay url theo chuyen muc
    GetUrlSearchByCategory: function (pageNumber, ModuleID) {
        var obj_Symbol = document.getElementById('AL_Symbol_Dll' + ModuleID);
        var obj_Source = document.getElementById('AL_Source_Dll' + ModuleID);
        var obj_Category = document.getElementById('SearchArticle_Categoryddl' + ModuleID);
        DateUtils.GetBeginEndDateByModuleID(ModuleID);
        if (obj_Category.value != '-1') {
            SetOfCategoryID = obj_Category.value;
        }
        var Symbol = obj_Symbol.value;
        var dMaCK = obj_Symbol.value;
        if (dMaCK == '') {
            dMaCK = '-1';
        }
        var strURL = '/Handler/AG.News/ALS_Category.ashx?page=' + pageNumber + '&Symbol=' + dMaCK + '&BeginDate=' + dBegin + '&Enddate=' + dEnd + '&NumberOfRecord=' + NumberOfItemPerPage + '&Category=' + SetOfCategoryID + '&Source=' + obj_Source.value;
        return strURL;
    }
}
//Ham search
AGBB.Search = {
    SearchByBeginDateEndDate: function (pageNumber, ModuleID) {
        var URl = AGBB.URL.GetUrlByBeginDateEndDate(pageNumber, ModuleID);
        AGBB.App.FillData(URl, pageNumber, ModuleID);
    },
    SearchNoParam: function (pageNumber, ModuleID) {
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var FuncList = ModuleUtils.GetFuncList(CollectionParam);
        var URl = "/Handler/AG.News/AL_GetByCategory.ashx?SetOfCategoryID=" + ModuleUtils.GetCategory(CollectionParam) + "&NumberOfRecord=" + ModuleUtils.GetNumberOfRecordPerPage(CollectionParam) + "&Order=" + ModuleUtils.GetOrder(CollectionParam) + "&OrderBy=" + ModuleUtils.GetOrderBy(CollectionParam) + "&Page=" + pageNumber + "&Floor=" + ModuleUtils.GetFloorID(CollectionParam);
        AGBB.App.FillData(URl, pageNumber, ModuleID);
    },
    //truong hop dac biet
    SearchAD: function (ModuleID, pageNumber) {
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var FuncList = ModuleUtils.GetFuncList(CollectionParam);
        var URl = "/Handler/AG.News/AL_GetByCategory.ashx?SetOfCategoryID=" + ModuleUtils.GetCategory(CollectionParam) + "&NumberOfRecord=" + ModuleUtils.GetNumberOfRecordFirstPage(CollectionParam) + "&Order=" + ModuleUtils.GetOrder(CollectionParam) + "&OrderBy=" + ModuleUtils.GetOrderBy(CollectionParam) + "&Page=" + pageNumber + "&Floor=" + ModuleUtils.GetFloorID(CollectionParam);
        AGBB.ArticleList.LoadTitleDate2(URl, pageNumber, ModuleID);
    },
    SearchCompany: function (ModuleID, pageNumber, symbol) {
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var Category = ModuleUtils.GetCategory(CollectionParam);
        var arCategory = new Array();
        arCategory = Category.split(',');
        var URl = " /Handler/AG.News/ALD_CustomerAdvisory.ashx?Symbol=" + symbol + "&page=" + pageNumber + "&SetOfCategoryID=" + Category + "&NumberOfItemPerPage=10";
        AGBB.ArticleList.LoadTitleDate3(URl, pageNumber, ModuleID);
    },
    SearchPriceBoardByDate: function (pageNumber, ModuleID) {
        var date = $("#ddlMonth" + ModuleID).val() + '/' + $("#ddlDay" + ModuleID).val() + '/' + $("#ddlYear" + ModuleID).val();
        var Url = "/Handler/AG.News/PriceBoardOTC_SD.ashx?Date=" + date;
        AGBB.ArticleList.LoadBangThamKhaoGiaOTC(Url, '1', ModuleID);
    },
    FillDateToCombo: function (date, ModuleID) {
        var currentTime = new Date(date);
        var month = currentTime.getMonth() + 1;
        var day = currentTime.getDate();
        var year = currentTime.getFullYear();
        var i = 1;
        var j = 1;
        var k = 2006;
        var contentDay = '';
        var contentMonth = '';
        var contentYear = '';
        contentDay = '<option value="' + day + '" selected="selected" >' + day + '</option>';
        for (i = 1; i <= 31; i++) {
            contentDay += '<option value="';
            contentDay += i;
            contentDay += '">';
            contentDay += i;
            contentDay += '</option>';
        }
        $("#ddlDay" + ModuleID).html(contentDay);
        contentMonth += '<option value="' + month + '" selected="selected" >' + month + '</option>';
        for (j = 1; j <= 12; j++) {
            contentMonth += '<option value="';
            contentMonth += j;
            contentMonth += '">';
            contentMonth += j;
            contentMonth += '</option>';
        }
        $("#ddlMonth" + ModuleID).html(contentMonth);
        contentYear += '<option value="' + year + '" selected="selected" >' + year + '</option>';
        for (k = 2005; k <= year; k++) {
            contentYear += '<option value="';
            contentYear += k;
            contentYear += '">';
            contentYear += k;
            contentYear += '</option>';
        }
        $("#ddlYear" + ModuleID).html(contentYear);
    },
    SearchBySource: function (Page, ModuleID) {
        var URl = AGBB.URL.GetUrlBySource(Page, ModuleID);
        AGBB.App.FillData(URl, Page, ModuleID);
    },
    SearchBySymbol: function (Page, ModuleID) {
        var URl = AGBB.URL.GetUrlBySymbol(Page, ModuleID);
        AGBB.App.FillData(URl, Page, ModuleID);
    },
    SearchAdvanced: function (Page, ModuleID) {
        var URl = AGBB.URL.GetUrlSearchAdvanced(Page, ModuleID);
        AGBB.App.FillData(URl, Page, ModuleID);
    },
    SearchMarketCalendar: function (Page, ModuleID) {
        $(document).ready(function () {
            var URl = AGBB.URL.GetUrlSearchMarketCalendar(Page, ModuleID);
            AGBB.App.FillData(URl, Page, ModuleID);
        });
    },
    SearchByCategory: function (Page, ModuleID) {
        var URl = AGBB.URL.GetUrlSearchByCategory(Page, ModuleID);
        AGBB.App.FillData(URl, Page, ModuleID);
    },
    SearchMarketCalendarByDate: function (date, Page, ModuleID) {
        var URl = '/Handler/AG.News/MarketCalendar_SearchByDate_Hander.ashx?page=' + Page + "&Date=" + date + "&language=" + agLanguageName;
        AGBB.App.FillData(URl, Page, ModuleID);
    },
    SearchMarketCalendarByDateTypeSymbol: function (Page, ModuleID) {
        AGBB.Search.SearchMarketCalendarByDate_CurrentFilter = $("#AL_Symbol_Dll" + ModuleID).val() + "|" + $("#Search_EventType_DDL" + ModuleID).val() + "|" + $("#Article_BeginDate" + ModuleID).val() + "|" + $("#Article_EndDate" + ModuleID).val();
        var URl = AGBB.URL.GetUrlMarketCalendar(Page, ModuleID);
        ModuleUtils.SetFuncSearch('SearchMarketCalendarByDateTypeSymbol', ModuleID);
        ModuleUtils.SetXML(URl, ModuleID);
        AGBB.App.FillData(URl, Page, ModuleID);
    },
    FuncSearch_DauGia: function (Page, ModuleID) {
        $(document).ready(function () {
            var ObjectModuleName = '#ObjectModuleID' + ModuleID;
            var CollectionParam = $(ObjectModuleName).text();
            // Loại tin
            var Type = document.getElementById("m_SearchByTypeSourceDate_ListLoaiTin_CBB").value;
            // Nguồn tin
            var Source = document.getElementById("m_SearchByTypeSourceDate_ListNguon_CBB").value;
            // Ngày bắt đầu
            var BeginDate = document.getElementById('m_SearchByTypeSourceDate_InputTuNgay_IP').value;
            if (BeginDate == "")
                BeginDate = '1/1/1900';
            var TempDate = BeginDate.split('/');
            var BeginDateFix = TempDate[1] + '/' + TempDate[0] + '/' + TempDate[2];
            // Ngày kết thúc
            var EndDate = document.getElementById('m_SearchByTypeSourceDate_InputDenNgay_IP').value;
            if (EndDate == "")
                EndDate = '1/1/2100';
            TempDate = EndDate.split('/');
            var EndDateFix = TempDate[1] + '/' + TempDate[0] + '/' + TempDate[2];
            // Handler
            var URL = "/Handler/AG.News/TinTuc_DauGia_Search_Hander.ashx";
            URL = URL + '?page=' + Page + '&Type=' + Type + '&Source=' + Source + '&BeginDate=' + BeginDateFix + '&Enddate=' + EndDateFix;
            AGBB.App.FillData(URL, Page, ModuleID);
        });
    },
    FuncSearch_CongBoTT: function (Page, ModuleID) {
        $(document).ready(function () {
            var ObjectModuleName = '#ObjectModuleID' + ModuleID;
            var CollectionParam = $(ObjectModuleName).text();
            // Loại tin
            var Type = document.getElementById("m_SearchCongBoTT_ListLoaiTin_CBB").value;
            // Nguồn tin
            var Source = document.getElementById("m_SearchCongBoTT_ListNguon_CBB").value;
            // Ngày bắt đầu
            var BeginDate = document.getElementById('m_SearchCongBoTT_InputTuNgay_IP').value;
            if (BeginDate == "")
                BeginDate = '1/1/1900';
            var TempDate = BeginDate.split('/');
            var BeginDateFix = TempDate[1] + '/' + TempDate[0] + '/' + TempDate[2];
            // Ngày kết thúc
            var EndDate = document.getElementById('m_SearchCongBoTT_InputDenNgay_IP').value;
            if (EndDate == "")
                EndDate = '1/1/2100';
            TempDate = EndDate.split('/');
            var EndDateFix = TempDate[1] + '/' + TempDate[0] + '/' + TempDate[2];
            // Handler
            var URL = "/Handler/AG.News/TinTuc_CongBoThongTin_Search_Hander.ashx";
            URL = URL + '?page=' + Page + '&Type=' + Type + '&Source=' + Source + '&BeginDate=' + BeginDateFix + '&Enddate=' + EndDateFix;
            AGBB.App.FillData(URL, Page, ModuleID);
        });
    },
    SearchArticleListInside: function (Page, ModuleID) {
        DateUtils.GetBeginEndDateByModuleID(ModuleID);
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var SetOfCategoryID = ModuleUtils.GetCategory(CollectionParam);
        var Order = ModuleUtils.GetOrder(CollectionParam);
        var strURL = '/Handler/AG.News/SearchByDateHander.ashx?page=' + Page + '&CategoryID=' + SetOfCategoryID + '&BeginDate=' + dBegin + '&EndDate=' + dEnd + '&Order=' + Order;
        AGBB.App.FillData(strURL, Page, ModuleID);
    },
    /********** VuLM - Update: 8/9/2010 - Description: bổ sung hàm search FuncSearchFinancialReport (VDSC) **********/
    FuncSearchFinancialReport: function (Page, ModuleID) {
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var SetOfCategoryID = ModuleUtils.GetCategory(CollectionParam);
        var Order = ModuleUtils.GetOrder(CollectionParam);
        var OrderBy = ModuleUtils.GetOrderBy(CollectionParam);
        var NumberOfRecordFirstPage = ModuleUtils.GetNumberOfRecordFirstPage(CollectionParam);
        var t = DateUtils.GetDateTimeNow();
        var Span = "#m_SearchFinancialReport_Span_" + ModuleID
        var Temp = $(Span).text().split('||');
        var Year = Temp[1];

        var Url = "/Handler/AG.News/AL_GetByCategoryAndYear.ashx";
        var FullUrl = Url + "?SetOfCategoryID=" + SetOfCategoryID + "&Year=" + Year + "&Order=" + Order + "&OrderBy=" + OrderBy + "&NumberOfRecord=" + NumberOfRecordFirstPage + "&Page=" + Page + "&t=" + t;
        AGBB.App.FillData(FullUrl, Page, ModuleID);
    }
},
AGBB.InnitSearch = {
    SearchByBeginDateEndDate: function (ModuleID) {
        var SearchContent = '';
        SearchContent += '<div class="M_ASBDED_Search_Contain">';
        SearchContent += '<div class="M_AL_Search_Title">' + SearchInfo.FromDate + '</div> <div class="M_ASBDED_Search_BeginDate_Text">';
        SearchContent += ' <input type="text" class="M_ASBDED_Search_Input" id="Article_BeginDate' + ModuleID + '"/> </div>';
        SearchContent += '<div class="M_AL_Search_Title"> &nbsp;&nbsp;&nbsp;&nbsp;' + SearchInfo.ToDate + '</div><div class="M_ASBDED_Search_BeginDate_Text">  <input type="text" id="Article_EndDate' + ModuleID + '" class="M_ASBDED_Search_Input" /></div>';
        SearchContent += '<div class="M_AL_Search_Button"> <a id="imgSearchByDate' + ModuleID + '" onclick="javascript: AGBB.Search.SearchByBeginDateEndDate(\'1\',\'' + ModuleID + '\');"><img src="' + ImageInfo.Search + '"/> </a> </div>';
        SearchContent += '</div><div class="clear"/>';
        $('#ArticleSearch' + ModuleID).html('');
        $('#ArticleSearch' + ModuleID).html(SearchContent);
        DateUtils.GetDatePicker('#Article_BeginDate' + ModuleID);
        DateUtils.GetDatePicker('#Article_EndDate' + ModuleID);
    },
    SearchBySource: function (ModuleID) {
        var SearchContent = '';
        SearchContent += '<div  class="M_AL_Search_Contain">';
        SearchContent += '<div class="AS_Source_Div"><span class="M_AL_Search_Title"> ' + SearchInfo.Source + '</span></div>';
        SearchContent += '<div style="float: left;">';
        SearchContent += '<select id="AL_Source_Dll' + ModuleID + '" style="overflow: auto;">';
        SearchContent += '<option selected="selected" value="-1">' + SearchInfo.ChoiseSource + '</option>';
        SearchContent += '<option value="HNX"> HNX </option>';
        SearchContent += '<option value="HSX"> HSX </option>';
        SearchContent += '<option value="UBCKNN"> UBCKNN </option>';
        SearchContent += '</select></div>';
        //tu ngay den ngay
        SearchContent += '<div class="M_AL_Search_Title">' + SearchInfo.FromDate + '</div> <div class="M_AL_Search_BeginDate_Text">';
        SearchContent += ' <input type="text" class="M_AL_Search_Input" id="Article_BeginDate' + ModuleID + '"/> </div>';
        SearchContent += '<div class="M_AL_Search_BeginDate_Calendar"><a class="AL_Search_A" onclick="javascript:popUpCalendar(this,Article_BeginDate' + ModuleID + ',\'' + SearchInfo.DateType + '\')"> <img align="absmiddle" class="M_AL_Search_Img" src="/Portals/0/Skins/MKS/Images/M_IcoCalendar.gif" /></a></div>';
        SearchContent += '<div class="M_AL_Search_Title">' + SearchInfo.ToDate + '</div><div class="M_AL_Search_BeginDate_Text">';
        SearchContent += '<input type="text" id="Article_EndDate' + ModuleID + '" class="M_AL_Search_Input" /></div>';
        SearchContent += '<div class="M_AL_Search_BeginDate_Calendar"><a class="AL_Search_A" onclick="javascript:popUpCalendar(this,Article_EndDate' + ModuleID + ',\'' + SearchInfo.DateType + '\')"> <img align="absmiddle" class="M_AL_Search_Img" src="/Portals/0/Skins/MKS/Images/M_IcoCalendar.gif"/></a></div>';
        SearchContent += '<div class="M_AL_Search_Button"><a id="imgSearchByDate' + ModuleID + '" onclick="javascript: AGBB.Search.SearchBySource(\'1\',\'' + ModuleID + '\');"><img src="' + ImageInfo.Search + '"/></a></div>';
        SearchContent += '</div><div style="padding-bottom:20px;clear:both"  class="clear"/>';
        SearchContent += '<div style="clear:both"></div>';
        $('#ArticleSearch' + ModuleID).html('');
        $('#ArticleSearch' + ModuleID).html(SearchContent);
    },
    SearchAdvanced: function (ModuleID) {
        var SearchContent = '<div class="ASA_Contain"><div style="clear: both;"/>';
        SearchContent += '<div class="ASA_BeginDate_Line">';
        SearchContent += '<div class="ASA_Title">' + SearchInfo.FromDate + '</div>';
        SearchContent += '<div class="ASA_BeginDate_Text">';
        SearchContent += '<input type="text" class="M_AL_Search_Input" id="Article_BeginDate' + ModuleID + '"/> </div>';
        SearchContent += '<div class="ASA_BeginDate_Calendar"><a class="AL_Search_A" onclick="javascript:popUpCalendar(this,Article_BeginDate' + ModuleID + ',\'' + SearchInfo.DateType + '\')"> <img align="absmiddle" class="M_AL_Search_Img" src="/Portals/0/Skins/MKS/Images/M_IcoCalendar.gif" /></a></div>';
        SearchContent += '</div> <div style="clear: both;"/>';
        SearchContent += '<div class="ASA_EndDate_Line">';
        SearchContent += '<div class="ASA_Title">' + SearchInfo.ToDate + '</div>';
        SearchContent += '<div class="ASA_BeginDate_Text">';
        SearchContent += ' <input type="text" class="M_AL_Search_Input" id="Article_EndDate' + ModuleID + '"/> </div>';
        SearchContent += '<div class="ASA_BeginDate_Calendar"><a class="AL_Search_A" onclick="javascript:popUpCalendar(this,Article_EndDate' + ModuleID + ',\'' + SearchInfo.DateType + '\')"> <img align="absmiddle" class="M_AL_Search_Img" src="/Portals/0/Skins/MKS/Images/M_IcoCalendar.gif"/></a></div>';
        SearchContent += '</div> <div style="clear: both;"/>';
        SearchContent += '<div class="ASA_Symbol_Line">';
        SearchContent += '<div class="ASA_Title">' + SearchInfo.Symbol + '</div>';
        SearchContent += '<div class="ASA_BeginDate_Text">';
        SearchContent += '<select id="AL_Symbol_Dll' + ModuleID + '" style="overflow: auto;">';
        SearchContent += '</select></div></div><div style="clear: both;"/>';
        SearchContent += '<div class="ASA_KeyWord_Line">';
        SearchContent += '<div class="ASA_Title">' + SearchInfo.KeyWord + '</div>';
        SearchContent += '<div class="ASA_KeyWord_Text">';
        SearchContent += '<input type="text" id="SearchArticle_KeyWord' + ModuleID + '" style="height: 22px; width: 220px;" />';
        SearchContent += '</div></div><div style="clear: both;"/>';
        SearchContent += '<div class="ASA_Title_Line"><span>';
        SearchContent += '<input class="Normal" id="SearchArticle_IsTitle' + ModuleID + '" type="checkbox" checked="checked" value="0" />';
        SearchContent += SearchInfo.SearhInTitle + '</span> <span style="padding-left: 20px;">';
        SearchContent += '<input class="Normal" id="SearchArticle_IsContent' + ModuleID + '" type="checkbox" />';
        SearchContent += SearchInfo.SearhInContent + '</span></div>';
        SearchContent += '<div style="clear: both;"/>';
        SearchContent += ' <div class="ASA_Category_Line">';
        SearchContent += '<div class="ASA_Title">' + SearchInfo.CategoryName + '</div>';
        SearchContent += '<div style="float: left;padding-left:10px;">';
        SearchContent += '<select id="SearchArticle_Categoryddl' + ModuleID + '" style="height: 20px;">';
        SearchContent += '</select></div><div >';
        SearchContent += '<a style="padding-left:10px" id="imgSearchByDate' + ModuleID + '" onclick="javascript: AGBB.Search.SearchAdvanced(\'1\',\'' + ModuleID + '\');"><img src="' + ImageInfo.Search + '"/></a>';
        SearchContent += '</div></div></div><div style="padding-bottom:20px; clear:both"  class="clear"/>';
        $('#ArticleSearch' + ModuleID).html('');
        $('#ArticleSearch' + ModuleID).html(SearchContent);
        ComboUtils.FillToID('AL_Symbol_Dll' + ModuleID, SearchInfo.ChoiseSymbol, URL.GetAllSymbol);
        AGBB.InnitSearch.LoadCategory(AGBB.URL.CategoryList, ModuleID);
    },
    SearchByDayMonthYear: function (ModuleID) {
        var SearchContent = '<div style="text-align:center; margin:0 auto;">';
        SearchContent += '<div  style="padding-top:20px;  text-align:center; margin:0 auto; width:440px;">';
        SearchContent += ' <div  style="width:40px; float:left">';
        SearchContent += '<span class="M_AL_Search_Title">' + SearchInfo.Day + '</span></div><div class="M_N_IMaCKH">';
        SearchContent += '<select id="ddlDay' + ModuleID + '" class="M_N_InMaCK" style="overflow:auto; width:65px;" ></select></div><div class="M_N_IMaCKH">';
        SearchContent += '<select id="ddlMonth' + ModuleID + '" class="M_N_InMaCK" style="width:65px"></select></div> <div class="M_N_IMaCKH">';
        SearchContent += '<select id="ddlYear' + ModuleID + '" class="M_N_InMaCK" style="width:65px"></select></div><div class="M_N_imgSearch">';
        SearchContent += '<a  class="M_N_imgSe" onclick="  AGBB.Search.SearchPriceBoardByDate(\'1\',\'' + ModuleID + '\')"> ' + SearchInfo.Search + '</a></div> <div class="clear"></div></div> </div>';
        $('#ArticleSearch' + ModuleID).html('');
        $('#ArticleSearch' + ModuleID).html(SearchContent);
    },
    LoadCategory: function (url, ModuleId) {
        var strContent = "<option value=\"-1\" selected=\"selected\" >" + SearchInfo.ChoiseCategory + "</option>";
        $.get(url, function (data) {
            $(data).find('Category').each(function () {
                var $Symbol = $(this);
                strContent += '<option value="' + $Symbol.find('CategoryId').text() + '">';
                strContent += $Symbol.find('Name').text();
                strContent += '</option>';
            })
            $('#SearchArticle_Categoryddl' + ModuleId).html(strContent);
        })
    },
    SearchMarketCalendar: function (ModuleID) {
        $(document).ready(function () {
            var SearchContent = '<div  class="M_AL_Search_Contain">';
            SearchContent += '<div class="M_AL_Search_Contain">';
            SearchContent += '<div class="ASA_Symbol_Line">';
            SearchContent += '<div class="ASA_Title">' + SearchInfo.Symbol + '</div>';
            SearchContent += '<div class="ASA_BeginDate_Text">';
            SearchContent += '<select id="AL_Symbol_Dll' + ModuleID + '" class="M_MKS_DLL">';
            SearchContent += '</select></div></div>';
            SearchContent += '<div class="ASA_Title">' + SearchInfo.FromDate + '</div> <div class="M_AL_Search_BeginDate_Text">';
            SearchContent += ' <input type="text" class="M_AL_Search_Input" id="Article_BeginDate' + ModuleID + '"/> </div>';
            SearchContent += '<div class="M_AL_Search_Title">' + SearchInfo.ToDate + '</div><div class="M_AL_Search_BeginDate_Text" style="padding-left:10px;"><input type="text" id="Article_EndDate' + ModuleID + '" class="M_AL_Search_Input_EndDate" />';
            SearchContent += '</div>';
            SearchContent += '</div></div><div style="padding-bottom:20px; clear:both;" class="clear"/>';
            SearchContent += '<div class="ASA_Symbol_Line">';
            SearchContent += '<div class="ASA_Title">' + MarketCalendarInfo.EventType + '</div><div class="ASA_BeginDate_Text">';
            SearchContent += '<select id="Search_EventType_DDL' + ModuleID + '" class="M_MKS_DLL">';
            SearchContent += '<option value="-1" selected="selected">' + SearchInfo.All + '</option>';
            SearchContent += '<option value="Cash Dividends /Interest pay"> Cash Dividends </option><option value="Dividend in kind">Dividend in kind </option>';
            SearchContent += '<option value="Poll"> Poll</option>';
            SearchContent += '<option value="Sell incentives">Sell incentives</option><option value="Shareholder meeting"> Shareholder meeting </option><option value="Stock Dividends">Stock Dividends</option>';
            SearchContent += ' </select>';
            SearchContent += '</div>'
            SearchContent += '</div>'
            SearchContent += '<div class="ASA_Keywords_Line">';
            SearchContent += '<div class="ASA_Title">' + SearchInfo.KeyWord + '</div>';
            SearchContent += '<div style="float:left">';
            SearchContent += '<input type="text" id="SearchArticle_KeyWord' + ModuleID + '" style="height: 22px; width: 164px;" />';
            SearchContent += '</div></div>';
            SearchContent += '<div class="ASA_Keywords_Line">';
            SearchContent += '<div class="ASA_Title" style="Padding-left:5px;">' + SearchInfo.PageSize + '</div>';
            SearchContent += '<div class="ASA_KeyWord_Text_News">';
            SearchContent += '<input type="text" id="SearchArticle_PageSize' + ModuleID + '" style="height: 22px; width: 170px;min-width:180px;" />';
            SearchContent += '</div></div><div style="clear: both;"/>';
            SearchContent += '<div class="M_AL_Search_ButtonNews"> <a id="imgSearchByDate' + ModuleID + '" onclick="javascript: AGBB.Search.SearchMarketCalendar(\'1\',\'' + ModuleID + '\');"><img src="' + ImageInfo.Search + '"/> </a> </div>';
            $('#ArticleSearch' + ModuleID).html('');
            $('#ArticleSearch' + ModuleID).html(SearchContent);
            ComboUtils.FillToID('AL_Symbol_Dll' + ModuleID, SearchInfo.ChoiseSymbol, URL.GetAllSymbol);
            DateUtils.GetDatePicker('#Article_BeginDate' + ModuleID);
            DateUtils.GetDatePicker('#Article_EndDate' + ModuleID);
        });
    },
    GetDate: function (Year) {
        var url = "/Handler/AG.News/MarketCalendar_InitDate.ashx?Year=" + Year;
        var result = '';
        $.ajax({
            type: "GET",
            url: url,
            dataType: "xml",
            async: false,
            success: function (data) {
                result = $(data).find("Articles").text();
            }
        });
        return result;
    },
    CurrentYear: ($.cookie('Year') == null) ? DateUtils.GetYearNow() : $.cookie('Year'),
    SearchMarketCalendarByDate_CurrentFilter: "",
    CurrentDate: "",
    SearchMarketCalendarByDate: function (ModuleID) {
        $(document).ready(function () {
            var temp = '';
            temp = AGBB.InnitSearch.GetDate(AGBB.InnitSearch.CurrentYear);
            var SearchContent = '<div style="width:760px;padding:10 0 20 0;"><div style="float:left;margin-left:10px;width:200px;">';
            SearchContent += ' <div id="cont"></div>';
            SearchContent += "<script>  var SPECIAL_DAYS = " + temp;
            SearchContent += "</script>";
            SearchContent += '</div><div  style="float:left;text-align:left; margin-left:10px;width:538px;">';
            SearchContent += '<div class="M_LSK_T"><div class="M_LSK_T_L"/><div class="M_LSK_T_C">' + ArticleListLibInfo.SearchEvent + '</div><div class="M_LSK_T_R"/></div>';
            SearchContent += ' <div class="clear" style="padding-bottom:12px"/>';
            SearchContent += '<div class="LSK_WrapC">';
            SearchContent += '<div class="M_LSK_Symbol_Lbl">';
            SearchContent += ArticleListLibInfo.StockSymbol + '</div>';
            SearchContent += '<div class="M_LSK_SymbolL">';
            SearchContent += '<select id="AL_Symbol_Dll' + ModuleID + '" class="M_LSK_Symbol_DLL"/>';
            SearchContent += '</div></div><div class="clear"/> ';
            SearchContent += '<div ><div class="M_LSK_TheLoai">' + ArticleListLibInfo.Type + '</div>';
            SearchContent += '<div class="LSK_SourceD">';
            SearchContent += '<select id="Search_EventType_DDL' + ModuleID + '" class="LSK_SourceInput">';
            SearchContent += ' </select> </div></div><div class="clear"/>';
            SearchContent += '<div class="M_LSK_FromDateL">  <div class="M_LSK_Date_Lbl"> ' + ArticleListLibInfo.DateStart + '</div>';
            SearchContent += '  <div class="M_LSK_LineDate">';
            SearchContent += ' <input type="text" id="Article_BeginDate' + ModuleID + '" class="M_AL_Search_Input" />';
            SearchContent += '</div></div><div class="clear"/>';
            SearchContent += ' <div class="M_LSK_ToDateL">';
            SearchContent += '  <div class="M_LSK_Date_Lbl"> ' + ArticleListLibInfo.DateEnd + '</div>';
            SearchContent += '  <div class="M_LSK_LineDate"">';
            SearchContent += ' <input type="text" class="M_AL_Search_Input" id="Article_EndDate' + ModuleID + '"/> </div>';
            SearchContent += '<div style="width: 90px;float:left;margin-left:15px;">';
            SearchContent += '<a id="imgSearchByDate' + ModuleID + '" onclick="javascript: AGBB.Search.SearchMarketCalendarByDateTypeSymbol(\'1\',\'' + ModuleID + '\');"><img style="cursor:pointer" src="' + ImageInfo.Search + '"/> </a>';
            SearchContent += '</div></div></div><div class="clear"/>';
            $('#ArticleSearch' + ModuleID).html('');
            $('#ArticleSearch' + ModuleID).html(SearchContent);
            ComboUtils.FillToID('AL_Symbol_Dll' + ModuleID, SearchInfo.ChoiseSymbol, '/Handler/AG.News/GetAllSymbol.ashx');
            var SearchTypeDDL = 'Search_EventType_DDL' + ModuleID;
            ComboUtils.FillToID(SearchTypeDDL, ArticleListLibInfo.ChooseTypeEvent, '/Handler/AG.News/MarketCalendar_GetType.ashx?&Lang=' + agLanguageName);
            ModuleUtils.SetFuncSearch('SearchMarketCalendarByDateTypeSymbol', ModuleID);
            DateUtils.GetDatePicker('#Article_BeginDate' + ModuleID);
            DateUtils.GetDatePicker('#Article_EndDate' + ModuleID);
            function dateIsSpecial(year, month, day) {
                if (year != AGBB.InnitSearch.CurrentYear) {
                    AGBB.InnitSearch.CurrentYear = year;
                    var temp = AGBB.InnitSearch.GetDate(AGBB.InnitSearch.CurrentYear);
                    $('#ExcecuteJS').html("<script> " + "var Innit=" + temp + ";</script>");
                    SPECIAL_DAYS = Innit;
                }
                var m = SPECIAL_DAYS[month];
                if (!m) return false;
                for (var i in m) if (m[i] == day) return true;
                return false;
            };

            var YearChange = "0";
            function dateChanged(calendar) {
                //Neu thay doi nam
                var Year = calendar.date.getFullYear();
                var Month = calendar.date.getMonth() + 1;     // integer, 0..11
                var Day = calendar.date.getDate();      // integer, 1..31
                var Dates = Month + "/" + Day + "/" + Year;
                // Beware that this function is called even if the end-user only
                // changed the month/year.  In order to determine if a date was
                // clicked you can use the dateClicked property of the calendar:
                if (calendar.dateClicked) {
                    // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
                    var y = calendar.date.getFullYear();
                    var m = calendar.date.getMonth() + 1;     // integer, 0..11
                    var d = calendar.date.getDate();      // integer, 1..31
                    // redirect...
                    // window.location = "/" + y + "/" + m + "/" + d + "/index.php";
                    var date = d + "/" + m + "/" + y;
                    var date1 = m + "/" + d + "/" + y;
                    AGBB.InnitSearch.CurrentDate = date1;
                    AGBB.Search.SearchMarketCalendarByDate(date, 1, ModuleID);
                    ModuleUtils.SetFuncSearch('SearchMarketCalendarByDate', ModuleID);
                    $.cookie("Date", date);
                }
            };
            Calendar.setup(
         {
             flat: "cont",
             displayArea: "calendar-container", // ID of the parent element
             flatCallback: dateChanged,          // our callback function
             date: AGBB.InnitSearch.CurrentDate,
             dateStatusFunc: function (date, y, m, d) {
                 if (dateIsSpecial(y, m, d)) return "special";
                 else return false; // other dates are enabled
             }
         }
        );
        })
    },
    SearchByCategory: function (ModuleID) {
        var SearchContent = '<div  class="M_AL_Search_Contain">';
        SearchContent += '<div class="M_ASC_Line">';
        SearchContent += '<div class="M_ASC_Title1">' + SearchInfo.Symbol + '</div>';
        SearchContent += '<div class="M_ASC_Div1">';
        SearchContent += '<select id="AL_Symbol_Dll' + ModuleID + '" class="M_ASC_DLL1">';
        SearchContent += '</select></div>';
        SearchContent += '<div class="M_ASC_Title2">' + SearchInfo.FromDate + '</div> <div class="M_ASC_Div2">';
        SearchContent += '<input type="text" class="M_AL_Search_Input" id="Article_BeginDate' + ModuleID + '"/> </div>';
        SearchContent += '<div class="M_ASC_Title3"> &nbsp;&nbsp;&nbsp;&nbsp;' + SearchInfo.ToDate + '</div><div class="M_ASC_Div4">  <input type="text" id="Article_EndDate' + ModuleID + '" class="M_AL_Search_Input" />';
        SearchContent += '</div>';
        SearchContent += '</div><div style="padding-bottom:20px; clear:both" />';
        SearchContent += '<div class="M_ASC_Line"><div class="M_ASC_Title1">' + SearchInfo.Source + '</div>';
        SearchContent += '<div class="M_ASC_Div1">';
        SearchContent += '<select id="AL_Source_Dll' + ModuleID + '" class="M_ASC_DLL1">';
        SearchContent += '<option selected="selected" value="-1">' + SearchInfo.ChoiseSource + '</option>';
        SearchContent += '<option value="HNX"> HNX </option>';
        SearchContent += '<option value="HSX"> HSX </option>';
        SearchContent += '<option value="UBCKNN"> UBCKNN </option>';
        SearchContent += '</select></div>';
        SearchContent += ' <div class="M_ASC_Title2">';
        SearchContent += SearchInfo.News + '</div>';
        SearchContent += '<div class="M_ASC_Div23">';
        SearchContent += '<select id="SearchArticle_Categoryddl' + ModuleID + '" class="M_ASC_DLL2">';
        SearchContent += '</select></div>';
        SearchContent += '<div class="M_ASC_SearchBtn" > <a id="imgSearchByDate' + ModuleID + '" onclick="javascript: AGBB.Search.SearchByCategory(\'1\',\'' + ModuleID + '\');"><img src="' + ImageInfo.Search + '"/> </a> </div>';
        SearchContent += '<div style="padding-bottom:20px"  class="clear"/>';
        $('#ArticleSearch' + ModuleID).html('');
        $('#ArticleSearch' + ModuleID).html(SearchContent);
        ComboUtils.FillToID('AL_Symbol_Dll' + ModuleID, SearchInfo.ChoiseSymbol, URL.GetAllSymbol);
        AGBB.InnitSearch.LoadCategory(URL.CategoryNews, ModuleID);
        DateUtils.GetDatePicker('#Article_BeginDate' + ModuleID);
        DateUtils.GetDatePicker('#Article_EndDate' + ModuleID);

    },
    SearchFinancialReport: function (ModuleID) {
        var ArticleSearch = "#ArticleSearch" + ModuleID;
        var Content = "";
        // Vẽ div m_SearchFinancialReport bọc bên ngoài
        Content += "<div class='m_SearchFinancialReport'>";
        // Vẽ button back
        Content += "<div class='m_SearchFinancialReport_Back' onclick=\"StringUtils.Back(" + ModuleID + "), AGBB.Search.FuncSearchFinancialReport(1," + ModuleID + ")\"></div>";
        // Vẽ các button search theo năm
        Content += "<div class='m_SearchFinancialReport_Button_Active' id='m_SearchFinancialReport_Button_1" + ModuleID + "' onmouseover=\"StringUtils.ChangeClass('" + ModuleID + "','m_SearchFinancialReport_Button_1" + ModuleID + "', 'm_SearchFinancialReport_Button_Active')\" onmouseout=\"StringUtils.ChangeClass('" + ModuleID + "','m_SearchFinancialReport_Button_1" + ModuleID + "', 'm_SearchFinancialReport_Button')\" onclick=\"StringUtils.Click('" + ModuleID + "','m_SearchFinancialReport_Button_1" + ModuleID + "'), AGBB.Search.FuncSearchFinancialReport(1," + ModuleID + ")\"></div>";
        Content += "<div class='m_SearchFinancialReport_Button' id='m_SearchFinancialReport_Button_2" + ModuleID + "' onmouseover=\"StringUtils.ChangeClass('" + ModuleID + "','m_SearchFinancialReport_Button_2" + ModuleID + "', 'm_SearchFinancialReport_Button_Active')\" onmouseout=\"StringUtils.ChangeClass('" + ModuleID + "','m_SearchFinancialReport_Button_2" + ModuleID + "', 'm_SearchFinancialReport_Button')\" onclick=\"StringUtils.Click('" + ModuleID + "','m_SearchFinancialReport_Button_2" + ModuleID + "'), AGBB.Search.FuncSearchFinancialReport(1," + ModuleID + ")\"></div>";
        Content += "<div class='m_SearchFinancialReport_Button' id='m_SearchFinancialReport_Button_3" + ModuleID + "' onmouseover=\"StringUtils.ChangeClass('" + ModuleID + "','m_SearchFinancialReport_Button_3" + ModuleID + "', 'm_SearchFinancialReport_Button_Active')\" onmouseout=\"StringUtils.ChangeClass('" + ModuleID + "','m_SearchFinancialReport_Button_3" + ModuleID + "', 'm_SearchFinancialReport_Button')\" onclick=\"StringUtils.Click('" + ModuleID + "','m_SearchFinancialReport_Button_3" + ModuleID + "'), AGBB.Search.FuncSearchFinancialReport(1," + ModuleID + ")\"></div>";
        Content += "<div class='m_SearchFinancialReport_Button' id='m_SearchFinancialReport_Button_4" + ModuleID + "' onmouseover=\"StringUtils.ChangeClass('" + ModuleID + "','m_SearchFinancialReport_Button_4" + ModuleID + "', 'm_SearchFinancialReport_Button_Active')\" onmouseout=\"StringUtils.ChangeClass('" + ModuleID + "','m_SearchFinancialReport_Button_4" + ModuleID + "', 'm_SearchFinancialReport_Button')\" onclick=\"StringUtils.Click('" + ModuleID + "','m_SearchFinancialReport_Button_4" + ModuleID + "'), AGBB.Search.FuncSearchFinancialReport(1," + ModuleID + ")\"></div>";
        // Vẽ button next
        Content += "<div class='m_SearchFinancialReport_Next' onclick=\"StringUtils.Next(" + ModuleID + "), AGBB.Search.FuncSearchFinancialReport(1," + ModuleID + ")\"></div>";
        // Vẽ thẻ span ẩn để chứa thông tin về tab được active
        Content += "<div class='m_SearchFinancialReport_Span' id='m_SearchFinancialReport_Span_" + ModuleID + "'></div>";
        Content += "<div class='clear'></div>";
        Content += "</div>";
        // Đẩy chuỗi html vào div ArticleSearch
        $(ArticleSearch).html(Content);
        // Hiển thị 4 năm gần nhất
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var SetOfCategoryID = ModuleUtils.GetCategory(CollectionParam);
        var t = DateUtils.GetDateTimeNow();
        var Url = "/Handler/AG.News/ALS_GetYearByCategories.ashx";
        var FullUrl = Url + "?c=" + SetOfCategoryID + "&t=" + t;
        $.ajax({
            type: "GET",
            url: FullUrl,
            dataType: "xml",
            async: false,
            success: function (result) {
                var TotalFor = 0;
                if ($(result).find("Year").length <= 3) {
                    TotalFor = $(result).find("Year").length;
                }
                else {
                    TotalFor = 4;
                }
                // Hiển thị 4 năm gần nhất
                var ButtonID = "#m_SearchFinancialReport_Button_";
                for (var i = 1; i <= 4; i++) {
                    $(ButtonID + i + ModuleID).hide();
                }
                for (var i = 1; i <= TotalFor; i++) {
                    $(ButtonID + i + ModuleID).html($(result).find("Year[id=" + (i - 1) + "]").text());
                    $(ButtonID + i + ModuleID).show();
                }
            },
            error: function displayError(request, errorType, errorThrown) {
                AGBB.ALProcessData.ProcessError();
            }
        });
        // Khởi tạo giá trị ban đầu cho thẻ span
        $("#m_SearchFinancialReport_Span_" + ModuleID).html("m_SearchFinancialReport_Button_1" + ModuleID + "||" + $("#m_SearchFinancialReport_Button_1" + ModuleID).text() + "||0");
    }
}
//Ham phan trang la ham goi lai ham search theo so trang
AGBB.Paging = {
    SetCurrentPage: function(ModuleID, Page) {
        var ObjectModuleName = '#ObjectModuleID' + ModuleID;
        var CollectionParam = $(ObjectModuleName).text();
        var FuncSearch = ModuleUtils.GetFuncSearch(CollectionParam);
        switch (FuncSearch) {
            case 'SearchByBeginDateEndDate': AGBB.Search.SearchByBeginDateEndDate(Page, ModuleID); break;
            case 'SearchBySource': AGBB.Search.SearchBySource(Page, ModuleID); break;
            case 'SearchBySymbol': AGBB.Search.SearchBySymbol(Page, ModuleID); break;
            case 'SearchAdvanced': AGBB.Search.SearchAdvanced(Page, ModuleID); break;
            case 'SearchMarketCalendar': AGBB.Search.SearchMarketCalendar(Page, ModuleID); break;
            case 'SearchMarketCalendarByDateTypeSymbol': AGBB.Search.SearchMarketCalendarByDateTypeSymbol(Page, ModuleID); break;
            case 'SearchByCategory': AGBB.Search.SearchByCategory(Page, ModuleID); break;
            case 'SearchMarketCalendarByDate': AGBB.Search.SearchMarketCalendarByDate($.cookie('Date'), Page, ModuleID); break;
            case 'FuncSearchFinancialReport': AGBB.Search.FuncSearchFinancialReport(Page, ModuleID); break;
            default: AGBB.Search.SearchNoParam(Page, ModuleID); break;
        }
    }
}


