function Parents()
 {
     $args = func_get_arg(0);
     $this->ObjektArray();
     $this->meta = array();
     if (is_object($args['parent']) && !strcasecmp(get_class($args['parent']), 'Objekt')) {
         # parent on objekt
         $this->parent_id = $args["parent"]->objekt_id;
         $this->debug->msg("Parents. Antud on objekt: parent_id = " . $this->parent_id);
     } elseif (preg_match("/^\\d+\$/", $args["parent"])) {
         # parent on objekti ID
         $this->parent_id = $args["parent"];
         $this->debug->msg("Parents. Antud on objekti ID: parent_id = " . $this->parent_id);
     } else {
         # parent on vigane
         $this->debug->msg("vigased algandmed: \"{$args['parent']}\" pole objekt ega objekti ID");
     }
     # merle h�mar kommentaar "lisa_objekt"-ile: mulle tundub, et see on vajalik situatsioonis,
     # kus URL-i peal id puudub JA tegu on vana fiks. op-malliga: siis "on meil eriobjekt"
     # ja oleks vaja seda op-malli n�idata HOME rubriigi all ja seep�rast lisatakse parentsi l�ppu objekt HOME.
     if ($args["lisa_objekt"]) {
         $this->add($args["lisa_objekt"]);
     }
     if ($this->parent_id) {
         $id = $this->parent_id;
         $this->debug->msg("Parents. Alguses parent_id = " . $this->parent_id);
         $idid = array();
         # juhul kui HOME, on vaja �he sammu v�rra alla minna
         if ($args["on_esileht"]) {
             $this->debug->msg("Antud HOME rubriik, h�ppame �he taseme v�rra alla");
             $alamlist = new Alamlist(array("parent" => $id, "start" => 0, "limit" => 1, "klass" => 'rubriik', "order" => "objekt.kesk asc, sorteering DESC"));
             $this->debug->msg($alamlist->debug->get_msgs());
             if ($alamlist->size) {
                 $obj = $alamlist->get(0);
                 $id = $obj->objekt_id;
                 $this->debug->msg("Uus ID = {$id}");
             } else {
                 $this->debug->msg("Kahjuks alla h�pata ei saa... Pole sobivat kohta");
             }
         }
         $this->aktiivne_id = $id;
         #############################
         # allah�ppamine
         $this->debug->msg("JUMP: ================START================");
         $this->debug->msg("Jump down? " . ($this->site->in_editor || $this->site->in_admin ? "We are in editor-area or admin-area => abort mission" : "We are in public area => start mission"));
         # We are in public area => start missio:
         if (!($this->site->in_editor || $this->site->in_admin)) {
             do {
                 $last_id = $id;
                 $obj = new Objekt(array("objekt_id" => $id));
                 $this->debug->msg($obj->debug->get_msgs());
                 #####################
                 # kui objekt on rubriik JA talle pole ei lehe- ega sisumalli m��ratud
                 # siis tuleb objekti auto avanemine ise otsustada.
                 # variante on 2:
                 if ($obj->all[klass] == "rubriik" && !$obj->all["page_ttyyp_id"] && !$obj->all["ttyyp_id"]) {
                     $obj->all["on_auto_avanev"] = $this->site->master_tpl["on_auto_avanev"];
                     $this->debug->msg("JUMP: Auto avanemise m��rab saidi p�himall (ID=" . $this->site->master_tpl[ttyyp_id] . ")" . $this->site->master_tpl["on_auto_avanev"]);
                 } elseif ($obj->all["page_ttyyp_id"] && !$obj->all["ttyyp_id"]) {
                     $sql = $this->site->db->prepare("SELECT on_auto_avanev FROM templ_tyyp WHERE ttyyp_id=?", $obj->all["page_ttyyp_id"]);
                     $sth = new SQL($sql);
                     $obj->all["on_auto_avanev"] = $sth->fetchsingle();
                 }
                 $this->debug->msg("JUMP: Tulemus: objekt " . $obj->objekt_id . " " . ($obj->all["on_auto_avanev"] ? "ON" : "EI OLE") . " auto avanev ");
                 # juhul, kui malli on_auto_avanev = 1,
                 # siis hakka pihta
                 if ($obj->all["on_auto_avanev"]) {
                     # kontrollime objektide olemasolu
                     $alamlist = new Alamlist(array("parent" => $obj->objekt_id, "on_counter" => 1, "not_klass" => "rubriik,loginkast,kogumik,link", "order" => "sorteering DESC"));
                     $this->debug->msg($alamlist->debug->get_msgs());
                     # alamlist on tyhi
                     if ($alamlist->rows == 0) {
                         $this->debug->msg("JUMP: Otsime esimest alamrubriiki, kuhu v�iks h�pata");
                         $alamlist = new Alamlist(array("parent" => $obj->objekt_id, "start" => 0, "klass" => "rubriik", "not_tyyp_nimi" => "Lingikast"));
                         $this->debug->msg($alamlist->debug->get_msgs());
                         # kui leiti alamrubriik vaata talle otsa ja p��a teda lisada
                         if ($alamlist->rows > 0) {
                             $obj = $alamlist->next();
                             $this->debug->msg($alamlist->debug->get_msgs());
                             # kui ei �nnestunud objekti korralikult k�tte saada (polnud �iguseid)
                             # siis nendi fakti ja �ra h�ppa alla
                             if (!$obj->objekt_id) {
                                 $this->debug->msg("JUMP: Objekti ei tehtud, ei h�ppa alla");
                             } else {
                                 # JUMP REALLY DOWN here:
                                 $this->debug->msg("JUMP: H�ppasime alla ja n��d on aktiivne id = " . $obj->objekt_id);
                                 $id = $obj->objekt_id;
                             }
                             # kas objekt on vaatamiseks tibens
                         } else {
                             $this->debug->msg("JUMP: Ei h�ppa alla, sest polnud rubriiki, kuhu h�pata");
                         }
                     } else {
                         $this->debug->msg("JUMP: Ei h�ppa alla, sest leiti alamobjekte!");
                     }
                 }
             } while ($last_id !== $id);
         }
         # to jump or not to jump
         $this->aktiivne_id = $id;
         $this->debug->msg("JUMP: ================END================");
         # / allah�ppamine
         #############################
         #############################
         # loop over parents
         $first = 1;
         $i = 0;
         while ($id) {
             # hakkame antud objektist �lesse minna
             #######################
             # if current object, do extra checks:
             # 1) decide which parent to use from now on
             # 2) check if object's language matches with site language
             if ($first || $i == 1) {
                 # if first or second (if we have sub-article as current object, Bug #1955)
                 $obj_parent = "";
                 # 1. ja 2. objekti p�ritakse 2 korda (pole ilus lahendus, hetkel h�davajadus):
                 # 1. kord selleks, et teada saada tema klass
                 $obj = new Objekt(array("objekt_id" => $id, "no_cache" => 1));
                 #################
                 # 1) if current object is article, then start searching parents (we have to find correct parent)
                 if ($obj->all["klass"] == "artikkel") {
                     $this->debug->msg("Current object" . ($i == 1 ? "'s parent" : "") . " is article. Start doing extra check.");
                     # find all parent id-s of this object
                     #####################
                     # 1a. if found more than 1 parent => go on and find right parent
                     if ($obj->all['parents_count'] > 1) {
                         $all_parents = $obj->get_obj_all_parents($obj->objekt_id);
                         # v6ttame maha prygikasti rubriik parenti listist:
                         if ($this->site->alias("trash")) {
                             if (in_array($this->site->alias("trash"), $all_parents)) {
                                 $all_parents = array_diff($all_parents, array($this->site->alias("trash")));
                             }
                         }
                         $this->debug->msg("Object " . $obj->objekt_id . " has " . sizeof($all_parents) . " parents: " . join(",", $all_parents));
                         # get cookie with previous page current section value
                         #$cookie_parent = $this->site->sess_get("current_section");
                         $cookie_parent = $_COOKIE["current_section"];
                         ###################
                         # parent_id in URL (Bug #538)
                         # new feature: parameter "parent_id" in URL, it overrides "current_section" cookie settings
                         if ($this->site->fdat['parent_id']) {
                             $obj_parent = $this->site->fdat['parent_id'];
                             $this->debug->msg("Parent found in URL. Parent set to: " . $obj_parent);
                         } elseif (is_array($_SESSION['alias'])) {
                             #Alias being used and a direct path to the object is being shown.
                             foreach ($_SESSION['alias'] as $cuuki) {
                                 if ($cuuki['objekt_id'] == $obj->objekt_id) {
                                     $obj_parent = $cuuki['parent_id'];
                                 }
                             }
                         }
                         ###################
                         # if cookie has value, go on
                         if ($cookie_parent && $obj_parent == "") {
                             $this->debug->msg("Found current_section cookie: " . $cookie_parent);
                             # if 1 object parent is same as cookie, take this for parent
                             if (in_array($cookie_parent, $all_parents)) {
                                 $obj_parent = $cookie_parent;
                                 $this->debug->msg("Parent set to:" . $obj_parent);
                             } else {
                                 $this->debug->msg("Cookie doesn't match. Searching match from parents...");
                                 foreach ($all_parents as $par) {
                                     # find all parents for parent
                                     $all_parents = $obj->get_obj_all_parents($par);
                                     # if 1 object parent is same as cookie, take this for parent
                                     if (in_array($cookie_parent, $all_parents)) {
                                         $obj_parent = $par;
                                         $this->debug->msg("Parent set to:" . $obj_parent);
                                         break;
                                     }
                                 }
                                 # foreach
                                 if (!$obj_parent) {
                                     $this->debug->msg("No match found in parents. Parent not set.");
                                 }
                             }
                             # if not match
                         } else {
                             $this->debug->msg("I have no idea, which parent to prefer => choosing just the first one");
                         }
                         # / just pick first parent - we have no info which one to prefer
                         ###################
                     }
                     # / if found more than 1 parent, go on
                     #####################
                 }
                 # / if current object is article, then start searching parents
                 #################
                 # 2) check if object's language matches with site language
                 # bug #2398 : skip language check and automatic langchange for folders, files.
                 # bug #2661 : Sisuobjekti detailvaate lingile lisatud ?lang=en parameeter peab alati m�juma (site classis v�etakse fdat->keel m�lemast parameetrist juba)
                 if ($obj->objekt_id && !in_array($obj->all['tyyp_id'], array(21, 22)) && !isset($this->site->fdat['keel'])) {
                     $this->debug->msg("Language check: current object (ID=" . $obj->objekt_id . ") language is: " . $obj->all[keel] . "; site language is: " . $this->site->keel);
                     # if they differ, change site language
                     if ($obj->all[keel] != $this->site->keel) {
                         $this->site->change_keel($obj->all[keel]);
                         $this->debug->msg("Site language set to: " . $obj->all[keel]);
                     }
                 }
                 $no_cache = 1;
             } else {
                 $obj_parent = "";
                 $no_cache = 0;
             }
             # / if current object, decide which parent to use from now on
             #######################
             ###################
             # create object
             $obj = new Objekt(array("objekt_id" => $id, "parent_id" => $obj_parent, "no_cache" => $no_cache));
             $this->debug->msg($obj->debug->get_msgs());
             # if creating object fails (because of wrong parent), do it without parent
             if (!$obj->objekt_id) {
                 $obj = new Objekt(array("objekt_id" => $id, "no_cache" => 1));
                 $this->debug->msg($obj->debug->get_msgs());
             }
             ############# if creating object still fails then QUIT because PARENT IS FORBIDDEN
             if (!$obj->objekt_id) {
                 $this->debug->msg("PARENTS: Kuna �ks parentitest on keelatud siis l�peta kogu t�� ja reseti parents");
                 $this->list = array();
                 $this->objekts = array();
                 $this->set_size();
                 $this->index = -1;
                 return;
             } elseif (!$idid["id" . $id]) {
                 # viimases rubriigis vaatame on_peida_vmenyy v��rtus
                 if ($obj->all["klass"] == "rubriik" && !isset($on_peida_vmenyy)) {
                     $obj->load_sisu();
                     $on_peida_vmenyy = $obj->all["on_peida_vmenyy"];
                     $this->debug->msg("Aktiivse rubriigi on_peida_vmenyy is: " . $obj->all["on_peida_vmenyy"]);
                 }
                 # lisame objekt
                 $this->add($obj);
                 # meta
                 if ($this->meta["keywords"] == "" && $obj->all["meta_keywords"] != "") {
                     $this->meta["keywords"] = $obj->all["meta_keywords"];
                     $this->debug->msg("meta keyword = " . $this->meta["keywords"]);
                 }
                 if ($this->meta["description"] == "" && $obj->all["meta_description"] != "") {
                     $this->meta["description"] = $obj->all["meta_description"];
                     $this->debug->msg("meta description = " . $this->meta["description"]);
                 }
                 if ($this->meta["title"] == "" && $obj->all["meta_title"] != "") {
                     $this->meta["title"] = $obj->all["meta_title"];
                     $this->debug->msg("meta title = " . $this->meta["title"]);
                 }
                 $idid["id" . $id] = 1;
                 ############################
                 # set next ID
                 $id = $obj->parent_id;
                 ############################
                 # set next ID exception: 18.05.03 by merle
                 # force another parent for system article:
                 # if object is system article, then dont proceed with its real parent (system section)
                 # but force its parent to be first page in the site
                 if ($first && $obj->parent_id == $this->site->alias("system") && $obj->all["klass"] == "artikkel") {
                     $this->debug->msg("Current object is system article: " . $obj->all[sys_alias]);
                     $home_alamlist = new Alamlist(array("parent" => $this->site->alias("rub_home_id"), "start" => 0, "limit" => 1, "tyyp" => 'rubriik'));
                     if ($home_alamlist->size) {
                         $home_obj = $home_alamlist->get(0);
                         $id = $home_obj->objekt_id;
                         $this->debug->msg("Because its system article, parent is forced to be: {$id}");
                     } else {
                         $this->debug->msg("Setting new parent for system article failed - not found any section");
                     }
                 }
                 # force another parent for system article:
                 ############################
             } else {
                 $idid["id" . $id] = 1;
                 $id = '';
             }
             $i++;
             $first = 0;
         }
         # while obj
         # / loop over parents
         ####################
         $this->on_peida_vmenyy = $on_peida_vmenyy;
         #defined("on_peida_vmenyy") ? constant("on_peida_vmenyy"):0;
     }
     # if parent
 }