﻿var imagensMenu = "/content/img/menu/";

function over(obj, imagem) {

    obj.src = imagensMenu + imagem + ".jpg";

}

function out(obj, imagem) {
    obj.src = imagensMenu + imagem + ".jpg";
}

function navegar(url) {

    window.location = url;

}

function adicionaEventos() {

    var menu = document.getElementById("menu");  

    for (i = 0; i < menu.childNodes.length -1; i++) {

        var item = menu.childNodes[i];

            item.onclick = function () {
                navegar("/" + this.id);
            }
       
            item.onmouseover = function () {
                over(this, this.id + "_a");
            }

            item.onmouseout = function () {
                out(this, this.id);
            }
        
    
    }



}

window.onload = function () {
    adicionaEventos();

}

function ValidarEmail(email) {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if (reg.test(email) == false) {
        return false;
    }
    else
        return true;
}


function mascaras() {

    jQuery(function ($) {
        $("#txttelefone").mask("(99) 9999-9999");
    });

}

function EnviarContato() {


    var formulario = document.getElementById("form_contato");

    var nome = document.getElementById("txtnome");
    var email = document.getElementById("txtemail");
    var telefone = document.getElementById("txttelefone");
    var cidade = document.getElementById("txtcidade");
    var assunto = document.getElementById("txtassunto");
    var mensagem = document.getElementById("txtmensagem");


    if (nome.value != '') {

        if (email.value != '') {

            if (ValidarEmail(email.value)) {              

                    if (telefone.value != '') {

                        if (cidade.value != '') {

                            if (assunto.value != '') {

                                if (mensagem.value != '') {
                                    form_contato.submit();
                                }
                                else {
                                    alert("Informe a Mensagem");
                                    mensagem.focus();
                                }
                            }
                            else {

                                alert("Informe o Assunto");
                                assunto.focus();

                            }

                        }
                        else {

                            alert("Informe a Cidade");
                            cidade.focus();

                        }            
                     
                    }
                    else {

                        alert("Informe o Telefone");
                        telefone.focus();
                    
                    }              


            }
            else {
                alert("Informe um e-mail válido");
                email.focus();
            }

        }
        else {
            alert("Informe o e-mail");
            email.focus();
        }

    }
    else {
        alert("Informe o nome");
        nome.focus();
    }





}



function EnviarNewsletter() {


    var formulario = document.getElementById("form_contato");

    var nome = document.getElementById("txtnome");
    var email = document.getElementById("txtemail");


    if (nome.value != '') {

        if (email.value != '') {

            if (ValidarEmail(email.value)) {


                newsletter.submit();

            }
            else {
                alert("Informe um e-mail válido");
                email.focus();
            }

        }
        else {
            alert("Informe o e-mail");
            email.focus();
        }

    }
    else {
        alert("Informe o nome");
        nome.focus();
    }





}
