function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
		
	}
	return ajaxRequest;
}
function showData(all,idref) {
	//alert("i m here");
	htmlRequest = ajaxFunction();
	if (htmlRequest==null){ // If it cannot create a new Xmlhttp object.
		alert ("Browser does not support HTTP Request"); // Alert Them!
		return; // Returns.
	} // End If.
	
	if(all == 'false'){
		htmlRequest.open("GET", "outputinfo.php?id=" + idref + "&all=" + all, true);
	}else{
		htmlRequest.open("GET", "outputinfo.php?id=" + idref + "&all=" + all, true);
	}
	htmlRequest.onreadystatechange = function(){
		if(htmlRequest.readyState == 4){
			document.getElementById("mensaje").innerHTML = htmlRequest.responseText;
		}
	}
	htmlRequest.send(null);

}

function updateData(all,idref){
	setInterval("showData(all,idref)",1000);
}

function saveData(){ // This is our SaveData function, we will use this to send data to the database.
	htmlRequest = ajaxFunction();
	//alert(htmlRequest);
	if (htmlRequest==null){ // If it cannot create a new Xmlhttp object.
		alert ("Browser does not support HTTP Request"); // Alert Them!
		return; // Returns.
	} // End If.
	
	if(document.formulario.nombre.value == "" || document.formulario.nombre.value == "Tu nombre" || document.formulario.comentario.value == "" || document.formulario.comentario.value == "Escribe tu comentario"){ // If one of the fields is left Blank.
		alert('You need to fill in name and message!'); // Alters the user they forgot a field
		return; // Stops the rest of the script.
	} // End If.
	htmlRequest.open('POST', 'sendshout.php'); // Sends our shout to sendshout.php.
	htmlRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // This tells our browser that a form is being submitted.
	htmlRequest.send('nombre='+document.formulario.nombre.value+'&comentario='+document.formulario.comentario.value+'&tabla='+document.formulario.tabla.value+'&idnota='+document.formulario.idnota.value); // Sends the data.

	document.formulario.comentario.value = ''; // Updates the shout box’s text area to NULL.
	document.formulario.comentario.focus(); // Focuses the text area.
	
} // End Function.
