<div class="my-account">
    <div class="heading">
        <dl class="acctip">
            <dt><?php echo $heading_title; ?></dt>
        </dl>
    </div>
    <?php if ($message) { ?> 
    <div class="message"><?php echo $message; ?></div>
    <?php } ?>
    <?php if ($error) { ?>
    <div class="warning"><?php echo $error; ?></div>
    <?php } ?>
        <div style="text-align:right;">
        	<input type="button" class="btn_button btn_orange" value="<?php echo $button_new_address; ?>" onClick="location='<?php echo $insert; ?>'" style="padding:0 20px;"/>
        </div>
    <div id="address">
      <div class="b"><?php echo $text_address_book; ?> </div>
      <?php foreach ($addresses as $result) { ?>
      <div class="c">
        <table width="100%">
          <tr>
            <?php if ($result['address_id'] == $default_address_id) { ?>
            <td width="50%" style="color:blue"><div style="line-height:180%;"><?php echo $result['address']; ?></br><span style="color:red;">(default address)</span></div></td>
              <?php } else { ?>
            <td width="50%"><div style="line-height:180%;"><?php echo $result['address']; ?></div></td>
             <?php } ?>
             <td valign="bottom" align="right" width="14%">
                <a title="Edit" onclick="location='<?php echo $result['update']; ?>'" class="btn-remove icon_link">
                    <span class="icon">
                        <span class="glyphicon glyphicon-pencil"></span>
                    </span>
                </a>
                <a title="Delete" onclick="location='<?php echo $result['delete']; ?>'" class="btn-remove icon_link">
                <span class="icon">
                    <span class="glyphicon glyphicon-trash"></span>
                </span>
               </a>
            </td>
            <td valign="bottom" align="right"><input type="button" class="btn_button btn_orange" value="Set Default Address" onClick="location='<?php echo $result['setdefault']; ?>'" /></td>
          </tr>
        </table>
      </div>
     
      <?php } ?> 
    </div>
</div>
<div class="toolbar clearfix row">
    <div class="sorter_bottom">
         <div class="col-sm-8 left"><?php echo $text_results;?></div>
         <div class="col-sm-16 right">                   
            <a href="<?php echo $action . '&page=' . (($page>1)?($page-1):$page); ?>"><?php echo 'Previous'?></a>                     
            <?php foreach ($pages as $f_page) { ?>        
            <?php if ( $f_page['value'] < ($page - 2) ) {continue; } ?>
            <?php if ( $f_page['value'] > ($page + 4) ) {continue; } ?>                                               
            <?php if ($f_page['value'] == $page) { ?>
            <b class="selected"><?php $x = explode(" ",$f_page['text']);echo $x[0]; ?></b>
            <?php } else { ?>
              <a class="page_btn" href="<?php echo $action . '&page=' . $f_page['value']; ?>"><?php $x = explode(" ",$f_page['text']);echo $x[0]; ?></a></td>
            <?php } ?>   
            <?php } ?>                       
            <a class="page_btn" href="<?php echo $action . '&page=' . (($page<count($pages))?($page+1):$page); ?>"><?php echo 'Next'?></a>                     
            <label>Go to Page</label>
            <select onchange="return SelectPage(this.value)" style="width:50px;">
                <?php foreach ($pages as $f_page){?>
                <option value="<?php echo $f_page['value']?>" <?php if ($f_page['value'] == $page){echo 'selected';}?>><?php echo $f_page['value']?></option>
                <?php };?>
            </select>
            <script type="text/javascript">
				function SelectPage(page) {
					window.location.href="<?php echo $action; ?>&page=" + page;
				}
			</script>
       </div>
   </div>
</div>
<div class="buttons" style="text-align:right; margin-top:20px;">
   <a style="margin-right:0;" href="/index.php?controller=account" class="btn_button btn_gray"><i class="icon-back"></i>Back to Account</a>
</div>