var menuSpeed = 500;


$(document).ready(function () {
    
    /* NOVAS ALTERAÇÕES */
    
    $('#txtNomeNew').watermark('Nome');
    $('#txtEmailNew').watermark('E-mail');
    
    $('#txtNomepNew2').watermark('Seu nome');
    $('#txtNomeNew2').watermark('Nome do destinatário');
    $('#txtEmailNew2').watermark('E-mail do destinatário');
   
   /* NOVAS ALTERAÇÕES */
    
    $("body").prepend('<img src="img/submenu-bem-estar.png" style="position: absolute; width: 1px; height: 1px" />');

    $("body").prepend('<img src="img/submenu-conceito.png" style="position: absolute; width: 1px; height: 1px" />');

    $("body").prepend('<img src="img/submenu-fitness.png" style="position: absolute; width: 1px; height: 1px" />');



    $(document).bind("contextmenu", function (event) {

        if (!event || !event.target ||

            (event.target.nodeName != "A" && event.target.nodeName != "INPUT" && event.target.nodeName != "TEXTAREA"))

            return false;

        else {

            if (event.target.nodeName == "A" && $(event.target).hasClass("button"))

                return false;

            else

                return true;

        }

    });



    $(window).resize(onResize);



    if ($(document).columnize) {

        $("div.columnize").columnize({

            width: 260,

            doneFunc: function () {

                $("div.columnize .last p:first").addClass("first");

            }

        });

    }



    if ($(document).accordion) {

        $(".esquerda > .accordion.open").accordion({

            header: "h5",

            animated: "slide",

            autoHeight: false

        });



        $(".esquerda > .accordion:not(.open)").accordion({

            active: false,

            header: "h5",

            animated: "slide",

            autoHeight: false

        });



        $(".datas > .accordion").accordion({

            header: "h6",

            animated: "slide",

            autoHeight: false

        });

    }



    $(".cabecalho .aumentar-texto").click(function (event) {

        $("p").each(function () {

            var currentSize = parseFloat($(this).css("font-size"), 10);

            if (currentSize < 18) $(this).css("font-size", (currentSize + 2));

        })



        event.preventDefault();

        return false;

    });



    $(".cabecalho .diminuir-texto").click(function (event) {

        $("p").each(function () {

            var currentSize = parseFloat($(this).css("font-size"), 10);

            if (currentSize > 10) $(this).css("font-size", (currentSize - 2));

        })



        event.preventDefault();

        return false;

    });



    $(function(){
    $("#form2").submit(function(event){
        event.preventDefault();
        var nome = $("#txtNomeNew").attr("value");
        var email = $("#txtEmailNew").attr("value");
        /*var artigos = $("#chkArtigos").attr("checked");
        var informacoes = $("#chkInformacoes").attr("checked");
        var cursos = $("#chkCursos").attr("checked");
        var novidades = $("#chkNovidades").attr("checked");
        var dicas = $("#chkDicas").attr("checked");
        var programacao = $("#chkProgramacao").attr("checked");*/


		var parte1 = email.indexOf("@");
        var parte2 = email.indexOf(".");
        var parte3 = email.length;

		if(nome == ""){
			alert("Por favor, preecha o campo nome");
			$("#txtNomeNew").focus();
			return false;
		}

		if(email == ""){
			alert("Por favor, preecha o campo email");
			$("#txtEmailNew").focus();
			return false;
		}

		if (!(parte1 >= 3 && parte2 >= 4 && parte3 >= 4)) {
            alert("Por favor, informe seu e-mail corretamente.");
   			$("#txtEmail").focus();
            return false;
        }

      /*  if(artigos == false && informacoes == false && cursos == false && novidades == false && dicas == false && programacao == false){
        	alert("Escolha uma opcao");
        	return false;
        }*/

		$.post('news.php', {nome: nome, email: email/*, artigos: artigos, informacoes: informacoes, cursos: cursos, novidades: novidades, dicas: dicas, programacao: programacao*/}, function(json){
            $(".receba-noticias-form").fadeOut(function() {
            $(".receba-noticias-sucesso").fadeIn();

          });
        }, "json");
    });
});

/* NOVAS ALTERAÇÕES 02/12 >> */
    $(function(){
    $("#form3").submit(function(event){
        event.preventDefault();
        var nomep = $("#txtNomepNew2").attr("value");
        var nome = $("#txtNomeNew2").attr("value");
        var email = $("#txtEmailNew2").attr("value");
        /*var artigos = $("#chkArtigos").attr("checked");
        var informacoes = $("#chkInformacoes").attr("checked");
        var cursos = $("#chkCursos").attr("checked");
        var novidades = $("#chkNovidades").attr("checked");
        var dicas = $("#chkDicas").attr("checked");
        var programacao = $("#chkProgramacao").attr("checked");*/


		var parte1 = email.indexOf("@");
        var parte2 = email.indexOf(".");
        var parte3 = email.length;
        
		if(nomep == ""){
			alert("Por favor, preecha o campo Seu nome");
			$("#txtNomepNew2").focus();
			return false;
		}
                
		if(nome == ""){
			alert("Por favor, preecha o campo nome");
			$("#txtNomeNew2").focus();
			return false;
		}

		if(email == ""){
			alert("Por favor, preecha o campo email");
			$("#txtEmailNew2").focus();
			return false;
		}

		if (!(parte1 >= 3 && parte2 >= 4 && parte3 >= 4)) {
            alert("Por favor, informe seu e-mail corretamente.");
   			$("#txtEmail2").focus();
            return false;
        }

      /*  if(artigos == false && informacoes == false && cursos == false && novidades == false && dicas == false && programacao == false){
        	alert("Escolha uma opcao");
        	return false;
        }*/

		$.post('news2.php', {nomep: nomep, nome: nome, email: email/*, artigos: artigos, informacoes: informacoes, cursos: cursos, novidades: novidades, dicas: dicas, programacao: programacao*/}, function(json){
            
            alert('teste');
            $(".receba-noticias-form2").fadeOut(function() {
            
            $(".receba-noticias-sucesso").fadeIn();

          });
        }, "json");
    });
});

/* <<  NOVAS ALTERAÇÕES 02/12 */


    ajustarMenus();



    onResize();

});



function onResize() {

    if ($(document).width() > 1202) {

        $("html").css("overflow-x", "hidden");

    } else {

        $("html").css("overflow-x", "scroll");

    }

}



function menuEnter() {

    fecharMenus();



    $(window).stopTime("fecharMenus");



    var subMenu = $("ul", this);

    if (subMenu.length == 0)

        return;



    subMenu.show();

    subMenu.css("left", $(this).position().left);



    if ($.support.opacity) {

        subMenu.fadeTo(0, 0);

        subMenu.stop(false, true).animate({ opacity: [1, "swing"] }, { queue: false, duration: menuSpeed });

    }

}



function menuLeave() {

    $(window).oneTime(500, "fecharMenus", fecharMenus);

}



function fecharMenus() {

    $("ul.conceito, ul.fitness, ul.bem-estar", ".menu > ul").each(function () {

        if ($(this).is(":visible")) {

            if ($.support.opacity) {

                $(this).stop(true, true).animate({ opacity: 0 }, { queue: false, duration: menuSpeed - 200, easing: "swing", complete: function () { $(this).hide(); } });

            } else {

                $(this).hide();

            }

        }

    });

}



function ajustarMenus() {

    $("ul.conceito, ul.fitness, ul.bem-estar", ".menu > ul").parent()

        .mouseenter(menuEnter)

        .mouseleave(menuLeave)

        .children("a").click(function (event) {

            event.preventDefault();

            return false;

        });



    $("a.beleza, a.cursos, a.nossa-equipe", ".menu > ul").hover(function () {

        fecharMenus();

    });

}
