//Script by Edan Boy Atun Pedragosa alias HACKERSOFT
function updShouts() {
	$(document).ready(function(){
		$("#ShoutData").load(SiteRoot + "infusions/shoutbox_panel/includes/data.php");
    });
	setTimeout('updShouts()', RefreshTime);
	document.getElementById('ShoutProcessing') ? document.getElementById('ShoutProcessing').style.display='none' : "";
}

$(document).ready(function(){
	$("form#chatform").submit(function(){
		$.post(SiteRoot + "infusions/shoutbox_panel/includes/data.php",{
					shout_message: $("#shout_message").val(),
					shout_name: $("#shout_name").val(),
					es_id: $("#es_id").val(),
					action: "postShout"
				}, function() {
			$("#shout_message").val('');
			$("#es_id").val('');
			document.getElementById('chars_max').value = CharMax - document.getElementById('shout_message').value.length;
			updShouts();
		});
		return false;
	});
});

function editShouts(id) {
	document.getElementById('ShoutProcessing').style.display='none';
	$(document).ready(function(){
		var html = $.ajax({
		  url: SiteRoot + "infusions/shoutbox_panel/includes/data.php?shout_id=" + id,
		  async: false
		 }).responseText;
		$("#shout_message").val(html);
    });
}

function deleteShouts(id) {
	$(document).ready(function(){
		var html2 = $.ajax({
		  url: SiteRoot + "infusions/shoutbox_panel/includes/data.php?dshout_id=" + id,
		  async: false
		 }).responseText;
    });
	updShouts();
}

function ShoutCharLimit () {
	if (document.getElementById('shout_message').value.length > CharMax) { 
		document.getElementById('shout_message').value = document.getElementById('shout_message').value.substring(0, CharMax);
		alert(ShoutMaxNotice);
	} else { 
		document.getElementById('chars_max').value = CharMax - document.getElementById('shout_message').value.length; 
	}
}
