<?php

foreach ($c_referral as $referral) {
    ?>
		<tr>
			<td><?php 
    echo numberFixAULocal($referral['phone']);
    ?>
</td>
			<td><a onClick="openCustomer(<?php 
    echo $uId;
    ?>
,<?php 
    echo $referral['id'];
    ?>
);"><?php 
    echo $referral['name'];
    ?>
</a></td>
			<td><?php 
    echo $referral['relationship'];
    ?>
</td>
			<td><?php 
    echo $referral['state'];
    ?>
</td>
			<td><?php 
    if ($referral['sex'] == 'm') {
        echo 'Male';
    } else {
</div>

<div class="row-fluid">
	<div class="span6" id="customerPhonesBlock_<?php 
echo $customer->id;
?>
">
		<table class="table table-hover table-condensed">
		<caption><b>Customer phones</b><button class="btn btn-link" onClick="$('#addPhone_<?php 
echo $customer->id;
?>
').show();">Add new</button></caption>
		<?php 
foreach ($c_phones as $key => $phone) {
    echo '<tr id="customerPhonesBlockEditNumber_' . $phone['id'] . '">';
    echo '<td><strong>Phone ' . ($key + 1) . ': </strong></td><td><a id="customerPhonesBlockEditNumberVal_' . $phone['id'] . '" onClick="changePhoneNumber(' . $phone['id'] . ');">' . numberFixAULocal($phone['phone']) . '</a></td>';
    echo '</tr>';
}
?>
		<tr id="addPhone_<?php 
echo $customer->id;
?>
" style="display:none;">
			<td>Phone: <input type="text" name="phone" id="new_phone_<?php 
echo $customer->id;
?>
" maxlength="11"></td>
			<td><button class="btn" id="savePhoneNumberButton_<?php 
echo $customer->id;
?>
" onClick="savePhoneNumber(<?php