/**
     * page show participants function
     * @return HTML presentation of data
     */
    function PageSDatingShowParticipants()
    {
        global $site;
        global $oTemplConfig;
        $sYOC = _t('_y/o');
        $sRetHtml = '';
        $sEventParticipantsC = _t('_Event participants');
        $sListOfParticipantsC = _t('_List') . ' ' . _t('_of') . ' ' . _t('_Participants');
        // collect information about current member
        if ($logged['member']) {
            $aMember['ID'] = (int) $_COOKIE['memberID'];
            $aMemberData = getProfileInfo($aMember['ID']);
        } else {
            $aMember['ID'] = 0;
        }
        $aMembership = getMemberMembershipInfo($aMember['ID']);
        /*$iEventID = (int)$_REQUEST['event_id'];*/
        $iEventID = $this->bUseFriendlyLinks ? (int) db_value("SELECT `ID` FROM `SDatingEvents` WHERE `EntryUri`='" . $this->process_html_db_input($_REQUEST['eventUri']) . "' LIMIT 1") : (int) $_REQUEST['event_id'];
        $sQuery = "\r\n\t\t\tSELECT `ID`, `Title`,\r\n\t\t\t\t(NOW() > `EventEnd` AND NOW() < DATE_ADD(`EventEnd`, INTERVAL `ChoosePeriod` DAY)) AS `ChooseActive`\r\n\t\t\tFROM `SDatingEvents`\r\n\t\t\tWHERE\r\n\t\t\t\t`ID` = {$iEventID} AND `Status` = 'Active' AND `AllowViewParticipants` = 1";
        $aEventData = db_arr($sQuery);
        if (!$aEventData['ID']) {
            return DesignBoxContent('', '<center>' . _t('_Event is unavailable') . '</center>', $oTemplConfig->PageSDatingShowParticipants_db_num);
        }
        $sRetHtml .= '<div class="text">' . process_line_output($aEventData['Title']) . '</div>';
        // list of participants
        $aSelfPart = db_arr("SELECT `ID` FROM `SDatingParticipants`\r\n\t\t\t\t\t\t\t\t\tWHERE `IDEvent` = {$iEventID}\r\n\t\t\t\t\t\t\t\t\tAND `IDMember` = {$aMember['ID']}");
        $iPartPage = isset($_REQUEST['part_page']) ? (int) $_REQUEST['part_page'] : 1;
        $iPartPPerPage = isset($_REQUEST['part_p_per_page']) ? (int) $_REQUEST['part_p_per_page'] : 30;
        $iLimitFirst = (int) ($iPartPage - 1) * $iPartPPerPage;
        $vPartProfilesRes = db_res("SELECT `Profiles`.*, `SDatingParticipants`.`ParticipantUID` AS `UID`\r\n\t\t\t\t\t\t\t\t\t\tFROM `SDatingParticipants`\r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN `Profiles` ON `SDatingParticipants`.`IDMember` = `Profiles`.`ID`\r\n\t\t\t\t\t\t\t\t\t\tWHERE `SDatingParticipants`.`IDEvent` = {$iEventID}\r\n\t\t\t\t\t\t\t\t\t\tORDER BY `Profiles`.`NickName`\r\n\t\t\t\t\t\t\t\t\t\tLIMIT {$iLimitFirst}, {$iPartPPerPage}");
        $aTotal = db_arr("SELECT COUNT(*) FROM `SDatingParticipants`\r\n\t\t\t\t\t\t\t\t\tWHERE `SDatingParticipants`.`IDEvent` = {$iEventID}");
        $iPartProfilesTotal = (int) $aTotal[0];
        $iPagesNum = ceil($iPartProfilesTotal / $iPartPPerPage);
        $sGenUrlP = $this->genUrl($iEventID, '', 'part', true);
        $sPartGetUrl = $sGenUrlP . (isset($_REQUEST['part_p_per_page']) ? '&amp;part_p_per_page=' . (int) $_REQUEST['part_p_per_page'] : '');
        if ($iPartProfilesTotal == 0) {
            $sRetHtml .= _t('_There are no participants for this event');
        } else {
            if ($iPagesNum > 1) {
                $sRetHtml .= '<div class="text">' . _t('_Pages') . ':&nbsp;';
                for ($i = 1; $i <= $iPagesNum; $i++) {
                    if ($i == $iPartPage) {
                        $sRetHtml .= "[{$i}]&nbsp;";
                    } else {
                        $sRetHtml .= "<a href=\"{$sPartGetUrl}&amp;part_page={$i}\">{$i}</a>&nbsp;";
                    }
                }
                $sRetHtml .= '</div><br />';
            }
            $sProfilesTrs = '';
            while ($part_profiles_arr = mysql_fetch_assoc($vPartProfilesRes)) {
                $iUserIsOnline = get_user_online_status($part_profiles_arr[ID]);
                $sCont = get_member_thumbnail($part_profiles_arr['ID'], 'none') . '<br /><center>' . getProfileOnlineStatus($iUserIsOnline) . '</center>';
                //$sProfilesTrs .= DesignBoxContentBorder( process_line_output( strmaxtextlen( $part_profiles_arr['NickName'], 11 ) ) . ': ' . age( $part_profiles_arr['DateOfBirth'] ) . ' ' . _t('_y/o'), $sCont );
                $sThumb = get_member_thumbnail($part_profiles_arr['ID'], 'none');
                $sProfLink = getProfileLink($part_profiles_arr['ID']);
                $sAge = age($part_profiles_arr['DateOfBirth']) . $sYOC;
                $sProfilesTrs .= <<<EOF
<div style="float:left;text-align:center;margin-right:10px;position:relative;">
\t{$sThumb}
\t<div class="browse_nick" style="width:{$this->iThumbSize}px;">
\t\t<a href="{$sProfLink}">{$part_profiles_arr['NickName']}</a>: {$sAge}
\t</div>
</div>
EOF;
            }
            $sNicknameC = _t('_Nickname');
            $sDateOfBirthC = _t('_DateOfBirth');
            $sSexC = _t('_Sex');
            $sEventUIDC = _t('_Event UID');
            $sChooseParts = '';
            // show 'choose participants' link only during choose period and if member is participant of this event
            // if ( $this->bAdminMode==FALSE || ($aEventData['ChooseActive'] && $aSelfPart['ID'] )) {
            // $sChooseParts = '<div class="text" align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=select_match&amp;event_id='.$iEventID.'">'._t('_Choose participants you liked').'</a></div><br />';
            // }
            $sPagesHref = '';
            if ($iPagesNum > 1) {
                $sPagesHref .= '<div class="text">' . _t('_Pages') . ':&nbsp;';
                for ($i = 1; $i <= $iPagesNum; $i++) {
                    if ($i == $iPartPage) {
                        $sPagesHref .= "[{$i}]&nbsp;";
                    } else {
                        $sPagesHref .= "<a href=\"{$sPartGetUrl}&amp;part_page={$i}\">{$i}</a>&nbsp;";
                    }
                }
                $sPagesHref .= '</div><br />';
            }
            $sRetHtml .= $sProfilesTrs . $sPagesHref;
        }
        $sRetHtml .= '<div class="clear_both"></div>';
        return DesignBoxContent($sListOfParticipantsC, $sRetHtml, $oTemplConfig->PageSDatingShowParticipants_db_num);
    }
function get_member_thumbnail($ID, $float, $bDrawMargin = FALSE)
{
    global $site;
    require_once BX_DIRECTORY_PATH_ROOT . 'profilePhotos.php';
    $user_is_online = get_user_online_status($ID);
    //$sSexSql = "SELECT `Sex` FROM `Profiles` WHERE `ID` = '{$ID}'";
    $aSexSql = getProfileInfo($ID);
    //db_arr( $sSexSql );
    $oPhoto = new ProfilePhotos($ID);
    $oPhoto->getActiveMediaArray();
    $aFile = $oPhoto->getPrimaryPhotoArray();
    if (extFileExists($oPhoto->sMediaDir . 'thumb_' . $aFile['med_file'])) {
        $sFileName = $oPhoto->sMediaUrl . 'thumb_' . $aFile['med_file'];
    } else {
        if ($aSexSql['Sex'] == 'female' or $aSexSql['Sex'] == 'Female') {
            $sSexPic = 'woman_medium.gif';
        } elseif ($aSexSql['Sex'] == 'male' or $aSexSql['Sex'] == 'Male') {
            $sSexPic = 'man_medium.gif';
        } else {
            $sSexPic = 'visitor_medium.gif';
        }
        $sFileName = getTemplateIcon($sSexPic);
    }
    $sMarginsAddon = $bDrawMargin ? " margin-right:10px;margin-bottom:10px; " : '';
    $style = 'width:' . $oPhoto->aMediaConfig['size']['thumbWidth'] . 'px;' . 'height:' . $oPhoto->aMediaConfig['size']['thumbHeight'] . 'px;' . 'background-image:url(' . $sFileName . ');';
    $ret = '';
    $ret .= '<div class="thumbnail_block" style="float:' . $float . '; ">';
    $ret .= getProfileOnlineStatus($user_is_online, $bDrawMargin);
    $ret .= "<a href=\"" . getProfileLink($ID) . "\">";
    $ret .= '<img src="' . getTemplateIcon('spacer.gif') . '" style="' . $sMarginsAddon . $style . '" alt="' . process_line_output($aFileName['med_title']) . '" />';
    $ret .= '</a>';
    $ret .= '</div>';
    return $ret;
}
function PageCompPageMainCode()
{
    global $sex_sel;
    global $country_sel;
    global $age_start_sel;
    global $age_end_sel;
    global $onl_only;
    global $pic_only;
    global $site;
    global $p_num;
    global $page;
    global $pages_num;
    global $p_per_page;
    global $page_first_p;
    global $pages_num;
    global $search_start_age;
    global $search_end_age;
    global $max_thumb_width;
    global $max_thumb_height;
    $query = "SELECT * FROM ProfilesDesc WHERE `name` IN ( 'Sex', 'Country')";
    $res = db_res($query);
    while ($arr = mysql_fetch_array($res)) {
        switch ($arr['name']) {
            case 'Sex':
                $sex_sel = $sex_sel ? $sex_sel : 'male,female';
                $sex_options = makeCheckbox('sex', $arr['extra'], $sex_sel);
                break;
            case 'Country':
                $country_sel = $country_sel ? $country_sel : 'all';
                //getParam('default_country');
                $country_options = makeList('country', '', $arr['extra'], $country_sel, 'onchange="javascript: flagImage = document.getElementById(\'flagImageId\'); if (this.value == \'all\') {flagImage.src = \'' . $site['images'] . 'spacer.gif\';} else {flagImage.src = \'' . $site['flags'] . '\' + this.value.toLowerCase() + \'.gif\';}"');
                break;
            default:
                break;
        }
    }
    $age_start_sel = $age_start_sel ? $age_start_sel : $search_start_age;
    $age_end_sel = $age_end_sel ? $age_end_sel : $search_end_age;
    $age_option_start = makeList('age_start', "{$search_start_age}-{$search_end_age}", '', $age_start_sel);
    $age_option_end = makeList('age_end', "{$search_start_age}-{$search_end_age}", '', $age_end_sel);
    $photo_only_check = '<input type="checkbox" name="photo_only" id="photo_only_id" ' . ($pic_only ? 'checked="checked"' : '') . ' /><label for="photo_only_id"><b>' . _t('_With photos only') . '</b></label>';
    $online_only_check = '<input type="checkbox" name="online_only" id="online_only_id" ' . ($onl_only ? 'checked="checked"' : '') . ' /><label for="online_only_id"><b>' . _t('_online only') . '</b></label>';
    $country_def_flag = $country_sel == 'all' ? $site['images'] . 'spacer.gif' : $site['flags'] . strtolower($country_sel) . '.gif';
    $ret = '
	    <form id="browse_form" action="' . $_SERVER['PHP_SELF'] . '" method="get">
			<div class="browse_form_wrapper">
			
				<div class="browse_form_row">
					<div class="clear_both"></div>
						<div class="label">' . _t('_Sex') . ':</div>
						<div class="value">' . $sex_options . '</div>
					<div class="clear_both"></div>
				</div>
				
				<div class="browse_form_row">
					<div class="clear_both"></div>
						<div class="label">' . _t('_DateOfBirth') . ':</div>
						<div class="value">' . _t("from") . '&nbsp;' . $age_option_start . '&nbsp;' . _t("to") . '&nbsp;' . $age_option_end . '</div>
					<div class="clear_both"></div>
				</div>

				<div class="browse_form_row">
					<div class="clear_both"></div>
		    			<div class="label">' . _t('_Country') . ':</div>' . '<div class="value">' . $country_options . '&nbsp;<img id="flagImageId" src="' . $country_def_flag . '" alt="flag" />
						</div>
					<div class="clear_both"></div>
				</div>

				<div class="only">
				    ' . $photo_only_check . '
				    ' . $online_only_check . '
				</div>

				<div class="submit">
		    		<input id="search" name="search" type="submit" value="' . _t('_Show') . '" />
				</div>

			</div>
		</form>
	    ';
    //====================================================================================================
    //----------------------- search results -------------------------------------------------
    //====================================================================================================
    $page = (int) $_GET[page];
    $p_per_page = (int) $_GET[p_per_page];
    $aVar = array(30, 60, 90);
    if (!$page) {
        $page = 1;
    }
    if (!$p_per_page) {
        $p_per_page = 30;
    }
    $real_first_p = (int) ($page - 1) * $p_per_page;
    $page_first_p = $real_first_p + 1;
    $temp_arr = explode(',', $sex_sel);
    foreach ($temp_arr as $value) {
        if ($value) {
            $sex_add .= " `Sex` = '{$value}' OR ";
        }
    }
    if ($country_sel && 'all' != $country_sel) {
        $country_add = " `Country` = '{$country_sel}' AND ";
    }
    if ($age_start_sel) {
        $age_add .= " ( (YEAR(NOW()) - {$age_start_sel}) >= YEAR(`DateofBirth`) ) AND ";
    }
    if ($age_end_sel) {
        $age_add .= " ( (YEAR(NOW()) - {$age_end_sel}) <= YEAR(`DateofBirth`) ) AND ";
    }
    if ($pic_only) {
        $pic_add = " AND `Picture` = '1' ";
    }
    if ($onl_only) {
        $onl_add = " AND (LastNavTime > SUBDATE(NOW(), INTERVAL " . getParam("member_online_time") . " MINUTE)) ";
    }
    $sex_add = $sex_add ? '(' . $sex_add . ' 1=0 ) AND ' : '';
    $age_add = $age_add ? '(' . $age_add . ' 1=1 )' : '';
    $sql_add = $sex_add . $country_add . $age_add . $pic_add . $onl_add;
    $p_num = db_arr("SELECT COUNT(*) FROM Profiles WHERE {$sql_add} AND `Status` = 'Active'");
    $p_num = $p_num[0];
    $pages_num = ceil($p_num / $p_per_page);
    $profiles_list_query = "SELECT `ID`, `NickName`, `Sex`, `DateOfBirth` FROM Profiles WHERE {$sql_add} AND `status`='Active' ORDER BY `Picture` DESC LIMIT {$real_first_p}, {$p_per_page};";
    $function = '
		    $ret = \'?\';
		    foreach ( $_GET as $key => $value )
			if ( $value )
			    $ret .= $key . \'=\' . $value . \'&amp;\';

		    return $ret;
		';
    $ret .= '<div id="container_result" style="border: 0px solid #000000">';
    $ret .= '<div style="margin-bottom:10px;"><center>' . ResNavigationRet('ProfilesUpper', 0, $function, $aVar) . '</center></div>';
    if ($p_num > 0) {
        $res = db_res($profiles_list_query);
        $iI = 1;
        while ($arr = mysql_fetch_array($res)) {
            $user_is_online = get_user_online_status($arr['ID']);
            if ($iI == 6) {
                $cont = '<div class="browse_thumb_thin">';
            } else {
                $cont = '<div class="browse_thumb">';
            }
            $cont .= getProfileOnlineStatus($user_is_online) . get_member_thumbnail($arr['ID'], 'none') . '<div class="browse_nick"><a href="' . getProfileLink($arr['ID']) . '">' . $arr['NickName'] . '</a></div></div>';
            $ret .= $cont;
            $iI++;
            if ($iI > 6) {
                $iI = 1;
            }
        }
    } else {
        $ret .= '<div class="no_result">';
        $ret .= '<div>' . _t('_No results found') . '</div>';
        $ret .= '</div>';
    }
    $ret .= '<div style="clear:both;margin-top:10px;"><center>' . ResNavigationRet('ProfilesLower', 0, $function, $aVar) . '</center></div>';
    $ret .= '</div>';
    return $ret;
}