function parseXML() {
	ts();
	com();
	setTimeout("parseXML()",5000);
}

function ts() {
	extensiones_imagen = new Array(".gif", ".jpg"); 
	
	if (window.XMLHttpRequest) {
  		xhttp=new window.XMLHttpRequest();
  	}
	else { // Internet Explorer 5/6
  		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xhttp.open("GET","destacadosTemasSalud.xml",false);
	xhttp.send("");
	xmlDoc=xhttp.responseXML;
	var idDestacado = document.getElementById('idDestacadoTS').value;
    var longitud = xmlDoc.getElementsByTagName("imagen");
    var longitudtotal = longitud.length;
    longitudtotal--;
	var archivo = "http://www.prosaltlaxcala.gob.mx/images/"+xmlDoc.getElementsByTagName("imagen")[idDestacado].childNodes[0].nodeValue;
	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase();
	//alert(extension);
	if(extension == ".jpg" || extension == ".gif"){
		document.getElementById('divTemasSalud2').style.display='none';
		document.getElementById('divTemasSalud1').style.display='';
		//alert(archivo);
		document['imgArticuloDestacadoSalud'].src = "http://www.prosaltlaxcala.gob.mx/images/"+xmlDoc.getElementsByTagName("imagen")[idDestacado].childNodes[0].nodeValue;
	}
	else {
		 document.getElementById('divTemasSalud1').style.display='none';
		 document.getElementById('divTemasSalud2').style.display='';
		 texto = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';
		 texto += 'width="320" height="155"><param name="movie" value="http://www.prosaltlaxcala.gob.mx/images/';
		 texto += xmlDoc.getElementsByTagName("imagen")[idDestacado].childNodes[0].nodeValue;
		 texto += '"/><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="http://www.prosaltlaxcala.gob.mx/images/';
		 texto += xmlDoc.getElementsByTagName("imagen")[idDestacado].childNodes[0].nodeValue;
		 texto += '" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="320" height="155"></embed>';
		 texto += '</object>';
		 document.getElementById('divTemasSalud2').innerHTML = texto;
		 
		 
  	}
	document.getElementById("txtSpotlightTemasSalud").innerHTML = xmlDoc.getElementsByTagName("titulo")[idDestacado].childNodes[0].nodeValue;
	document.getElementById("linkSpotlightSalud").href = "articulo.php?a="+xmlDoc.getElementsByTagName("linkid")[idDestacado].childNodes[0].nodeValue;	
	
	idDestacado++; 
	if(idDestacado > longitudtotal) {
		idDestacado = 0;
	}
		
	/*if (idDestacado == 0) {
        if(idDestacado < longitudtotal) {
            idDestacado = 1;
        }
	}
	else if (idDestacado == 1) {
        if(idDestacado == longitudtotal) {
            idDestacado = 0;
        }
        else if(idDestacado < longitudtotal) {
            idDestacado = 2;
        } 
	}
	else if (idDestacado == 2) {
        if(idDestacado == longitudtotal) {
            idDestacado = 0;
        }
	}*/
    //alert("D:"+idDestacado);
    document.getElementById('idDestacadoTS').value = idDestacado;
}
function com() {
	if (window.XMLHttpRequest) {
  		xhttp=new window.XMLHttpRequest();
  	}
	else { // Internet Explorer 5/6
  		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xhttp.open("GET","destacadosComunicados.xml",false);
	xhttp.send("");
	xmlDoc=xhttp.responseXML;
	var idDestacado = document.getElementById('idDestacadoCOM').value;
    var longitud = xmlDoc.getElementsByTagName("imagen");
    var longitudtotal = longitud.length;
    longitudtotal--;

	var archivoext = "http://www.prosaltlaxcala.gob.mx/images/"+xmlDoc.getElementsByTagName("imagen")[idDestacado].childNodes[0].nodeValue;
	exten = (archivoext.substring(archivoext.lastIndexOf("."))).toLowerCase();
	//alert(extension);
	if(exten == ".jpg" || exten == ".gif"){
		document.getElementById('divComunicados2').style.display='none';
		document.getElementById('divComunicados1').style.display='block';
		document['imgArticuloDestacadoComunicados'].src = "http://www.prosaltlaxcala.gob.mx/images/"+xmlDoc.getElementsByTagName("imagen")[idDestacado].childNodes[0].nodeValue;
	}
	else {
		 document.getElementById('divComunicados1').style.display='none';
		 document.getElementById('divComunicados2').style.display='block';
		 texto = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';
		 texto += 'width="320" height="155"><param name="movie" value="http://www.prosaltlaxcala.gob.mx/images/';
		 texto += xmlDoc.getElementsByTagName("imagen")[idDestacado].childNodes[0].nodeValue;
		 texto += '"/><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="http://www.prosaltlaxcala.gob.mx/images/';
		 texto += xmlDoc.getElementsByTagName("imagen")[idDestacado].childNodes[0].nodeValue;
		 texto += '" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="320" height="155"></embed>';
		 texto += '</object>';
		 document.getElementById('divComunicados2').innerHTML = texto;
  	}
	//document['imgArticuloDestacadoComunicados'].src = "images/"+xmlDoc.getElementsByTagName("imagen")[idDestacado].childNodes[0].nodeValue;
	
	document.getElementById("txtSpotlightComunicados").innerHTML = xmlDoc.getElementsByTagName("titulo")[idDestacado].childNodes[0].nodeValue;
	document.getElementById("linkSpotlightComunicados").href = "articulo.php?a="+xmlDoc.getElementsByTagName("linkid")[idDestacado].childNodes[0].nodeValue;	
	
	idDestacado++; 
	if(idDestacado > longitudtotal) {
		idDestacado = 0;
	}
	
	/*if (idDestacado == 0) {
        if(idDestacado < longitudtotal) {
            idDestacado = 1;
        }
	}
	else if (idDestacado == 1) {
        if(idDestacado == longitudtotal) {
            idDestacado = 0;
        }
        else if(idDestacado < longitudtotal) {
            idDestacado = 2;
        } 
	}
	else if (idDestacado == 2) {
        if(idDestacado == longitudtotal) {
            idDestacado = 0;
        }
	}*/
    //alert("D:"+idDestacado);
    document.getElementById('idDestacadoCOM').value = idDestacado;
}

function rotateImageSpotlight() {
	document.getElementById('idDestacadoTS').value = 0;
	document.getElementById('idDestacadoCOM').value = 0;
	parseXML();
}

function mouseOverMenu(id, img) {
	document[id].src = img;
}

function mouseOutMenu(id, img) {
	document[id].src = img;
}

function tabsInfo(id) {
	if (window.XMLHttpRequest) {
  		xhttp=new window.XMLHttpRequest();
  	}
	else { // Internet Explorer 5/6
  		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xhttp.open("GET","direccionPromocion.xml",false);
	xhttp.send("");
	xmlDoc=xhttp.responseXML;
	document.getElementById("entryarticle").innerHTML = xmlDoc.getElementsByTagName("data")[id].childNodes[0].nodeValue;
}

function mostrardiv(post) { 
    div = document.getElementById(post); 
    div.style.display = ''; 
} 

function cerrar(post) { 
    div = document.getElementById(post); 
    div.style.display='none'; 
} 
