<link rel="stylesheet" type="text/css" href="catalog/template/beststoreitems/css/cart.css">
<script type="text/javascript" src="catalog/javascript/ajax/jquery.js"></script>

<div class="main container">
    <div class="row" id="cart">
    	<!--left-->
    	<div class="col-md-24">
        	<div class="page-title clearfix">
                <h1><?php echo $text_new_address; ?></h1>
                <div class="clear"></div>
                <p class="tips"><?php echo $heading_title; ?></p>
            </div>
            <div id="checkout_address">
                <?php if ($addresses) { ?>
                <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">         
                <table class="default_address">
                    <?php foreach ($addresses as $address) { ?>
                    <?php if ($address['address_id'] == $default) { ?>
                    <tr>
                      <td class="e"><label style="color:blue;" for="address_id[<?php echo $address['address_id']; ?>]">
                        <input type="radio" name="address_id" value="<?php echo $address['address_id']; ?>" id="address_id[<?php echo $address['address_id']; ?>]" CHECKED />
                        <?php echo $address['address']; ?></label><label style="color:red; display:inline;">(Default)</label></td>      
                    <?php } else { ?>
                      <td class="e"><label for="address_id[<?php echo $address['address_id']; ?>]">
                        <input type="radio" name="address_id" value="<?php echo $address['address_id']; ?>" id="address_id[<?php echo $address['address_id']; ?>]" />
                        <?php echo $address['address']; ?></label></td>     
                    <?php } ?>
                    <td valign="bottom" align="right">
                        <a class="btn-remove icon_link" onclick="location='<?php echo $address['update']; ?>'" title="Edit">
                            <span class="icon">
                                <span class="glyphicon glyphicon-pencil"></span>
                            </span>
                        </a>
                        <a class="btn-remove icon_link" onclick="location='<?php echo $address['delete']; ?>'" title="Delete">
                            <span class="icon">
                                <span class="glyphicon glyphicon-trash"></span>
                            </span>
                        </a>
                    </td>
                     </tr>
                	<?php } ?>
                </table>
                <div class="buttons">
                    <table style="margin:0;">
                        <tr>
                            <td><input type="hidden" name="change_address_type" value="<?php echo $change_address_type?>" /></td>
                            <td valign="center" align="left"><a onclick="window.history.back(-1)" class="btn_button btn_gray"/><i class="icon-back"></i>Back</a></td>
                            <td valign="bottom" align="center" class="hidden-xs"><a href="https://www.beststoreitems.com/index.php?controller=account_address" class="btn_button btn_orange">Set Default Address</a></td>    
                            <td valign="bottom" align="right"><input type="submit" class="btn_button btn_orange" value="Continue"  /></td>
                        </tr>
                    </table>
                </div>
                </form>
                <?php } ?>
                
                <form action="<?php echo $save_action; ?>" method="post" enctype="multipart/form-data">
                <div class="d">
                <table>
                <tr>
                  <th><span class="required">*</span> <?php echo $entry_firstname; ?></th>
                  <td><input  class="input-text" type="text" name="firstname" value="<?php echo $firstname; ?>" />
                    <?php if ($error_firstname) { ?>
                    <span class="error"><?php echo $error_firstname; ?></span>
                    <?php } ?></td>
                </tr>
                <tr>
                  <th><span class="required">*</span> <?php echo $entry_lastname; ?></th>
                  <td><input class="input-text" type="text" name="lastname" value="<?php echo $lastname; ?>" />
                    <?php if ($error_lastname) { ?>
                    <span class="error"><?php echo $error_lastname; ?></span>
                    <?php } ?></td>
                </tr>
                <tr>
                  <th><span class="required">*</span ><?php echo $entry_address_1; ?></th>
                  <td><textarea  class="input-text" name="address_1" cols="40" rows="4"><?php echo $address_1; ?></textarea>
                    <?php if ($error_address_1) { ?>
                    <span class="error"><?php echo $error_address_1; ?></span>
                    <?php }else{ ?>
                    <?php } ?></td>
                </tr>   
                <tr>
                  <th><span class="required">*</span> <?php echo $entry_city; ?></th>
                  <td><input class="input-text" type="text" name="city" value="<?php echo $city; ?>" />
                    <?php if ($error_city) { ?>
                    <span class="error"><?php echo $error_city; ?></span>
                    <?php } ?></td>
                </tr>
                <tr>
                  <th><span class="required">*</span> <?php echo $entry_country; ?></th>
                  <td><select name="country_id" onchange="$('#zone').load('index.php?controller=checkout_address&action=zone&country_id='+this.value+'&zone_id=<?php echo $zone_id; ?>');">
                      <?php foreach ($countries as $country) { ?>
                      <?php if ($country['country_id'] == $country_id) { ?>
                      <option value="<?php echo $country['country_id']; ?>" SELECTED><?php echo $country['name']; ?></option>
                      <?php } else { ?>
                      <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                      <?php } ?>
                      <?php } ?>
                    </select></td>
                </tr>
                <tr>
                  <th><span class="required">*</span> <?php echo $entry_zone; ?></th>
                  <td id="zone"><select name="zone_id">
                    </select></td>
                </tr>
                <tr>
                  <th><span class="required">*</span> <?php echo $entry_postcode; ?></th>
                  <td><input class="input-text" type="text" name="postcode" value="<?php echo $postcode; ?>" />
                  <?php if ($error_postcode) { ?>
                    <span class="error"><?php echo $error_postcode; ?></span>
                    <?php } ?></td>
                </tr>
                <tr>
                  <th><span class="required">*</span> <?php echo $entry_company; ?></th> 
                  <td> <input class="input-text" type="text" name="company" value="<?php echo $company; ?>" />
                  <span><font color="#FF0000">(Mobile is recommended, please ingore country prefix)</font></span>
                  <?php if ($error_company) { ?>
                
                    <span class="error"><?php echo $error_company; ?></span>
                
                    <?php } ?><br /></td>
                
                </tr>       
                <tr><td valign="bottom" align="left">
                
                <input type="submit" class="btn_button btn_orange" value="Save" />
                
                </td>
                </tr>
                
                
                </table>
                </div>
                </form>
               <script language="javascript"> 
				function waring() 
				{
					return confirm("Do you confirm choose this address as your shipping address?");
				}
				
				$('#zone').load('index.php?controller=checkout_address&action=zone&country_id=<?php echo $country_id; ?>&zone_id=<?php echo $zone_id; ?>')
			  </script>
            </div>
        </div>
        <!--left end-->
    </div>
</div>

