function ancho_foto()
	{
	document.getElementById('colaborador').style.width=document.fotonoticia.width+20+"px"
	}
function ancho_capa()
	{
	document.getElementById('principalsec').style.width=document.fotonoticia.width+5+"px"
	document.getElementById('foto').style.width=document.fotonoticia.width+20+"px"
	document.getElementById('imagen').style.width=document.fotonoticia.width+20+"px"
	}	

function contar(texto,e)
 	{
	if (texto.length > 150 ) {
	if (navigator.appName == "Netscape") tecla = e.which
	else tecla = e.keyCode
	if (tecla != 8) return false
	}
return true
} 
	
function anuncio(sup,inf)
	{
	isup=sup;
	iinf=inf;
	if(enlace[sup][2]==1)
		{
		document.write ("<center><a href='"+enlace[sup][1]+"' id='link1' target='_blank'>")
		document.write ("<img src='anunciantes/anunciante"+enlace[isup][3]+".jpg' name='anun1' align='center' border='0'></a>")
		document.write ("<br>&nbsp<br><a href='#' id='link2' target='_blank'><img src='anunciantes/blanco.gif' name='anun2' align='center' border='0'></a>")
		pte=inf;
		j=j+2;
		}
	else
		{	
		if(enlace[inf][2]==1)
			{
			document.write ("<center><a href='"+enlace[inf][1]+"' id='link1' target='_blank'>")
			document.write ("<img src='anunciantes/anunciante"+enlace[iinf][3]+".jpg' name='anun1' align='center' border='0'></a>")
			document.write ("<br>&nbsp<br><a href='#' id='link2' target='_blank'><img src='anunciantes/blanco.gif' name='anun2' align='center' border='0'></a>")
			j=j+1;
			pte=sup;
			}	
		}
	if (enlace[sup][2]==0 && enlace[inf][2]==0)	
		{
		document.write ("<center><a href='"+enlace[sup][1]+"' id='link1' target='_blank'>")
		document.write ("<img src='anunciantes/anunciante"+enlace[isup][3]+".jpg' name='anun1' align='center' border='0'></a>")
		document.write ("<br>&nbsp<br><a href='"+enlace[inf][1]+"' id='link2' target='_blank'>")
		document.write ("<img src='anunciantes/anunciante"+enlace[iinf][3]+".jpg' name='anun2' align='center' border='0'></a>")
		j=j+2;
		}
	}

function enciende(y)
	{
	document.images[y].src="graficos/hemerotecail.jpg";
	}
function apaga(y)
	{
	document.images[y].src="graficos/hemeroteca.jpg";
	}
	
function cambia_anuncio(max)
	{
	var sup;
	var inf;
	sup=posicion[j];
	if (j==max)j=0;
	inf=posicion[j+1]
	
	
	
	//Caso en el que los dos anuncios son grandes
	if (enlace[sup][2]==1 && enlace[inf][2]==1) 
		{
		document.images["anun1"].src="anunciantes/anunciante"+enlace[sup][3]+".jpg"
	 	document.getElementById('link1').href =enlace[sup][1];
		document.images["anun2"].src=""
		document.getElementById('link2').href ="";
		pte=inf;
		j=j+1
		if (j==max) j=1;
		if (j==max+1) j=2;
		}
	else
		{	
		if(pte>-1)
			{
			sup=pte;
			pte=-1
			}
		//Caso en el que los dos anuncios son iguales
		if (enlace[sup][2]==0 && enlace[inf][2]==0) 
			{
			document.images["anun1"].src="anunciantes/anunciante"+enlace[sup][3]+".jpg"
			document.getElementById('link1').href =enlace[sup][1];
			document.images["anun2"].src="anunciantes/anunciante"+enlace[inf][3]+".jpg"
			document.getElementById('link2').href =enlace[inf][1];;
			j=j+2
		
			if (j==max) j=1;
			if (j==max+1) j=2;
	
			}
		else
			{	
		//Caso en el que el anuncio superior es grande
			if (enlace[sup][2]==1) 
				{
				document.images["anun1"].src="anunciantes/anunciante"+enlace[sup][3]+".jpg"
				document.getElementById('link1').href =enlace[sup][1];
				document.images["anun2"].src="anunciantes/blanco.gif"
				document.getElementById('link2').href ="";
		
				j=j+1
				if (j==max+1) j=1;
				
				}	
			//Caso en el que el anuncio inferior es grande
			if (enlace[inf][2]==1) 
				{
				document.images["anun1"].src="anunciantes/anunciante"+enlace[inf][3]+".jpg"
				document.getElementById('link1').href =enlace[inf][1];
				document.images["anun2"].src="anunciantes/blanco.gif"
				document.getElementById('link2').href ="";
				pte=sup;
		
				j=j+1
				if (j==max) j=1;
				if (j==max+1) j=2;
				
				}
			}	
			
		}
	
}
function aleatorio(inferior,superior)
	{
    numPosibilidades = superior - inferior
    aleat = Math.random() * numPosibilidades
    aleat = Math.round(aleat)
	return parseInt(inferior) + aleat
	} 
	
function mostrarCapa(n)
	{
	document.getElementById(n).style.visibility="visible";
	}
	
function publicidad(max)
	{
	for (n=1;n<=max;n++)
				{
				posicion[n]=aleatorio(1,max)	
				repetido=comprobar(posicion[n],n)	
				while (repetido)
					{
					posicion[n]=aleatorio(1,max)
					repetido=comprobar(posicion[n],n)	
					}
				}
		
	}
function comprobar(numero,n)
	{
	for(j=0;j<n;j++)
		{
		if(posicion[j]==numero) return true;
		}
	}	
function confirmarSuscripcion()
	{
	mensaje=false
	texto="Los siguientes campos no pueden estar en blanco:\n\n"
	if (document.forms[0].Nombre.value.length==0)
		{
		mensaje=true
		texto=texto+"Nombre\n\r"
		}
	if (document.forms[0].Apellidos.value.length==0)
		{
		mensaje=true
		texto=texto+"Apellidos\n\r"
		}
	if (document.forms[0].Direccion.value.length==0)
		{
		mensaje=true
		texto=texto+"Direccion\n\r"
		}	
	if (document.forms[0].Poblacion.value.length==0)
		{
		mensaje=true
		texto=texto+"Poblacion\n\r"
		}
	if (document.forms[0].CP.value.length==0)
		{
		mensaje=true
		texto=texto+"CP\n\r"
		}
	if (document.forms[0].Telefono.value.length==0)
		{
		mensaje=true
		texto=texto+"Telefono\n\r"
		}			
	if (document.forms[0].Mail.value.length==0)
		{
		mensaje=true
		texto=texto+"Mail\n\r"
		}			
	else
		{
		valor=document.forms[0].Mail.value
		if (/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/.test(valor))
			{
			}
		else 
			{
			if(	mensaje=true)
				{
				mensaje=true
				texto=texto+"La dirección de email "+ valor+" es incorrecta.";
				}
			else
				{
				mensaje=true
				texto="La dirección de email "+ valor+" es incorrecta.";
				}	
			}
		}	
		
	if (mensaje) 
		{
		alert(texto)
		}
	else
		{
		document.forms[0].submit();
		}	
	}	
function validarEmail(valor) 
	{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3,4})+$/.test(valor))
		{
		alert("La dirección de email " + valor + " es correcta.");
		}
	else 
		{
		alert("La dirección de email es incorrecta.");
		}
	}

