$(document).ready(function() { 

	$("#twmessage").keydown(function() { 
		var currentChars = this.value.length;
		var returnMessageC = 140 - currentChars;
		var returnMessage = returnMessageC +" chars left";
		if(returnMessageC < 0) {
			$("#counter").text("This message is invalid.");
		} else {
			$("#counter").text(returnMessage);
		}
	});
	
	$("#sendMessage").click(function() { 
		$.post("newmessage.php", { tmessage: $("#twmessage").val(), tuser:$("#twuser").val(), tpass:$("#twpass").val(), tto:$("#twto").val() }, function(data) { 
			$("#messageDisp").text("Your message has been updated with success!");
		});
	});

});

function disable() {
	$.post("disable.php", function(data) { 
		$("#enable-disable").html(data);
	});
}

function enable() {
	$.post("enable.php", function(data) { 
		$("#enable-disable").html(data);
	});
}

function addB(asintoAdd) {
	$.post("/jsaddbook.php", { asintoAdd: asintoAdd }, function(data) { 
		$("#messageDisp").text("Your Book has been updated with success!");
	});
}