// JavaScript Document
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
var slideCache = new Array();
var repe;
var repe2;
var futureImages;
var futureTitulos;
var futureNoticias;
var futureDatos;
var futureURL;
var futureAntetitulo;
function RunSlideShow(pictureName,imageFiles,displaySecs,titulos,noticias,datos,url,antetitulos){
	//alert(document.getElementById('lema').firstChild.nodeValue);
var imageSeparator = imageFiles.indexOf(";");
var nextImage = imageFiles.substring(0,imageSeparator);
var textSeparator=titulos.indexOf("|");
var nextTitulo = titulos.substring(0,textSeparator);
var textnoticiasSeparator=noticias.indexOf("|");
var nextNoticias = noticias.substring(0,textnoticiasSeparator);
var textdatosSeparator=datos.indexOf("|");
var nextDatos = datos.substring(0,textdatosSeparator);
var texturlSeparator=url.indexOf("|");
var nexturl = url.substring(0,texturlSeparator);
var textantetituloSeparator=antetitulos.indexOf("|");
var nextantetitulo = antetitulos.substring(0,textantetituloSeparator);
if (document.all){
document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
document.getElementById(pictureName).filters.blendTrans.Apply();
}
document.getElementById(pictureName).src = nextImage;
document.getElementById("tituloPortada").innerHTML ="<a href='#' class='tituloPortada' onclick=\"aperturaLenta(1,"+nexturl+")\">"+ nextTitulo+"</a>";
document.getElementById("antetitulo").innerHTML ="<a href='#' class='antetituloPortada' onclick=\"aperturaLenta(1,"+nexturl+")\">"+ nextantetitulo+"</a>";
document.getElementById("textoPortada").innerHTML = "<a href='#' class='textoPortada' onclick=\"aperturaLenta(1,"+nexturl+")\">"+nextNoticias+"</a>";
document.getElementById("datoPortada").innerHTML = nextDatos;
document.title="GUADALAJARADIGITAL :: "+ nextTitulo;
window.status="GUADALAJARADIGITAL :: "+ nextTitulo;
if (document.all){
document.getElementById(pictureName).filters.blendTrans.Play();
}
futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)
+ ';' + nextImage;
futureTitulos=titulos.substring(textSeparator+1,titulos.length)
+ '|' + nextTitulo;
futureNoticias=noticias.substring(textnoticiasSeparator+1,noticias.length)
+ '|' + nextNoticias;
futureDatos=datos.substring(textdatosSeparator+1,datos.length)
+ '|' + nextDatos;
futureURL=url.substring(texturlSeparator+1,url.length)
+ '|' + nexturl;
futureAntetitulos=antetitulos.substring(textantetituloSeparator+1,antetitulos.length)
+ '|' + nextantetitulo;
repe = setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+",'"+futureTitulos+"','"+futureNoticias+"','"+futureDatos+"','"+futureURL+"','"+futureAntetitulos+"')",displaySecs*1000);
// Cache the next image to improve performance.
imageSeparator = futureImages.indexOf(";");
nextImage = futureImages.substring(0,imageSeparator);
if (slideCache[nextImage] == null) {
slideCache[nextImage] = new Image;
slideCache[nextImage].src = nextImage;
}
}
function cambiaFondo(elemento, estilo){
	document.getElementById(elemento.id).className=estilo;
}
function navegador(){
	posicion=navigator.appName.indexOf("Microsoft");
if (posicion==0) {
document.write('<link rel="stylesheet" href="estiloIE.css" type="text/css">');
}
else {
document.write('<link rel="stylesheet" href="estilo.css" type="text/css">');
}
	
}
function pararPortada(){
document.getElementById("btPararPortada").style.display="none";
clearTimeout(repe);
document.getElementById("btPlayPortada").style.display="block";
}
function playPortada(){
document.getElementById("btPararPortada").style.display="block";
repe = setTimeout("RunSlideShow('imgPortada','"+futureImages+"',4,'"+futureTitulos+"','"+futureNoticias+"','"+futureDatos+"')",1000)
document.getElementById("btPlayPortada").style.display="none";
}
//AJAX
function muestraNoticia(url){
if(!isNaN(url)){
		 url2="damenoticia.php?idNoticia="+url;
		 }else{
			 url2=url;
		 }
var aleatorio=Math.random();
ajax=nuevoAjax(); 
ajax.open("GET", url2+"&aleatorio="+aleatorio,true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
    document.getElementById('contenedor').innerHTML=ajax.responseText;
	pontitulo(url);
   } 
} 
ajax.send(null) 
} 

function pontitulo(url){

		 url2="dametitulo.php?idNoticia="+url;
var aleatorio=Math.random();
ajax=nuevoAjax(); 
ajax.open("GET", url2+"&aleatorio="+aleatorio,true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
    document.title='GUADALAJARADIGITAL :: '+ ajax.responseText;
	ponroll(url);
	   } 
} 
ajax.send(null) 
} 

function ponroll(url){

url2="dameroll.php?idNoticia="+url;
var aleatorio=Math.random();
ajax=nuevoAjax(); 
ajax.open("GET", url2+"&aleatorio="+aleatorio,true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
if(ajax.responseText!=''){
	var devuelto=(ajax.responseText).split(",");
    RunSlideShowNoticias(devuelto[0],devuelto[1],devuelto[2],devuelto[3]);
}
	  } 
} 
ajax.send(null) 
} 
function aperturaLenta(valor,url){
	if(valor==1){
	document.getElementById('tblcontenedor').style.display='block';
	document.getElementById('contenedor').innerHTML="<div align='center'><img src='images/carga.gif' alt='actualizando' width='50' height='50' /><br><span class='antetituloPortada'>Cargando informaci&oacute;n...</span></div>";
	}
	if(valor<=300){
		document.getElementById('contenedor').height=valor;
		//document.getElementById('contador').innerHTML=valor;
		valor=valor+8;
		setTimeout("aperturaLenta("+valor+",'"+url+"')",1);
	}else{
		muestraNoticia(url);
	}
		
}
function nuevoAjax(){ 
  var xmlhttp=false; 
  try { 
   // Creación del objeto ajax para navegadores diferentes a Explorer 
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
  } catch (e) { 
   // o bien 
   try { 
     // Creación del objet ajax para Explorer 
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { 
     xmlhttp = false; 
   } 
  } 

  if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
   xmlhttp = new XMLHttpRequest(); 
  } 
  return xmlhttp; 
} 
var slideCache1 = new Array();
var repe1;
var futureImages1;
var futureTitulos1;
function RunSlideShowNoticias(pictureName1,imageFiles1,displaySecs,titulos1){
	if (document.getElementById(pictureName1)){
var imageSeparator1 = imageFiles1.indexOf(";");
var nextImage1 = imageFiles1.substring(0,imageSeparator1);
var textSeparator1=titulos1.indexOf("|");
var nextTitulo1 = titulos1.substring(0,textSeparator1);
if (document.all){
document.getElementById(pictureName1).style.filter="blendTrans(duration=2)";
document.getElementById(pictureName1).filters.blendTrans.Apply();
}
document.getElementById(pictureName1).src = nextImage1;

//document.getElementById("piedefoto").innerHTML = nextTitulo;

if (document.all){
document.getElementById(pictureName1).filters.blendTrans.Play();
}
futureImages1= imageFiles1.substring(imageSeparator1+1,imageFiles1.length)
+ ';' + nextImage1;
futureTitulos1=titulos1.substring(textSeparator1+1,titulos1.length)
+ '|' + nextTitulo1;
repe1 = setTimeout("RunSlideShowNoticias('"+pictureName1+"','"+futureImages1+"',"+displaySecs+",'"+futureTitulos1+"')",displaySecs*1000);
// Cache the next image to improve performance.
imageSeparator1 = futureImages1.indexOf(";");
nextImage1 = futureImages1.substring(0,imageSeparator1);
if (slideCache1[nextImage1] == null) {
slideCache1[nextImage1] = new Image;
slideCache1[nextImage1].src = nextImage1;
}
}
}
function MM_jumpMenu(targ,selObj,restore){
	idlocalidad=selObj.options[selObj.selectedIndex].value;
	aperturaLenta(1,idlocalidad);
 //if (restore) selObj.selectedIndex=0;
}
function mostrar(etiqueta){
if(document.getElementById(etiqueta).style.display== "block"){
document.getElementById(etiqueta).style.display="none";
}else{
document.getElementById(etiqueta).style.display="block";
}
}
function validaEnvioNoticia(idNoticia){
	var errores='';
	var nombre=document.getElementById('nombre').value;
	if(nombre==""){
errores +="Debes escribir tu nombre para enviar el link.\n";	
}
var email=document.getElementById('email').value;
re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
    if(!re.exec(email))    {
        errores += "La direcci\u00f3n de email es incorrecta."
    }


if (errores!=''){
	alert(errores);
}else{
	url='enviaAmigo.php?idNoticia='+idNoticia+'&Email='+email+'&nombre='+nombre
	//alert(url);
	enviaAmigo(url);
}
}
function enviaAmigo(url){
	document.getElementById('enviaAmigo').innerHTML="<div align='center'><img src='images/carga.gif' alt='actualizando' width='50' height='50' /><br><span class='antetituloPortada'>Intentando enviar el enlace...</span></div>";
	
var aleatorio=Math.random();
ajax=nuevoAjax(); 
ajax.open("GET", url+"&aleatorio="+aleatorio,true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
    document.getElementById('enviaAmigo').innerHTML=ajax.responseText;
   } 
} 
ajax.send(null) 
} 
function dadatos(url, etiqueta){
	document.getElementById(etiqueta).innerHTML="<div align='center'><img src='images/carga.gif' alt='actualizando' width='50' height='50' /><br><span class='antetituloPortada'>Actualizando...</span></div>";
	
var aleatorio=Math.random();
ajax=nuevoAjax(); 
ajax.open("GET", url+"&aleatorio="+aleatorio,true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
    document.getElementById(etiqueta).innerHTML=ajax.responseText;
   } 
} 
ajax.send(null) 
}
function validaEnvioSuscrito(idNoticia){
	var errores='';
	var nombre=document.getElementById('nombre').value;
	if(nombre==""){
errores +="Debe escribir tu nombre para enviar el link.\n";	
}
var email=document.getElementById('email').value;
re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
    if(!re.exec(email))    {
        errores += "La direcci\u00f3n de email es incorrecta."
    }


if (errores!=''){
	alert(errores);
}else{
	url='enviaSuscripcion.php?idNoticia='+idNoticia+'&Email='+email+'&nombre='+nombre
	//alert(url);
	enviaAmigo(url);
}
}
function volverA(ancla){
	document.getElementById('tblcontenedor').style.display="none";
	document.location.href='#'+ancla;
}
function enviamail(direccion){
document.location.href='mailto:'+direccion+'@guadalajaradigital.es';	
}
///GOOGLEMAPS
function cargamapa(){
document.getElementById('contenedor').innerHTML="<div id='map' style='width: 100%; height: 300px'></div>"; 
 var map = new GMap(document.getElementById("map")); 
   map.setMapType(G_NORMAL_MAP); 
	map.addControl(new GLargeMapControl()); 
   map.addControl(new GMapTypeControl()); 
map.centerAndZoom(new GPoint (-3.166493, 40.629817), 3); 
}
function abroMapa(valor){
if(valor==1){
	document.getElementById('tblcontenedor').style.display='block';
	document.getElementById('contenedor').innerHTML="<div align='center'><img src='images/carga.gif' alt='actualizando' width='50' height='50' /><br><span class='antetituloPortada'>Cargando informaci&oacute;n...</span></div>";
	}
	if(valor<=300){
		document.getElementById('contenedor').height=valor;
		//document.getElementById('contador').innerHTML=valor;
		valor=valor+8;
		setTimeout("abroMapa("+valor+")",1);
	}else{
		cargamapa();
	}
}