	$().ready(function() {
		
		$("#lc4-box").corner();


		$forms = $('form');
		$forms.bind('submit', function(){

				$.ajax({
					type: 'POST',
					url: "index.php",
					data: "longUrl="+$("#longUrl").val()+"&rand="+Math.random(),
					beforeSend: function(){
						$('#resultado').show();
						$('#resultado').html("<img src='img/loading.gif' alt='Aguarde, carregando...' border='0' />");
						$("#longUrl").val("http://");

					},
					success: function(txt){
						$('#resultado').hide();
						$('#resultado').html(txt);
						$('#resultado').show("slow");
						$("#longUrl").val("http://");
						
					},
		
					// Se acontecer algum erro é executada essa função
					error: function(txt){
						$('#resultado').hide();
						$('#resultado').html(txt);
						$('#resultado').show("slow");
						$("#longUrl").val("http://");
					}
				})
				return false;
			});

	});
