function resize() {
	if ($(window).width() > 990) {
	  $('html').css({'overflow-x':'hidden'});
	} else {
	  $('html').css({'overflow-x':'auto'});
	}
		Cufon.replace('ul.menu-principal li a, .cufon');
}

Cufon('.cufonSombra', {
		textShadow: '-1px 1px 20px black'
});

$(window).resize(function(){ resize(); });
$(document).ready(function() {
    $('.fondhome').maxImage({
        isBackground: true,
        slideShow: false,
        slideDelay: 5.2,
        loaderClass: 'scalingLoader',
        verticalAlign: 'top'
    });

    $("div.fotoImg").hover(function() { //On hover...
        var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'

        //Set a background image(thumbOver) on the <a> tag - Set position to bottom
        $(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});

        //Animate the image to 0 opacity (fade it out)
        $(this).find("span").stop().fadeTo('normal', 0 , function() {
                $(this).hide() //Hide the image after fade
        });

        $(this).animate({ marginTop: "-10px" }, 500, "easeOutExpo");
    } , function() { //on hover out...
        //Fade the image to full opacity
        $(this).find("span").stop().fadeTo('normal', 1).show();
        $(this).animate({ marginTop: "0" }, 500, "easeOutExpo");
    });

    resize();
});

function validaNewsLetter() {

    var email = $('#form-email').val();
    var nome =  $('#form-nome');
               
    if(nome.val() == ""){
        $("#snome").html("Campo inválido.");
        nome.focus();
        return false;
    }
    else{
        $("#snome").html('');
    }
    
    if (!checkMail(email)) {
        $("#semail").html('Campo inválido.');
        $('#form-email').focus();
        return false;
    }
    else{
        $("#semail").html('');
    }

    var dataString = 'nome=' + nome.val() + '&mail=' + email;

    $.ajax({
        type: "POST",
        url: "imoveis/app/assinatura.php",
        data: dataString,
        beforeSend: function() {
            $("#saida").html('Aguarde...'); // ...mensagem de espera
        },
        success: function(txt) { // executa quando o servidor responde
            $("#saida").remove();
            $(".msgErro").remove();
            $(".msgSucesso").remove();
            $("#cadastro").append(txt);
        },
        error: function(txt) { // executa quando n?o responde ou envia um erro
            $("#saida").remove();
            $(".msgErro").remove();
            $(".msgSucesso").remove();
            $("#cadastro").append('<span class="msgErro">Desculpe, houve um erro interno.</span>');
        }
    });
    
    return false;

}

// valida��o de email
function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string") {
        if(er.test(mail)) {
            return true;
        }
    }
    else if(typeof(mail) == "object") {
        if(er.test(mail.value)) {
            return true;
        }
    }
    else {
        return false;
    }
}

