<!DOCTYPE html>
<!--[if lt IE 7]><html class="ie6" dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>"><![endif]-->
<!--[if IE 7]><html class="ie7" dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>"><![endif]-->
<!--[if IE 8]><html class="ie8" dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>"><![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>"><!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php echo $title; ?></title>
<base href="<?php echo $base; ?>" />
<!-- Palm -->
<meta name="HandheldFriendly" content="True" />
<!-- Windows -->
<meta name="MobileOptimized" content="320" />
<!-- Safari, Android, BB, Opera -->
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!-- Use the .htaccess and remove these lines to avoid edge case issues. -->

<?php if ($description) { ?>
<meta name="description" content="<?php echo $description; ?>" />
<?php } ?>
<?php if ($keywords) { ?>
<meta name="keywords" content="<?php echo $keywords; ?>" />
<?php } ?>
<?php if ($icon) { ?>
<link href="<?php echo $icon; ?>" rel="icon" />
<?php } ?>
<?php foreach ($links as $link) { ?>
<link href="<?php echo $link['href']; ?>" rel="<?php echo $link['rel']; ?>" />
<?php } ?>


<!--[if lt IE 9]>
	<link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $this->config->get('config_template') ?>/stylesheet/ie8.css" />
<![endif]-->

<?php foreach ($styles as $style) { ?>
<link rel="<?php echo $style['rel']; ?>" type="text/css" href="<?php echo $style['href']; ?>" media="<?php echo $style['media']; ?>" />
<?php } ?>
<!-- Megnor templatemela- Start-->
<?php if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
$http_type = "https:";} else {$http_type = "http:";}
 ?><link href='<?php echo $http_type;?>//fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
 <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>


<?php if($direction=='rtl'){ ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $this->config->get('config_template') ?>/stylesheet/megnor/rtl.css">
<?php }?>
<!--[if lt IE 9]><script type="text/javascript" src="catalog/view/javascript/megnor/html5.js"></script><![endif]-->
<!-- Megnor templatemela- End -->

<!--<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>-->

<!-- Megnor templatemela- End -->

<?php foreach ($scripts as $script) { ?>
<script type="text/javascript" src="<?php echo $script; ?>"></script>
<?php } ?>


<script type="text/javascript">
<?php if ($this->config->get('config_status_analytics_avancado')){ ?>
  var G_AnalyticsHabilitado = true;
<?php }else{ ?>
  var G_AnalyticsHabilitado = false;
<?php } ?>
</script>

<!--[if lt IE 7]>
<script type="text/javascript" src="catalog/view/javascript/DD_belatedPNG_0.0.8a-min.js"></script>
<script type="text/javascript">
DD_belatedPNG.fix('#logo img');
</script>
<![endif]-->
<?php
  if ($this->config->get('config_pixel_facebook_status')=='enable'){
    if (!$this->config->get('config_pixel_facebook')==''){
      echo html_entity_decode($this->config->get('config_pixel_facebook'), ENT_QUOTES, 'UTF-8');
    }
  }
?>

<?php if ($stores) { ?>
<script type="text/javascript"><!--
$(document).ready(function() {<?php foreach ($stores as $store) { ?>$('body').prepend('<iframe src="<?php echo $store; ?>" style="display: none;"></iframe>');<?php } ?>});//--></script>
<?php } ?>

<script type="text/javascript">


jQuery(document).ready(function(){
	jQuery(".cate_bullet").click(function(){
	jQuery(".main-navigation").slideToggle(800);
	$('.cate_inner .title_outer').toggleClass('active');
	});
});

$(document).ready(function(){

	$("#frm_account .password_input, #frm_account").live( "keydown", function(e) {

		if (e.keyCode == 13) {

			$('#login2').trigger('click');

		}

	});

	$( ".cpf, .cnpj" ).live( "click", function() {
		$('input.cpf').mask('999.999.999-99');
		$('input.cnpj').mask('99.999.999/9999-99');
	})

	$( "#logar" ).live( "click", function() {

		if ($("#fisica").is(':checked')) {
			$('.pessoa_juridica2').hide();
			$('.pessoa_fisica2').show();
		}

		if ($("#juridica").is(':checked')) {
			$('.pessoa_fisica2').hide();
			$('.pessoa_juridica2').show();
		}

		$( "#juridica" ).live( "click", function() {
			$('.pessoa_fisica2').hide();
			$('.pessoa_juridica2').show();
		});

		$( "#fisica" ).live( "click", function() {
			$('.pessoa_fisica2').show();
			$('.pessoa_juridica2').hide();
		});

		function validateForm(){
			if($("#fisica").is(":checked")){
				if ( $("#cpf").val() == "" || $("#cpf").val().length < 14)
				{
					$("#cpf").css({"border-color" : "#da251c"});
					$("#msg_cpf").css({"display" : "block"});
					$("#msg_cnpj").css({"display" : "none"});
				}else{
					$("#cpf").css({"border-color" : "#d4d4d4"});
					$("#frm_cad_user").submit();

				}
			}
			//NIPO é somente pessoa juridica//
			else if($("#juridica").is(":checked")){
				if ( $("#cnpj").val() == "" || $("#cnpj").val().length < 18)
				{
					$("#cnpj").css({"border-color" : "#da251c"});
					$("#msg_cnpj").css({"display" : "block"});
				}else{
					$("#cnpj").css({"border-color" : "#d4d4d4"});
					$("#frm_cad_user").submit();

				}
			}
		}

		$('#btn_cad_user').live( "click", function() {
			validateForm();
		});

		var HTML="";

			HTML+='<div id="frm_login">';
			HTML+='<div id="frm_account">';
			HTML+='	<h1>Já sou cliente.</h1>';
			HTML+='		<div class="content">';
			HTML+='  		<p>Digite abaixo seu e-mail e senha já cadastrados na loja.</p>';
			HTML+='  		<b>Seu e-mail:</b><br>';
			HTML+='  		<input type="text" name="email" value="">';
			HTML+='  		<br>';
			HTML+='  		<br>';
			HTML+='  		<b>Sua senha:</b><br>';
			HTML+='  		<input type="password" name="password" class="password_input" value="">';
			HTML+='  		<br>';
			HTML+='  		<a href="index.php?route=account/forgotten"><br>Esqueceu sua senha? Clique aqui para recuperar.</a><br>';
			HTML+='  		<br>';
			HTML+='  		<div id="msg_user"></div>';
			HTML+='  		<input type="submit" value="Entrar" class="button" id="login2">';
			HTML+='		</div>';
			HTML+='		</div>';
			HTML+='<br>';
			HTML+='<div id="frm_cad">';
			HTML+='<h1>Ainda não é Cadastrado?</h1>';
			HTML+='<form id="frm_cad_user" action="index.php?route=account/register" method="post" enctype="multipart/form-data">';
			HTML+='	<div class="content">';
			HTML+='	<p></p>';

			HTML+='<tr>';
			HTML+='<td>';

			<?php if ($fields_register_brazil_tipo_de_pessoa == 'J' ){ ?> // Juridica
			HTML+='<div class="pessoa_juridica2" margin-top:10px;">';
			HTML+='	<b>CNPJ:</b><br>';
			HTML+='	<input type="text" name="cnpj" id="cnpj" class="cnpj" value="">';
			HTML+='</div>';
			<?php } ?>

			HTML+='</tr>';
			HTML+='<tr>';

			<?php if ($fields_register_brazil_tipo_de_pessoa == 'F' ){ ?> // Fisisa
			HTML+='<div class="pessoa_fisica2" style="margin-top:10px;">';
			HTML+='	<b>CPF:</b><br>';
			HTML+='	<input type="text" name="cpf" id="cpf" class="cpf" value="">';
			HTML+='</div>';
			<?php } ?>

			<?php if ($fields_register_brazil_tipo_de_pessoa == 'A' ){ ?> // Ambas
			HTML+='<tr>';
			HTML+='<td>Tipo:</td>';
			HTML+='</tr><br>';
			HTML+='	<input type="radio" name="pessoa" id="fisica" checked value="fisica">Pessoa Física';
			HTML+='	<input type="radio" id="juridica" name="pessoa" value="juridica">Pessoa Juridica';
			HTML+='<div class="pessoa_juridica2" style="display: none; margin-top:10px;">';
			HTML+='	<b>CNPJ:</b><br>';
			HTML+='	<input type="text" name="cnpj" id="cnpj" class="cnpj" value="">';
			HTML+='</div>';
			HTML+='<div class="pessoa_fisica2" style="margin-top:10px;">';
			HTML+='	<b>CPF:</b><br>';
			HTML+='	<input type="text" name="cpf" id="cpf" class="cpf" value="">';
			HTML+='</div>';
			<?php } ?>

			HTML+='</tr>';
			HTML+='</td>';
			HTML+='</tr>';

			HTML+='<input type="hidden" name="cadastro_novo" id="cadastro_novo" value="S">';
			HTML+='<br>';
			HTML+='<span id="msg_cpf" class="error" style="display:none; margin-bottom: 20px;"><b>Atenção: </b>CPF inválido.</span>';
			HTML+='<span id="msg_cnpj" class="error" style="display:none; margin-bottom: 20px;"><b>Atenção: </b>CNPJ inválido.</span>';
			HTML+='<input type="button" id="btn_cad_user" value="Cadastrar" class="button">';
			HTML+='</div>';
			HTML+='</form>';
			HTML+='</div>';
			HTML+='</div>';

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

		});

});

</script>

<div class="menu-stick-base">
	<div class="geral">

		<div id="welcome" style="float:right; margin-left:20px; margin-top:-6px; margin-right:10px; color: #fff; text-align:right;">
			<?php if (!$logged) { ?>
				<?php echo $text_welcome; ?>
					<?php } else { ?>
				<?php echo $text_logged; ?>
			<?php } ?>
		</div>

		<div style="float: right !important; position: relative; top:2px; ">
		<?php echo $cart; ?>
		</div>

		<div id="meus-pedidos" style="float:right; margin-left:0px; margin-right:20px; margin-top:6px;">
			<i class="fa fa-bars" style="margin-right:6px;"></i>
			<a href="index.php?route=account/order">Meus Pedidos</a>
		</div>

		<div id="search" style="float:right; margin-right:20px; margin-top:-3px;">
			<div class="button-search-stick button-search"><?php echo $text_search; ?></div>
			<input type="text" name="search_stick" onClick="this.placeholder = '';" placeholder="<?php echo $text_search; ?>" value="<?php echo $search; ?>" />
		</div>

		<div style="margin-top:12px; margin-left:10px;">
			<a href="<?php echo $home; ?>">
			<img src="catalog/view/theme/OPC070156/image/logo-menu-stick.png" alt=""/>
			</a>
		</div>

	</div>
</div>

<?php echo $google_analytics; ?>

				<?php if ($this->config->get('fields_register_brazil_status')){ ?>
				<script type="text/javascript">
				 $(document).ready(function() {
					/* Registro - Tipo de Pessoa (PF/PJ) */
					if ($("#fisica").is(':checked')) {
						$("#cnpj").val("");
						$("#razao_social").val("");
						$("#inscricao_estadual").val("");
						$('.pessoa_juridica').hide();
						$('.pessoa_fisica').show();
					}
					if ($("#juridica").is(':checked')) {
						$('.pessoa_fisica').hide();
						$("#cpf").val("");
						$("#rg").val("");
						$('.pessoa_juridica').show();
					}
					$('#juridica').click( function() {
					$('.pessoa_fisica').hide();
						$("#cpf").val("");
						$("#rg").val("");
						$('.pessoa_juridica').show();
					});
					$('#fisica').click( function() {
					$('.pessoa_fisica').show();
						$("#cnpj").val("");
						$("#razao_social").val("");
						$("#inscricao_estadual").val("");
						$('.pessoa_juridica').hide();
					});

					/* Mascaras e Formatos */
					if($('input.phone').length > 0) $('input.phone').mask('(99) 9999-9999');
          var SPMaskBehavior = function (val) {
            return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
          },
          spOptions = {
            onKeyPress: function(val, e, field, options) {
                field.mask(SPMaskBehavior.apply({}, arguments), options);
              }
          };

          $('#celular').mask(SPMaskBehavior, spOptions);
					if($('input.date').length > 0) $('input.date').mask('99/99/9999');
					if($('input.cpf').length > 0) $('input.cpf').mask('999.999.999-99');
					if($('input.cnpj').length > 0) $('input.cnpj').mask('99.999.999/9999-99');
					if($('input.alphanumeric').length > 0) $('input.alphanumeric').alphanumeric();
					if($('input.numeric').length > 0) $('input.numeric').numeric();
				});
				</script>
				<?php } ?>

<!-- TemplateMela templatemela - Start -->
<!--[if lt IE 9]><script type="text/javascript" src="catalog/view/javascript/megnor/respond.min.js"></script><![endif]-->
<!-- TemplateMela templatemela - End -->
</head>
<body class="<?php echo $body_class; ?>" data-login="<?php echo ($logged) ? 'true' : 'false' ?>"  itemscope itemtype="http://schema.org/WebPage">
<div id="container">

<header id="header-container">
<?php echo $newsletter; ?>
<div class="header_top">
	<div class="header_inner">
		<?php echo $language; ?>
		<?php echo $currency; ?>

		<div id="welcome">
				<?php if (!$logged) { ?>
						<?php echo $text_welcome; ?>
					<?php } else { ?>
						<?php echo $text_logged; ?>
					<?php } ?>
	   </div>

	   </div>
</div>

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

	<div id="header_geral">
		<div id="header">
			<div class="header-left">  <!--megnor 'header-left' start -->

					<!--megnor added -->
			<div class="tm_headerlinkmenu">
					<div class="tm_headerlinks_inner"><div class="headertoggle_img">&nbsp;</div></div>
					<ul class="header_links">
					 <li><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a></li>
                                         <li><a href="index.php?route=account/order">Meus Pedidos</a></li>
					 <li><a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a></li>
					</ul>
			</div>

				<?php if ($logo) { ?>
					<a href="<?php echo $home; ?>"><div id="logo"></div></a>
				<?php } ?>



			</div>  <!--megnor 'header-left' end -->
			<div class="header-right">  <!--megnor 'header-right' start -->


		<div class="custom_header_main">
			<div class="custom_header_inner">
				<?php //echo $header_block; ?>
			</div>
		</div>


			   <div class="welcome-links">
					<div class="links">
						<a href="<?php echo $account; ?>"><?php echo $text_account; ?></a>
						<a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a>
					</div>

				</div>

				<div class="cart-stick">
					<?php echo $cart; ?>
				</div>

				<div class="contact_banner">
				<ul>
				<?php if ($this->config->get('config_inf_telefone')){ ?>
					<li><i class="fa fa-phone-square" aria-hidden="true"></i><?php echo $this->config->get('config_inf_telefone')?></li>
				<?php }?>
				<?php if (($this->config->get('config_inf_email'))&&($this->config->get('config_inf_status_email')=='enable')){ ?>
					<li><i class="fa fa-envelope" aria-hidden="true"></i></i><?php echo $this->config->get('config_inf_email');?></li>
				<?php }?>
				</ul>
				</div>

				<div id="meus-pedidos">
				<i class="fa fa-bars" style="margin-right:6px;"></i>
				<a href="index.php?route=account/order">Meus Pedidos</a>
			   </div>

				<div id="search">
					<div class="button-search"><?php echo $text_search; ?></div>
					<input type="text" name="search" onClick="this.placeholder = '';" placeholder="<?php echo $text_search; ?>" value="<?php echo $search; ?>" />
				</div>


			<div class="info_link">
				<ul>
					<?php foreach (array_slice($informations, 0, 3) as $information) { ?>
					<li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
					<?php } ?>
				</ul>
			</div>

			</div> <!--megnor 'header-right' end -->
		</div>
	</div>
</header>

  <?php if ($categories) { ?>
 <!--  =============================================== Mobile menu start  =============================================  -->
<div id="res-menu" class="main-menu nav-container1">
<div id="res-menu1" class="main-menu1 nav-container2">
	<div class="nav-responsive"><span>Menu</span><div class="expandable"></div></div>
    <ul class="main-navigation">
      <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>

        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
				<li>
				<?php if(count($category['children'][$i]['children'])>0){ ?>
					<a href="<?php echo $category['children'][$i]['href']; ?>" class="activSub" <?php echo $category['children'][$i]['id']; ?>><?php echo $category['children'][$i]['name'];?></a>
				<?php } else { ?>
					<a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a>
				<?php } ?>

				<?php if ($category['children'][$i]['children']) { ?>
				<ul>
				<?php for ($wi = 0; $wi < count($category['children'][$i]['children']); $wi++) { ?>
					<li><a href="<?php echo $category['children'][$i]['children'][$wi]['href']; ?>"  ><?php echo $category['children'][$i]['children'][$wi]['name']; ?></a></li>
				 <?php } ?>
				</ul>
			  <?php } ?>
			</li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>

      <?php } ?>
    </li>
    <?php } ?>
    </ul>
	</div>
</div>

<!--  ================================ Mobile menu end   ======================================   -->


<!-- ================================ Start Navigation =================== -->



<nav class="nav-container" role="navigation">



<div id="menu" class="main-menu">

<div class="nav-responsive"><span>Menu</span><div class="expandable"></div></div>
<div class="cate_inner">
<div class="title_outer">
		<p id="left_categorytitle" class="title_block">
			<span class="cat_title">Categorias</span>
		</p>
		</div>
	</div>
	<ul class="main-navigation">

	<div class="box treeview-list treeview" style="background-color: #f6f6f6 !important;">

    <?php foreach ($categories as $category_1) { ?>
      <li>
        <a href="<?php echo $category_1['href']; ?>" style="font-weight:600;"><?php echo $category_1['name']; ?></a>

        <ul>
		  <?php foreach ($category_1['children'] as $category_2) { ?>
          <li style="padding-top:8px !important; padding-bottom:0px !important;">
            <?php if($category['children']) { ?>
            <a href="<?php echo $category_2['href']; ?>" class="active"><?php echo $category_2['name']; ?></a>
            <?php } else { ?>
            <a href="<?php echo $category_2['href']; ?>"><?php echo $category_2['name']; ?></a>
            <?php } ?>
          </li>
          <?php } ?>
        </ul>
      </li>

	  <?php } ?>
    	</div>
	</ul>




</div>



</nav>

<?php } ?>




<!-- ================================ END Navigation =================== -->

<!-- section code start -->
<section id='content-wrapper'>

<div class="content-inner">

<?php if ($error) { ?>
<div class="warning"><?php echo $error ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
<?php } ?>

<div id="notification"></div>
<?php if ($customer_interests_remember) { ?>
  <div class="ft-overlay ft-overlay-black-3">
    <div class="ft-center-middle-fixed ft-rounded-medium ft-background-light ft-padding-large ft-rel" style="max-height: 80%; max-width: 80%; overflow: auto;">
      <a href="index.php?route=account/interests/remember&remember=1" class="ft-padding-small ft-margin-medium js-remember" style="position: absolute; top: 0; right: 0;"><i class="fa fa-close"></i></a>
      <form action="index.php?route=account/interests/insert&modal=true" method="post" class="interests-form">
        <h1 class="js-title-interests">
          Defina suas áreas de interesse
        </h1>
        <hr class="ft-vertical-margin-large">
        <?php echo $interests_categories ?>
        <hr class="ft-vertical-margin-large">
        <div class="ft-flex between-xs middle-xs">
          <div>
            <a href="index.php?route=account/interests/remember&remember=1" class="js-remember">Lembre-me depois</a>
            <span> | </span>
            <a href="index.php?route=account/interests/remember&remember=0" class="js-remember">Não me lembre mais</a>
          </div>
          <div>
            <button type="submit" class="js-btn-interests" style="padding: 8px 16px; font-size: 16px; cursor: pointer; color: #FFFFFF; background: #0CAD5F; border: 1px solid #0B9956; border-radius: 5px;">Salvar</button>
          </div>
        </div>
      </form>
    </div>
  </div>
  <script>
  $(document).ready(function(){
    function removeInterestsPopUp(result) {
    console.log(result);
      if (result == '1') {
        $('.ft-overlay').remove();
      } else {
        $('.ft-text-error').remove();
        $('.js-title-interests').after('<span class="ft-text-error ft-border-error ft-padding-small ft-rounded-small ft-full-width ft-visible-block ft-text-center" style="box-sizing: border-box;">Erro ao salvar áreas de interesse!</span>')
      }
    }
    $('.interests-form').on('submit', function(e){
      e.preventDefault();

      $.ajax({
        method: $(this).attr('method'),
        url: $(this).attr('action'),
        data: $(this).serialize()
      })
      .done(function(result) {
        removeInterestsPopUp(result);
      })
      .fail(function() {
        console.log( "error" );
      });
    });

    $('.js-remember').on('click', function(e){
      e.preventDefault();

      $.ajax({
        method: 'get',
        url: $(this).attr('href'),
      })
      .done(function(result) {
      console.log(result);
        removeInterestsPopUp(result);
      })
      .fail(function() {
        console.log( "error" );
      });
    });
  });
  </script>
<?php } ?>
