function ajaxFunction(){
	var ajaxRequest;
	try{
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}

///////////////////////////////////////////////////////////////////////////////////////

function showData() {
	htmlRequest = ajaxFunction();
	if (htmlRequest==null){
		alert ("Browser does not support HTTP Request");
		return;
	} 

	htmlRequest.onreadystatechange = function(){
		if(htmlRequest.readyState == 4){
			document.getElementById("shoutarea").innerHTML = htmlRequest.responseText;
		}
	}
	htmlRequest.open("GET", "obshout/outputinfo.php", true);
	htmlRequest.send(null);
}

showData();
setInterval("showData()",10000);

///////////////////////////////////////////////////////////////////////////////////////

function saveData(){
	htmlRequest = ajaxFunction();
	if (htmlRequest==null){
		alert ("Browser does not support 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('You need to fill in name and message!');
		return;
	}
	
	if(document.shoutbox.shouter.value == "OffBeat" || document.shoutbox.shouter.value == "Off Beat" || document.shoutbox.shouter.value == "OffBeat Music" || document.shoutbox.shouter.value == "Off Beat Music" || document.shoutbox.shouter.value == "OFFBEAT" || document.shoutbox.shouter.value == "OFF BEAT" || document.shoutbox.shouter.value == "OFFBEAT MUSIC" || document.shoutbox.shouter.value == "OFF BEAT MUSIC"){
		alert('You can not use this user name!');
		return;
	}
	
	htmlRequest.open('POST', 'obshout/sendshout.php');
	htmlRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	htmlRequest.send('name='+document.shoutbox.shouter.value+'&message='+document.shoutbox.shouter_comment.value+'&contact='+document.shoutbox.shouter_contact.value); 

	document.shoutbox.shouter_comment.value = '';
	document.shoutbox.shouter_comment.focus();

} 