$(function() {
				
	$.ajaxSetup ({
		cache: false
	});
	
	$("#codifica").click(function(){
		$("#encodeLoad").fadeIn();
		var text = $("#textarea").val();
		$.post(
			"encode.php",{'codifica':text},
			function(responseText){
				var html = responseText;
				//html.replace(/\"/g, '&quot;')
					//.replace(/\'/g, '&#39;');
				$("#textarea").val(html);
				$("#encodeLoad").fadeOut();
			},
			"html"
		);
		return false;
	});
	
	
	$("#decodifica").click(function(){
		$("#decodeLoad").fadeIn();
		var text = $("#textarea").val();
		$.post(
			"decode.php",{'decodifica':text},
			function(responseText){
				var html = responseText;
				//html.replace(/\"/g, '&quot;')
					//.replace(/\'/g, '&#39;');
				$("#textarea").val(html);
				$("#decodeLoad").fadeOut();
			},
			"html"
		);
		return false;
	});
	
	
	$("#open").click(function(){
		$(this).hide();
		$("#close").show();
		var width = $("#infobox").width();
		marg = ((916 - width - 20)/2);
		$("#infobox").css("margin-left", marg + "px");
		$("#infobox").fadeIn("slow");
		return false;
	});
	
	$("#close").click(function(){
		$(this).hide();
		$("#open").show();
		$("#infobox").fadeOut("slow", function(){
			$("#textarea").focus();
		});
		return false;
	});
	
});