function trim(str){return str.replace(/^\s+|\s+$/g,"");}


jQuery(document).ready(function($) {
		$(".tweet").tweet({
          join_text: "auto",
          username: "todarede",
          avatar_size: 32,
          count: 5,
          auto_join_text_default: "escrevemos,", 
          auto_join_text_ed: "we",
          auto_join_text_ing: "we were",
          auto_join_text_reply: "respondemos",
          auto_join_text_url: "we were checking out",
          loading_text: "Carregando..."
        }).bind("empty", function() { $(this).append("Ainda não encontramos nenhum tweet"); });
});

function envia() {
	if ($("#nome").val().length < 5 ) { $("#nome").focus(); pop('Preencha seu nome corretamente'); return;	}
		if ($("#email").val().length < 5 ) { $("#email").focus(); pop('Preencha seu email corretamente.'); return;	}
		var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
		if (regmail.test($("#email").val()) == false ) { $("#email").focus(); pop('Preencha seu email corretamente.'); return; }
		if ($("#comentarios").val().length < 10 ) { $("#comentarios").focus(); pop('Seu comentário deve conter no mínimo 10 digitos.'); return;	}
		//document.forms['envia_falecom'].submit();


		$.post("sender.php?falecom", { nome: $('#nome').val(), email: $('#email').val(), comentarios:$('#comentarios').val()  },
					function(data){
						if (trim(data) != '0') {
							$("#box_falecom").replaceWith(data);
							return false;
						} else {
							$("#nome").focus();
							pop('Verifique as informações fornecidas.');
							return false;
						}

						
						
					}
			);

}

function chat(x) {


	if (x == '1') {
		$("#chat").css({'display' : 'block'});
		$("#call_chat").css({'display' : 'none'});
	} else {
		$("#chat").css({'display' : 'none'});
		$("#call_chat").css({'display' : 'block'});
	}


}

function pop(msg) {
		$("#alert").html(msg);
		$(function () {
			var $alert = $('#alert');
			if($alert.length)
			{
				var alerttimer = window.setTimeout(function () { $alert.trigger('click'); }, 3000);
				$alert.animate({height: $alert.css('line-height') || '50px'}, 200).click(
					function () {
						window.clearTimeout(alerttimer);
						$alert.animate({height: '0'}, 200);
					});
			}
		});

	return false;
}