/// <summary>
        /// gets courses by page
        /// </summary>
        /// <param name="parentItem">If its first page, parent item should be passed. All its child pages will be verified.</param>
        /// <param name="pageNumber">1 is for first page, 2 is for next page & 0 is for previous page</param>
        /// <param name="referenceCourseItemID">the course item id of the first or last course teaser on page</param>
        /// <returns></returns>
        private List <CourseDetails> GetCoursesByPage(string coursesRootItemID, string pageNumber, string referenceCourseItemIDs, out bool showPrevButton, out bool showNextButton)
        {
            showPrevButton = false;
            showNextButton = false;
            List <CourseDetails> lstCourses    = new List <CourseDetails>();
            List <Item>          featuredItems = new List <Item>();
            int maxTeasersPerPage = Constants.MaxCourseTeasersPerPage;
            int itemsInList       = 0;

            if (pageNumber == "1" && !string.IsNullOrEmpty(coursesRootItemID))
            {
                Item coursesRootItem = SitecoreUtility.GetItem(new ID(coursesRootItemID));

                //get the list of courses for first page
                featuredItems = coursesRootItem != null?SitecoreUtility.GetItemsByTemplate(coursesRootItem, References.Templates.CourseDetailsPage.ID) : null;

                if (featuredItems != null && featuredItems.Count > 0)
                {
                    foreach (Item featuredItem in featuredItems)
                    {
                        if (itemsInList < maxTeasersPerPage)
                        {
                            CourseDetails courseDetailsItem = new CourseDetails(featuredItem);

                            if (courseDetailsItem != null && courseDetailsItem.IsActive)
                            {
                                courseDetailsItem.Instructor = GetInstructor(courseDetailsItem.SelectedInstructorItemID);
                                lstCourses.Add(courseDetailsItem);
                                itemsInList++;
                            }
                        }
                    }
                }
            }
            else if (!string.IsNullOrEmpty(referenceCourseItemIDs))
            {
                string[] arrItemIDs = referenceCourseItemIDs.Split(',');

                if (arrItemIDs != null && arrItemIDs.Length > 0)
                {
                    Item referenceCourseItemFirst = !string.IsNullOrEmpty(arrItemIDs[0]) ? SitecoreUtility.GetItem(new ID(arrItemIDs[0])) : null;
                    Item referenceCourseItemLast  = arrItemIDs.Length > 1 && !string.IsNullOrEmpty(arrItemIDs[1]) ? SitecoreUtility.GetItem(new ID(arrItemIDs[1])) : null;
                    Item siblingCourseItem        = null;

                    while (itemsInList < maxTeasersPerPage)
                    {
                        if (pageNumber == "0")
                        {
                            //get previous page items
                            siblingCourseItem = referenceCourseItemFirst != null?SitecoreUtility.GetPreceedingSiblingItemByTemplate(referenceCourseItemFirst, References.Templates.CourseDetailsPage.ID, References.Templates.CourseDetails.Fields.IsActive) : null;
                        }
                        else if (pageNumber == "2")
                        {
                            //get next page items
                            siblingCourseItem = referenceCourseItemLast != null?SitecoreUtility.GetSucceedingSiblingItemByTemplate(referenceCourseItemLast, References.Templates.CourseDetailsPage.ID, References.Templates.CourseDetails.Fields.IsActive) : null;
                        }

                        if (siblingCourseItem != null)
                        {
                            referenceCourseItemFirst = siblingCourseItem;
                            referenceCourseItemLast  = siblingCourseItem;
                            CourseDetails courseDetailsItem = new CourseDetails(siblingCourseItem);

                            if (courseDetailsItem != null && courseDetailsItem.IsActive)
                            {
                                courseDetailsItem.Instructor = GetInstructor(courseDetailsItem.SelectedInstructorItemID);
                                lstCourses.Add(courseDetailsItem);
                                itemsInList++;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            if (lstCourses != null && lstCourses.Count > 0)
            {
                //If the 'Previous' button was clicked, then the sibling items are added with the first item in page as reference.
                //so this list should be reversed ideally.
                if (lstCourses.Count > 1 && pageNumber == "0")
                {
                    lstCourses.Reverse();
                }

                showPrevButton = SitecoreUtility.GetPreceedingSiblingItemByTemplate(lstCourses.FirstOrDefault().InnerItem, References.Templates.CourseDetailsPage.ID, References.Templates.CourseDetails.Fields.IsActive) != null;
                showNextButton = SitecoreUtility.GetSucceedingSiblingItemByTemplate(lstCourses.LastOrDefault().InnerItem, References.Templates.CourseDetailsPage.ID, References.Templates.CourseDetails.Fields.IsActive) != null;
            }

            return(lstCourses);
        }