<?php echo $header; ?>
<?php
  if ($this->config->get('config_pixel_facebook_status')=='enable') {
    if (!$this->config->get('config_pixel_facebook')=='') {
      $vFbKeys  = '';
      foreach ($products as $product) {
        if ($vFbKeys == '') {
          $vFbKeys = "'".str_replace('::', '', $product['key'])."'";
        } else {
          $vFbKeys  = $vFbKeys .",'". str_replace('::', '', $product['key'])."'";
        }
      }
      $vFbTotal =  $this->cart->getSubTotal();
      echo html_entity_decode("<script> fbq('track', 'AddToCart', {
        content_type: 'product_group',
        content_ids: [$vFbKeys],
        value: $vFbTotal,
        currency: 'BRL'
      }); </script>", ENT_QUOTES, 'UTF-8');
    }
  }
?>

<?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 } ?>

<?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <h1><?php echo $heading_title; ?>
    <?php if ($weight) { ?>
    &nbsp;(<?php echo $weight; ?>)
    <?php } ?>
  </h1>
  <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
    <div class="cart-info">
      <table class="sortable">
        <thead>
          <tr>
            <td class="image"><?php echo $column_image; ?></td>
            <td class="name sortable_coll"><?php echo $column_name ?></td>
            <td class="model"><?php echo $column_model; ?></td>
            <td class="quantity"><?php echo $column_quantity; ?></td>
            <?php $modulostconf = $this->futuracalcularst->getconfiguracoes();
    				if(($this->customer->isLogged()) && ($this->customer->getTipo_pessoa() == 'J') && ($modulostconf['futuracalcularst_status']) ){ ?>
      				<td class="valorst"><?php echo "Valor ST";?> </td>
      				<td class="valoripi"><?php echo "Valor IPI";?> </td>
              <td class="valofcp"><?php echo "Valor FCP ST";?> </td>
    			  <?php } ?>
            <td class="price"><?php echo $column_price; ?></td>
            <td class="total"><?php echo $column_total; ?></td>
          </tr>
        </thead>
        <tbody>

		  <?php $productsreverse = array_reverse($products)?>

          <?php foreach ($productsreverse as $product) { ?>
            <?php if($product['recurring']): ?>
              <tr>
                  <td colspan="6" style="border:none;"><image src="catalog/view/theme/default/image/reorder.png" alt="" title="" style="float:left;" /><span style="float:left;line-height:18px; margin-left:10px;">
                      <strong><?php echo $text_recurring_item ?></strong>
                      <?php echo $product['profile_description'] ?>
                  </td>
                </tr>
            <?php endif; ?>
			<?php if($product['verify']){?>
			   <tr class="prod_cart" style="border: 2px solid red;">
			<?php }else{ ?>
            <tr>
			<?php } ?>

            <td class="image"><?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"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
              <?php //if (!$product['stock']) { ?>

              <!--span class="stock">***</span-->

              <?php //} ?>
			  </br>
			  <?php if($product['verify']){?>
			    <span class="msgerror" id="msgerrorid" ><?php echo $product['verify']; ?></span>
			  <?php }?>
              <div>
                <?php foreach ($product['option'] as $option) { ?>
                 <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?></small><br />
                <?php } ?>
                <?php if($product['recurring']): ?>
                 <small><?php echo $text_payment_profile ?>: <?php echo $product['profile_name'] ?></small>
                <?php endif; ?>
              </div>
              <?php if ($product['reward']) { ?>
              <small><?php echo $product['reward']; ?></small>
              <?php } ?>
			      </td>
            <td class="model"><?php echo $product['model']; ?></td>
            <td class="quantity" style="width:85px;">
      				<input type="text" name="quantity[<?php echo $product['key']; ?>]" value="<?php echo $product['quantity']; ?>" size="10" class="numeric" />
      				<input
              <?php if ($this->config->get('config_status_analytics_avancado')){ ?>
              onclick="atualizarQuantidade(<?php  echo '\''.'quantity['.$product['key'].']'.'\''.','. '\''.$product['product_id'].'\''.','.'\''.$product['name'].'\''.','.'\''.$product['category'].'\''.','.'\''.$product['manufacturer'].'\''.','.'\''.$product['price_format2'].'\''.','.$product['quantity'];?>)"
              <?php } ?>
              type="image" src="catalog/view/theme/default/image/update.png" alt="<?php echo $button_update; ?>" title="<?php echo $button_update; ?>" />
      				&nbsp;<a
              <?php if ($this->config->get('config_status_analytics_avancado')){ ?>
              onclick="atualizarQuantidade(<?php  echo '\''.'quantity['.$product['key'].']'.'\''.','.  '\''.$product['product_id'].'\''.','.'\''.$product['name'].'\''.','.'\''.$product['category'].'\''.','.'\''.$product['manufacturer'].'\''.','.'\''.$product['price_format2'].'\''.','.$product['quantity'];?>)"
              <?php } ?>
              href="<?php echo $product['remove']; ?>"><img style="padding-top: 10px;" src="catalog/view/theme/default/image/remove.png" alt="<?php echo $button_remove; ?>" title="<?php echo $button_remove; ?>" /></a>
      			</td>
            <?php $modulostconf = $this->futuracalcularst->getconfiguracoes();
            if(($this->customer->isLogged()) && ($this->customer->getTipo_pessoa() == 'J') && ($modulostconf['futuracalcularst_status']) ){ ?>
              <td class="valorst"><?php  if($product['st_valor'] !== 'N') {echo $product['st_valor'];}   else {echo "";};?></td>
              <td class="valoripi"><?php if($product['ipi_valor']!== 'N') {echo $product['ipi_valor'];}  else {echo "";};?></td>
              <td class="valorfcpst"><?php if($product['fcpst_valor']!== 'N') {echo  $product['fcpst_valor'];}  else {echo "";};?></td>
            <?php } ?>
            <td class="price"><?php echo $product['price']; ?></td>
            <td class="total"><?php echo $product['total']; ?></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']; ?>"><img style="padding-top: 10px;" src="catalog/view/theme/default/image/remove.png" alt="<?php echo $button_remove; ?>" title="<?php echo $button_remove; ?>" /></a></td>
            <td class="price"><?php echo $vouchers['amount']; ?></td>
            <td class="total"><?php echo $vouchers['amount']; ?></td>
          </tr>
          <?php } ?>
        </tbody>
      </table>
    </div>
  </form>
  <?php if ($coupon_status || $voucher_status || $reward_status || $shipping_status) { ?>
  <div class="cart-left-area"> <!-- Magento extra Div start -->

		<div class="cart-module">
    <div id="coupon" class="content" style="display: <?php echo ($next == 'coupon' ? 'block' : 'none'); ?>;">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
        <?php echo $entry_coupon; ?>&nbsp;<br />
        <input type="text" name="coupon" value="<?php echo $coupon; ?>" />
        <input type="hidden" name="next" value="coupon" />
        &nbsp;
        <input type="submit" value="<?php echo $button_coupon; ?>" class="button" />
      </form>
    </div>
    <div id="voucher" class="content" style="display: <?php echo ($next == 'voucher' ? 'block' : 'none'); ?>;">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
        <?php echo $entry_voucher; ?>&nbsp;
        <input type="text" name="voucher" value="<?php echo $voucher; ?>" />
        <input type="hidden" name="next" value="voucher" />
        &nbsp;
        <input type="submit" value="<?php echo $button_voucher; ?>" class="button" />
      </form>
    </div>
    <div id="reward" class="content" style="display: <?php echo ($next == 'reward' ? 'block' : 'none'); ?>;">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
        <?php echo $entry_reward; ?>&nbsp;
        <input type="text" name="reward" value="<?php echo $reward; ?>" />
        <input type="hidden" name="next" value="reward" />
        &nbsp;
        <input type="submit" value="<?php echo $button_reward; ?>" class="button" />
      </form>
    </div>

  </div>
  </div> <!-- Magento extra Div End -->
  <?php } ?>
  <div class="cart-right-area"> <!-- Magento extra Div start -->
		<div class="cart-total">
    <table id="total">
      <?php foreach ($totals as $total) { ?>
      <tr>
        <td class="right"><b><?php echo $total['title']; ?>:</b></td>
        <td class="right"><?php echo $total['text']; ?></td>
      </tr>
      <?php } ?>
    </table>
  </div>

  <div class="checkout-button">
		
    <?php if (($shipping_status) && ($this->customer->getTipo_pessoa() == 'J')) { ?>
       <a  class="button"   id="shipEst"  >Calcular Imposto (S.T)</a>
    <?php } ?>
  </div>
  <br>

  <div class="checkout-button">
   <a id="finalizar" class="button"><?php echo $button_checkout; ?></a>
  </div>

  </div> <!-- Magento extra Div End -->
  <div class="cart-clear">&nbsp;</div> <!-- Magento extra Div -->
  <div class="buttons cart-buttons">
    <div class="center"><a href="<?php echo $continue; ?>" class="button"><?php echo $button_shopping; ?></a></div>
  </div>
  <?php echo $content_bottom; ?></div>

<script type="text/javascript" src="catalog/view/javascript/jquery/sorttable.js"></script>



<script type="text/javascript">
  $('input[name=\'next\']').bind('change', function() {
  	$('.cart-module > div').hide();

  	$('#' + this.value).show();
  });
<?php if ($this->config->get('config_status_analytics_avancado')){ ?>
  function atualizarQuantidade(inputName, productID, nome, categoria, fabricante, preco, qtd){
    inputName = 'input[name=\''+inputName+'\']';
    newqtd = parseInt($(inputName).val());

    if (newqtd <= qtd){
      if(newqtd == qtd){//Para não zerar a quantidade//
        var qtdRemove = qtd;
      }else{
        var qtdRemove = qtd - newqtd;
      }

      var analyticsProduto = [];

      analyticsProduto['product_id'] = productID;
      analyticsProduto['nome'] = nome;
      analyticsProduto['categoria'] = categoria;
      analyticsProduto['marca'] = fabricante;
      analyticsProduto['preco'] = preco;
      analyticsProduto['quantidade'] = qtdRemove;

      analyticsRemoveProduto(analyticsProduto);
    }else{
      var qtdAdd = newqtd - qtd;
      var analyticsProduto = [];

      analyticsProduto['product_id'] = productID;
      analyticsProduto['nome'] = nome;
      analyticsProduto['categoria'] = categoria;
      analyticsProduto['marca'] = fabricante;
      analyticsProduto['preco'] = preco;
      analyticsProduto['quantidade'] = qtdAdd;

      analyticsAddProduto(analyticsProduto);
    }
  }
<?php } ?>
</script>
<?php if ($shipping_status) { ?>
<script type="text/javascript"><!--


$('#finalizar').bind('click',function(){
	var tipoPessoa = '<?php echo $this->customer->getTipo_pessoa(); ?>';
	if (tipoPessoa == 'J'){
			$.ajax({
				url: 'index.php?route=checkout/cart/getSt',
			dataType: 'json',
			success: function(json) {
			var html="";
			html+='<html><body><div style="width:100%;">';
			html+='<strong>Calcule os Impostos para Continuar, Deseja Calcular Agora?</strong>';
			html+='<br>';
			html+='<br>';
			html+='<br>';
			html+='<a style="position:relative; left:10%;" onclick="$.fancybox.close();" class="button"   id="ok"  >Não</a>';
			html+='<a style="position:relative; left:60%;" onclick="$.fancybox.close(); $(\'#shipEst\').trigger(\'click\');" class="button"   id="ok"  >Sim</a>';
			html+='</div></body></html>';

			if (json){
					if( (json['StCalc']=='S') || (json['St_status']==0) ){
					window.location.href = '<?php echo $checkout; ?>';

				}else{

				$.fancybox({
					opacity: 0.5,
					maxWidth    : '100%',
					maxHeight   : '100%',
					fitToView   : false,
					width		: '95',
					height		: '95%',
					autoSize    : true,
					closeClick  : false,
					openEffect  : 'none',
					closeEffect : 'none',
					href: false,
					loop: false,
					content     : html
					});

				}
			}

			},
			error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
				}
		});
	}else{
		window.location.href = '<?php echo $checkout; ?>';	
	}

});

$('#shipEst').live('click',function(e){
    //ConfirmaCadastro
    e.preventDefault();
	$.ajax({
		url: 'index.php?route=checkout/cart/ConfirmaCadastro',
		dataType: 'json',
		success: function(json) {
			if (json['confirmado']=='0'){
		        html= '<style> .btPop{ height:20%; width : 20%; margin-right:2%;  position:absolute;  } </style> <br> ';
				html += '<form enctype="multipart/form-data">';
				html += '  <table class="radio">';
				html += '  <h1 ><font color="black" style="font-size:16px;">Para continuar é necessário confirmar seus dados, deseja prosseguir?</font></h1>';
				html += '  <div id="but" style="background-color:red; overflow:hidden;">';
				html += '  <tr><td><input type="button" id="btnCancelar"  style=" float: left;"  class="button" name="btn_cancelar"  value="Cancelar"/></td>';
				html += '  <td><input type="button" id="btnContinuar" style=" float: right;"  class="button"   name="btn_continuar"  value="Continuar"/></td></tr>';
				html += '  </div></table></form>';
                $.fancybox({
				    opacity: 0.5,
					maxWidth    : '100%',
					maxHeight   : '100%',
					fitToView   : false,
					width       : false,
					height      : false,
					autoSize    : true,
					closeClick  : false,
					openEffect  : 'none',
					closeEffect : 'none',
					scrolling : false,
					content     : html
				});
			}else{
	            // Habilitar calculo da st
				$.ajax({
					url: 'index.php?route=checkout/cart/HabilitaCalculost',
					dataType: 'json',
          beforeSend: function() {
    				$('#shipEst').attr('disabled', true);
    				$('#shipEst').addClass('btn-loading');
    			}, 
  
					success: function(json) {

					    //verifica se não calculou a ST(se deu algum erro)
            location.reload();
          },
					error: function(xhr, ajaxOptions, thrownError) {
            $('#shipEst').attr('disabled', false);
            $('#shipEst').removeClass('btn-loading');
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
			    });
			}
		}
	});
});


$('#shipping select[name=\'country_id\']').live('change', function() {
	$.ajax({
		url: 'index.php?route=checkout/confirmacao_cadastro/country&country_id=' + this.value,
		dataType: 'json',
		success: function(json) {

			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>';
			}

			$('#shipping select[name=\'zone_id\']').html(html);
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});

$('#btnContinuar').live('click',function(){
	$.ajax({
		url: 'index.php?route=checkout/confirmacao_cadastro',
		dataType: 'html',
		success: function(html) {
			$.fancybox({
				opacity: 0.5,
				maxWidth    : '100%',
				maxHeight   : '100%',
				fitToView   : false,
				width		: '95',
			    height		: '95%',
				autoSize    : true,
				closeClick  : false,
				openEffect  : 'none',
				closeEffect : 'none',
				href: false,
			    loop: false,
				content     : html
			});
			$('#pay select[name=\'pay_country_id\']').trigger('change');
			$('#ship select[name=\'ship_country_id\']').trigger('change');
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
    $.fancybox.close();
});

$('#btnCancelar').live('click',function(){
	$.fancybox.close();
});

$('#pay select[name=\'pay_country_id\']').live('change', function() {
	$.ajax({
		url: 'index.php?route=checkout/confirmacao_cadastro/country&country_id=' + this.value,
		dataType: 'json',
		beforeSend: function() {
			$('#pay select[name=\'pay_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 $pay_zone_id; ?>') {
					   html += ' selected="selected"';
					}

	    			html += '>' + json['zone'][i]['name'] + '</option>';
				}
			} else {

				html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>';
			}

			$('#pay select[name=\'pay_zone_id\']').html(html);
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});


$('#ship select[name=\'ship_country_id\']').live('change', function() {

	$.ajax({
		url: 'index.php?route=checkout/cart/country&country_id=' + this.value,
		dataType: 'json',
		beforeSend: function() {
			$('#ship select[name=\'ship_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 $ship_zone_id; ?>') {
	      				html += ' selected="selected"';
	    			}

	    			html += '>' + json['zone'][i]['name'] + '</option>';
				}
			} else {
				html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>';
			}

			$('#ship select[name=\'ship_zone_id\']').html(html);
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});

// CONFIRMAÇÃO DE CADASTRO
$('#button-confirmacao-cadastro').live('click', function(e) {
  e.preventDefault();
	var dados = $('#cadCliente').serialize();
	$.ajax({
		url: 'index.php?route=checkout/confirmacao_cadastro/validate',
		type: 'POST',
		data: dados,
		dataType: 'json',
		beforeSend: function() {
			$('#button-confirmacao-cadastro').attr('disabled', true);
			$('#button-confirmacao-cadastro').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
		},
		complete: function() {
			$('#button-confirmacao-cadastro').attr('disabled', false);
			$('.wait').remove();
		},
		success: function(json) {
			if(json['error']){
				$('.error').remove();
				$('.warning').remove();
			    $('.error').remove();
				$('.warning').remove();
				if (json['error']['warning']) {
					$('#tagree input[name=\'botao\']').after('<span class="error">' +json['error']['warning']  + '</span>');
				}
				if (json['error']['firstname']) {
					$('#dados-pessoais input[name=\'firstname\']').after('<span class="error">' + json['error']['firstname'] + '</span>');
				}
				if (json['error']['lastname']) {
					$('#dados-pessoais input[name=\'lastname\']').after('<span class="error">' + json['error']['lastname'] + '</span>');
				}
				if (json['error']['sexo']) {
					$('#dados-pessoais input[name=\'sexo\']').after('<span class="error">' + json['error']['sexo'] + '</span>');
				}
				if (json['error']['data_nascimento']) {
					$('#dados-pessoais  input[name=\'data_nascimento\']').after('<span class="error">' + json['error']['data_nascimento'] + '</span>');
				}
				//faturamento
				if (json['error']['pay_address_1']) {
					$('#pay  input[name=\'pay_address_1\']').after('<span class="error">' + json['error']['pay_address_1'] + '</span>');
				}
				if (json['error']['pay_city']) {
					$('#pay input[name=\'pay_city\']').after('<span class="error">' + json['error']['pay_city'] + '</span>');
				}
				if (json['error']['pay_postcode']) {
					$('#pay  input[name=\'pay_postcode\']').after('<span class="error">' + json['error']['pay_postcode'] + '</span>');
				}
				if (json['error']['pay_country_id']) {
					$('#pay select[name=\'pay_country_id\']').after('<span class="error">' + json['error']['pay_country_id'] + '</span>');
				}
				if (json['error']['pay_zone_id']) {
					$('#pay select[name=\'pay_zone_id\']').after('<span class="error">' + json['error']['pay_zone_id'] + '</span>');
				}
				//entrega
				if (json['error']['ship_address_1']) {
					$('#ship input[name=\'ship_address_1\']').after('<span class="error">' + json['error']['ship_address_1'] + '</span>');
				}
				if (json['error']['ship_city']) {
					$('#ship input[name=\'ship_city\']').after('<span class="error">' + json['error']['ship_city'] + '</span>');
				}
				if (json['error']['ship_postcode']) {
					$('#ship input[name=\'ship_postcode\']').after('<span class="error">' + json['error']['ship_postcode'] + '</span>');
				}
				if (json['error']['ship_country_id']) {
					$('#ship select[name=\'ship_country_id\']').after('<span class="error">' + json['error']['ship_country_id'] + '</span>');
				}
				if (json['error']['ship_zone_id']) {
					$('#ship select[name=\'ship_zone_id\']').after('<span class="error">' + json['error']['ship_zone_id'] + '</span>');
				}
			}else{
				$.fancybox.close();
			    // Habilitar calculo da st
				$.ajax({
					url: 'index.php?route=checkout/cart/HabilitaCalculost',
					dataType: 'json',
          beforeSend: function() {
    				$('#shipEst').attr('disabled', true);
    				$('#shipEst').addClass('btn-loading');
    			}, 
          success: function(json) {
            location.reload();
          },
					error: function(xhr, ajaxOptions, thrownError) {
            $('#shipEst').attr('disabled', false);
            $('#shipEst').removeClass('btn-loading');
              //verifica se não calculou a ST(se deu algum erro)
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
			    });
			}
		},
	    error: function(xhr, ajaxOptions, thrownError) {
		    alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});



//--></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');
 $('#pay select[name=\'pay_country_id\']').trigger('change');
 $('#ship select[name=\'ship_country_id\']').trigger('change');


//--></script>
<?php } ?>
<script type="text/javascript"><!--
 $(document).ready(function(){

	var verify = '<?php echo $Produto_indisponivel; ?>';
	var  naoexibirmsg = '<?php echo $naoexibir; ?>';
	var html='';

	html+= '<div class="aviso">';
	html+= ' <b>Favor revisar o seu pedido de compras:</b></br>';
	html+= ' </br>Os produtos grifados na cor <span class="msgerror">vermelha</span> não estão';
	html+= ' </br>disponíveis na quantidade desejada, ou já esgotaram.';
	html+= ' </br>Favor editar o pedido alterando a quantidade ou';
	html+= ' </br>excluindo este item da lista para poder prosseguir com a compra.';
	html+= ' </br></br>Em caso de dúvidas, favor entrar em contato com o nosso';
	html+= ' </br>Suporte de Vendas: (11) 2081-6226 ou contato@nipocenter.com.br</br>';
	html+= ' </br> <input type="checkbox" name="naoexibir" value="1"> Não exibir novamente';
	html+= ' </br></br> <input type="submit" class="confirmamsg" name="confirma" value="Confirmar" style="position:relative;left:40%;"/>';
	html+= '</div>';


    if((verify) && (naoexibirmsg==0)){
		$.fancybox({
			opacity     : 0.5,
			maxWidth    : '100%',
			maxHeight   : '100%',
			fitToView   : false,
			width		: '480!important',
			height		: '640!important',
			autoSize    : true,
			closeClick  : false,
			openEffect  : 'none',
			closeEffect : 'none',
			href        : false,
			loop        : false,
			content     : html
		});


		$('.confirmamsg').live('click',function(){
		   // alert($('.aviso input[type=\'checkbox\']:checked').val());
			$.ajax({
				url  : 'index.php?route=checkout/cart/BloqueiaMsg',
				type :'post',
				data : $('.aviso input[type=\'checkbox\']:checked') ,
				success: function(json) {
					$.fancybox.close();
				}
			});
		});
    }
 });
//--></script>
<?php echo $footer; ?>
