<?php echo $header; ?>
<?php if ($attention) { ?>
<div class="attention"><?php echo $attention; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
<?php } ?>
<?php if ($success) { ?>
<div class="success"><?php echo $success; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
<?php } ?>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
<?php } ?>
<section class="main-container col1-layout">
    <article class="col-main">
        <div class="breadcrumbs">
            <ul>
                <?php foreach ($breadcrumbs as $breadcrumb) { ?>
                <li class="category11"><span><?php echo $breadcrumb['separator']; ?></span><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a> </li>
                <?php } ?>
            </ul>
        </div>
        <div class="cart">
            <div class="page-title">
                <h2><?php echo $heading_title; ?>
                    <?php if ($weight) { ?>
                    &nbsp;(<?php echo $weight; ?>)
                    <?php } ?>
                </h2>
            </div>

            <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
                <div class="cart-info">
                    <table class="data-table cart-table" id="shopping-cart-table">
                        <colgroup>
                            <col width="10%">
                            <col width="70%">
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                        </colgroup>
                        <thead>
                            <tr>
                                <th class="image a-center" rowspan="1"><?php echo $column_image; ?></th>
                                <th class="name" rowspan="1"><span class="nobr"><?php echo $column_name; ?></span></th>
                                <th class="model"><?php echo $column_model; ?></th>
                                <th class="quantity a-center" rowspan="1"><?php echo $column_quantity; ?></th>
                                <th class="a-center" colspan="1"><?php echo $column_price; ?></th>
                                <th class="total a-center" colspan="1"><?php echo $column_total; ?></th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <td class="a-right" colspan="50">
                                    <a href="<?php echo $continue; ?>" class="button btn-continue" title="<?php echo $button_shopping; ?>" type="button"><span><?php echo $button_shopping; ?></span></a>
                                    <a class="button btn-update" href="<?php echo $checkout; ?>"  title="<?php echo $button_checkout; ?>" value="update_qty" name="update_cart_action" ><span><?php echo $button_checkout; ?></span></a>

                                </td>
                            </tr>
                        </tfoot>
                        <tbody>
                            <?php foreach ($products as $product) { ?>
                            <tr>
                                <td class="image a-center cart-img"><?php if ($product['thumb']) { ?>
                                    <a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" /></a>
                                    <?php } ?></td>
                                <td class="name"><h4><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></h4></a>
                                    <?php if (!$product['stock']) { ?>
                                    <span class="stock">***</span>
                                    <?php } ?>
                                    <div>
                                        <?php foreach ($product['option'] as $option) { ?>
                                        - <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?></small><br />
                                        <?php } ?>
                                      
                                    </div>
                                    <?php if ($product['reward']) { ?>
                                    <small><?php echo $product['reward']; ?></small>
                                    <?php } ?></td>
                                <td class="model"><?php echo $product['model']; ?></td>
                                <td class="quantity"><input type="text" class="input-text qty" name="quantity[<?php echo $product['key']; ?>]" value="<?php echo $product['quantity']; ?>" size="1" />
                                    &nbsp;
                                    <button  class="button btn-update btn_cart_update" type="image"  alt="<?php echo $button_update; ?>" title="<?php echo $button_update; ?>"><span></span></button>
                                    &nbsp;<a href="<?php echo $product['remove']; ?>" class="remove-item"></a></td>
                                <td class="price a-center"><div class="cart-price"> <span class="price"><?php echo $product['price']; ?></span> </div></td>
                                <td class="total a-center"><div class="cart-price"> <span class="price"><?php echo $product['total']; ?></span> </div></td>
                            </tr>
                            <?php } ?>
                            <?php foreach ($vouchers as $vouchers) { ?>
                            <tr>
                                <td class="image"></td>
                                <td class="name"><?php echo $vouchers['description']; ?></td>
                                <td class="model"></td>
                                <td class="quantity"><input type="text" name="" value="1" size="1" disabled="disabled" />
                                    &nbsp;<a href="<?php echo $vouchers['remove']; ?>" class="remove-item"><img src="catalog/view/theme/default/image/remove.png" alt="<?php echo $button_remove; ?>" title="" /></a></td>
                                <td class="price"><?php echo $vouchers['amount']; ?></td>
                                <td class="total"><?php echo $vouchers['amount']; ?></td>
                            </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </form>  




            <div class="cart-collaterals">
                <div class="col2-set col-1">
                    <div class="discount">
                        <?php if ($coupon_status) { ?>
                        <h3><?php echo $entry_coupon; ?></h3>
                        <form  id="discount-coupon-form" action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
                            <label for="coupon_code">Enter your coupon code if you have one.</label>
                            <input type="text" name="coupon" value="<?php echo $coupon; ?>" class="input-text" />
                            <input type="hidden" name="next" value="coupon" />
                            &nbsp;
                            <button type="submit" value="<?php echo $button_coupon; ?>" class="button coupo" ><span><?php echo $button_coupon; ?></span></button>
                        </form>
                        <?php } ?>

                    </div>

                    <div class="shipping">
                        <h3><?php echo $text_shipping_detail; ?></h3>

                        <ul class="form-list">
                            <li>
                                <label for="country" class="required"><em>*</em><?php echo $entry_country; ?></label>
                                <div class="input-box">
                                    <label for="id_country"></label>
                                    <select name="country_id">
                                        <option value=""><?php echo $text_select; ?></option>
                                        <?php foreach ($countries as $country) { ?>
                                        <?php if ($country['country_id'] == $country_id) { ?>
                                        <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
                                        <?php } else { ?>
                                        <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
                                        <?php } ?>
                                        <?php } ?>
                                    </select>      
                                </div>
                            </li>
                            <li style="" id="states">
                                <label for="region_id id_state"> <?php echo $entry_zone; ?></label>
                                <div class="input-box">
                                    <select name="zone_id">
                                    </select>

                                </div>
                            </li>
                            <li>
                                <label for="postcode"> <?php echo $entry_postcode; ?></label>
                                <div class="input-box">
                                    <input   class="input-text" type="text" name="postcode" value="<?php echo $postcode; ?>" />
                                </div>
                            </li>
                        </ul>
                        <div class="buttons-set">
                            <p class="SE_SubmitRefreshCard">
                                <button  type="button" id="button-quote" class="button button get-quote"><span><span><?php echo $button_quote; ?></span></span></button>
                            </p>		
                        </div>
                    </div> 

                </div>
                <div class="totals col-2">
                    <table id="shopping-cart-totals-table">
                        <col>
                        <col width="1">

                        <tfoot>
                            <?php foreach ($totals as $total) { ?>
                            <tr>
                                <td class="a-left" colspan="1"><b><?php echo $total['title']; ?>:</b></td>
                                <td class="a-right"><strong><span class="price"><?php echo $total['text']; ?></span></strong> </td>
                            </tr>
                            <?php } ?>

                            <tr>
                            </tr>
                        </tfoot>
                    </table>
                    <ul class="checkout-types a-right">
                        <li>   
                            <button type="button" title="<?php echo $button_checkout; ?>" class="button btn-proceed-checkout btn-checkout" onclick="window.location='<?php echo $checkout; ?>';"><span><span><?php echo $button_checkout; ?></span></span></button>

                        </li>

                    </ul>
                </div>
            </div>
        </div>
        <?php echo $content_bottom; ?>
    </article>
</section>
<script type="text/javascript"><!--
    $('input[name=\'next\']').bind('change', function() {
    $('.cart-module > div').hide();
	
    $('#' + this.value).show();
});
//--></script>
<?php if ($shipping_status) { ?>
<script type="text/javascript"><!--
$('#button-quote').live('click', function() {
$.ajax({
url: 'index.php?route=checkout/cart/quote',
type: 'post',
data: 'country_id=' + $('select[name=\'country_id\']').val() + '&zone_id=' + $('select[name=\'zone_id\']').val() + '&postcode=' + encodeURIComponent($('input[name=\'postcode\']').val()),
dataType: 'json',		
beforeSend: function() {
$('#button-quote').attr('disabled', true);
$('#button-quote').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
},
complete: function() {
$('#button-quote').attr('disabled', false);
$('.wait').remove();
},		
success: function(json) {
$('.success, .warning, .attention, .error').remove();			
						
if (json['error']) {
if (json['error']['warning']) {
$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
					
$('.warning').fadeIn('slow');
					
$('html, body').animate({ scrollTop: 0 }, 'slow'); 
}	
							
if (json['error']['country']) {
$('select[name=\'country_id\']').after('<span class="error">' + json['error']['country'] + '</span>');
}	
				
if (json['error']['zone']) {
$('select[name=\'zone_id\']').after('<span class="error">' + json['error']['zone'] + '</span>');
}
				
if (json['error']['postcode']) {
$('input[name=\'postcode\']').after('<span class="error">' + json['error']['postcode'] + '</span>');
}					
}
			
if (json['shipping_method']) {
html  = '<h2><?php echo $text_shipping_method; ?></h2>';
html += '<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">';
html += '  <table class="radio">';
				
for (i in json['shipping_method']) {
html += '<tr>';
html += '  <td colspan="3"><b>' + json['shipping_method'][i]['title'] + '</b></td>';
html += '</tr>';
				
if (!json['shipping_method'][i]['error']) {
for (j in json['shipping_method'][i]['quote']) {
html += '<tr class="highlight">';
							
if (json['shipping_method'][i]['quote'][j]['code'] == '<?php echo $shipping_method; ?>') {
html += '<td><input type="radio" name="shipping_method" value="' + json['shipping_method'][i]['quote'][j]['code'] + '" id="' + json['shipping_method'][i]['quote'][j]['code'] + '" checked="checked" /></td>';
} else {
html += '<td><input type="radio" name="shipping_method" value="' + json['shipping_method'][i]['quote'][j]['code'] + '" id="' + json['shipping_method'][i]['quote'][j]['code'] + '" /></td>';
}
								
html += '  <td><label for="' + json['shipping_method'][i]['quote'][j]['code'] + '">' + json['shipping_method'][i]['quote'][j]['title'] + '</label></td>';
html += '  <td style="text-align: right;"><label for="' + json['shipping_method'][i]['quote'][j]['code'] + '">' + json['shipping_method'][i]['quote'][j]['text'] + '</label></td>';
html += '</tr>';
}		
} else {
html += '<tr>';
html += '  <td colspan="3"><div class="error">' + json['shipping_method'][i]['error'] + '</div></td>';
html += '</tr>';						
}
}
				
html += '  </table>';
html += '  <br />';
html += '  <input type="hidden" name="next" value="shipping" />';
				
<?php if ($shipping_method) { ?>
html += '  <input type="submit" value="<?php echo $button_shipping; ?>" id="button-shipping" class="button" />';	
<?php } else { ?>
html += '  <input type="submit" value="<?php echo $button_shipping; ?>" id="button-shipping" class="button" disabled="disabled" />';	
<?php } ?>
							
html += '</form>';
				
$.colorbox({
overlayClose: true,
opacity: 0.5,
width: '600px',
height: '400px',
href: false,
html: html
});
				
$('input[name=\'shipping_method\']').bind('change', function() {
$('#button-shipping').attr('disabled', false);
});
}
}
});
});
//--></script> 
<script type="text/javascript"><!--
$('select[name=\'country_id\']').bind('change', function() {
$.ajax({
url: 'index.php?route=checkout/cart/country&country_id=' + this.value,
dataType: 'json',
beforeSend: function() {
$('select[name=\'country_id\']').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
},
complete: function() {
$('.wait').remove();
},			
success: function(json) {
if (json['postcode_required'] == '1') {
$('#postcode-required').show();
} else {
$('#postcode-required').hide();
}
			
html = '<option value=""><?php echo $text_select; ?></option>';
			
if (json['zone'] != '') {
for (i = 0; i < json['zone'].length; i++) {
html += '<option value="' + json['zone'][i]['zone_id'] + '"';
	    			
if (json['zone'][i]['zone_id'] == '<?php echo $zone_id; ?>') {
html += ' selected="selected"';
}
	
html += '>' + json['zone'][i]['name'] + '</option>';
}
} else {
html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>';
}
			
$('select[name=\'zone_id\']').html(html);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});

$('select[name=\'country_id\']').trigger('change');
//--></script>
<?php } ?>
<?php echo $footer; ?>
