/*
 * Ver http://jibbering.com/2002/4/httprequest.html
*/
var xmlhttp=false;
/*@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') {
  xmlhttp = new XMLHttpRequest();
}

function replace_elemento(idcontenedor,idgaleria,idalbum,idelemento,tamano,idplantilla_elemento,idplantilla_imagen) {
	var div = document.getElementById(idcontenedor);
	if (!div || (div == null)) {
		return false;
	}
	html = get_html_elemento(idgaleria,idalbum,idelemento,tamano,idplantilla_elemento,idplantilla_imagen);
	div.innerHTML=html;

	return true;
}

function get_html_elemento(idgaleria,idalbum,idelemento,tamano,idplantilla_elemento,idplantilla_imagen) {
	var html = '';
	var url = '/cgi-bin/galerias/elemento.shtml?idgaleria='+idgaleria+'&idalbum='+idalbum+'&idelemento='+idelemento+'&t='+tamano+'&idplantilla_elemento='+idplantilla_elemento+'&idplantilla_imagen='+idplantilla_imagen+'&rnd='+Math.random();
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	if (xmlhttp.readyState==4) {
		html=xmlhttp.responseText;
	}

	return html;
}

function check_elemento_en_url(idcontenedor,tamano,idplantilla_elemento,idplantilla_imagen,defecto) {
	function get_url_params() {
		var pares=unescape(location.search.substring(1).replace(/\+/g," ")).split('&');
		for (var i=0;i<pares.length;i++) {
			var par = pares[i].split('=')
			this[par[0]]=par[1];
		}
	}
	url_params = new get_url_params();
	if (url_params['idelemento']) {
		replace_elemento(idcontenedor,url_params['idgaleria'],url_params['idalbum'],url_params['idelemento'],tamano,idplantilla_elemento,idplantilla_imagen);
	} else if (defecto!='') {
		eval(defecto);
	}

	return true;
}

