<?php
session_start();

include "../phpconfig/config.php";
include "../phpconfig/valida_login.php";
include "../phpconfig/funcoes.php";
include "../includes/topo.php"; 

$id = $_GET['id'];


$sqle = mysql_query("SELECT * FROM l_estados ORDER BY estado asc");
//$sqlc = mysql_query("SELECT * FROM l_cidades ORDER BY cidade asc");


// ALTEARAR NOME DO BANCO



$sql = mysql_query("SELECT * FROM info_estado WHERE id='$id'");






$lin = mysql_fetch_assoc($sql);

// ANTIGO  uf agora id_uf 

$id_uf = $lin['id_uf'];
$id_cidade = $lin['id_cidade'];

?>


 <!--ANTIGO titulo_pt -->

        <ul class="breadcrumb">
          <li><a href="<?php echo sti('adm');  ?>">Home</a></li>
          <li>Editar noticia
          <li class="active"><?php echo $lin['nome_estado']; ?> </li>
        </ul>
<div class='row'>

  <div class='col-md-8'>
 <form class="form-horizontal" method="post" action="edita.php" id='depform'  enctype="multipart/form-data">

        <fieldset>

<!-- ANTIGO  uf agora id_uf  -->
               <input type='hidden'  id='id_uf' name='id_uf'>
               <input type='hidden'  id='cidade' name='cidade'>

           <br/>
          
           <div class="control-group">
            <label>Estado</label>
              <select id='estados' name='estados' class="form-control">
             <option>- Estado -</option>

                <?php while($line = mysql_fetch_assoc($sqle)){ ?>                
                
                <!-- ANTIGO  uf agora id_uf  -->
                
                  <option value='<?php  echo $line['id'];  ?>' <?php if(isset($id_uf)){ if($id_uf==$line['id']) {echo 'selected';}    } ?> ><?php  echo $line['estado'];  ?></option>
                <?php } ?>   

              </select>  <br />

                <div id='retc'>


                     <!--ANTIGO titulo_pt -->
       
          <div class="control-group">
            <label class="control-label" for="titulop">Nome do Estado (emp)</label>
            <div class="controls">
              <input type="text" class="input-xlarge" name='titulop'size='45' id="titulop" value='<?php echo $lin['nome_estado'];  ?>' >
            </div>
          </div>
          <div class="control-group">
              
               <div class="control-group">
            <label class="control-label" for="titulop">Titulo</label>
            <div class="controls">
              <input type="text" class="input-xlarge" name='titulopl'size='45' id="titulopl" value='<?php echo $lin['titulo'];  ?>' >
            </div>
          </div>
          <div class="control-group">


 <div class="control-group">
            <label class="control-label" for="titulop">Slug</label>
            <div class="controls">
              <input type="text" class="input-xlarge" name='slug'size='45' id="slug" value='<?php echo $lin['slug'];  ?>' >
            </div>
          </div>
          <div class="control-group">


<!--

ANTIGO slug - mdelo para passar id

-->

          <div class="control-group">
            <label class="control-label" for="nome"></label>
            <div class="controls">
              <input type="hidden" class="input-xlarge" name='id' size='45' id="id" value='<?php echo $lin['id'];  ?>' >
              
              
    
              
            </div>
          </div>             
          <div class="control-group">
            <label class="control-label"  for="depp">Editar - Info Estado</label>
            <div class="controls">
              <?php


                    $substitute = "src=\"".sti('urlbase')."assets/uploads/noticias/";
          
          
          // ANTIGO texto_pt
                    $src = str_replace('src="images/',$substitute,$lin['info']);

  

              ?>
              <textarea name='depp' id="myArea2" cols='20' style='width:800px' rows='10'><?php echo $src; ?></textarea>
            </div>
          </div>
    
     <br/>
          <div class="form-actions">
            <input  type="submit" class="btn btn-primary" value='Salvar' />
            <a class="btn btn-warning pull-right" href="index.php">Voltar</a>
          </div>
        </fieldset>
      </form>

</div>

<div class='col-md-4'>

              
</div>
</div>
 <script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
    <script type="text/javascript">
      //<![CDATA[
      var area1;

      function toggleArea1() {
      
            area1 = new nicEditor({fullPanel : true}).panelInstance('myArea2',{hasPanel : true});

      }


      bkLib.onDomLoaded(function() { 
      
          new nicEditor({buttonList : ['fontFormat','bold','italic','underline','strikeThrough','subscript','superscript','html','image','link','ul']}).panelInstance('myArea2');
      
      toggleArea1(); 

    });

     
       $("#estados").change(function(){
        var uf = $("#estados").val();

    $.ajax({   
      url: "retCidades.php?uf="+uf,
      type: 'GET',
      beforeSend: function() {    


      },
    success: function(data)
    {
 
        $('#retc').html(data);  
        $("#uf").val(uf);
 
    }
  });

      });


       function aha(){

        var uf = $("#estados").val();

    $.ajax({   
      url: "retCidades.php?uf="+uf,
      type: 'GET',
      beforeSend: function() {    


      },
    success: function(data)
    {
 
        $('#retc').html(data);  
        $("#uf").val(uf);

 
    }
  });


       }
 $("#cidade").val('<?php  echo $id_cidade;  ?>');

//aha();
      </script>

 

<?php include "../includes/rodape.php"; ?>
