﻿function GetAjaxToDiv(urlPath, idOfDiv) {
    $.ajax({
        type: "POST",
        url: urlPath + urlSuffix,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + idOfDiv).html(result.toString());
        },
        error: function() {
            ////alert("ajax has error");
        }
    });
}


function FillInfoBaseId(urlCulturePath, idOfCultureContainerDiv, idOfItem) {
    FillCultureBaseId(urlCulturePath, idOfCultureContainerDiv, idOfItem);
}

function FillCultureBaseId(urlPath, idOfDiv, idOfItem) {
    $.ajax({
        type: "POST",
        data: idOfItem,
        url: urlPath + urlSuffix,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + idOfDiv).html(result.toString());
        },
        error: function() {
            ////alert("ajax has error");
        }
    });
}

function FillInforByPaging(urlPath, idOfDiv, idOfItem, pageIndex) {
    var param = {
        Id: idOfItem,
        PageIndex: pageIndex
    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: urlPath + urlSuffix,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + idOfDiv).html(result.toString());
        },
        error: function() {
            ////alert("ajax has error");
        }
    });
}

function FillContentBaseId(urlPath, idOfContentContainerDiv, idOfItem, culture) {
    var param = {
        Id: idOfItem,
        Culture: culture
    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: urlPath + urlSuffix,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + idOfContentContainerDiv).html(result.toString());
        },
        error: function() {
            ////alert("ajax has error");
        }
    });
}

function FillContentBaseIndex(urlPath, idOfContentContainerDiv, idOfItem, index, culture) {
    var param = {
        Id: idOfItem,
        IntParam: index,
        StrParam: culture
    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: urlPath + urlSuffix,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + idOfContentContainerDiv).html(result.toString());
        },
        error: function() {
            ////alert("ajax has error");
        }
    });
}

function ActionOfItem(urlPath, idOfDiv, idOfItem, strParam) {
    var param = {
        Id: idOfItem,
        StrParam: strParam
    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: urlPath + urlSuffix,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + idOfDiv).html(result.toString());
        },
        error: function() {
            ////alert("ajax has error");
        }
    });
}

//

function getCheckedValue(radioObj) {
    if (!radioObj)
        return "";
    var radioLength = radioObj.length;
    if (radioLength == undefined)
        if (radioObj.checked)
        return radioObj.value;
    else
        return "";
    for (var i = 0; i < radioLength; i++) {
        if (radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}


function loadModule(module, path, cateId, id) {
    var param = {
        Id: id,
        CateId: cateId,
        Module: module
    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: path + urlSuffix,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
        $("." + module.toLowerCase()).html(result.toString());
        },
        error: function() {
            //alert("Module "+ module.toString() + " ajax has error");
        }
    });
}

function ApprovallPress(urlPath, idOfDiv, idOfItem, idOfCate, page, culture){
    $.ajax({
        type: "POST",
        data: idOfItem,
        url: urlPath + urlSuffix,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            FillContentBaseIndex('/Admin/Cms/Press/GetListPress', 'pressEditContainer', idOfCate, page, culture);
        },
        error: function() {
            //   
        }
    });
}


/*-------------------Student Books--------------------*/
function SaveSchedule(page, idDepartment, idClassSession, idSubject, urlPath, div) {
    var param = {
        PageIndex: page,
        IdDepartment: idDepartment,
        IdClassSession: idClassSession,
        IdSubject: idSubject
    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: urlPath,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + div).html(result.toString());

        },
        error: function() {
            //alert("ajax has error");
        }
    });
}
function ShowStudentAdmin(idClass, idSubject, urlPath, div) {
    var param = {
        IdClass: idClass,
        IdSubject: idSubject

    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: urlPath,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + div).html(result.toString());

        },
        error: function() {
            //alert("ajax has error");
        }
    });
}

function ShowStudent(page, idStudent, idClass, urlPath, div) {
    var param = {
        PageIndex: page,
        IdStudent: idStudent,
        IdClass: idClass

    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: urlPath,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $('#ListStudentMark').show("slow");
            $("#" + div).html(result.toString());

        },
        error: function() {
            //alert("ajax has error");
        }
    });
}


function SearchStudent(page, name, idClass, urlPath, div) {
    var param = {
        PageIndex: page,
        Name: name,
        IdClass: idClass

    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: urlPath,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $('#ListStudentMark').hide("slow");
            $("#" + div).html(result.toString());

        },
        error: function() {
            //alert("ajax has error");
        }
    });
}

function EditMark(studentStudentClassId, subjectId, urlPath, div) {
    var param = {
        StudentStudentClassId: studentStudentClassId,
        SubjectId: subjectId
    };
    var jsonParams = $.toJSON(param);
    $.ajax({
        type: "POST",
        data: jsonParams,
        url: urlPath,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + div).html(result.toString());

        },
        error: function() {
            //alert("ajax has error");
        }
    });
}

function ViewSubjectAjax(id,urlPath, idOfDiv) {
    $.ajax({
        type: "POST",
        url: urlPath,
        data: id,
        dataType: "html",
        contentType: "application/json",
        success: function(result) {
            $("#" + idOfDiv).html(result.toString());
        },
        error: function() {
            ////alert("ajax has error");
        }
    });
}







    
