//AJAX TOMADO DE AJAX.JS


function nuevoAjax(){
var xmlhttp=false; 
	try { 
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
	} 
	catch (e) { 
		try { 
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch (E) { 
			xmlhttp = false; 
		} 
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
var http = getXmlHttpObject(); 

function getXmlHttpObject() {
	var xmlhttp;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
}
@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		}
		catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

function handleHttpResponse() {
	if (http.readyState == 1) {
		document.getElementById('fotos').innerHTML = "<div id=\"mensaje\">Cargando...</div>";
	}
	if (http.readyState == 4) {
		results = http.responseText;
		document.getElementById('fotos').innerHTML = results;
	}
}

function verVideo(Pelicula, Seccion) {
	http.open("GET", "video.php?seccion=" + Seccion + "&video=" + Pelicula, true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
}

var step=1
function slideit(CantidaddeImagenes){
//if browser does not support the image object, exit.
if (!document.images)
return
//document.images.slide.src=eval("image"+step+".src");
document.getElementById('fotos').innerHTML = "<img name=\"slide\" src=\"" + eval("image"+step+".src") + "\" width=\"357\" height=\"207\">";
document.getElementById('espepigrafe').innerHTML = eval("epigrafe"+step);
if (step < CantidaddeImagenes)
step++
else
step=1
//call function "slideit()" every 2.5 seconds
sliderecursivo = setTimeout("slideit("+CantidaddeImagenes+")",5000)
}

function cargaVideo (Video, Seccion, Imagenes, Idioma) {
	if (Imagenes > 0) {
		Cartel = (Idioma == 1) ? "Im&aacute;genes" : "Images";
		clearTimeout(sliderecursivo);
		document.getElementById('espepigrafe').innerHTML = "<span style=\"cursor:pointer;\" onClick=\"slideit("+Imagenes+")\"><small>" + Cartel + "</small></span>";
	}
	var fo = new FlashObject("swf/videoreproductor.swf", "menu", "357", "207", "8", "#000000");
	fo.addVariable("pelicula", Video);
	fo.addVariable("seccion", Seccion);
	fo.write("fotos");
}





// Ajax
var _xmlhttp, _id, _idioma;

/*@cc_on @*//*@if (@_jscript_version >= 5)
var idAX = ["Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];
for(var i=0; !_xmlhttp && i<idAX.length; i++)
{try{ _xmlhttp = new ActiveXObject(idAX[i]);}
catch(ex) { _xmlhttp = false; }
}@end @*/

if (!_xmlhttp && typeof XMLHttpRequest != 'undefined') {
	_xmlhttp = new XMLHttpRequest();
}

function leerPagina(url, id, idioma) {
	if (_xmlhttp.readyState == 4 || _xmlhttp.readyState == 0) {
		_id = id;
		_idioma = idioma;
		_xmlhttp.open("GET", url, true);
		_xmlhttp.onreadystatechange = evaluarResultado;
		_xmlhttp.send(null);
	}
}

function evaluarResultado() {
	if (_xmlhttp.readyState == 1) {
		if (_idioma == 1) document.getElementById(_id).innerHTML = "<span class=\"txt_negro\">Cargando...</span>";
		else document.getElementById(_id).innerHTML = "<span class=\"txt_negro\">Loading...</span>";
	}
	else if (_xmlhttp.readyState == 4) {
		if (_xmlhttp.status == 200) {
			document.getElementById(_id).innerHTML = _xmlhttp.responseText;
		}
		else {
			if (_idioma == 1) document.getElementById(_id).innerHTML = "Ha ocurrido un error:\n" + _xmlhttp.statusText;
			else document.getElementById(_id).innerHTML = "An error has occurred:\n" + _xmlhttp.statusText;
		}
	}
}
// - Fin Ajax

function imprimir() {
	win=window.open();
	win.document.write(document.all.tablaresultados.outerHTML);
	win.document.close();
	win.print();
	win.close();
}
function recargaCaptcha(idioma) {
	var mensaje = (idioma == 1) ? "Cargando" : "Loading";
	http.open("GET", "inc_captcha.php", true);
	http.onreadystatechange = function () {
		if (http.readyState == 1) {
			document.getElementById("captcha").innerHTML = "<div id=\"mensaje\">" + mensaje + "...</div>";
		}
		if (http.readyState == 4) {
			document.getElementById("captcha").innerHTML = http.responseText;
		}
	};
	http.send(null);
}
