var objGetMyCalendar = null;
var CutShiftDate;
var EmployeeCode;
function ajaxGetmyCalendar(ShiftDate) {
    if (window.ActiveXObject) {
        try {
            objGetMyCalendar = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objGetMyCalendar = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e1) {
                objGetMyCalendar = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            objGetMyCalendar = new XMLHttpRequest("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objGetMyCalendar = new XMLHttpRequest("Microsoft.XMLHTTP");
            } catch (e1) {
                objGetMyCalendar = null;
            }
        }
    }
    if (objGetMyCalendar != null) {
        var k = Math.floor(Math.random() * 111);
        if (window.ActiveXObject) {
            objGetMyCalendar.onreadystatechange = Process_Response_GetMyCalendar;
            //var url = window.location.pathname.split("/").slice(-1);
            objGetMyCalendar.open("GET", "GetMyCalendarData.aspx?ShiftDate=" + ShiftDate, false);
            objGetMyCalendar.send(null);
        } else if (window.XMLHttpRequest) {
            //var url = window.location.pathname.split("/").slice(-1);
            objGetMyCalendar.open("GET", "GetMyCalendarData.aspx?ShiftDate=" + ShiftDate, false);
            objGetMyCalendar.send(null);
            objGetMyCalendar.onreadystatechange = Process_Response_GetMyCalendar();
        }
    }
    return false;
}
function Process_Response_GetMyCalendar() {

    if (objGetMyCalendar.readyState == 4) {
        if (objGetMyCalendar.status == 200) {

            var retval = objGetMyCalendar.responseText;
            if (retval == "") {
                $('#ctl00_BodyContentPH_txt_ShiftDate').text('');
                $('#ctl00_BodyContentPH_txt_ShiftDetails').text('');
                $('#ctl00_BodyContentPH_txt_FirstIntime').text('');
                $('#ctl00_BodyContentPH_txt_LastOuttime').text('');
                $('#ctl00_BodyContentPH_txt_WorkHours').text('');
                $('#ctl00_BodyContentPH_txt_LateHours').text('');
                $('#ctl00_BodyContentPH_txt_EarlyExitHours').text('');
                $('#ctl00_BodyContentPH_txt_Lunchhours').text('');
                $('#ctl00_BodyContentPH_txt_Attendancedetails').text('');
                $('#ctl00_BodyContentPH_lbl_ShiftDefineHours').text('');
                $('#ctl00_BodyContentPH_txt_Present').text('');
                $('#ctl00_BodyContentPH_txt_AbsentDays').text('');
                $('#ctl00_BodyContentPH_txt_LeaveDays').text('');
                $('#ctl00_BodyContentPH_txt_Holidays').text('');
                $('#ctl00_BodyContentPH_txt_WeeklyOffDays').text('');
                $('#ctl00_BodyContentPH_lblTotaldays').text('');
                $('#ctl00_BodyContentPH_txt_MonthName').text('');
            }
            else {
                if (retval.length > 0 && retval != "Fail") {
                    var arr1 = retval.split('#');
                    var arr = arr1[0].split(',');
                    var arr2 = arr1[1].split(',');
                    $('#ctl00_BodyContentPH_txt_ShiftDate').text(arr[0]);
                    $('#ctl00_BodyContentPH_txt_ShiftDetails').text(arr[1]);
                    $('#ctl00_BodyContentPH_txt_FirstIntime').text(arr[3]);
                    $('#ctl00_BodyContentPH_txt_LastOuttime').text(arr[4]);
                    $('#ctl00_BodyContentPH_txt_WorkHours').text(arr[2]);
                    $('#ctl00_BodyContentPH_txt_LateHours').text(arr[5]);
                    $('#ctl00_BodyContentPH_txt_EarlyExitHours').text(arr[6]);
                    $('#ctl00_BodyContentPH_txt_Lunchhours').text(arr[7]);
                    $('#ctl00_BodyContentPH_txt_Attendancedetails').text(arr[8]);
                    $('#ctl00_BodyContentPH_lbl_ShiftDefineHours').text(arr[9]);
                    $('#ctl00_BodyContentPH_txt_BrackHrs').text(arr[10]);
                    $('#ctl00_BodyContentPH_txt_Present').text(arr2[0]);
                    $('#ctl00_BodyContentPH_txt_AbsentDays').text(arr2[1]);
                    $('#ctl00_BodyContentPH_txt_LeaveDays').text(arr2[2]);
                    $('#ctl00_BodyContentPH_txt_Holidays').text(arr2[3]);
                    $('#ctl00_BodyContentPH_txt_WeeklyOffDays').text(arr2[4]);
                    $('#ctl00_BodyContentPH_lblTotaldays').text(arr2[5]);
                    $('#ctl00_BodyContentPH_txt_MonthName').text(arr2[6]);

                }
            }
        }
        else if (objGetMyCalendar.status == 404) {
            //var url = window.location.pathname.split("/").slice(-1);
            objGetMyCalendar.open("GET", "../GetMyCalendarData.aspx?ShiftDate=" + ShiftDate, false);
            objGetMyCalendar.send(null);
            objGetMyCalendar.onreadystatechange = Process_Response_GetMyCalendar();
        }
    }
}

function GetIndividualCalendar() {

    if (window.ActiveXObject) {
        try {
            GetIndividualCalendar = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                GetIndividualCalendar = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e1) {
                GetIndividualCalendar = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            GetIndividualCalendar = new XMLHttpRequest("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                GetIndividualCalendar = new XMLHttpRequest("Microsoft.XMLHTTP");
            } catch (e1) {
                GetIndividualCalendar = null;
            }
        }
    }
    if (GetIndividualCalendar != null) {
        var k = Math.floor(Math.random() * 111);
        if (window.ActiveXObject) {
            GetIndividualCalendar.onreadystatechange = Process_Response_GetIndividualCalendar;
            //var url = window.location.pathname.split("/").slice(-1);
            GetIndividualCalendar.open("GET", "GetMyCalendarData.aspx?individualUser=Yes", false);
            GetIndividualCalendar.send(null);
        } else if (window.XMLHttpRequest) {
            //var url = window.location.pathname.split("/").slice(-1);
            GetIndividualCalendar.open("GET", "GetMyCalendarData.aspx?individualUser=Yes", false);
            GetIndividualCalendar.send(null);
            GetIndividualCalendar.onreadystatechange = Process_Response_GetIndividualCalendar();
        }
    }
    return false;
}
function Process_Response_GetIndividualCalendar() {
    if (GetIndividualCalendar.readyState == 4) {
        if (GetIndividualCalendar.status == 200) {

            var retval = GetIndividualCalendar.responseText;
            if (retval == "") {
                $('#calendar').fullCalendar({
                    header: {
                        right: 'prev,next today',
                        center: 'title',
                        left: ''
                    },
                    buttonText: {
                        today: 'Today',
                        month: 'month',
                        week: 'week',
                        day: 'day'
                    },
                });
            }
            else {
                if (retval.length > 0 && retval != "Fail") {
                    if (retval != "") {
                        $('#tablist a[href="#ctl00_BodyContentPH_tab1"]').tab('show');
                        $('html, body').animate({ scrollTop: 0 }, 'slow');
                        var ArrMyCalendarMonth = retval.split('%');
                        var ArrMyCalendarDay = [];
                        var DataPoints = [];
                        for (var i = 0; i < ArrMyCalendarMonth.length; i++) {
                            ArrMyCalendarDay = ArrMyCalendarMonth[i].split(',');
                            var date = ArrMyCalendarDay[2];

                            var shiftDates = ArrMyCalendarDay[2].split('#');
                            var todate;
                            if (shiftDates.length > 1) {
                                date = shiftDates[0];
                                todate = shiftDates[1];
                            }
                            else {
                                date = ArrMyCalendarDay[2];
                                todate = shiftDates[0];
                            }

                            var Datesplit = date.split('-');
                            var d = Datesplit[2],
                                m = Datesplit[1],
                                y = Datesplit[0];


                            if (ArrMyCalendarDay[5] == ArrMyCalendarDay[6]) {
                                if (ArrMyCalendarDay[5] == "Present") {
                                    DataPoints.push(
                                        {
                                            title: ArrMyCalendarDay[3],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                        },
                                        {
                                            title: ArrMyCalendarDay[8],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: "arrow-circle-o-up",
                                            textColor: (ArrMyCalendarDay[10] != 0) ? '#FF5151' : "",
                                            tooltip: (ArrMyCalendarDay[10] != 0) ? "Late In : " + Math.floor(ArrMyCalendarDay[10] / 60) + " hr(s) " + ArrMyCalendarDay[10] % 60 + " min(s)" : ""
                                        },
                                        {
                                            title: ArrMyCalendarDay[9],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: "arrow-circle-o-down",
                                            textColor: (ArrMyCalendarDay[11] != 0) ? '#FF5151' : "",
                                            tooltip: (ArrMyCalendarDay[11] != 0) ? "Early Out : " + Math.floor(ArrMyCalendarDay[11] / 60) + " hr(s) " + ArrMyCalendarDay[11] % 60 + " min(s)" : ""
                                        },
                                        {
                                            title: ArrMyCalendarDay[4],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: "clock-o"
                                        },
                                        {
                                            title: ArrMyCalendarDay[5],
                                            start: ArrMyCalendarDay[2],
                                            color: '#008247',
                                            textColor: "#fff",
                                            center: true,

                                        }
                                    );
                                }
                                    //Implemented by Manikandan.R on 30-03-2018 02.27 PM
                                else if (ArrMyCalendarDay[5] == "Weekly Off") {
                                    DataPoints.push(
                                        {
                                            title: ArrMyCalendarDay[3],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                        },
                                        {
                                            title: ArrMyCalendarDay[8],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: (ArrMyCalendarDay[8] != "") ? "arrow-circle-o-up" : "",
                                        },
                                        {
                                            title: ArrMyCalendarDay[9],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: (ArrMyCalendarDay[9] != "") ? "arrow-circle-o-down" : "",
                                        },
                                        {
                                            title: ArrMyCalendarDay[4],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: (ArrMyCalendarDay[9] != "") ? "clock-o" : ""
                                        },
                                        {
                                            title: ArrMyCalendarDay[5],
                                            start: ArrMyCalendarDay[2],
                                            color: '#02749E', textColor: "#fff",
                                        });
                                }
                                else if (ArrMyCalendarDay[5] == "Holiday") {
                                    DataPoints.push(
                                        {
                                            title: ArrMyCalendarDay[3],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                        },
                                        {
                                            title: ArrMyCalendarDay[8],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: (ArrMyCalendarDay[8] != "") ? "arrow-circle-o-up" : "",
                                        },
                                        {
                                            title: ArrMyCalendarDay[9],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: (ArrMyCalendarDay[9] != "") ? "arrow-circle-o-down" : "",
                                        },
                                        {
                                            title: ArrMyCalendarDay[4],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: (ArrMyCalendarDay[9] != "") ? "clock-o" : ""
                                        },
                                        {
                                            title: ArrMyCalendarDay[5],
                                            start: ArrMyCalendarDay[2],
                                            color: '#FF7F00', textColor: "#fff",
                                        });
                                }
                                else if (ArrMyCalendarDay[5] == "Absent") {
                                    DataPoints.push(
                                        {
                                            title: ArrMyCalendarDay[3],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                        },
                                        {
                                            title: ArrMyCalendarDay[8],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: "arrow-circle-o-up",
                                        },
                                        {
                                            title: ArrMyCalendarDay[9],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: "arrow-circle-o-down"
                                        },
                                        {
                                            title: ArrMyCalendarDay[4],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: "clock-o"
                                        },
                                        {
                                            title: ArrMyCalendarDay[5],
                                            start: ArrMyCalendarDay[2],
                                            color: '#FF5151',
                                            textColor: "#fff",
                                        });
                                }
                                else if (ArrMyCalendarDay[5] != null && ArrMyCalendarDay[5] != "") {
                                    DataPoints.push(
                                        {
                                            title: ArrMyCalendarDay[3],
                                            start: date,
                                            end: todate,
                                            center: true,
                                        },
                                        {
                                            title: ArrMyCalendarDay[8],
                                            start: date,
                                            end: todate,
                                            center: true,
                                            icon: (ArrMyCalendarDay[8] != "") ? "arrow-circle-o-up" : "",
                                        },
                                        {
                                            title: ArrMyCalendarDay[9],
                                            start: date,
                                            end: todate,
                                            center: true,
                                            icon: (ArrMyCalendarDay[9] != "") ? "arrow-circle-o-down" : "",
                                        },
                                        {
                                            title: ArrMyCalendarDay[4],
                                            start: date,
                                            end: todate,
                                            center: true,
                                            icon: (ArrMyCalendarDay[9] != "") ? "clock-o" : ""
                                        },
                                        {
                                            title: ArrMyCalendarDay[5],
                                            start: date,
                                            end: todate,
                                            color: '#D0457B', textColor: "#fff",
                                        });
                                }
                                else {
                                    DataPoints.push(
                                        {
                                            title: ArrMyCalendarDay[3],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                        },
                                        {
                                            title: ArrMyCalendarDay[8],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: (ArrMyCalendarDay[8] != "") ? "arrow-circle-o-up" : "",
                                        },
                                        {
                                            title: ArrMyCalendarDay[9],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: (ArrMyCalendarDay[9] != "") ? "arrow-circle-o-down" : "",
                                        },
                                        {
                                            title: ArrMyCalendarDay[4],
                                            start: ArrMyCalendarDay[2],
                                            center: true,
                                            icon: (ArrMyCalendarDay[9] != "") ? "clock-o" : ""
                                        },
                                        {
                                            title: ArrMyCalendarDay[5],
                                            start: ArrMyCalendarDay[2],
                                            color: '#FF5151', textColor: "#fff",
                                        });
                                }
                            }
                            else {
                                DataPoints.push(
                                    {
                                        title: ArrMyCalendarDay[3],
                                        start: ArrMyCalendarDay[2],
                                        center: true,
                                    },
                                    {
                                        title: ArrMyCalendarDay[8],
                                        start: ArrMyCalendarDay[2],
                                        center: true,
                                        icon: (ArrMyCalendarDay[8] != "") ? "arrow-circle-o-up" : "",
                                    },
                                    {
                                        title: ArrMyCalendarDay[9],
                                        start: ArrMyCalendarDay[2],
                                        center: true,
                                        icon: (ArrMyCalendarDay[9] != "") ? "arrow-circle-o-down" : "",
                                    },
                                    {
                                        title: ArrMyCalendarDay[4],
                                        start: ArrMyCalendarDay[2],
                                        center: true,
                                        icon: (ArrMyCalendarDay[9] != "") ? "clock-o" : ""
                                    },
                                    {
                                        title: ArrMyCalendarDay[5].substring(0, 1) + " / " + ArrMyCalendarDay[6],
                                        start: ArrMyCalendarDay[2],
                                        //rendering: 'background',
                                        color: '#A9A9A9', textColor: "#fff",
                                    });
                            }
                        }
                    }
                    else {
                        var date = new Date();
                        var d = date.getDate(),
                            m = date.getMonth(),
                            y = date.getFullYear();
                        var DataPoints = [];
                    }
                    $('#calendar').fullCalendar({
                        header: {
                            left: 'prev,next today week',
                            center: 'title',
                            right: 'month,basicWeek,basicDay'
                        },
                        buttonText: {
                            today: 'Today',
                            month: 'Month',
                            week: 'Week',
                            day: 'Day'
                        },
                        editable: true,
                        selectable: false,
                        select: function (start, end, allDay) {
                            $('#createEventModal').modal('show');
                            $('#fromdate').val(start);
                            $('#todate').val(end);
                        },
                        dayClick: function (date, jsEvent, view) {
                            var formatdate;
                            formatdate = date.format();
                            ajaxGetmyCalendar(formatdate);
                        },
                        eventClick: function (event) {
                            var formatdate;
                            formatdate = event.start.format();
                            ajaxGetmyCalendar(formatdate);
                            return false;
                        },
                        events: DataPoints,
                        eventRender: function (event, element) {
                            element.attr('title', event.tooltip);
                            if (event.icon) {
                                element.find(".fc-title").prepend("<i class='fa fa-" + event.icon + "'></i>&nbsp;&nbsp;&nbsp;");
                            }
                        }
                    });
                    $('#submitButton').on('click', function () {

                        // Clear modal inputs
                        $('.modal').find('input').val('');

                        // hide modal
                        $('.modal').modal('hide');
                    });
                }
            }
        }
        else if (GetIndividualCalendar.status == 404) {
            GetIndividualCalendar.open("GET", "../GetMyCalendarData.aspx?individualUser=Yes", false);
            GetIndividualCalendar.send(null);
            GetIndividualCalendar.onreadystatechange = Process_Response_GetIndividualCalendar();
        }
    }
}

function GetTeamCalendar(EmployeeID) {
    EmployeeCode = EmployeeID;
    if (window.ActiveXObject) {
        try {
            GetTeamCalendar = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                GetTeamCalendar = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e1) {
                GetTeamCalendar = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            GetTeamCalendar = new XMLHttpRequest("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                GetTeamCalendar = new XMLHttpRequest("Microsoft.XMLHTTP");
            } catch (e1) {
                GetTeamCalendar = null;
            }
        }
    }
    if (GetTeamCalendar != null) {
        var k = Math.floor(Math.random() * 111);
        if (window.ActiveXObject) {
            GetTeamCalendar.onreadystatechange = Process_Response_GetTeamCalendar;
            //var url = window.location.pathname.split("/").slice(-1);
            GetTeamCalendar.open("GET", "GetMyCalendarData.aspx?Team=Yes", false);
            GetTeamCalendar.send(null);
        } else if (window.XMLHttpRequest) {
            //var url = window.location.pathname.split("/").slice(-1);
            GetTeamCalendar.open("GET", "GetMyCalendarData.aspx?Team=Yes", false);
            GetTeamCalendar.send(null);
            GetTeamCalendar.onreadystatechange = Process_Response_GetTeamCalendar();
        }
    }
    return false;
}
function Process_Response_GetTeamCalendar() {
    if (GetTeamCalendar.readyState == 4) {
        if (GetTeamCalendar.status == 200) {
            var retval = GetTeamCalendar.responseText;
            if (retval == "") {
                $('#Teamcalendar').fullCalendar({
                    header: {
                        right: 'prev,next today',
                        center: 'title',
                        left: ''
                    },
                    buttonText: {
                        today: 'Today',
                        month: 'month',
                        week: 'week',
                        day: 'day'
                    },
                });
            }
            else {
                if (retval.length > 0 && retval != "Fail") {
                    $('#tablist a[href="#ctl00_BodyContentPH_tab2"]').tab('show');
                    $('html, body').animate({ scrollTop: 0 }, 'slow');
                    if (retval != "") {
                        var ArrTotalEmployee = retval.split('~');
                        var ArrMyCalendarMonth = ArrTotalEmployee[0].split('%');
                        var ArrMyCalendarDay = [];
                        var DataPoints = [];
                        if (ArrMyCalendarMonth[0] != "") {
                            for (var i = 0; i < ArrMyCalendarMonth.length; i++) {
                                ArrMyCalendarDay = ArrMyCalendarMonth[i].split(',');
                                var date = ArrMyCalendarDay[0];
                                if (ArrMyCalendarDay[1] == "P - 0 / 0" && ArrMyCalendarDay[2] == "A - 0 / 0" && ArrMyCalendarDay[3] == "L - 0 / 0") {
                                    if (ArrMyCalendarDay[4] == "W - 0 / 0") {
                                        var SplitData = ArrMyCalendarDay[4].split('-');
                                        var SplitCount = SplitData[1].split('/');
                                        if (ArrTotalEmployee[1].trim() == SplitCount[0].trim() && ArrTotalEmployee[1].trim() == SplitCount[1].trim()) {
                                            DataPoints.push({
                                                title: "Weekly Off",
                                                start: date,
                                                url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                color: '#02749E',
                                                textColor: '#FFF',
                                                center: true,
                                            });
                                        }
                                        else {
                                            DataPoints.push(
                                                {
                                                    title: ArrMyCalendarDay[1],
                                                    start: date,
                                                    url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                    color: '#33aae6',//#FFF
                                                    textColor: '#FFF',
                                                    tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                                    center: true,
                                                },
                                                {
                                                    title: ArrMyCalendarDay[2],
                                                    start: date,
                                                    url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                    color: '#FF5151',//#FFF
                                                    textColor: '#FFF',
                                                    tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                                    center: true,
                                                },
                                                {
                                                    title: ArrMyCalendarDay[3],
                                                    start: date,
                                                    url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                    color: '#D0457B',//#FFF
                                                    textColor: '#FFF',
                                                    tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                                    center: true,
                                                }
                                            );

                                        }
                                    }
                                    else if (ArrMyCalendarDay[5] == "H - 0 / 0") {
                                        var SplitData = ArrMyCalendarDay[5].split('-');
                                        var SplitCount = SplitData[1].split('/');
                                        if (ArrTotalEmployee[1].trim() == SplitCount[0].trim() && ArrTotalEmployee[1].trim() == SplitCount[1].trim()) {
                                            DataPoints.push(
                                                {
                                                    title: "Holiday",
                                                    start: date,
                                                    url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                    color: '#FF7F00',
                                                    textColor: '#FFF',
                                                    center: true,
                                                });
                                        }
                                        else {
                                            DataPoints.push(
                                                {
                                                    title: ArrMyCalendarDay[1],
                                                    start: date,
                                                    url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                    color: '#33aae6',//#FFF
                                                    textColor: '#FFF',
                                                    tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                                    center: true,
                                                },
                                                {
                                                    title: ArrMyCalendarDay[2],
                                                    start: date,
                                                    url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                    color: '#FF5151',//#FFF
                                                    textColor: '#FFF',
                                                    tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                                    center: true,
                                                },
                                                {
                                                    title: ArrMyCalendarDay[3],
                                                    start: date,
                                                    url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                    color: '#D0457B',//#FFF
                                                    textColor: '#FFF',
                                                    tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                                    center: true,
                                                }
                                            );
                                        }
                                    }
                                    else {
                                        DataPoints.push(
                                            {
                                                title: ArrMyCalendarDay[1],
                                                start: date,
                                                url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                color: '#33aae6',//#FFF
                                                textColor: '#FFF',
                                                tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                                center: true,
                                            },
                                            {
                                                title: ArrMyCalendarDay[2],
                                                start: date,
                                                url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                color: '#FF5151',//#FFF
                                                textColor: '#FFF',
                                                tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                                center: true,
                                            },
                                            {
                                                title: ArrMyCalendarDay[3],
                                                start: date,
                                                url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                                color: '#D0457B',//#FFF
                                                textColor: '#FFF',
                                                tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                                center: true,
                                            }
                                        );
                                    }
                                }
                                else {
                                    DataPoints.push(
                                        {
                                            title: ArrMyCalendarDay[1],
                                            start: date,
                                            url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                            color: '#33aae6',//#FFF
                                            textColor: '#FFF',
                                            tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                            center: true,
                                        },
                                        {
                                            title: ArrMyCalendarDay[2],
                                            start: date,
                                            url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                            color: '#FF5151',//#FFF
                                            textColor: '#FFF',
                                            tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                            center: true,
                                        },
                                        {
                                            title: ArrMyCalendarDay[3],
                                            start: date,
                                            url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                            color: '#D0457B',//#FFF
                                            textColor: '#FFF',
                                            tooltip: 'Present - First Session / Second Session \nAbsent - First Session / Second Session \nLeave - First Session / Second Session',
                                            center: true,
                                        }
                                        //,
                                        //{
                                        //    title: ArrMyCalendarDay[6],
                                        //    start: date,
                                        //    url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                        //    color: '#33aae6',//#FFF
                                        //    textColor: '#FFF',
                                        //    tooltip: 'LC - Late Comers',
                                        //    center: true,
                                        //},
                                        //{
                                        //    title: ArrMyCalendarDay[7],
                                        //    start: date,
                                        //    url: 'Reports/TA_UI_Report_ReportViewer.aspx?ReportName=MonthlyAttendance&MyEmpAutoID=' + EmployeeCode + '&MonthlydataLoadingVer=0&dtFrom=' + date + '&dtTo=' + date + '&empid=&shft=0&EmpName=&Level=0&EmpCategory=0&EmpType=0&ParentLevelId=0&UserGroupName=SuperAdmin&GradeLevel=0&MinWorkHours=&SwipeCard=&Designation=0&Gender=Both',
                                        //    color: '#33aae6',//#FFF
                                        //    textColor: '#FFF',
                                        //    tooltip: 'EO - Early Out',
                                        //    center: true,
                                        //}
                                    );
                                }
                            }
                            $('#Teamcalendar').fullCalendar({
                                header: {
                                    left: 'prev,next today week',
                                    center: 'title',
                                    right: 'month,basicWeek,basicDay'
                                },
                                buttonText: {
                                    today: 'Today',
                                    month: 'month',
                                    week: 'week',
                                    day: 'day'
                                },
                                events: DataPoints,
                                eventRender: function (event, element) {
                                    element.attr('title', event.tooltip);
                                },
                                eventClick: function (event) {
                                    if (event.url != null) {
                                        window.open(event.url, 'gcalevent', 'left=10px, top=60px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');
                                        return false;
                                    }
                                }

                            });
                        }
                        else {
                            $('#Teamcalendar').fullCalendar({
                                header: {
                                    right: 'prev,next today',
                                    center: 'title',
                                    left: ''
                                },
                                buttonText: {
                                    today: 'Today',
                                    month: 'month',
                                    week: 'week',
                                    day: 'day'
                                },
                            });
                        }
                    }
                }
            }
        }
        else if (GetTeamCalendar.status == 404) {
            GetTeamCalendar.open("GET", "../GetMyCalendarData.aspx?Team=Yes", false);
            GetTeamCalendar.send(null);
            GetTeamCalendar.onreadystatechange = Process_Response_GetTeamCalendar();
        }
    }
}