deivisonarthur
7/3/2013 - 1:01 AM

troque o arquivo /app/design/frontend/base/default/template/onepagecheckout/onepage/billing.phtml

troque o arquivo /app/design/frontend/base/default/template/onepagecheckout/onepage/billing.phtml

<?php
/*=========================================================================================================================================================
 *
 *  PROJETO OSC MAGENTO BRASIL - VERSÃO FINAL V3.0
 *  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *  O módulo One Step Checkout normatizado para a localização brasileira.
 *  site do projeto: http://onestepcheckout.com.br/
 *  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *
 *
 *
 *  Mmantenedores do Projeto:
 *  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *
 *  Deivison Arthur Lemos Serpa
 *  deivison.arthur@gmail.com
 *  www.deivison.com.br
 *  (21)9203-8986
 *
 *  Denis Colli Spalenza
 *  http://www.xpdev.com.br
 *
 *  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *
 *
 *
 *  GOSTOU DO MÓDULO?
 *  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *  Se você gostou, se foi útil para você, se fez você economizar aquela grana pois estava prestes a pagar caro por aquele módulo pago, pois não achava uma
 *  solução gratuita que te atendesse e queira prestigiar o trabalho feito efetuando uma doação de qualquer valor, não vou negar e vou ficar grato! você
 *  pode fazer isso visitando a página do projeto em: http://onestepcheckout.com.br/
 *  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *
/*=========================================================================================================================================================
 */

$logged  	= $this->isCustomerLoggedIn();
$has_addr	= $this->customerHasAddresses();

?>
<?php $this->setShowAddressFields(true);?>

<div class="onepagecheckout_block">
    <div class="op_block_title">
		<?php	echo $this->__('Name & Address');	?>
    </div>
    <div class="form_fields">
    <?php if ($has_addr){ ?>
        <div class="full">
            <label for="billing_cutomer_address">
            	<?php echo $this->__('Select a billing address from your address book or enter a new address.') ?>
            </label>
            <div class="data_area">
                <?php echo $this->getCustomerBillAddr() ?>
            </div>
        </div>
    <?php } ?>
	    <div id="bill_form"<?php if ($has_addr) {echo ' style="display:none;" ';} ?>>
			<input type="hidden" name="billing[address_id]" id="billing:address_id" value="<?php echo $this->getBillAddress()->getId() ?>" />


           <!-- Start Logged ###########################################################################################-->
           <!-- START CAMPOS DO CADASTRO ###########################################################################################-->



           <!--
                NOME, SOBRENOME E EMAIL  -----------------------------------------
           -->
            <?php if (!$logged)  : ?>
			<div class="two_fields">
				<?php echo $this->getLayout()->createBlock('onepagecheckout/widget_name')->setObject($this->getCustomer())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
			</div>
			<div class='clr'></div>
				<div class="full">
					<label for="billing:email" class="required">
						<?php echo $this->__('Email Address') ?>
					</label>
					<sup>*</sup>
					<div class="data_area">
						<input type="text" name="billing[email]" value="<?php echo $this->htmlEscape($this->getCustomer()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="t1 validate-email required-entry" />
					</div>
				</div>



           <!--
                BLOCO TIPO PESSOA -----------------------------------------
           -->
                    <div style="clear: both; height: 0px;" ></div>
                      <?php
          			$tipopessoa = Mage::getStoreConfig('onepagecheckout/billing/tipopessoa');
          			if ($tipopessoa !== 'hidden') :
                      ?>

                	 	<?php
                	 		$attribute = Mage::getModel('eav/config')->getAttribute('customer','tipopessoa');
                	 	?>
                          <ul style="list-style: none">

                              <li style="float: left" class="editando">
                                      <label style="padding-left: 0px" for="persona_pf" <?php if ( $tipopessoa  === 'required' ){ echo 'class="required"'; }?>>Pessoa F&iacute;sica<input type="radio" style="margin-left: 5px" name="billing[tipopessoa]" id="persona_pf" value="Fisica" checked="" title="Pessoa Fisica" <?php if ( $tipopessoa  === 'required' ){ echo 'class="required"'; }?> ></label>
                              </li>
                              <li>
                                      <label style="padding-left: 15px" for="persona_pj" <?php if ( $tipopessoa  === 'required' ){ echo 'class="required"'; }?>>Pessoa Jur&iacute;dica<input type="radio" style="margin-left: 5px" name="billing[tipopessoa]" id="persona_pj" value="Juridica" title="Pessoa Juridica" <?php if ( $tipopessoa  === 'required' ){ echo 'class="required"'; }?> ></label>
                              </li>


                              <script type="text/javascript">
                              //<![CDATA[
                                      <?php
                                        $tipoPessoa = $this->htmlEscape($this->getCustomer()->getTipopessoa());
                                        if (!$tipoPessoa) $tipoPessoa = 'Fisica';  //ccd: conserta default errado no IE
                                      ?>
                                      $j('input[value*="<?php echo $tipoPessoa;?>"]').attr('checked', true);
                              //]]>
                              </script>

                          </ul>
                      <?php endif; ?>
                      <br style="clear: both" />



           <!--
                BLOCO IDENTIDADE E CPF -----------------------------------------
           -->
            <div class="two_fields boxpf"> <!-- START -->
                     <!--
                          BLOCO IDENTIDADE -----------------------------------------
                     -->
                      <?php
            			$identidade = Mage::getStoreConfig('onepagecheckout/outrasopcoes/rgiregistro');
            			if ($identidade !== 'hidden') : ?>
                          <div class="short">
          	                <label <?php if ( $identidade  === 'required' ){ echo 'class="required"'; }?> >
                            <?php echo $this->__('Identidade') ?>
                            <?php
                              if($identidade === 'required') {
                                echo ' <sup>*</sup> ';
                              }else{
                                echo ' <sup>&nbsp;</sup> ';
                              }
                              ?>
                          </label>
                              <div class="data_area">
                                  <input type="text" name="billing[rg]" id="rg"  value="<?php echo $this->htmlEscape($this->getCustomer()->getRg()) ?>" title="<?php echo $this->__('Identidade'); ?>" class="input-text t1 validate-number <?php if($identidade === 'required'){ echo ' required-entry';} ?>" />
                              </div>
                          </div>
                      <?php endif; ?>
                     <!--
                          BLOCO CPF -----------------------------------------
                     -->
                      <?php
            			$cpfcnpj = Mage::getStoreConfig('onepagecheckout/outrasopcoes/cpfcnpjregistro');
            			if ($cpfcnpj !== 'hidden') : ?>
                          <div class="short">
          	                <label <?php if ( $cpfcnpj  === 'required' ){ echo 'class="required"'; }?> >
                            <?php echo $this->__('CPF') ?>
                            <?php
                              if($cpfcnpj === 'required') {
                                echo ' <sup>*</sup> ';
                              }else{
                                echo ' <sup>&nbsp;</sup> ';
                              }
                              ?>
                            </label>
                              <div class="input-box">
                                  <input type="text" id="cpfcnpj" name="billing[cpfcnpj]"  value="<?php echo $this->htmlEscape($this->getCustomer()->getCpfcnpj()) ?>"  title="<?php echo $this->__('CPF'); ?>" class="input-text t1 Binputcpf validar_cpf <?php if($cpfcnpj === 'required'){ echo ' required-entry';} ?>" />
                              </div>
                          </div>
                      <?php endif; ?>


                      <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
                      <?php
            			if ($_taxvat->isEnabled() && $cpfcnpj === 'hidden'): ?>
                          <div class="short">
          	                <label class="required" >
                            <?php echo $this->__('CPF') ?>
                            <sup>*</sup>
                          </label>
                              <div class="input-box">
                                  <input type="text" style="width: 109px !important" id="taxvat" name="billing[taxvat]"  value="<?php echo $this->htmlEscape($this->getCustomer()->getTaxvat()) ?>"  title="<?php echo $this->__('CNPJ'); ?>" class="input-text t1  validar_cpf required-entry" />
                              </div>
                          </div>                                                                                                                                                                                                                                   <!--Binputcpf-->
                      <?php endif; ?>
            </div> <!-- END -->





           <!--
                BLOCO DT NASCIMENTO E SEXO -----------------------------------------
           -->
           <div class="two_fields boxpf"> <!-- START -->
                     <!--
                          BLOCO DT NASCIMENTO -----------------------------------------
                     -->
                      <?php $dob = $this->getLayout()->createBlock('onepagecheckout/widget_dob'); ?>
                      <?php if ($dob->isEnabled()): ?>
                                  <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
                                  <?php if ($_dob->isEnabled()): ?>
                                      <div class="short" style="margin-bottom: 0px !important">
                                          <?php echo $dob->setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml();  ?>
                                      </div>
                                  <?php endif ?>
                      <?php endif ?>
                     <!--
                          BLOCO SEXO -----------------------------------------
                     -->
                      <?php $gender	= $this->getLayout()->createBlock('onepagecheckout/widget_gender'); ?>
                      <?php if ($gender->isEnabled()): ?>
                                  <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
                                  <?php if ($_gender->isEnabled()): ?>
                                      <div class="short" style="margin-bottom: 0px !important">
                                          <?php echo $gender->setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml();  ?>
                                      </div>
                                  <?php endif ?>
                      <?php endif ?>
            </div> <!-- END -->




           <!--
                BLOCO CNPJ E IE -----------------------------------------
           -->
            <div class="two_fields boxpj" style="display: none"> <!-- START -->
                     <!--
                          IF BLOCO CNPJ -----------------------------------------
                     -->
                      <?php
            			$cpfcnpj = Mage::getStoreConfig('onepagecheckout/outrasopcoes/cpfcnpjregistro');
            			if ($cpfcnpj !== 'hidden') : ?>
                          <div class="short">
          	                <label <?php if ( $cpfcnpj  === 'required' ){ echo 'class="required"'; }?> >

                            <?php echo $this->__('CNPJ') ?>
                            <?php
                              if($cpfcnpj === 'required') {
                                echo ' <sup>*</sup> ';
                              }else{
                                echo ' <sup>&nbsp;</sup> ';
                              }
                              ?>
                          </label>
                              <div class="input-box">
                                  <input type="text" style="width: 109px !important" id="cpfcnpj" name="billing[cpfcnpj]"  value="<?php echo $this->htmlEscape($this->getCustomer()->getCpfcnpj()) ?>"  title="<?php echo $this->__('CNPJ'); ?>" class="input-text t1 Binputcnpj validar_cpf2 <?php if($cpfcnpj === 'required'){ echo ' required-entry';} ?>" />
                              </div>
                          </div>
                      <?php endif; ?>
                     <!--
                          IF BLOCO TAXVAT -----------------------------------------
                     -->
                      <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>  
                      <?php
            			if ($_taxvat->isEnabled() && $cpfcnpj === 'hidden'): ?>
                          <div class="short">
          	                <label class="required" >
                            <?php echo $this->__('CNPJ') ?>
                            <sup>*</sup>
                          </label>
                              <div class="input-box">
                                  <input type="text" style="width: 109px !important" id="taxvat" name="billing[taxvat]"  value="<?php echo $this->htmlEscape($this->getCustomer()->getTaxvat()) ?>"  title="<?php echo $this->__('CNPJ'); ?>" class="input-text t1  validar_cpf2 required-entry" />
                              </div>
                          </div>                                                                                                                                                                                                                                   <!--Binputcnpj-->
                      <?php endif; ?>



                     <!--
                          IF BLOCO IE -----------------------------------------
                     -->
                    <?php
        			$ie = Mage::getStoreConfig('onepagecheckout/outrasopcoes/ieregistro');
        			if ($ie !== 'hidden') : ?>
                        <div class="short">
        	                <label <?php if ( $ie  === 'required' ){ echo 'class="required"'; }?> >
                            <?php echo $this->__('IE') ?>
                            <?php
                            if($ie === 'required') {
                              echo ' <sup>*</sup> ';
                            }else{
                              echo ' <sup>&nbsp;</sup> ';
                            }
                            ?>
                          </label>
                            <div class="input-box">
                                <input type="text" style="width: 115px !important" for="isento" name="billing[ie]" id="ie"  value="<?php echo $this->htmlEscape($this->getCustomer()->getIe()) ?>"   title="<?php echo $this->__('IE (Inscri&ccedil;&atilde;o Estadual)'); ?>" class="input-text t1 validate-alphanum <?php if($ie === 'required'){ echo ' required-entry';} ?>" />
                            </div>
                            <div class="control">
                                <div class="input-box">
                                        <label for="isento"><input type="checkbox" name="isento" title="Isento?" value="1" id="isento" class="checkbox">Isento?</label>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>
            </div> <!-- END -->




           <!--
                BLOCO RAZÃO SOCIAL E NOME FANTASIA -----------------------------------------
           -->
            <div class="two_fields boxpj" style="display: none">  <!-- START -->
                     <!--
                          IF BLOCO EMPRESA -----------------------------------------
                     -->
                      <?php
          			$company = Mage::getStoreConfig('onepagecheckout/outrasopcoes/empresaregistro');
          			if ($company !== 'hidden') : ?>
                          <div class="short">
          	                <label <?php if ( $company  === 'required' ){ echo 'class="required"'; }?> >

                              <?php echo $this->__('Raz&atilde;o Social') ?>
                            <?php
                              if($company === 'required') {
                                echo ' <sup>*</sup> ';
                              }else{
                                echo ' <sup>&nbsp;</sup> ';
                              }
                              ?>
                            </label>
                              <div class="input-box">
                                  <input type="text" style="width: 109px !important" name="billing[empresa]" id="empresa"  value="<?php echo $this->htmlEscape($this->getCustomer()->getEmpresa()) ?>"  title="<?php echo $this->__('Raz&atilde;o Social'); ?>" class="input-text t1 <?php if($company === 'required'){ echo ' required-entry';} ?>" />
                              </div>
                          </div>
                      <?php endif; ?>
                     <!--
                          IF BLOCO NOME FANTASIA -----------------------------------------
                     -->
                      <?php
          			$company2 = Mage::getStoreConfig('onepagecheckout/outrasopcoes/nomefantasiaregistro');
          			if ($company2 !== 'hidden') : ?>
                          <div class="short">
          	                <label <?php if ( $company2  === 'required' ){ echo 'class="required"'; }?> >
                              <?php echo $this->__('Nome Fantasia') ?>
                                <?php
                              if($company2 === 'required') {
                                echo ' <sup>*</sup> ';
                              }else{
                                echo ' <sup>&nbsp;</sup> ';
                              }
                              ?>
                            </label>
                              <div class="input-box">
                                  <input type="text" style="width: 115px !important" name="billing[nomefantasia]" id="nomefantasia"  value="<?php echo $this->htmlEscape($this->getCustomer()->getNomefantasia()) ?>"  title="<?php echo $this->__('Nome Fantasia'); ?>" class="input-text t1 <?php if($company2 === 'required'){ echo ' required-entry';} ?>" />
                              </div>
                          </div>
                      <?php endif; ?>
            </div> <!-- END -->




            <div class="clr"></div>
            <?php else: ?>
                <input type="hidden" name="billing[address_id]" value="<?php echo $this->getBillAddress()->getId() ?>" />
                <input type="hidden" name="billing[firstname]" value="<?php echo $this->htmlEscape($this->getCustomer()->getFirstname()) ?>"/>
                <input type="hidden" name="billing[lastname]" value="<?php echo $this->htmlEscape($this->getCustomer()->getLastname()) ?>"/>
                <input type="hidden" name="billing[tipopessoa]" value="<?php echo $this->htmlEscape($this->getCustomer()->getTipopessoa()) ?>"/>
                <input type="hidden" name="billing[rg]" value="<?php echo $this->htmlEscape($this->getCustomer()->getRg()) ?>"/>
                <input type="hidden" name="billing[cpfcnpj]" value="<?php echo $this->htmlEscape($this->getCustomer()->getCpfcnpj()) ?>"/>
                <input type="hidden" name="billing[taxvat]" value="<?php echo $this->htmlEscape($this->getCustomer()->getTaxvat()) ?>"/>
                <input type="hidden" name="billing[ie]" value="<?php echo $this->htmlEscape($this->getCustomer()->getIe()) ?>"/>
                <input type="hidden" name="billing[empresa]" value="<?php echo $this->htmlEscape($this->getCustomer()->getEmpresa()) ?>"/>
                <input type="hidden" name="billing[nomefantasia]" value="<?php echo $this->htmlEscape($this->getCustomer()->getNomefantasia()) ?>"/>
            <?php endif; ?>
            <!-- END IF LOGGED ###########################################################################################-->
            <!-- END CAMPOS DO CADASTRO ###########################################################################################-->





           <!--
                BLOCO RAZÃO SOCIAL E NOME FANTASIA -----------------------------------------
           -->
			<?php
			$phone_r= Mage::getStoreConfig('onepagecheckout/address_form/phone');
			$fax_r	= Mage::getStoreConfig('onepagecheckout/address_form/fax');
			$celular	= Mage::getStoreConfig('onepagecheckout/address_form/celular');
			?>

            <?php if ($phone_r !== 'hidden' || $fax_r !== 'hidden' ) : ?>
            <div class="two_fields">
                         <!--
                              IF BLOCO TELEFOENE -----------------------------------------
                         -->
        				<?php if ($phone_r !== 'hidden') : ?>
        					<div class="short">
        						<label for="billing:telephone"<?php if($phone_r === 'required') { echo ' class="required" ';}?>>
        							<?php echo $this->__('Telephone') ?>
        						</label>
            					<?php
                                if($phone_r === 'required') {
                                  echo ' <sup>*</sup> ';
                                }else{
                                  echo ' <sup>&nbsp;</sup> ';
                                }
                                ?>
        						<div class="data_area">
        							<input type="text" name="billing[telephone]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="t1 required-entry" id="billing:telephone" />
        						</div>
        					</div>
        				<?php endif; ?>
                         <!--
                              IF BLOCO FAX -----------------------------------------
                         -->
            			<?php if ($fax_r !== 'hidden') : ?>
            				<div class="short">
            					<label for="billing:fax"<?php if($fax_r === 'required') {echo ' class="required" ';}?>>
            						<?php echo $this->__('Fax') ?>
                          <?php
                                if($fax_r === 'required') {
                                  echo ' <sup>*</sup> ';
                                }else{
                                  echo ' <sup>&nbsp;</sup> ';
                                }
                                ?>
            					</label>

            					<div class="data_area">
            						<input type="text" name="billing[fax]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="t1 required-entry" id="billing:fax" />
            					</div>
            				</div>
                        <?php endif ?>
                         <!--
                              IF BLOCO CELULAR -----------------------------------------
                         -->
            			<?php if ($celular !== 'hidden') : ?>
            				<div class="short">
            					<label for="billing:fax"<?php if($celular === 'required') {echo ' class="required" ';}?>>
            						<?php echo $this->__('Celular') ?>
            					</label>
            					<?php
                                if($celular === 'required') {
                                  echo ' <sup>*</sup> ';
                                }else{
                                  echo ' <sup>&nbsp;</sup> ';
                                }
                                ?>
            					<div class="data_area">
            						<input type="text" id="celular" name="billing[celular]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getCelular()) ?>" title="<?php echo $this->__('Celular') ?>" class="t1 required-entry" id="billing:fax" />
            					</div>
            				</div>
                        <?php endif ?>
            </div>
            <div class='clr'></div>
            <?php endif ?>
            <div class="clr"></div>




           <!--
                BLOCO DADOS DO ENDEREÇO -----------------------------------------
           -->
           <!--
                IF BLOCO CEP -----------------------------------------
           -->
			<?php
			$tracoAtivo = Mage::getStoreConfig('onepagecheckout/general/tracoativo');
			$zip_r	= Mage::getStoreConfig('onepagecheckout/address_form/zip');
			if ($zip_r !== 'hidden') :
			?>
					<div class="full">
						<label for="billing:postcode"<?php if($zip_r === 'required'){echo ' class="required" ';}?>>
							<?php echo $this->__('Zip Code') ?>
						</label>
    					<?php
                        if($zip_r === 'required') {
                          echo ' <sup>*</sup> ';
                        }else{
                          echo ' <sup>&nbsp;</sup> ';
                        }
                        ?>
						<div class="data_area">
							<input maxlength="8" type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getBillAddress()->getPostcode()) ?>" class="t1 validate-zip-international<?php if($zip_r === 'required'){echo ' required-entry ';}?> <?php if($tracoAtivo === '1'){ echo ' tracoAtivo';} ?>   " onblur="buscarEndereco('<?=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)?>','billing');"/>
						</div>
					</div>
			<?php endif; ?>
            <div class="clr"></div>
           <!--
                IF BLOCO ENDEREÇO -----------------------------------------
           -->
            <?php
			$endereco = Mage::getStoreConfig('onepagecheckout/address_form/address');
			if ($endereco !== 'hidden') : ?>
				<div class="full">
                    <label for="endereco" <?php if ( $endereco  === 'required' ){ echo 'class="required"'; }?> ><?php echo $this->__('Endere&ccedil;o') ?></label>
  					<?php
                      if($endereco === 'required') {
                        echo ' <sup>*</sup> ';
                      }else{
                        echo ' <sup>&nbsp;</sup> ';
                      }
                      ?>
					<div class="data_area">
						<input type="text" id="billing:street1" name="billing[street][1]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getStreet(1)) ?>" title="<?php echo $this->__('Endere&ccedil;o') ?>" class="input-text t1<?php if($endereco === 'required'){ echo ' required-entry';} ?>" />
					</div>
				</div>
            <?php endif; ?>
           <!--
                IF BLOCO NUMERO E COMPLEMENTO -----------------------------------------
           -->
			<?php
			$complemento = Mage::getStoreConfig('onepagecheckout/address_form/address3');
            $numero = Mage::getStoreConfig('onepagecheckout/address_form/address2');
			?>
            <?php if ($numero !== 'hidden' || $complemento !== 'hidden' ) : ?>
            <div class="two_fields">
                         <!--
                              IF BLOCO NUMERO -----------------------------------------
                         -->
        				<?php if ($numero !== 'hidden') : ?>
        					<div class="short">
        						<label for="billing:street2"<?php if($numero === 'required') { echo ' class="required" ';}?>>
        							<?php echo $this->__('N&uacute;mero') ?>
        						</label>
            					<?php
                                if($numero === 'required') {
                                  echo ' <sup>*</sup> ';
                                }else{
                                  echo ' <sup>&nbsp;</sup> ';
                                }
                                ?>
        						<div class="data_area">
            						<input type="text" id="billing:street2" name="billing[street][2]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getStreet(2)) ?>" title="<?php echo $this->__('N&uacute;mero') ?>" class="input-text t1<?php if($numero === 'required'){ echo ' required-entry';} ?>" />
        						</div>
        					</div>
        				<?php endif; ?>
                         <!--
                              IF BLOCO COMPLEMENTO -----------------------------------------
                         -->
            			<?php if ($complemento !== 'hidden') : ?>
            				<div class="short comp">

            					<label for="billing:street3"<?php if($complemento === 'required') {echo ' class="required" ';}?>>
            						<?php echo $this->__('Complemento') ?>
            					</label>
            					<?php
                                if($complemento === 'required') {
                                  echo ' <sup>*</sup> ';
                                }else{
                                  echo ' <sup>&nbsp;</sup> ';
                                }
                                ?>
            					<div class="data_area">
            						<input type="text" id="billing:street3" name="billing[street][3]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getStreet(3)) ?>" title="<?php echo $this->__('Complemento') ?>" class="input-text t1<?php if($complemento === 'required'){ echo ' required-entry';} ?>" />
            					</div>
            				</div>
                        <?php endif ?>
            </div>
            <div class='clr'></div>
            <?php endif ?>
             <!--
                  IF BLOCO BAIRRO -----------------------------------------
             -->
            <?php
			$bairro = Mage::getStoreConfig('onepagecheckout/address_form/address4');
			if ($bairro !== 'hidden') : ?>
                <!-- endereco-->
				<div class="full">
                    <label for="bairro" <?php if ( $bairro  === 'required' ){ echo 'class="required"'; }?> ><?php echo $this->__('Bairro') ?></label>
  					<?php
                      if($bairro === 'required') {
                        echo ' <sup>*</sup> ';
                      }else{
                        echo ' <sup>&nbsp;</sup> ';
                      }
                      ?>
					<div class="data_area">
						<input type="text" id="billing:street4" name="billing[street][4]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getStreet(4)) ?>" title="<?php echo $this->__('Bairro') ?>" class="input-text t1<?php if($bairro === 'required'){ echo ' required-entry';} ?>" />
					</div>
				</div>
            <?php endif; ?>
             <!--
                  IF BLOCO CIDADE E ESTADO -----------------------------------------
             -->
             <!--
                  IF BLOCO CIDADE -----------------------------------------
             -->
			 <?php
			$city_r = Mage::getStoreConfig('onepagecheckout/address_form/city');
			$state_r= Mage::getStoreConfig('onepagecheckout/address_form/state');
			?>
			<div class="two_fields"<?php if(($city_r === 'hidden' && $state_r === 'hidden')){echo ' style="display:none"';}?> >
			<?php if ($city_r !== 'hidden') : ?>
				<div class="short">
					<label for="billing:city"<?php if ($city_r === 'required'){ echo ' class="required" ';}?>>
						<?php echo $this->__('City') ?>
					</label>
  					<?php
                      if($city_r === 'required') {
                        echo ' <sup>*</sup> ';
                      }else{
                        echo ' <sup>&nbsp;</sup> ';
                      }
                      ?>
					<div class="data_area">
						<input type="text" title="<?php echo $this->__('City') ?>" name="billing[city]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getCity()) ?>" class="t1<?php if ($city_r === 'required'){ echo ' required-entry ';}?>" id="billing:city" />
					</div>
				</div>
			<?php endif; ?>
             <!--
                  IF BLOCO ESTADO -----------------------------------------
             -->
				<div class="short"<?php if($state_r === 'hidden'){ echo ' style="display:none" ';}?>>
					<label for="billing:region_id"<?php if($state_r === 'required'){ echo ' class="required" ';}?>>
						<?php echo $this->__('State / Province') ?>
					</label>
  					<?php
                        echo ' <sup>*</sup> ';
                      ?>
					<div class="data_area">
						<select id="billing:region_id" name="billing[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select required-entry" style="display:none;">
							<option value=""><?php echo $this->__('Select One') ?></option>
						</select>
						<script type="text/javascript">
						//<![CDATA[
							$('billing:region_id').setAttribute('defaultValue',  "<?php echo $this->getBillAddress()->getRegionId() ?>");
						//]]>
						</script>
						<input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->htmlEscape($this->getBillAddress()->getRegion()) ?>"  title="<?php echo $this->__('State/Province') ?>" class="t1 required-entry" style="display:none;" />
					</div>
				</div>
			</div>
			<div class='clr'></div>
             <!--
                  IF BLOCO PAIS -----------------------------------------
             -->
	        <?php
	        $country_r = Mage::getStoreConfig('onepagecheckout/address_form/country');
	        ?>
			<div class="full"<?php if($country_r === 'hidden'){ echo ' style="display:none" ';}?>>
				<label for="billing:country_id"<?php if($country_r === 'required') { echo ' class="required" ';}?>>
	        		<?php echo $this->__('Country') ?>
	        	</label>
	            <?php
                if($country_r === 'required') {
                  echo ' <sup>*</sup> ';
                }else{
                  echo ' <sup>&nbsp;</sup> ';
                }
                ?>
				<div class="data_area">
					<?php echo $this->getBillingCountriesSelectBox() ?>
				</div>
			</div>






			<?php
			if (!$logged) :
				$agc = Mage::helper('onepagecheckout')->isGuestCheckoutAllowed();
                $habilitarcad = Mage::getStoreConfig('onepagecheckout/general/habilitarcad');
				if ($agc)  //$agc habilitarcad||
				{
				?>
				<ul>
					<li class="options">
						<input type="checkbox" name="billing[register_account]" value="1" title="<?php echo $this->__('Create an account for later use') ?>" id="billing:register_account" onclick="if(window.billing) billing.setCreateAccount(this.checked);"<?php if ($this->getBillAddress()->getRegisterAccount()):?> checked="checked"<?php endif;?> class="checkbox" />
						<label for="billing:register_account">
							<?php echo $this->__('Create an account for later use') ?>
						</label>
					</li>
				</ul>
				<?php
				}
				else
				{
				?>
					<input type="hidden" name="billing[register_account]" value="1"/>
				<?php
				}
				?>
				<div class="two_fields" id="register-customer-password" <?php if ($agc) { echo ' style="display: none;" '; } ?>>
					<div class="short">
						<label for="billing:customer_password" class="required">
							<?php echo $this->__('Password') ?>
						</label>
						<sup>*</sup>
						<div class="data_area">
							<input type="password" name="billing[customer_password]" id="billing:customer_password" title="<?php echo $this->__('Password') ?>" class="t1 required-entry validate-password" />
						</div>
					</div>
					<div class="short">
						<label for="billing:confirm_password" class="required">
							<?php echo $this->__('Confirm Password') ?>
						</label>
						<sup>*</sup>
						<div class="data_area">
							<input type="password" name="billing[confirm_password]" title="<?php echo $this->__('Confirm Password') ?>" id="billing:confirm_password" class="t1 required-entry validate-cpassword" />
						</div>
					</div>
					<div class='clr'></div>
				</div>
				<div class='clr'></div>
			<?php
			endif;
			?>
			<ul>
			<?php
			if ($logged && $has_addr){
			?>
				<li class="options">
					<input type="checkbox" class="checkbox" name="billing[save_in_address_book]" id="billing:save_in_address_book" value="1" title="<?php echo $this->__('Save in address book') ?>" <?php if ($this->getBillAddress()->getSaveInAddressBook()){ echo ' checked="checked" ';}?> />
					<label>
						<?php echo $this->__('Save in address book'); ?>
					</label>
				</li>
			<?php
			}
			else
			{
			?>
				<li class="no-display">
					<input type="hidden" value="1" name="billing[save_in_address_book]" />
				</li>
			<?php
			}
			?>
			</ul>
	    </div>

    <?php
    if (Mage::helper('onepagecheckout')->isShippingAddressAllowed() && $this->canShip()){
    ?>
    	<input type="hidden" name="billing[use_for_shipping]" id="billing:use_for_shipping" value="<?php echo ($this->isUseBillingAddressForShipping())?'1':'0'; ?>" />
    <?php
    }else{
    ?>
    	<input type="hidden" name="billing[use_for_shipping]" value="1" />
    <?php
    }
    ?>
	</div>
</div>




<script type="text/javascript">
//<![CDATA[
	var billing = new BillingAddress();
	RegionUpdater.prototype.setMarkDisplay = function(){};
	ZipUpdater.prototype._setPostcodeOptional = function(){};
	var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', countryRegions, undefined, 'billing:postcode');

//]]>
</script>




<script type="text/javascript">
//<![CDATA[

     /*One Step Checkout
     Verifica se tem value no cep
     */

      var temcep = $j('input[name*="[postcode]"]').val();
      if(temcep != ''){
          buscarEndereco('<?=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)?>','billing');
      }

//]]>
</script>




<script type="text/javascript">
//<![CDATA[
    // Adicionar validacao de cpf e cnpj ao campo Taxvat
    Validation.add('validar_cpf', 'O CPF informado \xE9 invalido', function(v){return validaCPF(v,0);});
    Validation.add('validar_cpf2', 'O CNPJ informado \xE9 invalido', function(v){return validaCPF(v,0);});
    Validation.add('validar_cpfcnpj', 'O CPF/CNPJ informado \xE9 invalido', function(v){return validaCPF(v,0);});
//]]>
</script>




<script type="text/javascript">
//<![CDATA[

/*===================================================== ONLOAD ===========================================================*/

        var tipovindobanco;
        var existe;

        /*Pega tipo pessoa vindo do banco e o seta*/
        tipovindobanco = "<?php echo $this->htmlEscape($this->getCustomer()->getTipopessoa()) ?>";

        /*Verifica se existe o Taxvat*/
        existe = $j('input[name*="[taxvat]"]').length;


        if(tipovindobanco == 'Fisica'){
          /*fisica*/

            /*Se existe o Taxvat alterna entre eles mudando o name conforme selecionado o tipo pessoa*/
            if( existe != ''){
                /*BILLING*/
                $j('input[name*="[taxvat-old]"]').attr('name', 'billing[taxvat]');     /*CNPJ OK*/
                $j('input[name*="[taxvat]"]:eq(1)').attr('name', 'NULL');              /*CPF NULL*/

                /*LIMPA CAMPOS*/
                $j('input[name*="[taxvat]"]').attr('class', 'validar_cpfcnpj input-text');
            }else{
                /*BILLING*/
                $j('.Binputcnpj').attr('name', "NULL");           /*CNPJ NULL*/
                $j('.Binputcpf').attr('name', "billing[cpfcnpj]");  /*CPF OK*/
            }

            /*Exibe ou oculta os boxs*/
            $j('.boxpj').hide();
            $j('.boxpf').show();

            /*Exibe ou oculta o entregar em outro endereço conforme a selecao do tipo pessoa*/
            $j('li.options').find("label:contains('Entregar')").css('visibility', 'visible');
            $j('input[name*="[same_as_billing]"]').css('visibility', 'visible');

        }else if(tipovindobanco == 'Juridica'){
          /*juricica*/

            /*Se existe o Taxvat alterna entre eles mudando o name conforme selecionado o tipo pessoa*/
            if( existe != ''){
                /*BILLING*/
                $j('input[name*="[taxvat-old]"]').attr('name', 'billing[taxvat]');     /*CNPJ OK*/
                $j('input[name*="[taxvat]"]:eq(0)').attr('name', 'NULL');             /*CPF NULL*/

                /*ADD CLASS NO TAXVAT*/
                $j('input[name*="[taxvat]"]').attr('class', 'validar_cpfcnpj input-text');
            }else{
                /*BILLING*/
                $j('.Binputcnpj').attr('name', 'billing[cpfcnpj]'); /*CNPJ OK*/
                $j('.Binputcpf').attr('name', 'NULL');            /*CPF NULL*/
            }

            /*Exibe ou oculta os boxs*/
            $j('.boxpj').show();
            $j('.boxpf').hide();

            /*Exibe ou oculta o entregar em outro endereço conforme a selecao do tipo pessoa*/
            $j('li.options').find("label:contains('Entregar')").css('visibility', 'hidden');
            $j('input[name*="[same_as_billing]"]').css('visibility', 'hidden');
        }
//]]>
</script>