/**
 * page code function
 */
function PageCompPageMainCode()
{
    global $site;
    $messageID = (int) $_GET['message'];
    $memberID = (int) $_COOKIE['memberID'];
    $sender_sql = "SELECT `Recipient` FROM `Messages` WHERE `Sender` = '{$memberID}' AND `ID` = '{$messageID}'";
    $sender_arr = db_arr($sender_sql);
    $senderID = $sender_arr['Recipient'];
    $message_sql = "SELECT m.`Text`, m.`Subject`, DATE_FORMAT( m.`Date`, '%Y-%m-%d' ) AS `Date`, p.Status FROM `Messages` AS m LEFT JOIN Profiles AS p ON m.Recipient = p.ID WHERE m.`ID` = '{$messageID}'";
    // AND`Sender` = '$senderID'";
    $message_arr = db_arr($message_sql);
    $ret = '';
    $ret .= '<div class="profile_ditails_block">';
    $ret .= ProfileDetails($senderID);
    $ret .= '<div class="clear_both"></div>';
    $ret .= '</div>';
    $ret .= '<div class="m_block">';
    $ret .= '<div class="m_subject_date">';
    $ret .= '<div class="name">';
    $ret .= _t('_Date') . ':';
    $ret .= '</div>';
    $ret .= '<div class="value">';
    $ret .= $message_arr['Date'];
    $ret .= '</div>';
    $ret .= '<div class="name">';
    $ret .= _t('_Subject') . ':';
    $ret .= '</div>';
    $ret .= '<div class="value">';
    $ret .= process_smiles(process_line_output($message_arr['Subject']));
    $ret .= '</div>';
    $ret .= '</div>';
    $ret .= '<div class="m_text">';
    $ret .= process_html_output($message_arr['Text'], 80);
    $ret .= '</div>';
    $ret .= '<div class="clear_both"></div>';
    $ret .= '</div>';
    //$ret .= '<div class="reply_block">';
    if ($message_arr['Status'] == 'Active') {
        $ret .= '<div class="reply">';
        $ret .= '<a href="' . $site['url'] . 'compose.php?ID=' . $senderID . '">Write new Message</a>';
        $ret .= '</div>';
        $ret .= '<div class="clear_both"></div>';
    } else {
        $ret .= '';
    }
    //####################################################
    $ret .= '<div style="position:relative; height:20px;"></div>';
    $ret .= PageCorespondence($memberID, $senderID);
    $ret .= '<div class="clear_both"></div>';
    return $ret;
}
function print_row_area($first_row, $arr, $val = "", $tr_class = "", $rd = 0, $columns = 3, $width_first = "", $read_only = 0)
{
    $fname = get_input_name($arr);
    $disabled = $read_only ? "readonly=\"readonly\"" : "";
    $vals = split("x", $arr['extra']);
    // at second page of joinform hidden input with name $fname already exist !!!! thats why i need name different from $fname.
    //    $fname .= 'original';
    if (!$rd) {
        $ret = '<table cellspacing="0" cellpadding="0">';
        $ret .= "<tr><td><textarea class=\"textarea_edit\" id=\"{$fname}\" name=\"{$fname}\" cols=\"{$vals['0']}\" rows=\"{$vals['1']}\"\n            onKeyDown=\"javascript: document.getElementById('{$fname}counter').value = document.getElementById('{$fname}').value.length;\"\n            onKeyUp=\"javascript: document.getElementById('{$fname}counter').value = document.getElementById('{$fname}').value.length;\" {$disabled}>" . htmlspecialchars($val) . "</textarea>\n";
        $ret .= "</td></tr>";
        $ret .= '<tr>';
        $ret .= '<td align="right">';
        $ret .= '<table cellpadding="0" cellspacing="2" border="0" align="right">';
        $ret .= '<tr>';
        $ret .= '<td align="right" valign="middle">';
        $ret .= _t("_Character counter");
        $ret .= '</td>';
        $ret .= '<td width="30">';
        $ret .= "<input type=\"text\" readonly=\"readonly\" id=\"{$fname}counter\" name=\"{$fname}counter\" size=\"3\" value=" . strlen($val) . " class=\"input_textarea_counter\" />";
        $ret .= '</td>';
        $ret .= '</tr>';
        $ret .= '</table>';
        $ret .= '</td>';
        $ret .= '</tr>';
        $ret .= "<tr><td style=\"text-align:center;\">" . put_smiles($fname, 11);
        $ret .= "</td></tr></table>";
    } else {
        $ret = process_smiles("{$val}\n");
    }
    return print_row_content($first_row, $arr, $ret, $tr_class, $columns, $width_first);
}
/**
 * page code function
 */
function PageCompPageMainCode()
{
    global $site;
    global $short_date_format;
    $messageID = (int) $_GET['message'];
    $memberID = (int) $_COOKIE['memberID'];
    $sender_sql = "SELECT `Sender` FROM `Messages` WHERE `Recipient` = '{$memberID}' AND `ID` = '{$messageID}'";
    $sender_arr = db_arr($sender_sql);
    $senderID = (int) $sender_arr['Sender'];
    $message_sql = "SELECT m.`Text`, m.`Subject`, DATE_FORMAT( m.`Date`, '{$short_date_format}' ) AS `Date`, p.Status FROM `Messages` AS m LEFT JOIN Profiles AS p ON m.Sender = p.ID  WHERE m.`ID` = '{$messageID}' AND `Recipient` = '{$memberID}'";
    // Did you find me, Smoge? I see you...
    $message_arr = db_arr($message_sql);
    $ret = '';
    $ret .= '<div class="profile_ditails_block">';
    $ret .= ProfileDetails($senderID);
    $ret .= '<div class="clear_both"></div>';
    $ret .= '</div>';
    $ret .= '<div class="m_block">';
    $ret .= '<div class="m_subject_date">';
    $ret .= '<div class="name">';
    $ret .= _t('_Date') . ':';
    $ret .= '</div>';
    $ret .= '<div class="value">';
    $ret .= $message_arr['Date'];
    $ret .= '</div>';
    $ret .= '<div class="name">';
    $ret .= _t('_Subject') . ':';
    $ret .= '</div>';
    $ret .= '<div class="value">';
    $ret .= process_smiles(process_line_output($message_arr['Subject']));
    $ret .= '</div>';
    $ret .= '</div>';
    $ret .= '<div class="m_text">';
    $ret .= process_html_output($message_arr['Text'], 150);
    $ret .= '</div>';
    $ret .= '<div class="clear_both"></div>';
    $ret .= '</div>';
    if ($message_arr['Status'] == 'Active') {
        $ret .= '<div class="reply">';
        $ret .= '<a href="' . $site['url'] . 'compose.php?ID=' . $senderID . '&messageID=' . $messageID . '&amp;subject=' . process_smiles(process_line_output($message_arr['Subject'])) . '">Reply</a>';
        $ret .= '</div>';
        $ret .= '<div class="reply">';
        $ret .= "<a onClick=\"javascript:window.open( 'list_pop.php?action=spam&ID=" . $senderID . "', '', 'width=500,height=200,menubar=no,status=no,resizeable=no,scrollbars=no,toolbar=no,location=no' );\" href=\"javascript:void(0)\">" . _t('_Spam report') . "</a>";
        $ret .= '</div>';
        $ret .= '<div class="reply">';
        $ret .= '<a href="messages_inbox.php?action=delete&message=' . $messageID . '">' . _t('_Delete') . '</a>';
        $ret .= '</div>';
        $ret .= '<div class="clear_both"></div>';
    } else {
        $ret .= '';
    }
    //$ret .= '</div>';
    //####################################################
    $ret .= '<div style="position:relative; height:20px;"></div>';
    $ret .= PageCorespondence($memberID, $senderID);
    $ret .= '<div class="clear_both"></div>';
    return $ret;
}
/**
 * page code function
 */
function ThisPageMainCode()
{
    global $site;
    global $oTemplConfig;
    global $logged;
    global $tmpl;
    global $date_format;
    $content = "\r\n    \t<form name=\"shoutbox\" method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">\r\n    \t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n    \t\t\t<tr><td>\r\n    \t\t\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
    $class = 'shoutbg1';
    // Print input box
    $content .= "\r\n    \t\t\t\t\t<tr><td align=\"center\" class=\"{$class}\">";
    if ($_COOKIE['memberID'] && $logged['member']) {
        if ($tmpl == 'g4') {
            $content .= "\r\n\t\t\t\t\t\t\t<table border=\"0\" cellpadding=\"7\" cellspacing=\"0\" width=\"100%\" bgcolor=\"#FFFFFF\">\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<td align=\"left\"><input maxlength=\"" . $oTemplConfig->maxtextlength . "\" type=\"text\" name=\"shout\" class=\"shoutinp\"></td>\r\n\t\t\t\t\t\t\t\t\t<td><strong>" . _t('_shout_box_title') . "</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t</table>";
        } else {
            $content .= "\r\n\t\t\t\t\t\t\t<input maxlength=\"" . $oTemplConfig->maxtextlength . "\" type=\"text\" name=\"shout\" />";
        }
    } else {
        $content .= _t('_to_post');
    }
    $content .= "\r\n\t\t\t\t\t\t</td></tr>";
    // End of print input box
    $query = "SELECT `shoutbox`.`id`, `shoutbox`.`text`, DATE_FORMAT(`shoutbox`.`date`,  '{$date_format}' ) AS 'date', `shoutbox`.`class`, `Profiles`.`ID` as `prID`, `Profiles`.`NickName` FROM `shoutbox` LEFT JOIN `Profiles` ON `Profiles`.`ID` = `shoutbox`.`id` ORDER BY `shoutbox`.`date` DESC";
    $shout_res = db_res($query);
    while ($shout_arr = mysql_fetch_array($shout_res)) {
        $shout_text = process_smiles(process_line_output($shout_arr['text'], $oTemplConfig->maxwordlength));
        $content .= "\r\n\t\t\t\t\t\t<tr><td title=\"{$shout_arr['date']}\" class=\"{$shout_arr['class']}\">\r\n\t\t\t\t\t\t\t<a target=\"_blank\" href=\"" . getProfileLink($shout_arr['prID']) . "\" class=\"membermenu\">{$shout_arr['NickName']}</a>: {$shout_text}\r\n\t\t\t\t\t\t</td></tr>";
    }
    $content .= "\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td></tr>\r\n\t\t\t</table>\r\n\t\t</form>\n";
    return $content;
}
    function getComments($iReplyTo = 0)
    {
        global $site;
        $iPerPage = 5;
        //if( $iReplyTo )
        $sqlLimit = '';
        // navigation will be here very very soon
        /*else
        		{
        			$this -> comm_page = (int)$_GET['comm_page'];
        			
        			if( $this -> comm_page < 1 )
        				$this -> comm_page = 1;
        			
        			$sqlLimitFrom = ( $this -> comm_page - 1 ) * $iPerPage;
        			
        			$sqlLimit = "LIMIT $sqlLimitFrom, $iPerPage";
        		}*/
        if ($iReplyTo == 0) {
            $sOrder = "ASC";
        } else {
            $sOrder = "DESC";
        }
        $sQuery = "\r\n\t\t\tSELECT\r\n\t\t\t\t`ProfilesComments`.`ID`,\r\n\t\t\t\t`ProfilesComments`.`Date`,\r\n\t\t\t\tUNIX_TIMESTAMP(`Date`) AS `UnixDate`,\r\n\t\t\t\t`ProfilesComments`.`IP`,\r\n\t\t\t\t`ProfilesComments`.`Text`,\r\n\t\t\t\t`ProfilesComments`.`New`,\r\n\t\t\t\t`ProfilesComments`.`ReplyTO`,\r\n\t\t\t\t`Profiles`.`ID` AS `senderID`,\r\n\t\t\t\t`Profiles`.`NickName` AS `senderNick`\r\n\t\t\tFROM `ProfilesComments`\r\n\t\t\tLEFT JOIN `Profiles` ON\r\n\t\t\t\t`ProfilesComments`.`Sender` = `Profiles`.`ID`\r\n\t\t\tWHERE\r\n\t\t\t\t`ProfilesComments`.`Recipient` = {$this->_iProfileID} AND\r\n\t\t\t\t`ReplyTO` = {$iReplyTo}\r\n\t\t\tORDER BY `Date` {$sOrder}\r\n\t\t\t{$sqlLimit}\r\n\t\t\t";
        $rComments = db_res($sQuery);
        ob_start();
        while ($aComment = mysql_fetch_assoc($rComments)) {
            ?>
			<div class="comment_row">
				<div class="comment_author">
					<?php 
            echo get_member_icon($aComment['senderID']);
            ?>
				</div>
				<div class="comment_view">
					<a href="<?php 
            echo getProfileLink($aComment['senderID']);
            ?>
">
						<?php 
            echo trim(process_line_output($aComment['senderNick']));
            ?>
					</a>
				<?php 
            echo '(' . $this->defineTimeInterval($aComment['UnixDate']) . ')';
            ?>
			<?php 
            if ($this->owner && $aComment['New']) {
                ?>
					<span class="commentNew"><?php 
                echo _t("_new");
                ?>
</span>
				<?php 
                db_res("UPDATE `ProfilesComments` SET `New` = '0' WHERE `ID` = {$aComment['ID']}");
            }
            ?>
				</div>
				
				<div class="comment_text">
					<?php 
            echo process_smiles($aComment['Text']);
            ?>
				</div>
			
			<?php 
            echo $this->getCommentActions($aComment['ID']);
            ?>
			
			</div>
			<?php 
            echo $this->getAddCommentForm($aComment['ID']);
            if ($answers = $this->getComments($aComment['ID'])) {
                ?>
			<div id="replies_to_<?php 
                echo $aComment['ID'];
                ?>
" class="comment_replies">
				<?php 
                echo $answers;
                ?>
			</div>
				<?php 
            }
        }
        return ob_get_clean();
    }
/**
 * returns HTML code for one search row
 */
function PrintSearhResult($p_arr, $templ_search, $iNumber = 1, $bCouple = false, $aCoupleInfo = '')
{
    global $site;
    global $pa_icon_preload;
    global $aPreValues;
    global $logged;
    global $tmpl;
    global $dir;
    global $max_thumb_width;
    global $max_thumb_height;
    global $anon_mode;
    global $enable_zodiac;
    global $enable_friendlist;
    global $pic_num;
    global $oTemplConfig;
    global $NickName;
    $member['ID'] = (int) $_COOKIE['memberID'];
    $free_mode = getParam("free_mode") == "on" ? 1 : 0;
    $bEnableRay = getParam('enable_ray') == 'on';
    $gl_thumb_width = $max_thumb_width;
    $gl_thumb_height = $max_thumb_height;
    // get user online status
    $user_is_online = get_user_online_status($p_arr[ID]);
    $templ = $templ_search;
    // ------------ template variables --------------
    $thumbnail = get_member_thumbnail($p_arr['ID'], 'none', true);
    // online/offline status
    $launch_ray_im = "";
    //--- Ray IM integration ---//
    if ($user_is_online) {
        $check_res = checkAction($member['ID'], ACTION_ID_USE_RAY_IM);
        if ($bEnableRay && $check_res[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED && $member['ID'] != $p_arr['ID'] && !empty($member['ID'])) {
            $iSndId = (int) $member['ID'];
            $sSndPassword = getPassword($member['ID']);
            $iRspId = (int) $p_arr['ID'];
            $launch_ray_im = "<a href=\"javascript:void(0);\" onClick=\"javascript: openRayWidget( 'im', 'user', '" . $iSndId . "', '" . $sSndPassword . "', '" . $iRspId . "' ); return false;\">" . _t("_IM now", $p_arr['NickName']) . "</a>";
        }
    }
    //--- Ray IM integration ---//
    // Template customizations
    // profile Nick/Age/Sex etc.
    $nick = '<a href="' . getProfileLink($p_arr['ID']) . '">' . $p_arr['NickName'] . '</a>';
    $age_str = $p_arr['DateOfBirth'] != "0000-00-00" ? _t("_y/o", age($p_arr['DateOfBirth'])) . ' ' : "";
    $age_only = $p_arr['DateOfBirth'] != "0000-00-00" ? age($p_arr['DateOfBirth']) : "";
    $y_o_sex = $age_str . _t("_" . $p_arr['Sex']);
    $city = _t("_City") . ": " . process_line_output($p_arr['City']);
    $country = _t("_Country") . ": " . _t($aPreValues['Country'][$p_arr['Country']]['LKey']) . '&nbsp;<img src="' . ($site['flags'] . strtolower($p_arr['Country'])) . '.gif" alt="flag" />';
    $sFlag = $p_arr['Country'] != '' ? '&nbsp;<img src="' . ($site['flags'] . strtolower($p_arr['Country'])) . '.gif" alt="flag" />' : '';
    $city_con = process_line_output($p_arr['City']) . ", " . _t($aPreValues['Country'][$p_arr['Country']]['LKey']) . $sFlag;
    $occupation = process_line_output($p_arr['Occupation']);
    $children = $p_arr['Children'] ? $p_arr['Children'] . " " . _t("_children") : "";
    $id = _t("_ID") . ": " . $p_arr['ID'];
    // description
    $i_am = _t("_I am");
    $i_am_desc = process_smiles(strip_tags(process_text_output($p_arr['DescriptionMe']), '<img>')) . "...";
    $you_are = _t("_You are");
    $you_are_desc = process_smiles(process_text_output($p_arr['DescriptionYou'])) . "... <a href=\"" . getProfileLink($p_arr['ID']) . "\">" . _t("_more") . "</a>";
    /*
    echo '<hr>';
    print_r( $p_arr );
    echo '<hr>';
    */
    $sCity = $p_arr['City'];
    //echo $sCity . '<hr>';
    //--- Ray IM integration start ---//
    $ai_im = '';
    $al_im = '';
    $chechActionRes = checkAction($member['ID'], ACTION_ID_USE_RAY_IM);
    if ($bEnableRay && $chechActionRes[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED && $member['ID'] != $p_arr['ID'] && !empty($member['ID'])) {
        $iSndId = (int) $member['ID'];
        $sSndPassword = getPassword($member['ID']);
        $iRspId = (int) $p_arr['ID'];
        if ($user_is_online) {
            $file_icon = $dir['root'] . "templates/tmpl_" . $tmpl . "/images/icons/action_im_small.gif";
            if (file_exists($file_icon)) {
                $ai_im .= "<img alt=\"" . _t("_IM now") . "\" class=\"links_image\" name=i06{$p_arr['ID']} src=\"{$site['url']}templates/tmpl_{$tmpl}/images/icons/action_im_small.gif\" />";
            }
            $al_im .= '<a href="javascript:void(0);" onClick="javascript: openRayWidget( \'im\', \'user\', \'' . $iSndId . '\', \'' . $sSndPassword . '\', \'' . $iRspId . '\' ); return false;">';
            $al_im = '<span class="links_span">' . $ai_im . $al_im . ucwords(_t("_IM now", $p_arr['NickName'])) . '</a></span>';
        }
    }
    //--- Ray IM integration end ---//
    /* Standard IM commented out
    	else if ( $enable_im )
    	{
    		if ( $user_is_online )
    		{
    			$al_im = "<a href=\"javascript:void(0);\" OnClick=\"javascript: launchAddToIM({$p_arr['ID']}); return false;\"";
    		}
    		else
    		{
    			$al_im = "<a href='javascript: void(0);' OnClick=\"javascript: alert('". _t("_Sorry, user is OFFLINE") ."'); return false;\"";
    		}
    
    		if ( $pa_icon_preload )
    			$al_im .= "onMouseOut =\"javascript: i06$p_arr[ID].src='$site[images]pa_im.gif';\"";
    
    		$al_im .= ">";
    
    		$file_icon = $dir['root'] ."templates/tmpl_".$tmpl."/images/pa_im.gif";
    		if ( file_exists( $file_icon ) )
    			$ai_im .= $al_im ."<img name=i06$p_arr[ID] src=\"". $site['images']. "pa_im.gif\" border=0></a>";
    		$al_im .= _t("_chat now") ."</a>";
    	}
     Standard IM commented out */
    /* View Profile commented out
    	    $ai_viewprof = "<img alt=\""._t("_View Profile")."\" name=i00$p_arr[ID] src=\"$site[images]pa_profile.gif\" border=0>";
    	    $al_viewprof = "<a href=\"$p_arr[NickName]\"";
    
            if ( $pa_icon_preload )
            {
             $al_viewprof.="onMouseOver=\"javascript:i00$p_arr[ID].src='$site[images]pa_profile2.gif';\"";
             $al_viewprof.="onMouseOut =\"javascript:i00$p_arr[ID].src='$site[images]pa_profile.gif';\"";
            }
    		$al_viewprof .= ">";
    		$ai_viewprof = $al_viewprof.$ai_viewprof."</a>";
            $al_viewprof .= _t("_View Profile")."</a>";
     View Profile commented out */
    //--- Greeting start ---//
    $chechActionRes = checkAction($member['ID'], ACTION_ID_SEND_VKISS);
    if ($chechActionRes[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED && $member['ID'] != $p_arr['ID']) {
        $ai_kiss = "<img alt=\"" . _t("_Greet") . "\" class=\"links_image\" name=i01{$p_arr['ID']} src=\"" . $site['url'] . "templates/tmpl_" . $tmpl . "/images/icons/action_greet_small.gif\" />";
        $al_kiss = '<a target=_blank href="greet.php?sendto=' . $p_arr[ID] . '"';
        if ($pa_icon_preload) {
            $al_kiss .= "onMouseOver=\"javascript: i01{$p_arr['ID']}.src='{$site['images']}pa_kiss2.gif';\"";
            $al_kiss .= "onMouseOut =\"javascript: i01{$p_arr['ID']}.src='{$site['images']}pa_kiss.gif';\"";
        }
        $al_kiss .= ">";
        $al_kiss = "<span class=\"links_span\">" . $ai_kiss . $al_kiss . _t("_Greet") . "</a></span>";
    } else {
        $al_kiss = '';
    }
    //--- Greeting end ---//
    //--- Contact start ---//
    $chechActionRes = checkAction($member['ID'], ACTION_ID_SEND_MESSAGE);
    if ($chechActionRes[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED && $member['ID'] != $p_arr['ID']) {
        $ai_sendmsg = "<img alt=\"" . _t("_SEND_MESSAGE") . "\" name=i02{$p_arr['ID']} src=\"{$site['url']}templates/tmpl_{$tmpl}/images/icons/action_send_small.gif\" class=\"links_image\" />";
        $al_sendmsg = "<a href=\"compose.php?ID={$p_arr['ID']}\"";
        if ($pa_icon_preload) {
            $al_sendmsg .= "onMouseOver=\"javascript: i02{$p_arr['ID']}.src='{$site['images']}pa_send2.gif';\"";
            $al_sendmsg .= "onMouseOut =\"javascript: i02{$p_arr['ID']}.src='{$site['images']}pa_send.gif';\"";
        }
        $al_sendmsg .= ">";
        $al_sendmsg = "<span class=\"links_span\">" . $ai_sendmsg . $al_sendmsg . _t("_Contact") . "</a></span>";
    } else {
        $al_sendmsg = '';
    }
    //--- Contact end ---//
    if ($logged['member']) {
        $ai_hot = "<img alt=\"" . _t("_hot member") . "\" name=i03{$p_arr['ID']} src=\"{$site['images']}pa_hot.gif\" border=0>";
        $al_hot = "<a href=\"javascript:void(0);\" onClick=\"javascript:window.open( 'list_pop.php?action=hot&ID=" . $p_arr['ID'] . "', '', 'width=280,height=200,menubar=no,status=no,resizable=no,scrollbars=yes,toolbar=no, location=no' );\"";
        if ($pa_icon_preload) {
            $al_hot .= "onMouseOver=\"javascript: i03{$p_arr['ID']}.src='{$site['images']}pa_hot2.gif';\"";
            $al_hot .= "onMouseOut =\"javascript: i03{$p_arr['ID']}.src='{$site['images']}pa_hot.gif';\"";
        }
        $al_hot .= ">";
        $ai_hot = $al_hot . $ai_hot . "</a>";
        $al_hot .= _t("_hot member") . "</a>";
        $ai_friend = "<img alt=\"" . _t("_friend member") . "\" name=i03{$p_arr['ID']} src=\"{$site['images']}pa_friend.gif\" border=0>";
        $al_friend = "<a href=\"javascript:void(0);\" onClick=\"javascript:window.open( 'list_pop.php?action=friend&ID=" . $p_arr['ID'] . "', '', 'width=280,height=200,menubar=no,status=no,resizable=no,scrollbars=yes,toolbar=no, location=no' );\"";
        if ($pa_icon_preload) {
            $al_friend .= "onMouseOver=\"javascript: i03{$p_arr['ID']}.src='{$site['images']}pa_friend2.gif';\"";
            $al_friend .= "onMouseOut =\"javascript: i03{$p_arr['ID']}.src='{$site['images']}pa_friend.gif';\"";
        }
        $al_friend .= ">";
        $ai_friend = $al_friend . $ai_friend . "</a>";
        $al_friend .= _t("_friend member") . "</a>";
        $ai_block = "<img alt=\"" . _t("_block member") . "\" name=i04{$p_arr['ID']} src=\"{$site['images']}pa_block.gif\" border=0>";
        $al_block = "<a href=\"javascript:void(0);\" onClick=\"javascript:window.open( 'list_pop.php?action=block&ID=" . $p_arr['ID'] . "', '', 'width=280,height=200,menubar=no,status=no,resizable=no,scrollbars=yes,toolbar=no, location=no' );\"";
        if ($pa_icon_preload) {
            $al_block .= "onMouseOver=\"javascript: i04{$p_arr['ID']}.src='{$site['images']}pa_block2.gif';\"";
            $al_block .= "onMouseOut =\"javascript: i04{$p_arr['ID']}.src='{$site['images']}pa_block.gif';\"";
        }
        $al_block .= ">";
        $ai_block = $al_block . $ai_block . "</a>";
        $al_block .= _t("_block member") . "</a>";
    }
    //--- Fave Start ---//
    if ($logged['member'] && $member['ID'] != $p_arr['ID']) {
        $ai_fave = "<img alt=\"" . _t("_Fave") . "\" class=\"links_image\" name=i03{$p_arr['ID']} src=\"{$site['url']}templates/tmpl_{$tmpl}/images/icons/action_fave_small.gif\" />";
        $al_fave = "<a href=\"javascript:void(0);\" onclick=\"window.open( 'list_pop.php?action=hot&amp;ID={$profileID}',    '', 'width={$oTemplConfig->popUpWindowWidth},height={$oTemplConfig->popUpWindowHeight},menubar=no,status=no,resizable=no,scrollbars=yes,toolbar=no,location=no' );\">";
        $al_fave = '<span class="links_span">' . $ai_fave . $al_fave . _t("_Fave") . "</a></span>";
    } else {
        $al_fave = '';
    }
    //--- Fave End ---//
    $more = '<a href="' . getProfileLink($p_arr['ID']) . '" target="_blank">';
    $more .= '<img src="' . $site['icons'] . 'desc_more.gif" alt="' . _t('_more') . '" />';
    $more .= '</a>';
    $enable_more_photos = 'on' == getParam("more_photos_on_searchrow") ? 1 : 0;
    if ($enable_more_photos) {
        $more_photos = '';
        for ($i = 1; $i <= $pic_num; ++$i) {
            if ($p_arr['Pic_' . $i . '_addon'] > 0) {
                $photo_counter++;
            }
        }
        if (0 < $photo_counter && ($logged['admin'] || $check_res[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED)) {
            $more_photos = '<a href="javascript:void(0);" onClick="javascript: get_gallery(' . $p_arr['ID'] . ');" class="search_more_photo">';
            $more_photos .= $photo_counter . '&nbsp;' . _t("_More Photos");
            $more_photos .= '</a>';
        } else {
            $more_photos = '';
        }
    }
    // ------------ [end] template variables --------------
    if ($aCoupleInfo) {
        // profile Nick/Age/Sex etc.
        $nick2 = '<a href="' . getProfileLink($aCoupleInfo['ID']) . '">' . $aCoupleInfo['NickName'] . '</a>';
        $age_str2 = $aCoupleInfo['DateOfBirth'] != "0000-00-00" ? _t("_y/o", age($aCoupleInfo['DateOfBirth'])) . ' ' : "";
        $age_only2 = $aCoupleInfo['DateOfBirth'] != "0000-00-00" ? age($aCoupleInfo['DateOfBirth']) : "";
        $y_o_sex2 = $age_str2 . _t("_" . $aCoupleInfo['Sex']);
        $city2 = _t("_City") . ": " . process_line_output($aCoupleInfo['City']);
        $country2 = _t("_Country") . ": " . _t($aPreValues['Country'][$aCoupleInfo['Country']]['LKey']) . '&nbsp;<img src="' . ($site['flags'] . strtolower($aCoupleInfo['Country'])) . '.gif" alt="flag" />';
        $city_con2 = process_line_output($aCoupleInfo['City']) . ", " . _t($aPreValues['Country'][$aCoupleInfo['Country']]['LKey']) . '&nbsp;<img src="' . ($site['flags'] . strtolower($aCoupleInfo['Country'])) . '.gif" alt="flag" />';
        $occupation2 = process_line_output($aCoupleInfo['Occupation']);
        $children2 = $aCoupleInfo['Children'] ? $aCoupleInfo['Children'] . " " . _t("_children") : "";
        $id2 = _t("_ID") . ": " . $aCoupleInfo['ID'];
        // description
        $i_am2 = _t("_I am");
        $i_am_desc2 = process_smiles(strip_tags(process_text_output($aCoupleInfo['DescriptionMe']), '<img>')) . "...";
        $you_are2 = _t("_You are");
        $you_are_desc2 = process_smiles(process_text_output($aCoupleInfo['DescriptionYou'])) . "... <a href=\"" . getProfileLink($aCoupleInfo['ID']) . "\">" . _t("_more") . "</a>";
        $sCity2 = $aCoupleInfo['City'];
        $templ = str_replace("__add_style_c1__", 'float:left;width:31%;margin-right:10px;', $templ);
        $templ = str_replace("__add_style_c2__", 'float:left;width:31%;display:block;', $templ);
        $templ = str_replace("__nick2__", $nick2, $templ);
        $templ = str_replace("__age_sex2__", $y_o_sex2, $templ);
        $templ = str_replace("__city_con2__", $city_con2, $templ);
        $templ = str_replace("__i_am_desc2__", $i_am_desc2, $templ);
        if ($logged['member'] && $member['ID'] != $aCoupleInfo['ID'] && getParam('enable_match')) {
            $templ = str_replace("__match2__", getProfileMatch($member['ID'], $aCoupleInfo['ID']), $templ);
        } else {
            $templ = str_replace("__match2__", '', $templ);
        }
    } else {
        $templ = str_replace("__add_style_c1__", '', $templ);
        $templ = str_replace("__add_style_c2__", 'display:none;', $templ);
        $templ = str_replace("__match2__", '', $templ);
    }
    // replace template variables
    $templ = str_replace("__row_title__", process_line_output($p_arr[Headline]), $templ);
    $templ = str_replace("__n__", $iNumber, $templ);
    if (isset($p_arr['Couple']) && $p_arr['Couple'] > 0) {
        $iMaxThumbWidth = getParam('max_thumb_width');
        $iNewWidth = 2 * ($iMaxThumbWidth + 10 + 2);
        $templ = str_replace("__ext_st__", 'style="width:' . $iNewWidth . 'px;"', $templ);
    } else {
        $iMaxThumbWidth = getParam('max_thumb_width');
        $iNewWidth = 1 * ($iMaxThumbWidth + 12);
        $templ = str_replace("__ext_st__", 'style="width:' . $iNewWidth . 'px;"', $templ);
    }
    //$templ = str_replace ( "__ext_st__", '', $templ );
    $templ = str_replace("__thumbnail__", $thumbnail, $templ);
    $templ = str_replace("__launch_ray_im__", $launch_ray_im, $templ);
    // match progress bar
    if ($logged['member'] && $member['ID'] != $p_arr['ID'] && getParam('enable_match')) {
        $templ = str_replace("__match__", getProfileMatch($member['ID'], $p_arr['ID']), $templ);
    } else {
        $templ = str_replace("__match__", '', $templ);
    }
    $templ = str_replace("__nick__", $nick, $templ);
    $templ = str_replace("__age_sex__", $y_o_sex, $templ);
    $templ = str_replace("__city__", $city, $templ);
    $templ = str_replace("__just_city__", $sCity, $templ);
    $templ = str_replace("__just_age__", $age_only, $templ);
    $templ = str_replace("__city_con__", $city_con, $templ);
    $templ = str_replace("__country__", $country, $templ);
    $templ = str_replace("__occupation__", $occupation, $templ);
    $templ = str_replace("__children__", $children, $templ);
    $templ = str_replace("__id__", $id, $templ);
    if ($enable_zodiac) {
        $templ = str_replace("__zodiac_sign__", getProfileZodiac($p_arr['DateOfBirth']), $templ);
    } else {
        $templ = str_replace("__zodiac_sign__", "", $templ);
    }
    $templ = str_replace("__i_am__", $i_am, $templ);
    $templ = str_replace("__i_am_desc__", $i_am_desc, $templ);
    $templ = str_replace("__you_are__", $you_are, $templ);
    $templ = str_replace("__you_are_desc__", $you_are_desc, $templ);
    $templ = str_replace("__ai_im__", $ai_im, $templ);
    $templ = str_replace("__al_im__", $al_im, $templ);
    $templ = str_replace("__ai_viewprof__", $ai_viewprof, $templ);
    $templ = str_replace("__al_viewprof__", $al_viewprof, $templ);
    $templ = str_replace("__ai_kiss__", $ai_kiss, $templ);
    $templ = str_replace("__al_kiss__", $al_kiss, $templ);
    $templ = str_replace("__ai_sendmsg__", $ai_sendmsg, $templ);
    $templ = str_replace("__al_sendmsg__", $al_sendmsg, $templ);
    $templ = str_replace("__ai_fave__", $ai_fave, $templ);
    $templ = str_replace("__al_fave__", $al_fave, $templ);
    $templ = str_replace("__ai_hot__", $ai_hot, $templ);
    $templ = str_replace("__al_hot__", $al_hot, $templ);
    $templ = str_replace("__ai_block__", $ai_block, $templ);
    $templ = str_replace("__al_block__", $al_block, $templ);
    $templ = str_replace("__from__", _t("_from"), $templ);
    $templ = str_replace("__more__", $more, $templ);
    $templ = str_replace("__more_photos__", $more_photos, $templ);
    $templ = str_replace("__images__", $site['images'], $templ);
    if (function_exists('colors_select')) {
        $templ = str_replace("__designBoxColor__", colors_select(), $templ);
    }
    return $templ;
}