
/* ---------- */

function textoDefecto(texto, formulario){
        
                if (texto == " Escriba t&eacute;rminos")
                {
                    formulario.cad.value= "";
                    
                  }
				  
}

/* ---------- */

function anuncio(formulario)
{

	if (formulario.elements.JUNT.value=="Escriba t&eacute;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 el e-mail.\n';
                } 
                else if (test!='R') 
                { 
                    num = parseFloat(val);
                    if (isNaN(val)) 
                        errors+='- '+nm+' debe contener un n&uacute;mero.\n';

                    if (test.indexOf('inRange') != -1) 
                    { 
                        p=test.indexOf(':');
                        min=test.substring(8,p); max=test.substring(p+1);                        
                        if (num<min || max<num) 
                            errors+='- '+nm+' debe contener un n�mero entre '+min+' y '+max+'.\n';
                    } 
                }                
            } 
            else if (test.charAt(0) == 'R') 
                errors += '- '+nm+' es necesario.\n'; 
        }
    } 
   
    if (errors) alert('Error:\n'+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 popUp (URL){
 ventana=open(URL,"nombre");
}

/*********************************************************
* Destaca seccion (Joaqu�n Siabra 3/12/2008)
*********************************************************/


function cambiarTexto() {
	var enlaces = Array('docu','legi','esta','inve','salu','recu','inte','agen','enla','bole','noti','preo')
    var i,seccion;
	seccion="";
	
	if (document.URL.indexOf(".es/documentacion/")!=-1){
		 seccion="docu";
	}  
	if (document.URL.indexOf(".es/senileg/")!=-1){
		 seccion="legi";
	}  
	if (document.URL.indexOf(".es/estadisticas/")!=-1){
		 seccion="esta";
	}  
	if (document.URL.indexOf(".es/seniinv/")!=-1){
		 seccion="inve";
	} 
	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";
	} 
	if (document.URL.indexOf(".es/boletin/")!=-1){
		 seccion="bole";
	} 	
	if (document.URL.indexOf(".es/seninot/")!=-1){
		 seccion="noti";
	} 		
	if (document.URL.indexOf(".es/programas/")!=-1){
		 seccion="preo";
	} 		
	if (document.URL.indexOf("/enlaces/cssms/")!=-1){
		 seccion="recu";
	} 
	if (document.URL.indexOf("/enlaces/inss/")!=-1){
		 seccion="recu";
	} 	

    for (i=0;i<=enlaces.length;i++) {
        if (seccion==enlaces[i] && document.getElementById) {
		 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;
	}
}

/************************************/

/******************** Accesibilidad ***********************************/

function addLoadEvent(func){
    var oldonload = window.onload;
    
    if (typeof window.onload != 'function')
    {
        
        window.onload = func;
    }else{
        
        window.onload = function(){
            if (oldonload)
            {
                oldonload();
            }
            func();
        }
    }
}


addLoadEvent(function(){
    var links = document.getElementsByTagName( 'a' );
//    var divs = document.getElementsByTagName( 'div' );
    var total = links.length;
    for( var i=0; i < total; i++ )
    {
        links[i].onclick = function()
        {
            if(this.id == "aumentaLetra")
                {
                    aumentaLetra();                
                }
            else if (this.id =="disminuyeLetra")
                {
                    disminuyeLetra();
                 }

        }
    }
});
