  <h1><?php echo $heading_title; ?></h1>
  <p><?php echo $text_account_already; ?></p>
  <form action="" method="post" enctype="multipart/form-data" id="cadCliente">
    <h2><?php echo $text_your_details; ?></h2>
    <div id="dados-pessoais" style="width:750px; min-width:60%;">
      <table class="form" > 
        <tr>
          <td><span class="required">*</span> <?php echo $entry_firstname; ?></td>
		</tr>
        <tr>		
          <td><input type="text" name="firstname" value="<?php echo $firstname; ?>"  maxlength="32"/> </td>
        </tr>
        <tr>
          <td><span class="required">*</span> <?php echo $entry_lastname; ?>
		  </td>
		</tr>
        <tr>		
          <td><input type="text" name="lastname" value="<?php echo $lastname; ?>" maxlength="32" /></td>
        </tr>
		<tr>
		    <td><span class="required">*</span> Sexo:</td>
		</tr>
        <tr> 		
			<td>
			     <?php if ($sexo == 'm'){ ?>
					<input type="radio" name="sexo" checked value="m">Masculino
					<input type="radio" name="sexo" value="f">Feminino
					<?php }else if($sexo == 'f'){ ?>
					<input type="radio" name="sexo" value="m">Masculino
					<input type="radio" name="sexo" checked value="f">Feminino
					<?php }else{ ?>
					<input type="radio" name="sexo" checked value="m">Masculino
					<input type="radio" name="sexo" value="f">Feminino
					<?php } ?>
		    </td>
		</tr>
		<tr></td>
		</tr>
		<tr>
		  <td>Data de Nascimento:</td>
		</tr>
        <tr>   
			<?php 
			$dataparts = explode("-",$data_nascimento);
			if (sizeof($dataparts) != '3'){
			    $data = $data_nascimento;
			}else{
			      $data = $dataparts[2]."/".$dataparts[1]."/".$dataparts[0]; 
			}
			$data = ($data != '00/00/0000') ? $data : '';
			?>
			<td><input type="text" name="data_nascimento" id="data" value="<?php echo $data; ?>" class="date" /></td>
		</tr>
	  </table>
    </div>
	
	 <h2>Pessoa Jurídica</h2>
    <div class="content" id="jur">
     <table class="form">
     <tr>
		 <td><span class="required">*</span> Perfil:</td>
	 </tr>
           <tr>  
				<td>
				    <?php if($perfil == '0'){ ?>
					<input type="radio" name="perfil" id="nenhum" checked value="0">Nenhum
					<input type="radio" name="perfil" id="lucropresumidoRPA" value="1">Lucro Presumido/RPA
					<input type="radio" name="perfil" id="simplesnacional" value="2">Simples nacional
					<input type="radio" name="perfil" id="lucroreal" value="3">Lucro Real
					<?php }else if($perfil == '1'){ ?>
					<input type="radio" name="perfil" id="nenhum"  value="0">Nenhum
					<input type="radio" name="perfil" id="lucropresumidoRPA" checked value="1">Lucro Presumido/RPA
					<input type="radio" name="perfil" id="simplesnacional" value="2">Simples nacional
					<input type="radio" name="perfil" id="lucroreal" value="3">Lucro Real
					<?php }else if($perfil == '2'){ ?>
					<input type="radio" name="perfil" id="nenhum"  value="0">Nenhum
					<input type="radio" name="perfil" id="lucropresumidoRPA"  value="1">Lucro Presumido/RPA
					<input type="radio" name="perfil" id="simplesnacional" checked value="2">Simples nacional
					<input type="radio" name="perfil" id="lucroreal"  value="3">Lucro Real
					<?php }else{ ?>
					<input type="radio" name="perfil" id="nenhum"  value="0">Nenhum
					<input type="radio" name="perfil" id="lucropresumidoRPA" alue="1">Lucro Presumido/RPA
					<input type="radio" name="perfil" id="simplesnacional" value="2">Simples nacional
					<input type="radio" name="perfil" id="lucroreal" checked value="3">Lucro Real
					<?php } ?>
		    </td>
		</tr>
				  
		
        </table>
    </div>
		
	<h2>Endereço de Faturamento</h2>
    
    <div class="content" id="pay">
      <table class="form">
        <tr>
          <td><?php echo $entry_local; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="pay_local" value="<?php echo $pay_local; ?>" /> (Ex: Casa, Trabalho, etc)</td>
		</tr>    
        
        <tr>
          <td><span class="required">*</span> <?php echo $entry_address_1; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="pay_address_1" value="<?php echo $pay_address_1; ?>" maxlength="128" /></td>
        </tr>
		<tr>
		  <td><span class="required">*</span> Número:</td>
		</tr>
        <tr>   
		  <td><input type="text" name="pay_numero"  id="pay_numero" value="<?php echo $pay_numero; ?>" class="large-field numeric" maxlength="6" /><span class="field-info">&nbsp;(apenas números, sem pontos ou traços)</span></td></td>		
		</tr>
		
		<tr>
	     <td>Complemento:</td>
		</tr>
        <tr>  
		 <td><input type="text" name="pay_complemento" value="<?php echo $pay_complemento; ?>" class="large-field" maxlength="128"/><span class="field-info">&nbsp;(Ex: Ap. 105)</span></td>
	    </tr>
		
        <tr>
          <td><?php echo $entry_address_2; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="pay_address_2" value="<?php echo $pay_address_2; ?>" maxlength="128"/></td>
        </tr>
        <tr>
          <td><span class="required">*</span> <?php echo $entry_city; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="pay_city" value="<?php echo $pay_city; ?>" maxlength="128"/></td>
        </tr>
        <tr>
          <td><span id="postcode-required" class="required">*</span> <?php echo $entry_postcode; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="pay_postcode" value="<?php echo $pay_postcode; ?>" class="large-field js-mask-postcode" maxlength="10"/></td>
        </tr>
        <tr>
          <td><span class="required">*</span> <?php echo $entry_country; ?></td>
		</tr>
		<tr>
           
          <td><select name="pay_country_id" class='paypais'>
              <option value=""><?php echo $text_select; ?></option>
      
			  
		
		<?php foreach ($countries as $country) { ?>
         
			  <?php if ($country['country_id'] == $pay_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></td>
        </tr>
        <tr>
          <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
		</tr>
        <tr>   
          <td><select name="pay_zone_id">      </select></td>
        </tr>
      </table>
    </div>
	
	<?php if($entrega == 1){ ?>
	
	 <h2>Endereço de Entrega</h2>
       
    <div class="content" id="ship">
      <table class="form">
        <tr>
          <td><?php echo $entry_local; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="ship_local" value="<?php echo $ship_local; ?>" /> (Ex: Casa, Trabalho, etc)</td>
		</tr>    
        <tr>
          <td><span class="required">*</span> <?php echo $entry_address_1; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="ship_address_1" value="<?php echo $ship_address_1; ?>" maxlength="128"/></td>
        </tr>
		<tr>
		  <td><span class="required">*</span> Número:</td>
		</tr>
        <tr>   
		  <td><input type="text" name="ship_numero" id="ship_numero" value="<?php echo $ship_numero; ?>" class="large-field numeric" maxlength="6"/><span class="field-info">&nbsp;(apenas números, sem pontos ou traços)</span></td>
		</tr>
		
		<tr>
	     <td>Complemento:</td>
		</tr>
        <tr>  
		 <td><input type="text" name="ship_complemento" value="<?php echo $ship_complemento ?>" class="large-field" maxlength="128"/><span class="field-info">&nbsp;(Ex: Ap. 105)</span></td>
	    </tr>
		
        <tr>
          <td><?php echo $entry_address_2; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="ship_address_2" value="<?php echo $ship_address_2; ?>" maxlength="128"/></td>
        </tr>
        <tr>
          <td><span class="required">*</span> <?php echo $entry_city; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="ship_city" value="<?php echo $ship_city; ?>" maxlength="128"/></td>
        </tr>
        <tr>
          <td><span id="postcode-required" class="required">*</span> <?php echo $entry_postcode; ?></td>
		</tr>
        <tr>   
          <td><input type="text" name="ship_postcode" value="<?php echo $ship_postcode; ?>" class="large-field js-mask-postcode" maxlength="10"/></td>
        </tr>
        <tr>
          <td><span class="required">*</span> <?php echo $entry_country; ?></td>
		</tr>
        <tr>   
          <td><select name="ship_country_id">
              <option value=""><?php echo $text_select; ?></option>
           
			 
			 <?php foreach ($countries as $country) { ?>
              <?php if ($country['country_id'] == $ship_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></td>
        </tr>
        <tr>
          <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
		</tr>
        <tr>   
          <td><select name="ship_zone_id">
		 </tr>
        <tr>  
		  </select></td>
        </tr>
      </table>
    </div>
	
	<?php } ?>
    
    <h2><?php echo $text_newsletter; ?></h2>
    <div class="content">
      <table class="form">
        <tr>
          <td><?php echo $entry_newsletter; ?></td>
          <td><?php if ($news) { ?>
            <input type="radio" name="news" value="1" checked="checked" />
            <?php echo $text_yes; ?>
            <input type="radio" name="news" value="0" />
            <?php echo $text_no; ?>
            <?php } else { ?>
            <input type="radio" name="news" value="1" />
            <?php echo $text_yes; ?>
            <input type="radio" name="news" value="0" checked="checked" />
            <?php echo $text_no; ?>
            <?php } ?></td>
        </tr>
      </table>
    </div>
    <?php if ($text_agree) { ?>
    <div class="buttons" id="tagree" style="line-height:280%;">
      <div class="right"><div class="left" style="margin-right:4px;"><?php echo $text_agree; ?></div>
        <?php if ($agree) { ?>
        <input type="checkbox" name="agree" value="1" checked="checked" />
        <?php } else { ?>
        <input type="checkbox" name="agree" value="1" />
        <?php } ?>
        <input type="button" value="<?php echo $button_continue; ?>" class="button" id="button-confirmacao-cadastro" name="botao" />
      </div>
    </div>
    <?php } else { ?>
    <div class="buttons">
      <div class="right">
        <input type="button" value="<?php echo $button_continue; ?>" class="button" id="button-confirmacao-cadastro"/>
      </div>
    </div>
    <?php } ?>
  </form>
  <?php echo $content_bottom; ?></div>

<script type="text/javascript"><!--
/*$("#button-confirmacao-cadastro").click(function(){
   //var dados = $('#cadCliente').serialize(); 	
  // alert(dados);
  // $('#cadCliente').submit();
});*/



$('select[name=\'pay_country_id\']').bind('change', function() {
	$.ajax({
		url: 'index.php?route=account/register/country&country_id=' + this.value,
		dataType: 'json',
		beforeSend: function() {
			$('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>';
			}
			
			$('select[name=\'pay_zone_id\']').html(html);
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});


$('select[name=\'ship_country_id\']').bind('change', function() {
  
	$.ajax({
		url: 'index.php?route=account/register/country&country_id=' + this.value,
		dataType: 'json',
		beforeSend: function() {
			$('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>';
			}
			
			$('select[name=\'ship_zone_id\']').html(html);
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});


$('select[name=\'pay_country_id\']').trigger('change');
$('select[name=\'ship_country_id\']').trigger('change');

//--></script> 
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.politica').live('click',function(){
		var url= '<?php echo $agree_Politica_privacidade; ?>';
    
		$.ajax({    
			url : url ,
			dataType: 'HTML',
			success : function(html){
				$.fancybox({
				    minheigh    : '50%',//'480',
					minWidth    : '50%',//'640',
					opacity     : 0.5,
					fitToView   : false,
					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);
            }			
	    });	
    });
	

	if($('input.numeric').length > 0) {
	    $('input.numeric').numeric();
    }
	
	$("#data").mask("99/99/9999");
});
//--></script> 
