pid . "\"\n");
		fwrite($fp, $indent . "      user=\"" . $this->user . "\"\n");
		fwrite($fp, $indent . "      title=\"" . convert_xml($this->title) . "\"\n");
		fwrite($fp, $indent . "      date=\"" . $this->date . "\">\n");
		fwrite($fp, $indent . "  " . convert_xml($this->message) . "\n");
		foreach($this->replies as $reply) {
			$reply->write($fp, $indent . "  ");
		}
		
		fwrite($fp, $indent . "\n");
	}
	public function add($post) {
		$key = $post->pid;
		$this->replies[$key] = $post;
	}
	public function getPost($pid)
	{
		$result = false;
		foreach($this->replies as $post) {
			if($post->pid == $pid) return $post;
			$result = $post->getPost($pid);
			if($result) return $result;
		}
		return $result;
	}
	public function show($indent = "    ", $recurse = true)
	{
		global $users, $fid, $tid, $current_user, $client_is_mobile_device;
		$user = $users->getUser($this->user);
		echo $indent . "
\n";
		if($client_is_mobile_device) {
			$avatar = "mobileavatar.gif";
		} else {
			if($user->avatar) $avatar = $user->avatar;
			else $avatar = "default.gif";
		}
		echo $indent . "  

\n";
		if(!$client_is_mobile_device) {
			echo $indent . "  
ID: " . $this->pid . "
\n";
			echo $indent . "  
Title: " . convert_xml($this->title) . "
\n";
		}
		echo $indent . "  
";
		if(!$client_is_mobile_device) echo "UserID: ";
		echo $user->name . "
\n";
		echo $indent . "  
";
		if(!$client_is_mobile_device) echo "Date: ";
		echo date("j. M Y - G:i", $this->date) . "
\n";
		echo $indent . "  
\n";
		echo parse($this->message, $indent . "    ") . "\n";
		if(trim($user->signature) != "") {
			echo $indent . "    
\n";
			echo parse("--------------------------\n" . $user->signature, $indent . "      ") . "\n";
			echo $indent . "    
\n";
		}
		echo $indent . "  
\n";
		echo $indent . "  
\n";
		echo $indent . "  
\n";
		if($recurse) {
			foreach($this->replies as $reply) {
				$reply->show($indent . "    ");
			}
		}
		echo $indent . "  
\n";
		echo $indent . "
\n";
			}
			$post->show("    ", false);
		}
		if($firstunread == true) {
			echo "    
\n";
		}
		
		$this->thread->lastseen[$current_user->uid] = time();
		$this->write();
		echo "