  function validar( f ) {
    // Chequea Campo Vacio
    if ( f.nombre.value.length < 1 ) {
      alert("Debe escribir un nombre!!!.");
      f.nombre.focus();
      return (false);
    }
    // Chequea minimo en caracteres
    if ( f.nombre.value.length < 3 ) {
      alert("El nombre parece estar incorrecto!!!.");
      f.nombre.focus();
      return (false);
    }
    // Chequea email valido (existencia de arroba )
    if ( f.amigo.value.indexOf ('@', 0) == -1 ) {
      alert("El EMail parece estar incorrecto!!!.");
      f.amigo.focus();
      return (false);
    }
    // Chequea email valido (existencia de '.' )
    if ( f.amigo.value.indexOf ('.', 0) == -1 ) {
      alert("El EMail parece estar incorrecto!!!.");
      f.amigo.focus();
      return (false);
    }
    // Chequea email valido (existencia de '.com' )
    //if ( f.usuario.value.indexOf ('.com', 0) == -1 ) {
    //  alert("El EMail parece estar incorrecto!!!.");
    //  f.usuario.focus();
    //  return (false);
    //}

    f.submit.disabled=true;
    return (true);
  }

  function changeBgcolor(cell) {
    if (cell.style.backgroundImage == "") {
      cell.style.backgroundImage = "url(/images/15_fondoRenglon.gif)";
    } else {
      cell.style.backgroundImage = "";
    }
  }
  function validar( f ) {
    // Chequea Campo Vacio
    if ( f.texto.value.length < 1 ) {
      alert("Debe escribir un texto!!!.");
      f.texto.focus();
      return (false);
    }
    // Chequea minimo en caracteres
    if ( f.texto.value.length < 2 ) {
      alert("El texto es muy corto!!!.");
      f.texto.focus();
      return (false);
    }
    // Chequea una seleccion de categoria
    if ( f.catego.value == 0 ) {
      alert("Debe elegir una categoria!!!.");
      f.catego.focus();
      return (false);
    }
    //f.submit.disabled=true;
    return (true);
  }
  function desplegar() {
    if (document.all['info'].style.display==''){
	document.all['info'].style.display='none';
	document.all['boton_'].src='/images/info.gif';
	} else {
    document.all['info'].style.display='';
	document.all['boton_'].src='/images/info2.gif';
	}
  }

  function cyan( obj ) {
   obj.style.background='#EDEFFA';
  }
  function white( obj ) {
   obj.style.background='#FFFFFF';
  }



  function validar2( f ) {
    // Chequea Campo Vacio
    if ( f.texto.value.length < 1 ) {
      alert("Debe escribir un texto!!!.");
      f.texto.focus();
      return (false);
    }
    // Chequea minimo en caracteres
    if ( f.texto.value.length < 2 ) {
      alert("El texto es muy corto!!!.");
      f.texto.focus();
      return (false);
    }
    //f.submit.disabled=true;
    return (true);
  }

  function cambiaprovi() {
    //alert("cambio provincia");
    var nueva=document.getElementById('selprovi').value;
    if ( nueva=="" ) {
      return false;
    } else {
      //location.href=nueva;
      window.open(nueva,'','');
    }
  }
  function cambiacate() {
    //alert("cambio categoria");
    var nueva=document.getElementById('selcate').value;
    if ( nueva=="" ) {
      return false;
    } else {
      //location.href=nueva;
      window.open(nueva,'','');
    }
  }
  function cambiaprovic() {
    //alert("cambio provincia categoria");
    var nueva=document.getElementById('selprovic').value;
    if ( nueva=="" ) {
      return false;
    } else {
      //location.href=nueva;
      window.open(nueva,'','');
    }
  }


  function abre( imagen, ancho, alto ) {
    window.open( '/fotos/'+imagen, '', 'top=50,left=50,width='+ancho+',height='+alto );
  }

function abre2( imagen, ancho, alto ) {

//   $tpl->gotoBlock( "_ROOT" );
//  $tpl->assign( "enlace_anuncio", 'http://todoanuncios.com'.$_SERVER['REQUEST_URI'] );
//  $tpl->assign( "campo_titulo", $titulo );

    var nuevoalto=60+parseInt(alto);
    var ror=window.open( '', '', 'top=50,left=50,width='+ancho+',height='+nuevoalto );
    ror.document.writeln( '<'+'html>' );
    ror.document.writeln( '<'+'title>Todoanuncios.com {campo_titulo}<'+'/title>' );
    ror.document.writeln( '<'+'body>' );
    ror.document.writeln( '<'+'center>' );
    ror.document.writeln( '<img src="/fotos/'+imagen+'" ><br>' );
    ror.document.writeln( '<'+'scr'+'ipt type="text/javascript"'+'>' );
//    ror.document.writeln( '<'+'!--' );
    ror.document.writeln( 'google_ad_client = "pub-5329248262602424";' );
    ror.document.writeln( 'google_ad_slot = "0127596225";' );
    ror.document.writeln( 'google_ad_width = 468;' );
    ror.document.writeln( 'google_ad_height = 60;' );
//    ror.document.writeln( '//--'+'>' );
    ror.document.writeln( '<'+'/script>' );
    ror.document.writeln( '' );
//    ror.document.writeln( '<'+'scr'+'ipt type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js" >' );
    ror.document.writeln( '<'+'/script>' );
    ror.document.writeln( '' );
    ror.document.writeln( '' );
    ror.document.writeln( '' );
    ror.document.writeln( '<br>' );
    ror.document.writeln( '<font size=-2>' );
    ror.document.writeln( '<a href="{enlace_anuncio}" target="_blank" >{campo_titulo}</a>' );
    ror.document.writeln( '<br>' );
    ror.document.writeln( '<'+'a href="http://todoanuncios.com" target="_blank" >' );
    ror.document.writeln( 'Anuncios gratuitos en España - Comprar - Vender - Anunciar Gratis' );
    ror.document.writeln( '<'+'/a>' );
    ror.document.writeln( '</font>' );
    //ror.document.writeln( '<br>{enlace_anuncio}' );
    ror.document.writeln( '<'+'/center>' );
    ror.document.writeln( '<'+'/body>' );
    ror.document.writeln( '<'+'/html>' );
    ror.document.close();
  }






























/********************************
Para sector Envia a un Amigo de la Ficha
********************************/

  function validaramigo( f ) {
    // Chequea Campo Vacio
    if ( f.nombre.value.length < 1 ) {
      alert("Debe escribir un nombre!!!.");
      f.nombre.focus();
      return (false);
    }
    // Chequea minimo en caracteres
    if ( f.nombre.value.length < 3 ) {
      alert("El nombre parece estar incorrecto!!!.");
      f.nombre.focus();
      return (false);
    }
    // Chequea email valido (existencia de arroba )
    if ( f.amigo.value.indexOf ('@', 0) == -1 ) {
      alert("El EMail parece estar incorrecto!!!.");
      f.amigo.focus();
      return (false);
    }
    // Chequea email valido (existencia de '.' )
    if ( f.amigo.value.indexOf ('.', 0) == -1 ) {
      alert("El EMail parece estar incorrecto!!!.");
      f.amigo.focus();
      return (false);
    }
    // Chequea email valido (existencia de '.com' )
    //if ( f.usuario.value.indexOf ('.com', 0) == -1 ) {
    //  alert("El EMail parece estar incorrecto!!!.");
    //  f.usuario.focus();
    //  return (false);
    //}

    f.submit.disabled=true;
    return (true);
  }






  function nformat( num, can ) {
    var numsal=""+"000000000"+num;
    var lar=numsal.length;
    return numsal.substr( lar-can, can );
  }
  function trim( str ) {
    return str.replace( /^\s+|\s+$/g , '' )
  }
  function llama( form ) {
    var url="http://www.todoanuncios.com/buscar_";
    var cadena=form.texto.value;
    cadena=trim(cadena);
    cadena=cadena.replace( /[ ]/g , '_' );
    url=url+cadena;
    var numcat=form.catego.value;
    var numpro=form.prov.value;
    url=url+"_"+nformat(numcat,3)+"";
    url=url+nformat(numpro,2);
    url=url+nformat( 1, 2 );
    var nomcat=form.catego.options[form.catego.selectedIndex].text;
    if ( nomcat=="Todas las Categorias" ) { nomcat="todas"; }
    var nompro=form.prov.options[form.prov.selectedIndex].text;
    if ( nompro=="Todas las Provincias" ) { nompro="todas"; }
    if ( nompro=="Almería" ) { nompro="Almeria"; }
    if ( nompro=="Cáceres" ) { nompro="Caceres"; }
    if ( nompro=="Cádiz" ) { nompro="Cadiz"; }
    if ( nompro=="Castellón" ) { nompro="Castellon"; }
    if ( nompro=="Córdoba" ) { nompro="Cordoba"; }
    if ( nompro=="Coruña" ) { nompro="Coruna"; }
    if ( nompro=="Guipúzcoa" ) { nompro="Guipuzcoa"; }
    if ( nompro=="Jaén" ) { nompro="Jaen"; }
    if ( nompro=="León" ) { nompro="Leon"; }
    if ( nompro=="Málaga" ) { nompro="Malaga"; }
    url=url+"_"+nomcat.replace( /[ ]/g , '_' );
    url=url+"_"+nompro.replace( /[ ]/g , '_' );
    url=url+".html";
    location.href=url;
  }



  var coorpro=new Array();

  function agre( num, nom, lat, lon, zom, la2, lo2 ) {
   coorpro[num]=new Array( nom, lat, lon, zom, la2, lo2 );
  }


agre(  1, "Alava",     "42.850799", "-2.675171", "10", "42.857846", "-2.668304");
agre(  2, "Albacete",  "39.001577", "-1.864929", "11", "39.004245", "-1.863556");
agre(  3, "Alicante",  "38.348657", "-0.486145", "11", "38.355657", "-0.488205");
agre(  4, "Almería",   "36.844461", "-2.469177", "11", "36.846109", "-2.469864");
agre(  5, "Asturias",  "43.362131", "-5.843353", "11", "43.367622", "-5.8461");
agre(  6, "Avila",     "40.662931", "-4.706955", "11", "40.664494", "-4.700775");
agre(  7, "Badajoz",   "38.887292", "-6.974258", "11", "38.890498", "-6.972198");
agre(  8, "Baleares",  "39.605688", "2.922363", "7", "39.639538", "2.988281");
agre(  9, "Barcelona", "41.388658",   "2.170486",    "11",   "41.399475",   "2.169113");
agre( 10, "Burgos",    "42.345858",   "-3.699646",   "11",   "42.35144",    "-3.700333");
agre( 11, "Cáceres", "39.477016", "-6.372757", "11", "39.481255", "-6.372757");
agre( 12, "Cádiz", "36.531709", "-6.293793", "11", "36.538329", "-6.291733");
agre( 13, "Cantabria", "43.467373", "-3.808823", "11", "43.465878", "-3.807449");
agre( 14, "Castellón", "39.987643", "-0.037079", "11", "39.994482", "-0.036392");
agre( 15, "Ceuta", "35.892944", "-5.322876", "11", "35.895725", "-5.313263");
agre( 16, "Ciudad Real", "38.994106", "-3.928299", "11", "38.995707", "-3.924866");
agre( 17, "Córdoba", "37.891654", "-4.779053", "11", "37.894905", "-4.776306");
agre( 18, "Coruña", "43.375109", "-8.421021", "11", "43.377105", "-8.416214");
agre( 19, "Cuenca", "40.071766", "-2.136154", "11", "40.077546", "-2.135468");
agre( 20, "Girona", "41.989608", "2.8228", "11", "41.987567", "2.823486");
agre( 21, "Granada", "37.17892", "-3.584976", "11", "37.182749", "-3.577423");
agre( 22, "Guadalajara", "40.634278", "-3.168182", "11", "40.636362", "-3.166122");
agre( 23, "Guipúzcoa", "43.323679", "-1.984406", "11", "43.330672", "-1.984406");
agre( 24, "Huelva", "37.259299", "-6.949539", "11", "37.262578", "-6.947479");
agre( 25, "Huesca", "42.138968", "-0.411301", "11", "42.147114", "-0.407867");
agre( 26, "Jaén", "37.768001", "-3.79097", "11", "37.773429", "-3.789597");
agre( 27, "La Rioja", "42.465006", "-2.449951", "11", "42.47311", "-2.452698");
agre( 28, "Las Palmas", "28.130128", "-15.430984", "11", "28.136183", "-15.430298");
agre( 29, "León", "42.597071", "-5.572815", "11", "42.603136", "-5.570068");
agre( 30, "Lleida", "41.613902", "0.628967", "11", "41.620576", "0.626221");
agre( 31, "Lugo", "43.012681", "-7.55928", "11", "43.017701", "-7.553787");
agre( 32, "Madrid",      "40.421338",   "-3.703766",   "11",   "40.424997",   "-3.701706");
agre( 33, "Málaga", "36.722925", "-4.42337", "11", "36.728429", "-4.42337");
agre( 34, "Melilla", "35.296073", "-2.946396", "11", "35.298315", "-2.936096");
agre( 35, "Murcia", "37.99508", "-1.132965", "11", "37.994539", "-1.130219");
agre( 36, "Navarra", "42.820588", "-1.647263", "11", "42.824617", "-1.645889");
agre( 37, "Orense", "42.342813", "-7.849045", "11", "42.345858", "-7.846985");
agre( 38, "Palencia", "42.01002", "-4.529114", "11", "42.018182", "-4.530487");
agre( 39, "Pontevedra", "42.430045", "-8.631821", "11", "42.435113", "-8.628387");
agre( 40, "Salamanca", "40.967456", "-5.667572", "11", "40.971604", "-5.662766");
agre( 41, "Tenerife", "28.464466", "-16.229553", "11", "28.471709", "-16.231613");
agre( 42, "Segovia", "40.952418", "-4.12468", "11", "40.956048", "-4.12056");
agre( 43, "Sevilla", "37.382162", "-5.997849", "11", "37.390891", "-5.995102");
agre( 44, "Soria", "41.761581", "-2.467804", "11", "41.769263", "-2.463684");
agre( 45, "Tarragona", "41.115055", "1.262054", "11", "41.12178", "1.264114");
agre( 46, "Teruel", "40.347591", "-1.109619", "11", "40.354393", "-1.106873");
agre( 47, "Toledo", "39.859155", "-4.030609", "11", "39.862844", "-4.025116");
agre( 48, "Valencia", "39.466945", "-0.378342", "11", "39.472775", "-0.377655");
agre( 49, "Valladolid", "41.654445", "-4.731674", "11", "41.660088", "-4.728928");
agre( 50, "Vizcaya", "43.261706", "-2.934036", "11", "43.266706", "-2.924423");
agre( 51, "Zamora", "41.504978", "-5.74585", "11", "41.509606", "-5.74585");
agre( 52, "Zaragoza", "41.65701", "-0.87822", "11", "41.664192", "-0.877533");







