/**
  * @return array
  * @param SiteContext $o_context
  * @param int $i_start_level
  * @desc Return first, previous, next and last categories in a section
  */
 function GetRelativeInSection($o_context, $i_start_level)
 {
     /* @var $o_current_category Category */
     /* @var $o_category Category */
     /* @var $o_next_category Category */
     /* @var $o_first_category Category */
     /* @var $o_last_category Category */
     $a_links = array();
     if ($o_context instanceof SiteContext and is_numeric($i_start_level)) {
         # get current category
         $o_current_category = $o_context->GetCurrent();
         # loop through all categories
         $i_total_categories = $this->GetCount();
         for ($i_count = 0; $i_count < $i_total_categories; $i_count++) {
             # match current category
             $o_category = $this->GetByIndex($i_count);
             if ($o_category->GetId() == $o_current_category->GetId()) {
                 # get prev link, if not section home
                 if ($o_category->GetHierarchyLevel() != $i_start_level) {
                     $a_links['prev'] = $this->GetByIndex($i_count - 1);
                 }
                 # get next link, if not new section
                 $o_next_category = $this->GetByIndex($i_count + 1);
                 if ($o_next_category->GetHierarchyLevel() > $i_start_level) {
                     $a_links['next'] = $o_next_category;
                 }
                 # get first link, unless this is first page
                 if ($o_category->GetHierarchyLevel() >= $i_start_level + 1) {
                     $i_first_count = $i_count;
                     $o_first_category = $this->GetByIndex($i_first_count);
                     while ($o_first_category->GetHierarchyLevel() >= $i_start_level) {
                         $a_links['first'] = $o_first_category;
                         if ($a_links['first']->GetId() == $o_category->GetParentId()) {
                             break;
                         }
                         $i_first_count--;
                         $o_first_category = $this->GetByIndex($i_first_count);
                     }
                 }
                 # get last link, if this isn't last
                 if ($o_next_category->GetHierarchyLevel() >= $i_start_level + 1) {
                     $i_last_count = $i_count;
                     # cater for section home page
                     if ($o_category->GetHierarchyLevel() == $i_start_level) {
                         $o_last_category = $this->GetByIndex($i_last_count + 1);
                         while ($o_last_category->GetParentId() == $o_category->GetId() or $o_last_category->GetHierarchyLevel() > $i_start_level + 1) {
                             $a_links['last'] = $this->GetByIndex($i_last_count);
                             $i_last_count++;
                             $o_last_category = $this->GetByIndex($i_last_count + 1);
                         }
                         $a_links['last'] = $this->GetByIndex($i_last_count);
                     } else {
                         $o_last_category = $this->GetByIndex($i_last_count);
                         while ($o_last_category->GetHierarchyLevel() > $i_start_level) {
                             $a_links['last'] = $o_last_category;
                             $i_last_count++;
                             $o_last_category = $this->GetByIndex($i_last_count);
                         }
                     }
                 }
                 break;
             }
         }
     }
     return $a_links;
 }