/**
 * @author milton
 */
function cambiarFoto(direccion)
{
	if(document.getElementById("inicial"))
	{
		//creo una variable para poder realizar el movimiento automatico y le asigno el valor del contador inicial
		valor = document.getElementById("inicial").value;
		//incremento la variable
		valor++;
		//asigno el nuevo valor al contador
		document.getElementById("inicial").value = valor;

		//Capturamos los divs
		var divFoto = document.getElementById("imagen_foto_noticia");
		var divTitular = document.getElementById("titular_foto_noticia");
		var divResumen = document.getElementById("resumen_foto_noticia");
		var divCategoriaActual = document.getElementById("categoria_actual_foto_noticia");
		var Categorias_Fotonoticia = document.getElementById("categorias_foto_noticia");
		var CategoriaActual = divCategoriaActual.value;


		ajax=nuevoAjax();
		ajax.open("GET", "tools/fotonoticia.php?direccion="+direccion+"&actual="+CategoriaActual+"&categorias_foto_noticia="+Categorias_Fotonoticia.value);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {

				//Aceptamos la respuesta del php
				var resultado = ajax.responseText;

				//Hacemos un explode a lo que viene para capturar titulo, imagen y resumen
				//El separador es |
				var datos = new Array();
				datos = resultado.split('|');

				//Pintamos los datos


				divTitular.innerHTML = datos[0];
				divFoto.innerHTML = datos[1];
				divResumen.innerHTML = datos[2];
				divCategoriaActual.value = datos[3];
				if(datos[4] == valor)
				{
					//alert("jajaj");
					cambiarFoto("undefined");
					document.getElementById("inicial").value='1';
				}
			}
		}
		ajax.send(null);
	}
}
//window.onload = cambiarFoto('undefined');
setInterval("cambiarFoto(\"sig\")", 10000);

/*
Effect.OpenUp = function(element) {
     element = $(element);
     new Effect.BlindDown(element, arguments[1] || {});
 }

 Effect.CloseDown = function(element) {
     element = $(element);
     new Effect.BlindUp(element, arguments[1] || {});
 }

 Effect.Combo = function(element) {
     element = $(element);
     if(element.style.display == 'none') {
          new Effect.OpenUp(element, arguments[1] || {});
     }else {
          new Effect.CloseDown(element, arguments[1] || {});
     }
 }*/