var PageIndex = 1;
function BindRegisterList() {
    $('[id$=MainUpdateProgress]').show();
	$.ajax({
        type: "POST",
        url: "/Pages/Attendance/DivisionRegister.aspx/BindRegisterList",
        data: '{"cid":"' + $('[id$=ClassDropDownList]').val() + '","did":"' + $('[id$=DivisionDropDownList]').val() + '","aid":"' + $('[id$=AttendanceTypeDropDownList]').val() + '","fm":"' + $('[id$=ForMonthDropDownList]').val() + '","fy":"' + $('[id$=ForYearDropDownList]').val() + '","pi":"' + PageIndex + '"}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (data) {
            var datas = $.parseJSON(data.d);            
			if(datas.Grid != '') {
				$('#tblList').html('');
				$('#trHeader').html('');
				$('#Div1').show();				
				$('#trHeader').html(datas.Header);				
				$('#tblList').html(datas.Grid); 
				//$('#pagging').html(datas.Paging);
				window.setTimeout(function () { $('[id$=MainUpdateProgress]').hide(); }, 300);
				
			}
			else {
			    $('#Div1').show();
			    $('#trHeader').html("<tr><td colspan='37'>No Records found !</td></tr>");
			    $('#tblList').html("");
			    $('[id$=MainUpdateProgress]').hide();
			}
        },
        error: function (xhr, status, error) {
            $('[id$=MainUpdateProgress]').hide();
            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);            
        }
    });
}
function ChangePage(pi) {
    PageIndex = pi;
    BindRegisterList();
}
function Test() {    
    $('#tblList').find('tr').each(function () {
        $(this).find('td').each(function () {
            if ($(this).html() == '<img src="../../Images/Yes.png">') {
                alert(1);
            }
        });        
    });
}

function Sum() {
    var LabelItem1 = document.getElementById("Item1");
    var LabelItem2 = document.getElementById("Item2");
    var LabelItem3 = document.getElementById("Item3");
    var Result = parseInt(LabelItem1) + parseInt(LabelItem2);
    if (!isNaN(Result)) {
        LabelItem3 = parseInt(Result);
    }
}

function test() {
    var grid = $("[id$=DivisionRegisterGridView]");
    $(this).find('tr').each(function () {
        $(this).find('td').each(function () {
            var Item1 = $('[Id$=Item1]').find();
            var Item2 = $('[Id$=Item2]').find();
            var result = parseInt(Item1) + parseInt(Item2);
            var Item3 = $('[Id$=Item3').find();
            Item3 = parseInt(result);
        });
    });

   
}
