function textoDefecto(texto, formulario){
        
                if (texto == " Escriba t&eacute;rminos")
                {
                    formulario.cad.value= "";
                    
                  }
				  
        }

/*         *******      */

function anuncio(formulario)
{

	if (formulario.elements.JUNT.value=="Escriba término/s")
	{
		formulario.elements.JUNT.value="";
		return true;
	}
	return true;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

/**********************************************************************************************
 *		Función que valida los formularios de envío de correspondencia
 **********************************************************************************************/
 //R: es requerido
 //isMail: es mail
 
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="")
	{
      if (test.indexOf('isEmail')!=-1)
	  {
		  p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una direccion e-mail valida.\n';
      } 
	  else if (test!='R')
	  {
		val = ignoreSpaces(val);
        if (isNaN(val)) errors+='- '+nm+' debe contener un número de 9 cifras.\n';
		else if (val.length<9)errors+='- '+nm+' debe contener un número de 9 cifras.\n';
        if (test.indexOf('inRange') != -1)
		{
			p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
          	if (val<min || max<val) errors+='- '+nm+' debe contener un número entre '+min+' y '+max+'.\n';
         }
	   }
	}
	else if (test.charAt(0) == 'R') errors += '- '+nm+' no debe quedar vacio.\n';
	}
  } if (errors) alert('Se ha producido el siguiente error:\n'+unescape(errors));
  document.MM_returnValue = (errors == '');
}
/*********************************************
 * Función que permite quitar los espacios en blancos
 *********************************************/
function ignoreSpaces(string) {
	var temp = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	temp += splitstring[i];
	return temp;
}
/**********************************************************************************************
 *		Función que valida los formularios de envío de correspondencia
 **********************************************************************************************/
 function Actual()
 {
 	var fecha = new Date();
	
	document.write (fecha.getDate()+"/"+fecha.getMonth()+"/"+fecha.getYear());
 }
 
 /**********************************************************************************************
 *		Función que se encarga de las comunidades
 **********************************************************************************************/

 function buscar(com)
{
	
	if (document.forms.envioCom)
	{
		document.forms.envioCom.elements.comunidad.value=com;
		document.forms.envioCom.submit();
	}
	else
	{
		document.forms.envio.elements.provincia.value=com;
		document.forms.envio.submit();
	}
  
  
}


 /**********************************************************************************************
 *		Función que genera la fecha de hoy en la portada
 **********************************************************************************************/

 //var pong;
function makeArray(n){
  this.length = n;
  for (i=1;i<=n;i++){
    this[i]=0;
  }
  return this;
}

// standard date display function with y2k compatibility
function mostrarFecha() {
  var tabla_mes = new makeArray(12);
  tabla_mes[0]  = "enero";
  tabla_mes[1]  = "febrero";
  tabla_mes[2]  = "marzo";
  tabla_mes[3]  = "abril";
  tabla_mes[4]  = "mayo";
  tabla_mes[5]  = "junio";
  tabla_mes[6]  = "julio";
  tabla_mes[7]  = "agosto";
  tabla_mes[8]  = "septiembre";
  tabla_mes[9]  = "octubre";
  tabla_mes[10] = "noviembre";
  tabla_mes[11] = "diciembre";

  var tabla_dia = new makeArray(7);
  tabla_dia[0]  = "Domingo";
  tabla_dia[1]  = "Lunes";
  tabla_dia[2]  = "Martes";
  tabla_dia[3]  = "Mi&eacute;rcoles";
  tabla_dia[4]  = "Jueves";
  tabla_dia[5]  = "Viernes";
  tabla_dia[6]  = "S&aacute;bado";

  var hoy = new Date();
  var day   = hoy.getDate();
  var month = hoy.getMonth();
  var year  = hoy.getYear();
  var dia = hoy.getDay();
    if (year < 1000) {
       year += 1900; }
  return( " " + tabla_dia[dia] + ", " + day + " de " + tabla_mes[month] + " de " + year);


}

function lanzar_netscape()
{
	var verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
	if (app.indexOf('Netscape') != -1 && version < 5.0) alert('-Ha entrado usted con un navegador que no optimiza la visualización del portal.\n-Los estilos y fondos no serán los definidos en el diseño.\n-Los fallos sólo se darán en la visualización, no en el funcionamiento.');
}

/*********************************************************************
*	Función para la validación de los campos "Año" de la búsqueda
*	avanzada de Legislación
*********************************************************************/

function comprobar_anio(aini, afin)
{
	if(isNaN(aini)  || isNaN(afin))
	{
			alert('Los valores introducidos para los años deben ser numéricos!');
			return false;
	}
	
	if(aini>afin && afin !="")
	{
		alert('El año de inicio de la búsqueda no puede ser superior al año del fin de la misma');
		return false;
	}
	
	return true;
		
}
/*********************************************************
*
*********************************************************/
function comprobarTelefono(campo)
{
	if(isNaN(campo.value))
	{
		alert('se permiten solo valores numéricos'); 
		return false;
	}
	else if(campo.value.length<9)
		{
			alert('los números telefónicos deben tener 9 dígitos'); 
			var nombre = campo.name;
			document.forms[0].elements[nombre].focus();
			return false;
		}

}

/*********************************************************
* Formatear una fecha
*********************************************************/


function alerta()
{
	alert('hola');
}

function textoDefecto(texto, formulario)
{
        
    if (texto == " Escriba t&eacute;rminos")
      {
        formulario.cad.value= "";                    
      }
				  
}

/*********************************************************
* Destaca sección (Joaquín Siabra 3/12/2008)
*********************************************************/


function cambiarTexto() {
	var enlaces = Array('tram','docu','esta','salu','recu','inte','agen','enla')
    var i,seccion;
	seccion="";
	
	if (document.URL.indexOf(".es/tramites/")!=-1){
		 seccion="tram";
	} 
	if (document.URL.indexOf(".es/documentacion/")!=-1){
		 seccion="docu";
	}  
	if (document.URL.indexOf(".es/estadisticas/")!=-1){
		 seccion="esta";
	}  
	if (document.URL.indexOf(".es/salud/")!=-1){
		 seccion="salu";
	}  
	if (document.URL.indexOf(".es/recursos/")!=-1){
		 seccion="recu";
	}  
	if (document.URL.indexOf(".es/internacional/")!=-1){
		 seccion="inte";
	}  
	if (document.URL.indexOf(".es/senieve/")!=-1){
		 seccion="agen";
	}  
	if (document.URL.indexOf(".es/enlaces/")!=-1){
		 seccion="enla";
	} 	

    for (i=0;i<=enlaces.length;i++) {
        if (seccion==enlaces[i]) {
		 document.getElementById(seccion).src="/imagenes/templates/iconos/menu-02.jpg";		 
       }else {
		   document.getElementById(seccion).src="/imagenes/templates/iconos/menu-02.jpg";
		 }
    }
}

/*************************************************************************************/
var tamanoLetrapordefecto = 1;
var tamanoLetra = tamanoLetrapordefecto; 
var tamanoLetraminimo = 1; 
var tamanoLetramaximo = 5; 
var identidadLetra;
var identidadLetraEntradilla;

function aumentaLetra() 
{
	if (tamanoLetra < tamanoLetramaximo) 
	{
		tamanoLetra += 1;
		identidadLetra = document.getElementById('noticia_texto');
		identidadLetraEntradilla = document.getElementById('noticia_entradilla');
		identidadLetra.className = 'noticia_texto' + tamanoLetra;
		identidadLetraEntradilla.className = 'noticia_texto' + tamanoLetra;
				
	}
}

function disminuyeLetra() 
{
	if (tamanoLetra > tamanoLetraminimo) 
	{
		tamanoLetra -= 1;
		identidadLetra = document.getElementById('noticia_texto');
		identidadLetraEntradilla = document.getElementById('noticia_entradilla');
		identidadLetra.className = 'noticia_texto' + tamanoLetra;
		identidadLetraEntradilla.className = 'noticia_texto' + tamanoLetra;
	}
}

/************************************/
