﻿
function beforeAjaxLoading() {
    
    var divAjaxLoading = document.getElementById('divAjaxLoading');
    divAjaxLoading.style.display = '';
}

function afterAjaxLoading() {
    
    var divAjaxLoading = document.getElementById('divAjaxLoading');
    divAjaxLoading.style.display = 'none';
}

function loadAllSearch(pageIndex) {
    
    beforeAjaxLoading();

    $.ajax({
        type: "POST",
        url: "/Ajaxloading/Ajaxloading-AllSearch.aspx",
        data: 'pageIndex=' + pageIndex + '&randCode=' + Math.random(),
        dataType: "html",
        success: function(msg){
            afterAjaxLoading();
            $('html, body').animate({scrollTop:0});
            $('#divAnnouncements').html(msg);
        }
    });
}

/*===== Announcements =====*/
function loadAnnouncements(pageIndex) {

    beforeAjaxLoading();

    $.ajax({
        type: "POST",
        url: "/Ajaxloading/Announcement/Ajaxloading-Announcements.aspx",
        data: 'pageIndex=' + pageIndex + '&randCode=' + Math.random(),
        dataType: "html",
        success: function(msg){
            afterAjaxLoading();
            $('html, body').animate({scrollTop:0});
            $('#divAnnouncements').html(msg);
        }
    });
}

function loadAnnouncementsByType(pageIndex) {

    beforeAjaxLoading();

    var announceType = $('#ctl00_ContentPlaceHolder1_hidAnnounceType').attr('value');

    $.ajax({
        type: "POST",
        url: "/Ajaxloading/Ajaxloading-AnnouncementsByType.aspx",
        data: 'pageIndex=' + pageIndex + '&announceType=' + announceType + '&randCode=' + Math.random(),
        dataType: "html",
        success: function(msg){
            afterAjaxLoading();
            $('html, body').animate({scrollTop:0});
            $('#divAnnouncements').html(msg);
        }
    });

}

function loadAnnouncesBySection(pageIndex) {

    beforeAjaxLoading();

    var sectionId = $('#ctl00_ContentPlaceHolder1_hidSectionID').attr('value');

    $.ajax({
        type: "POST",
        url: "/Ajaxloading/Announcement/Ajaxloading-AnnouncesBySection.aspx",
        data: 'pageIndex=' + pageIndex + '&sectionId=' + sectionId + '&randCode=' + Math.random(),
        dataType: "html",
        success: function(msg){
            afterAjaxLoading();
            $('html, body').animate({scrollTop:0});
            $('#divAnnouncements').html(msg);
        }
    });
}

function loadAnnouncementSearch(pageIndex) {
    
    beforeAjaxLoading();

    $.ajax({
        type: "POST",
        url: "/Ajaxloading/Ajaxloading-AnnouncementSearch.aspx",
        data: 'pageIndex=' + pageIndex + '&randCode=' + Math.random(),
        dataType: "html",
        success: function(msg){
            afterAjaxLoading();
            $('html, body').animate({scrollTop:0});
            $('#divAnnouncements').html(msg);
        }
    });
}
