/**
 * 
 */
$.fn.leloButtom = function(){
	var texto = this.html();
	this.html('');
	this.append('<span>'+texto+'</span>');
};

$(function() {
	
	// Iniciando o Superfish
	$('ul#menu-padrao.menu').superfish(); 
	
	// Configuração dos buttons
	$('a.buttom').leloButtom();
	
	// Formulários
	$('#forms form input.fb, #forms form textarea.fb').bind('blur focus', function(){
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('');
		}else if($(this).val() == ''){
			$(this).val($(this).attr('title'));
		}
	});
	
	
});

function verificaForm(mensagem)
{
//	<strong>Obrigado!</strong> Seu email foi enviado com sucesso.
	var $this = $('#forms form');
    $('#forms form .error').remove();
    var hasError = false;
    $('.requiredField').each(function() {
    	if(jQuery.trim($(this).val()) == jQuery.trim($(this).attr('title'))) {
    		var labelText = $(this).attr('title');
    		$(this).parent().append('<span class="error">'+labelText+' required</span>');
    		hasError = true;
    	} else if($(this).hasClass('email')) {
    		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    			if(!emailReg.test(jQuery.trim($(this).val()))) {
    				var labelText = $(this).attr('title');
    				$(this).parent().append('<span class="error">invalid '+labelText+'</span>');
    				hasError = true;
    			}
    	}
    });
    if ( hasError ) {
    	
    }else{
    	$this.slideUp("slow");
        var formInput = $this.serialize();
        $.post($this.attr('action'),formInput, function(data){
          $('#forms').slideUp("slow", function() {           
            $(this).before('<p class="thanks">'+mensagem+'</p>');
          });
        });
    }

}
