function myXMLHttpRequest (){
	var xmlhttplocal = false;
	if (typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttplocal = new XMLHttpRequest ();
		}
		catch (e) {
  			xmlhttplocal = false;
		}
	}
	if (!xmlhttplocal) {
		try {
			xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")
		}
		catch (e) {
			try {
				xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")
			}
			catch (E) {
				xmlhttplocal = false;
				alert ('Lamentablemente parece que su navegador no soporta aplicaciones Ajax y esta página lo utiliza.');
			}
  		}
	}
	return (xmlhttplocal);
}

function Emoticones(pag){
	var respuesta = new String;
	var xmlhttp = new myXMLHttpRequest ();
	if (xmlhttp) {
		target = document.getElementById ('div_motor');	
		if (target) {
			target.innerHTML = "<center><img border='0' src='imagenes/busqueda.gif' width='32' height='32' style='margin:15px'></center>";
			url =  "emoticones_dir.php?p=" + pag;
			xmlhttp.open ("GET", url, true);
			errormatch = new RegExp ("^ERROR:");

			xmlhttp.onreadystatechange = function () {
				if (xmlhttp.readyState == 1) {
					target.innerHTML = "<center><img border='0' src='imagenes/busqueda.gif' width='32' height='32' style='margin:15px'></center>";
				}//if	
					
				if (xmlhttp.readyState == 4) {
					respuesta = xmlhttp.responseText;
					if (respuesta.match (errormatch)) {	
						respuesta = respuesta.substring (6, respuesta.length);
						alert (respuesta);			
					}else{
						target.innerHTML = respuesta;
					}//if
				}//if
			}//  function() 
		}//if(target)
		xmlhttp.send (null);
		
	}//if (xmlhttp)
}//fun

function Descargar(camino,id){
	var respuesta = new String;
	target = document.getElementById ('div_ver' + id);	
	if (target) {
		target.innerHTML = "<center><img border='0' src='imagenes/busqueda.gif' width='32' height='32' style='margin:15px'></center>";
		
		respuesta += '<table border="0" cellpadding="2" cellspacing="0" width="100%">';
		respuesta += '  <tr>';
		respuesta += '    <td width="1%"><img src="' + camino + '" border="1"></td>';
		respuesta += '    <td width="99%"><p><b>Para descargar este emoticón:</b> pon encima el mouse y con el botón derecho despliega el menú de opciones, luego haz clic en &quot;Guardar imagen como&quot;. En la ventana que se abre elige un directorio en donde guardarla y cámbiale el nombre al archivo. <b>Recuerda conservar la extensión: gif</b>).</p><p><a href="javascript:Oculta(' + id + ');">Clic para cerrar esta ayuda</a></p></td>';
		respuesta += '  </tr>';
		respuesta += '</table>';
		target.innerHTML = respuesta;

	}//if(target)

}//fun

function Oculta(id){
	target = document.getElementById ('div_ver' + id);	
	if (target) {
		target.innerHTML = "";
	}
}
