function mdEfeito(node) {
	node.style.borderColor = "#2D3785";
	node.onmouseout = function () { node.style.borderColor = "#EBEBEB"; }
	node.onclick = function () { window.location = node.firstChild.childNodes[0].href; }		
}

function submitNews() {
	var node = document.newsletter;
	$("a#news").fancybox({ 'frameWidth' : 0 });
				
	if ( node.nome.value == "" ) {
		alert('Por favor digite seu nome!');
		node.nome.focus();
	} else if ( !node.email.value.match(/^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/) ) {
		alert('Por favor digite um email válido!');
		node.email.focus();
	} else {
		$("#news").attr("href", "actions/cadnews.php?n="+node.nome.value+"&e="+node.email.value);
		$("a#news").fancybox({'zoomSpeedIn':0, 'zoomSpeedOut':0, 'overlayShow' : true,'frameWidth':410, 'frameHeight':275});
		node.reset();
	}
	return false;
}
	
$(document).ready(function(){

    // Crio uma variável chamada $forms que pega o valor da tag form
    $forms = $('#fcontato');

    $forms.bind('submit', function(){

        //Crio a variável $button
        var $button = $('button',this).attr('disabled',true);
        var $input = $('input',this);
        var $textarea = $('textarea',this);
        var $select = $('select',this);
		
        //Cria variável params -  serialize(): pega os dados inseridos no formulário
        var params = $(this.elements).serialize();

        var self = this;
        $.ajax({
            type: 'POST',          
            url: this.action, // this.action onde vai ser enviado os dados
            data: params, // Os dados que pegamos com a função serialize()

            // Antes de enviar
            beforeSend: function(){
                $button.html("Enviando...");
            },
			
            success: function(txt){
				
				if ( txt != "OK" ) {
					$button.attr('disabled',false);
					$button.html("Enviar");
					$('#loading').html(txt);
					
				} else {
					$('#loading').html("Sua mensagem foi enviada com sucesso!");
					$input.attr("readonly", true);
					$textarea.attr("disabled", true);
					$select.attr("disabled", true);
				}

            },

            error: function(txt){
				$button.html("Enviar");
                $('#loading').html(txt);
            }
        })
        return false;
    });
});