app.MainHomeController = function ($scope, $element, $filter, $sce, myService) {
    var userid = sessionStorage.getItem("userid");
    $scope.hfUnitId = (sessionStorage.getItem("UnitId"));
    $scope.hfLayoutId = (sessionStorage.getItem("LayoutId"));
    $scope.hfLayoutPartId = (sessionStorage.getItem("LayoutPartId"));
    $scope.hfTabId = (sessionStorage.getItem("TabId"));
    $scope.hfMenuId = (sessionStorage.getItem("MenuId"));
    $scope.hfSubMenuId = (sessionStorage.getItem("SubMenuId"));
    $scope.FooterContent = "";
    $scope.GetQuickLinks = [];

    $scope.GetLastUpdateDate($scope.hfUnitId, $scope.hfMenuId, $scope.hfSubMenuId, $scope.hfTabId, '', 4);
    $scope.GetAboutUs = function (UnitId, MenuId, SubMenuId, TabId) {
        //if (MenuId == 'undefined')
        //    MenuId = null;
        //if (SubMenuId == 'undefined')
        //    SubMenuId = null;
        //if (TabId == 'undefined')
        //    TabId = null;
        //$scope.Lang = window.location.pathname.split('/')[3].split('_')[0];
        //var url = window.location.pathname;
        //var splits = url.split('/');
        //if (splits.length > 3) {
        //    var laststring = splits[3];
        //    var splitsids = splits[3].split('_');
        //    if (splitsids > 0)
        //        collectionobj.Language = splitsids[0];
        //}

        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 4;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.TabId = (typeof (TabId) === 'undefined' ? (splitsids.length > 2 ? (isNaN(splitsids[2]) ? null : splitsids[2]) : null) : TabId);
        collectionobj.MenuId = (typeof (MenuId) === 'undefined' ? (splitsids.length > 3 ? (isNaN(splitsids[3]) ? null : splitsids[3]) : null) : MenuId);
        collectionobj.SubMenuId = (typeof (SubMenuId) === 'undefined' ? (splitsids.length > 4 ? (isNaN(splitsids[4]) ? null : splitsids[4]) : null) : SubMenuId);

        var getData = myService.methode('POST', "/Homepage/GetBodyContent", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            if (response.data.length > 0)
                $scope.AboutUsHome = response.data[0].BodyContent;
            else
                $scope.GetAboutUsById();
        });

    };
    $scope.GetAboutUsById = function () {
        var id = window.location.href.split('?')[1];
        if (id != null && id.indexOf('P') == -1) {
            var collectionobj = {};
            collectionobj.Action = 7;
            collectionobj.BodyContentId = window.location.href.split('?')[1];
            var getData = myService.methode('POST', "/Homepage/GetBodyContent", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
            getData.then(function (response) {
                if (response.data.length > 0)
                    $scope.AboutUsHomeById = response.data[0].BodyContent;
            });
        }
    };
    $scope.GetFooters = [];
    $scope.GetFooterHeader = function (UnitId, MenuId, SubMenuId, TabId) {
        // 
        //if (MenuId == 'undefined')
        //    MenuId = null;
        //if (SubMenuId == 'undefined')
        //    SubMenuId = null;
        //if (TabId == 'undefined')
        //    TabId = null;

        //$scope.Lang = window.location.pathname.split('/')[3].split('_')[0];
        //var collectionobj = {};
        //var url = window.location.pathname;
        //var splits = url.split('/');
        //if (splits.length > 3) {
        //    var laststring = splits[3];
        //    var splitsids = splits[3].split('_');
        //    if (splitsids > 0)
        //        collectionobj.Language = splitsids[0];
        //}
        //collectionobj.Action = 3;
        //collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        //collectionobj.TabId = TabId;
        //collectionobj.MenuId = MenuId;
        //collectionobj.SubMenuId = SubMenuId;
        // 
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
            if (splitsids[0] == "1") {
                $scope.polenglish = true;
                $scope.polhindi = false;
            }
            else {
                $scope.polhindi = true;
                $scope.polenglish = false;
            }


        }
        collectionobj.Action = 3;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.TabId = (typeof (TabId) === 'undefined' ? (splitsids.length > 2 ? (isNaN(splitsids[2]) ? null : splitsids[2]) : null) : TabId);
        collectionobj.MenuId = (typeof (MenuId) === 'undefined' ? (splitsids.length > 3 ? (isNaN(splitsids[3]) ? null : splitsids[3]) : null) : MenuId);
        collectionobj.SubMenuId = (typeof (SubMenuId) === 'undefined' ? (splitsids.length > 4 ? (isNaN(splitsids[4]) ? null : splitsids[4]) : null) : SubMenuId);

        var getData = myService.methode('POST', "/Homepage/GetFooterHeader", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.GetFooterHeaders = response.data;
        });
    };


    $scope.GetFooter = function (FooterHeaderId, MenuId, SubMenuId, TabId) {

        //if (MenuId == 'undefined')
        //    MenuId = null;
        //if (SubMenuId == 'undefined')
        //    SubMenuId = null;
        //if (TabId == 'undefined')
        //    TabId = null;
        //var collectionobj = {};
        //var url = window.location.pathname;
        //var splits = url.split('/');
        //if (splits.length > 3) {
        //    var laststring = splits[3];
        //    var splitsids = splits[3].split('_');
        //    if (splitsids > 0)
        //        collectionobj.Language = splitsids[0];
        //}
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 3;

        collectionobj.TabId = (typeof (TabId) === 'undefined' ? (splitsids.length > 2 ? (isNaN(splitsids[2]) ? null : splitsids[2]) : null) : TabId);
        collectionobj.MenuId = (typeof (MenuId) === 'undefined' ? (splitsids.length > 3 ? (isNaN(splitsids[3]) ? null : splitsids[3]) : null) : MenuId);
        collectionobj.SubMenuId = (typeof (SubMenuId) === 'undefined' ? (splitsids.length > 4 ? (isNaN(splitsids[4]) ? null : splitsids[4]) : null) : SubMenuId);
        //collectionobj.FooterHeaderId = FooterHeaderId;

        var getData = myService.methode('POST', "/Homepage/GetFooter", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.GetFooters = response.data;


        });
    };
    $scope.GetFooterContent = function () {
        var FooterId = window.location.href.split('?')[1];
        if (FooterId.indexOf('P') != -1) {
            FooterId = FooterId.replace('P', '');
        }
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 6;
        var getData = myService.methode('POST', "/Homepage/GetFooter", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {

            $scope.GetFooterContents = response.data;
            if ($scope.GetFooterContents.length != 0)
                $scope.FooterContent = $filter('filter')($scope.GetFooterContents, { 'FooterId': FooterId })[0].Content;
        });
    };
    $scope.MinMaxBox = function (index) {
        // 
        if ($('#' + index).hasClass('readmore')) {
            $(document).find('.minmaxbox.readmore').removeClass('readmore');
        }
        else {
            $(document).find('.minmaxbox.readmore').removeClass('readmore');
            $('#' + index).addClass("readmore");
        }
    };
    $scope.AdvanceSearch = function () {
        // 
        if ($('#AdvanceSearchBox').hasClass('advance-table')) {
            $(document).find('.col1.advance-table').removeClass('advance-table');
        }
        else {
            $(document).find('#AdvanceSearchBox').addClass("advance-table");
        }
    };
    //$scope.GetQuickLinksHeader = function (UnitId, MenuId, SubMenuId, TabId) {

    //    if (MenuId == 'undefined')
    //        MenuId = null;
    //    if (SubMenuId == 'undefined')
    //        SubMenuId = null;
    //    if (TabId == 'undefined')
    //        TabId = null;
    //    var collectionobj = {};
    //    collectionobj.Action = 3;
    //    collectionobj.UnitId = UnitId;
    //    collectionobj.TabId = TabId;
    //    collectionobj.MenuId = MenuId;
    //    collectionobj.SubMenuId = SubMenuId;
    //    var getData = myService.methode('POST', "/site/GetQuickLinksHeader", '{obj:' + JSON.stringify(collectionobj) + '}');
    //    getData.then(function (response) {
    //        $scope.GetQuickLinksHeaders = response.data;
    //    });
    //};
    //$scope.GetQuickLinks = function (UnitId, QuickLinksHeaderId, MenuId, SubMenuId, TabId) {

    //    if (MenuId == 'undefined')
    //        MenuId = null;
    //    if (SubMenuId == 'undefined')
    //        SubMenuId = null;
    //    if (TabId == 'undefined')
    //        TabId = null;
    //    var collectionobj = {};
    //    collectionobj.Action = 6;
    //    collectionobj.UnitId = UnitId;
    //    collectionobj.TabId = TabId;
    //    collectionobj.MenuId = MenuId;
    //    collectionobj.SubMenuId = SubMenuId;
    //    collectionobj.QuickLinksHeaderId = QuickLinksHeaderId;

    //    var getData = myService.methode('POST', "/Site/GetQuickLinks", '{obj:' + JSON.stringify(collectionobj) + '}');
    //    getData.then(function (response) {

    //            $scope.GetQuickLinks[QuickLinksHeaderId] = response.data;

    //    });
    //};

    $scope.LoadNotice = function (UnitId, MenuId, SubMenuId, TabId) {
        //if (MenuId == 'undefined')
        //    MenuId = null;
        //if (SubMenuId == 'undefined')
        //    SubMenuId = null;
        //if (TabId == 'undefined')
        //    TabId = null;
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 5;
        //collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        //collectionobj.TabId = TabId;
        //collectionobj.MenuId = MenuId;
        //collectionobj.SubMenuId = SubMenuId;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.TabId = (typeof (TabId) === 'undefined' ? (splitsids.length > 2 ? (isNaN(splitsids[2]) ? null : splitsids[2]) : null) : TabId);
        collectionobj.MenuId = (typeof (MenuId) === 'undefined' ? (splitsids.length > 3 ? (isNaN(splitsids[3]) ? null : splitsids[3]) : null) : MenuId);
        collectionobj.SubMenuId = (typeof (SubMenuId) === 'undefined' ? (splitsids.length > 4 ? (isNaN(splitsids[4]) ? null : splitsids[4]) : null) : SubMenuId);

        var getData = myService.methode('POST', "/Homepage/GetNotice", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            if (response.data.length > 0) {
                $scope.Notice = response.data[0];
            }
        });
    };


    $scope.GetNoticeArchivalList = function (UnitId, MenuId, SubMenuId, TabId) {
        //if (MenuId == 'undefined')
        //    MenuId = null;
        //if (SubMenuId == 'undefined')
        //    SubMenuId = null;
        //if (TabId == 'undefined')
        //    TabId = null;
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 9;
        //collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        //collectionobj.TabId = TabId;
        //collectionobj.MenuId = MenuId;
        //collectionobj.SubMenuId = SubMenuId;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.TabId = (typeof (TabId) === 'undefined' ? (splitsids.length > 2 ? (isNaN(splitsids[2]) ? null : splitsids[2]) : null) : TabId);
        collectionobj.MenuId = (typeof (MenuId) === 'undefined' ? (splitsids.length > 3 ? (isNaN(splitsids[3]) ? null : splitsids[3]) : null) : MenuId);
        collectionobj.SubMenuId = (typeof (SubMenuId) === 'undefined' ? (splitsids.length > 4 ? (isNaN(splitsids[4]) ? null : splitsids[4]) : null) : SubMenuId);

        var getData = myService.methode('POST', "/Homepage/NoticeArchivalList", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.NoticeArchivalList = response.data.Table;
            $scope.PublishMonthYear = response.data.Table1;
        });
    };
    $scope.LoadAllNotice = function (UnitId, MenuId, SubMenuId, TabId) {
        //if (MenuId == 'undefined')
        //    MenuId = null;
        //if (SubMenuId == 'undefined')
        //    SubMenuId = null;
        //if (TabId == 'undefined')
        //    TabId = null;
        //var collectionobj = {};
        //var url = window.location.pathname;
        //var splits = url.split('/');
        //if (splits.length > 3) {
        //    var laststring = splits[3];
        //    var splitsids = splits[3].split('_');
        //    if (splitsids > 0)
        //        collectionobj.Language = splitsids[0];
        //}

        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 7;
        //collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        //collectionobj.TabId = TabId;
        //collectionobj.MenuId = MenuId;
        //collectionobj.SubMenuId = SubMenuId;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.TabId = (typeof (TabId) === 'undefined' ? (splitsids.length > 2 ? (isNaN(splitsids[2]) ? null : splitsids[2]) : null) : TabId);
        collectionobj.MenuId = (typeof (MenuId) === 'undefined' ? (splitsids.length > 3 ? (isNaN(splitsids[3]) ? null : splitsids[3]) : null) : MenuId);
        collectionobj.SubMenuId = (typeof (SubMenuId) === 'undefined' ? (splitsids.length > 4 ? (isNaN(splitsids[4]) ? null : splitsids[4]) : null) : SubMenuId);

        var getData = myService.methode('POST', "/Homepage/GetNotice", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {

            $scope.AllNoticeList = response.data[0];
            $scope.PublishMonthYear = response.data[1];

        });
    };

    $scope.LoadNoticeDetails = function () {
        var NoticeId = window.location.href.split('?')[1];
        //var UnitId = window.location.pathname.split('/')[3].split('_')[1];
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 10;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.NoticeId = NoticeId;
        // CHeck Faculty Notice
        if (NoticeId.split('#').length > 1) { collectionobj.Action = 11; collectionobj.NoticeId = NoticeId.split('#')[0]; }

        var getData = myService.methode('POST', "/Homepage/GetNotice", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {

            $scope.NoticeDetail = response.data[0];
        });
    };

    $scope.Notice_Click = function (NoticeId) {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/NoticeDetail/' + ids + '?' + NoticeId, '_blank');
    };

    $scope.NoticeReadmore_Click = function () {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/Notices/' + ids, '_blank');
    };
    $scope.LoadNoticeReadmore_Click = function () {

        var newid = window.location.href.split('?');
        var ids = newid[0].split('/')[5];
        //  /Site/CkEditerContent/1_52_1118_Institute-Of-Medical-Science-Faculty-of-Ayurveda?2078
        $scope.NoticeDetailLink = '/Site/CkEditerContent/' + ids + '?' + newid[1];
    };
    $scope.LoadfacultyNoticeDetails = function () {
        var FacultyNoticeId = "";
        var FacultyId = "";

        var values = window.location.href.split('?');
        if (values.length > 1) {
            FacultyNoticeId = values[1].split('#')[0];
            FacultyId = values[1].split('#')[1];
        }

        else {
            FacultyNoticeId = null;
            FacultyId = null;
        }

        var collectionobj = {};
        collectionobj.Action = 6;
        collectionobj.FacultyId = FacultyId;
        collectionobj.FacultyNoticeId = FacultyNoticeId;
        var getData = myService.methode('POST', "/Homepage/GetFaculty", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.facultyNoticeDetails = response.data.Table;
        });
    };

    $scope.AllNoticeOfFaculty = function () {
        var FacultyId = "";
        var values = window.location.href.split('?');
        if (values.length > 1)
            FacultyId = values[1].split('#')[0];
        else
            FacultyId = null;

        var collectionobj = {};
        collectionobj.Action = 6;
        collectionobj.FacultyId = FacultyId;
        collectionobj.FacultyNoticeId = null;
        var getData = myService.methode('POST', "/Homepage/GetFaculty", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {

            $scope.facultyAllNotices = response.data.Table;
        });
    };

    $scope.faculty_Notice_Click = function (FacultyNoticeId) {
        var newid = window.location.href.split('?')[0];
        var FacultyId = window.location.href.split('?')[1].split('#')[0];
        var ids = newid.split('/')[5];
        // 
        window.open('/Site/NoticeDetail/' + ids + '?' + FacultyNoticeId + '#' + FacultyId, '_blank');
    };

    $scope.LoadNews = function (UnitId, MenuId, SubMenuId, TabId) {
        if (MenuId == 'undefined')
            MenuId = null;
        if (SubMenuId == 'undefined')
            SubMenuId = null;
        if (TabId == 'undefined')
            TabId = null;
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        if (splits.length > 3) {
            var laststring = splits[3];
            var splitsids = splits[3].split('_');
            if (splitsids > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 5;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.TabId = TabId;
        collectionobj.MenuId = MenuId;
        collectionobj.SubMenuId = SubMenuId;
        var getData = myService.methode('POST', "/Homepage/GetNews", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {

            $scope.NewsList = response.data.Table;


        });
    };


    $scope.GetNewsArchivalList = function (UnitId, MenuId, SubMenuId, TabId) {
        if (MenuId == 'undefined')
            MenuId = null;
        if (SubMenuId == 'undefined')
            SubMenuId = null;
        if (TabId == 'undefined')
            TabId = null;
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        if (splits.length > 3) {
            var laststring = splits[3];
            var splitsids = splits[3].split('_');
            if (splitsids > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 9;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.TabId = TabId;
        collectionobj.MenuId = MenuId;
        collectionobj.SubMenuId = SubMenuId;
        var getData = myService.methode('POST', "/Homepage/NewsArchivalList", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {

            if (response.data.Table.length > 0) {
                $scope.NewsArchivalList = response.data.Table;
                $scope.PublishMonthYear = response.data.Table1;
            }
        });
    }


    $scope.LoadAllNews = function (UnitId, MenuId, SubMenuId, TabId) {
        if (MenuId == 'undefined')
            MenuId = null;
        if (SubMenuId == 'undefined')
            SubMenuId = null;
        if (TabId == 'undefined')
            TabId = null;
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        if (splits.length > 3) {
            var laststring = splits[3];
            var splitsids = splits[3].split('_');
            if (splitsids > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 7;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.TabId = TabId;
        collectionobj.MenuId = MenuId;
        collectionobj.SubMenuId = SubMenuId;
        var getData = myService.methode('POST', "/Homepage/GetNews", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.AllNewsList = response.data.Table;
            $scope.PublishMonthYear = response.data.Table1;
        });
    };

    $scope.LoadNewsDetails = function () {
        var NewsId = window.location.href.split('?')[1];
        var UnitId = window.location.pathname.split('/')[3].split('_')[1];
        var collectionobj = {};
        collectionobj.Action = 8;
        collectionobj.UnitId = UnitId;
        collectionobj.NewsId = NewsId;
        var getData = myService.methode('POST', "/Homepage/GetNews", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.NewsDetail = response.data.Table;
        });
    };

    $scope.News_Click = function (NoticeId) {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/NewsDetail/' + ids + '?' + NoticeId, '_blank');
    };

    $scope.NewsReadmore_Click = function () {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/NewsList/' + ids, '_blank');
    };

    $scope.NewsArchival_Click = function () {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/NewsArchival/' + ids, '_blank');
    };


    $scope.NoticeArchival_Click = function () {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/NoticeArchival/' + ids, '_blank');
    };
    $scope.EventsArchival_Click = function () {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/AcademicEventsArchival/' + ids, '_blank');
    };



    $scope.ToDoListItems = [];
    $scope.listItem = 0;
    $scope.numPerPage = 10;
    $scope.maxSize = 10;
    $scope.CreateFooterPage = function (data) {
        $scope.listItem = data.length;
        $scope.$applyAsync();
    };
    $scope.GetPublication = function () {
        var collectionobj = {};
        if ($scope.UnitId != undefined) {
            collectionobj.UnitId = $scope.UnitId;
        } else {
            var url = window.location.pathname;
            var splitsids = url.split('_');
            if (splitsids.length > 1) {
                collectionobj.UnitId = splitsids[1];
            }
        }
        var getData = myService.methode('POST', "/Homepage/GetPublication", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.Publications = response.data;
            //$scope.ToDoListItems = response.data;
            //$scope.CreateFooterPage(response.data);
            //$scope.Publications = $scope.ToDoListItems.slice(0, $scope.numPerPage);
        });
    };
    $scope.GetAwardsAndRecognition = function () {
        var UnitId = window.location.pathname.split('/')[3].split('_')[1];
        var collectionobj = {};
        collectionobj.UnitId = UnitId;
        var getData = myService.methode('POST', "/Homepage/GetAwardsAndRecognition", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            //$scope.ToDoListItems = response.data;
            //$scope.CreateFooterPage(response.data);
            //$scope.AwardsAndRecognitions = $scope.ToDoListItems.slice(0, $scope.numPerPage);
            $scope.Faculties = response.data.Table;
            $scope.AwardsAndRecognitions = response.data.Table1;
            // 
        });
    };
    $scope.GetProjects = function () {
        var UnitId = window.location.pathname.split('/')[3].split('_')[1];
        var collectionobj = {};
        collectionobj.UnitId = UnitId;
        var getData = myService.methode('POST', "/Homepage/GetProjects", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            //$scope.ToDoListItems = response.data;
            //$scope.CreateFooterPage(response.data);
            //$scope.Projects = $scope.ToDoListItems.slice(0, $scope.numPerPage);
            $scope.Faculties = response.data.Table;
            $scope.Projects = response.data.Table1;
        });
    };

    $scope.$watch('searchtext', function (term) {
        if (typeof ($scope.searchtext) === 'undefined') return;

        $scope.Publications = $filter('filter')($scope.ToDoListItems, { Authors: term });
        $scope.CreateFooterPage($scope.Publications);
        $scope.Publications = $scope.Publications.slice(0, $scope.numPerPage);
        $scope.Projects = $filter('filter')($scope.ToDoListItems, { Projecttitle: term });
        $scope.CreateFooterPage($scope.Projects);
        $scope.Projects = $scope.Projects.slice(0, $scope.numPerPage);
    });
    $scope.LoadAcademicEvents = function () {
        // 
        var UnitId = null;
        var splitstring = window.location.pathname.split('/')[3].split('_');
        if (splitstring.length > 1)
            UnitId = splitstring[1];

        var collectionobj = {};
        collectionobj.Action = 4;
        collectionobj.UnitId = UnitId;
        var getData = myService.methode('POST', "/Homepage/GetAcademicEvents", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.AcademicEvents = response.data.Table1;

        });
    };

    $scope.GetAcademicEventsArchival = function () {
        // 
        var UnitId = null;
        var splitstring = window.location.pathname.split('/')[3].split('_');
        if (splitstring.length > 1)
            UnitId = splitstring[1];

        var collectionobj = {};
        collectionobj.Action = 6;
        collectionobj.UnitId = UnitId;
        var getData = myService.methode('POST', "/Homepage/AcademicEventsArchivalList", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.AcademicEventsArchivalList = response.data.Table;
            $scope.PublishMonthYear = response.data.Table1;

        });
    };


    $scope.LoadAcademicEventlist = function () {
        var eventtype = window.location.href.split('?')[1];
        var splitstring = window.location.pathname.split('/')[3].split('_');
        var UnitId = splitstring[1];
        var collectionobj = {};
        collectionobj.Action = 4;
        collectionobj.UnitId = UnitId;
        //collectionobj.ShowDate = $scope.months;

        var getData = myService.methode('POST', "/Homepage/GetAcademicEvents", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.AcademicEventMonthYear = $filter('filter')(response.data.Table, { 'EventType': eventtype });
            $scope.CreateFooterPage($scope.AcademicEventMonthYear);
            //  $scope.AcademicEventMonthYear = $scope.AcademicEventMonthYear;//.slice(0, $scope.numPerPage);
            $scope.AcademicEvents = response.data.Table1;
            //setTimeout(function () {
            //    $scope.AcademicEvents = $filter('filter')(response.data.Table1, { 'EventType': eventtype });
            //    //$scope.CreateFooterPage($scope.AcademicEvents);
            //    //$scope.AcademicEvents = $scope.ToDoListItems.slice(0, $scope.numPerPage);
            //}, 500);

        });
    };

    $scope.LoadAcademicEventDetails = function () {
        var EventType = window.location.href.split('?')[1].split('&')[0];
        var AcademicEventsId = window.location.href.split('&')[1];
        var UnitId = window.location.pathname.split('/')[3].split('_')[1];
        var collectionobj = {};
        collectionobj.Action = 5;
        collectionobj.UnitId = UnitId;
        collectionobj.AcademicEventsId = AcademicEventsId;
        collectionobj.EventType = EventType;
        // 
        var getData = myService.methode('POST', "/Homepage/GetAcademicEvents", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.AcademicEvents = response.data.Table;
        });
    };

    $scope.Event_Click = function (AcademicEventsId) {
        var ids = window.location.href.split('/')[5];
        window.open('/Site/EventDetails/' + ids + '&' + AcademicEventsId, '_blank');
    };

    $scope.AcademicEvents_Click = function (AcademicEventsId) {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/EventDetails/' + ids + '?' + AcademicEventsId, '_blank');
    };

    $scope.AcademicEventsReadmore_Click = function (eventtype) {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/EventsList/' + ids + '?' + eventtype, '_blank');
    };

    $scope.GETProgramme = function () {
        var collectionobj = { Action: '' };
        if ($scope.UnitId != undefined) {
            collectionobj.UnitId = $scope.UnitId;
        } else {
            var url = window.location.pathname;
            var splitsids = url.split('_');
            if (splitsids.length > 1) {
                collectionobj.UnitId = splitsids[1];
            }
        }
        var getData = myService.methode('POST', "/Homepage/GetProgrammeMaster", '{obj:' + JSON.stringify(collectionobj) + '}');
        getData.then(function (response) {
            $scope.ProgrammeList = response.data;
        });
    };

    $scope.GetProgrammeDetails = function () {
        var ProgrammeId = window.location.href.split('?')[1];
        var collectionobj = {};
        collectionobj.ProgrammeId = ProgrammeId;
        var getData = myService.methode('POST', "/Homepage/GetProgrammeUsingId", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.ProgrammeList = response.data;
        });
    };

    $scope.DurationList = [];

    $scope.GetProgrammeSubjects = function () {
        var ProgrammeId = window.location.href.split('?')[1];
        var collectionobj = {};
        collectionobj.ProgrammeId = ProgrammeId;
        var getData = myService.methode('POST', "/Homepage/GetSubjectsUsingProgrammeId", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $.each(response.data, function (index, val) {
                if ($filter('filter')($scope.DurationList, { 'DurationName': val.DurationName }, true).length == 0)
                    $scope.DurationList.push({ 'DurationName': val.DurationName });
            });
            $scope.ProgrammeSubjectsList = response.data;
        });
    };

    $scope.GetSubjectDetails = function () {
        var SubjectDetailsId = window.location.href.split('?')[1];
        var collectionobj = {};
        collectionobj.SubjectDetailsId = SubjectDetailsId;
        var getData = myService.methode('POST', "/Homepage/GetSubjectDetails", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.SubjectDetails = response.data;
        });
    };

    $scope.newline = function (textdata) {
        return textdata.replace('\n', '<br />');
    };

    $scope.GetfacultyUsingSubjectId = function (SubjectId) {
        var collectionobj = {};
        collectionobj.SubjectId = SubjectId;
        var getData = myService.methode('POST', "/Homepage/Getfaculty", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {

            $scope.FacultyListSubject = response.data.Table;
        });
    };

    $scope.GetCampaignList = function (data) {
        var UnitId = window.location.pathname.split('/')[3].split('_')[1];
        var collectionobj = {};
        collectionobj.UnitId = UnitId;
        var getData = myService.methode('POST', "/Homepage/GetCampaignList", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.CampaignList = response.data
            $scope.CreateFooterPage($scope.CampaignList);
            $scope.CampaignList = $scope.ToDoListItems.slice(0, $scope.numPerPage);
        });
    }

    $scope.GetAllCampaignList = function (data) {
        var UnitId = window.location.pathname.split('/')[3].split('_')[1];
        var collectionobj = {};
        collectionobj.UnitId = UnitId;
        var getData = myService.methode('POST', "/Homepage/GetAllCampaignList", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.AllCampaignList = response.data
            $scope.CreateFooterPage($scope.AllCampaignList);
            $scope.AllCampaignList = $scope.ToDoListItems.slice(0, $scope.numPerPage);
        });
    }

    $scope.GetAllCampaigns = function () {
        // 
        var ids = window.location.href.split('/')[5];
        window.open('/Homepage/CampaignsList/' + ids, '_blank');
    }

    $scope.GetCampaignUsingId = function (data) {
        var CampaignId = window.location.href.split('?')[1];
        var collectionobj = {};
        collectionobj.CampaignId = CampaignId;
        var getData = myService.methode('POST', "/Homepage/GetCampaignUsingUnitId", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            // 
            $scope.CampaignListDetails = response.data.Table
            $scope.CampaignUpdates = response.data.Table1;
        });
    }

    $scope.Campaign_Click = function (CampaignId) {
        var ids = window.location.href.split('/')[5];
        window.open('/Homepage/CampaignPage/' + ids + '?' + CampaignId, '_blank');
    };

    $scope.CampaignStoryClick = function (id, nextid, descid1, descid2) {
        var currenttab = $(id);
        currenttab.addClass('resp-tab-active')
        var nexttab = $(nextid);
        nexttab.removeClass('resp-tab-active')

        var currentdiv = $(descid1);
        currentdiv.addClass('resp-tab-content-active')
        currentdiv.show();
        var nextdiv = $(descid2);
        nextdiv.removeClass('resp-tab-content-active')
        nextdiv.hide();
    }

    $scope.DonateAmount = function (UnitTypeId, UnitId, PurposeId, isAlumni, Title, Purpose, UnitName) {
        var ids = window.location.href.split('/')[5];
        if (isAlumni == '0') {
            window.open('../../Site/DonationForm/' + ids + '_' + UnitTypeId + '_' + UnitId + '_' + PurposeId + '_' + isAlumni + '_' + Title + '_' + Purpose + '_' + UnitName, '_blank');
        }
        else {
            window.open('../../Site/AlumniLogin/' + ids.split('?')[0], '_self');
        }
    };

    $scope.hideAboutUsDiv = function () {
        if (window.location.href.split('?').length > 1)
            return true;
        else return false;
    }

    $scope.getStoriesFromTheGround = function () {
        var collectionobj = {};
        collectionobj.Action = 4;
        var getData = myService.methode('POST', "../../Homepage/GetCategoryPost", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            // 
            $scope.StoriesFromTheGround = response.data;
        });
    }
    $scope.getYouMayBeInterestedIn = function () {
        var collectionobj = {};
        collectionobj.Action = 5;
        var getData = myService.methode('POST', "../../Homepage/GetCategoryPost", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            // 
            $scope.YouMayBeInterestedIn = response.data;
        });
    }
    $scope.getBHUGazette = function () {
        var collectionobj = {};
        collectionobj.Action = 6;
        var getData = myService.methode('POST', "../../Homepage/GetCategoryPost", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            // 
            $scope.BHUGazette = response.data;
        });
    };

    $scope.LoadStoriesFromTheGround = function () {
        var CategoryPostId = window.location.href.split('?')[1];
        var collectionobj = {};
        collectionobj.Action = 7;
        collectionobj.CategoryPostId = CategoryPostId;
        collectionobj.CategoryId = 1;
        var getData = myService.methode('POST', "../../Homepage/GetCategoryPost", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.StoriesFromTheGroundDetail = response.data;
        });
    };

    $scope.StoriesFromTheGround_Click = function (CategoryPostId) {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/StoriesFromGroundDetails/' + ids + '?' + CategoryPostId, '_blank');
    };
    $scope.YouMayBeInterestedIn_Click = function (CategoryPostId) {
        var newid = window.location.href.split('?')[0];
        var ids = newid.split('/')[5];
        window.open('/Site/YouMayBeInterestedInDetails/' + ids + '?' + CategoryPostId, '_blank');
    };
    $scope.LoadYouMayBeInterestedIn_Click = function () {
        // 
        var newid = window.location.href.split('?');
        var ids = newid[0].split('/')[5];
        //  /Site/CkEditerContent/1_52_1118_Institute-Of-Medical-Science-Faculty-of-Ayurveda?2078
        $scope.YouMayBeInterestedInLink = $sce.trustAsResourceUrl('/Site/YouMayBeInterestedInDetailsCkEditerContent/' + ids + '?' + newid[1]);
    };
    $scope.LoadStoriesFromGround_Click = function () {
        // 
        var newid = window.location.href.split('?');
        var ids = newid[0].split('/')[5];
        //  /Site/CkEditerContent/1_52_1118_Institute-Of-Medical-Science-Faculty-of-Ayurveda?2078
        $scope.StoriesFromGroundLink = '/Site/StoriesFromGroundDetailsCkEditerContent/' + ids + '?' + newid[1];
    };
    $scope.PublicationLang = function () {
        // 
        var absuri = window.location.href
        if (absuri.split('/').length > 5) {
            var ids = absuri.split('/')[5];
            var lan = ids.split('_')[0];
            var UnitId = ids.split('_')[1];

            var host = '../' + absuri.split('/')[4]

            if (lan == "1") {
                $scope.PubLanguage = "Publications";
            }
            else if (lan == "2") {
                $scope.PubLanguage = 'शोध प्रकाशन';
            }
        }
    }

    $scope.PublicationLang();
    $scope.GetAnnouncementDetail = function () {
        var collectionobj = {};
        collectionobj.Action = 5;
        var url = window.location.pathname;
        var splits = url.split('/');
        if (splits.length > 3) {
            var laststring = splits[3];
            var splitsids = splits[3].split('_');
            //if (splitsids > 0)
            collectionobj.Language = splitsids[0];
        }
        collectionobj.UnitId = splitsids[1];

        var getData = myService.methode('POST', "/Homepage/GetAnnouncement", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            // 
            $scope.AnnouncementDesc = response.data;
        });
    };

    $scope.SearchList = [];
    $scope.SearchTextData = function (e) {
        if (e == null || e.keyCode == 13) {
            $scope.ShowSearchWait = true;
            var collectionobj = {};
            var url = window.location.pathname;
            var splits = url.split('/');
            if (splits.length > 3) {
                var laststring = splits[3];
                var splitsids = laststring.split('_');
                //if (splitsids > 0)
                collectionobj.Language = splitsids[0];
            }
            collectionobj.Search = $scope.searchtext;
            var getData = myService.methode('POST', "/Homepage/SearchText", '{obj:' + JSON.stringify(collectionobj) + '}');
            getData.then(function (response) {
                $scope.ShowSearchWait = false;
                $scope.SearchList = response.data;
            });
        }
    };
    $scope.LoadAdmissionNotice = function (UnitId, MenuId, SubMenuId, TabId) {
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 5;

        collectionobj.UnitId = 3387;
        var getData = myService.methode('POST', "/Homepage/GetNotice", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            if (response.data.length > 0) {
                $scope.Notice = response.data[0];
            }
        });
    };

    $scope.LoadAdmissionAnnouncement = function () {
        var collectionobj = {};
        collectionobj.Action = 5;
        var url = window.location.pathname;
        var splits = url.split('/');
        if (splits.length > 3) {
            var laststring = splits[3];
            var splitsids = splits[3].split('_');
            //if (splitsids > 0)
            collectionobj.Language = splitsids[0];
        }
        collectionobj.UnitId = 3387;

        var getData = myService.methode('POST', "/Homepage/GetAnnouncement", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            // 
            $scope.AnnouncementDesc = response.data;
        });
    };
    $scope.GetNoticeAdmissionArchivalList = function (UnitId, MenuId, SubMenuId, TabId) {
        //if (MenuId == 'undefined')
        //    MenuId = null;
        //if (SubMenuId == 'undefined')
        //    SubMenuId = null;
        //if (TabId == 'undefined')
        //    TabId = null;
        var collectionobj = {};
        var url = window.location.pathname;
        var splits = url.split('/');
        var splitsids = [];
        if (splits.length > 3) {
            splitsids = splits[3].split('_');
            if (splitsids.length > 0)
                collectionobj.Language = splitsids[0];
        }
        collectionobj.Action = 9;
        
        //collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        //collectionobj.TabId = TabId;
        //collectionobj.MenuId = MenuId;
        //collectionobj.SubMenuId = SubMenuId;
        collectionobj.UnitId = (typeof (UnitId) === 'undefined' ? splitsids[1] : UnitId);
        collectionobj.TabId = (typeof (TabId) === 'undefined' ? (splitsids.length > 2 ? (isNaN(splitsids[2]) ? null : splitsids[2]) : null) : TabId);
        collectionobj.MenuId = (typeof (MenuId) === 'undefined' ? (splitsids.length > 3 ? (isNaN(splitsids[3]) ? null : splitsids[3]) : null) : MenuId);
        collectionobj.SubMenuId = (typeof (SubMenuId) === 'undefined' ? (splitsids.length > 4 ? (isNaN(splitsids[4]) ? null : splitsids[4]) : null) : SubMenuId);
        collectionobj.UnitId = 3387;
        var getData = myService.methode('POST', "/Homepage/NoticeArchivalList", '{obj:' + JSON.stringify(collectionobj) + '}', $scope.antiForgeryToken);
        getData.then(function (response) {
            $scope.NoticeArchivalList = response.data.Table;
            $scope.PublishMonthYear = response.data.Table1;
        });
    };
}
