function validaOrcamento(){
    var $form_orcamento = $('#form_orcamento');
    if ($form_orcamento) {
        $form_orcamento.validate({
            groups: {
                telefone: "ddd_tel tel",
                celular: "ddd_cel cel"
            },
            rules: {
                nome: "required",
                email: {
                    required:true,
                    email:true
                },
                ddd_tel: {
                    required:true,
                    digits:true,
                    rangelength: [2, 2]
                },
                tel: {
                    required: true,
                    digits:true,
                    rangelength: [7, 9]
                },
                ddd_cel: {
                    digits:true,
                    rangelength: [2, 2]
                },
                cel: {
                    digits:true,
                    rangelength: [7, 9]
                },
                servico: "required",
                mensagem: "required"
            },
            errorPlacement: function(error, element) {
                if (element.attr("name") == "ddd_tel" 
                    || element.attr("name") == "tel" )
                    error.insertAfter("#tel");
                else {
                    if (element.attr("name") == "ddd_cel" 
                        || element.attr("name") == "cel" )
                        error.insertAfter("#cel");
                    else
                        error.appendTo(element.parent());
                }
                           
            },
            success: function(label) {
                label.html("<img alt='ok' src='images/item_li.png' class='field_ok'/>").addClass("checked");
            }
        });
    }
}

function validaContato(){
    var $form_contato = $('#form_contato');
    if ($form_contato) {
        $form_contato.validate({
            groups: {
                username: "ddd_tel tel"
            },
            rules: {
                nome: "required",
                email: {
                    required:true,
                    email:true
                },
                ddd_tel: {
                    required:true,
                    digits:true,
                    rangelength: [2, 2]
                },
                tel: {
                    required: true,
                    digits:true,
                    rangelength: [7, 9]
                },
                mensagem: "required"
            },
            errorPlacement: function(error, element) {
                if (element.attr("name") == "ddd_tel" 
                    || element.attr("name") == "tel" )
                    error.insertAfter("#tel");
                else
                    error.appendTo(element.parent());
            },
            success: function(label) {
                label.html("<img alt='ok' src='images/item_li.png' class='field_ok'/>").addClass("checked");
            }
        });
    }
}

function mostra_vitrine(num){
    $('.vitrine').not('#vitrine'+num).hide('slow', function(){
        $('#vitrine'+num).show('slow');
    });
    return false;
}

$(document).ready(function(){
    $('.div_destaque').corner('15px');
    $('.esp_destaque').corner('15px');
    $('#depoimentos').corner('15px');
    $('#depoimentos div').corner('15px');
    $('.corner').corner('');
    var slider = $('#s3slider');
    if (slider.length>0) {
        slider.s3Slider({ 
            timeOut: 4000 
        });
    }

    $('#depo').anythingSlider({
        // Appearance
        width               : null,      // Override the default CSS width
        height              : null,      // Override the default CSS height
        resizeContents      : true,      // If true, solitary images/objects in the panel will expand to fit the viewport

        // Navigation
        startPanel          : 1,         // This sets the initial panel
        hashTags            : true,      // Should links change the hashtag in the URL?
        buildArrows         : false,      // If true, builds the forwards and backwards buttons
        buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
        navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
        forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
        backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

        // Slideshow options
        autoPlay            : true,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
        startStopped        : false,     // If autoPlay is on, this can force it to start stopped
        pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
        resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
        stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
        playRtl             : false,     // If true, the slideshow will move right-to-left
        startText           : "Start",   // Start button text
        stopText            : "Stop",    // Stop button text
        delay               : 7000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
        animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
        easing              : "swing"    // Anything other than "linear" or "swing" requires the easing plugin
    });

    validaOrcamento();
    validaContato();
});

