function ajaxFunction(){
	var ajaxRequest;

	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){
				//browsers all not support, rare case
				alert("Tu navegador no esta soportado!");
				return false;
			}
		}

	}
	return ajaxRequest;
}

function showData() {
	//alert("Entro a ShowData!");
	htmlRequest = ajaxFunction();
	if (htmlRequest==null){ // If it cannot create a new Xmlhttp object.
		alert ("El navegador no soporta HTTP Request");
		return;
	}

	htmlRequest.onreadystatechange = function(){
		if(htmlRequest.readyState == 4){
			document.getElementById("shoutarea").innerHTML = htmlRequest.responseText;
		}
	}
	htmlRequest.open("GET", "outputinfo.php", true);
	htmlRequest.send(null);
}

showData();
setInterval("showData()",1000);

function saveData(){
  htmlRequest = ajaxFunction();
	if (htmlRequest==null){ // If it cannot create a new Xmlhttp object.
		alert ("El navegador no soporta HTTP Request");
		return;
	}

	if(document.shoutbox.shouter.value == "" || document.shoutbox.shouter.value == "NULL" || document.shoutbox.shouter_comment.value == "" || document.shoutbox.shouter_comment.value == "NULL"){
		alert('Debe poner su nombre y un mensaje!');
		return;
	}

	// Controlar Spammer y demas salamines que molestan

	htmlRequest.open('POST', 'sendshout.php');
	htmlRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	htmlRequest.send('nombre='+document.shoutbox.shouter.value+'&mensaje='+document.shoutbox.shouter_comment.value+'&contacto='+document.shoutbox.shouter_contact.value);

	document.shoutbox.shouter_comment.value = ''; // Updates the shout box’s text area to NULL.
	document.shoutbox.shouter_comment.focus();    // Focuses the text area.
}
