function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objeto AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
} 

function eliminaEspacios(cadena)
{
	// Funcion equivalente a trim en PHP
	var x=0, y=cadena.length-1;
	while(cadena.charAt(x)==" ") x++;	
	while(cadena.charAt(y)==" ") y--;	
	return cadena.substr(x, y-x+1);
}

function limpiarDatos(idInput)
{
	var valorInput=document.getElementById(idInput).value;
	var divError=document.getElementById("error");
	
	valorInput.value= "";
	divError.innerHTML="";
	divError.style.display= "none";
}

function cargaDatos(idInput)
{
	var valorInput=document.getElementById(idInput).value;
	var divError=document.getElementById("error");
	
	if(valorInput){
	
	// Elimino todos los espacios en blanco al principio y al final de la cadena
	valorInput=eliminaEspacios(valorInput);
		
	// Creo objeto AJAX y envio peticion al servidor
	var ajax=nuevoAjax();
	ajax.open("GET", "/tags/insert_tag.php?dato="+valorInput+"&id_famosa="+idInput, true);
	ajax.send(null);
	
	divError.innerHTML="El tag ha sido insertado";
	divError.style.display="block";
	}
}