$(function(){  $('#estado').change(function(){        var valor = $(this).val();		$('#cidade').html('<option>Carregando ...</option>');        // Lista a lista de cidades do estado selecionado        $.ajax({            type: "post",            data: "act=cidade&id=" + valor,            url: "/ajax.php",            dataType: "html",            success: function(valor){                $('#cidade').html(valor);            }                    });          });		//////////////////////////////////////////////////////////////////////////////	// formulario Cadastro	$('#forma-contato').change( function () {		if ( $(this).val() == 'Consumidor Final' ) {			$('#final').show();			$('#revenda').hide();		}		else {			$('#final').hide();			$('#revenda').show();		}	}); 	/////////////////////////////////////////////////////////////////////////    // Formulario de Cadastro    $('#formulario-cadastro').pForm({        action: "http://quanta.com.br/ajax.php",        start: function(){            $('#formulario-cadastro fieldset').hide();            $('#formulario-cadastro').append('<p class="img-carregando"><span>carregando</span><img  src="http://www.computermusic.com.br/template/img/carregando.gif"/></p>');                    },        success: function(valor){                    $('.img-carregando').remove();                        // Cadastro Ok             if (valor.error == true) {				$('#cadastro-ok p').text('Cadastro efetuado com sucesso!.');                $('#cadastro-ok').show();                $('#formulario-cadastro fieldset').hide();                $('#nome,#senha,#senhac,#cpf,#rg,#celular,#email,#ie,#razao-social,#bairro,#endereco,#cep,#telefone').val('');            }            else {                if (valor.msg == '') {                    					$('#cadastro-ok p').text('Ocorreu algum erro inesperado, Por favor tente de novo ou entre em contato');					$('#cadastro-ok').show();              	  	$('#formulario-cadastro fieldset').hide();                }                else {                    $('#cadastro-ok p').text(valor.msg);					$('#cadastro-ok').show();              	  	$('#formulario-cadastro fieldset').hide();					                }            }        }            });            /////////////////////////////////////////////////////////////////////////////    // Color Box	    $('a[rel="popup"]').colorbox({        slideshow: true    });            /////////////////////////////////////////////////////////////////////////////    // Color Box	    $('a[rel="curriculo"]').colorbox({        slideshow: false,        width: "1000px"    });        ///////////////////////////////////////////////////////////////////////////    // Links Externos     $('.externo').attr('target', '_blanck');                      // Formulario Trabalhe conosco	$("#telefone").mask("(999)9999-9999");	$("#celular").mask("(999)9999-9999");	$("#con-telefone").mask("(999)9999-9999");	$("#cep").mask("99999-999");    $("#telefone-residencial").mask("9999-9999");    $("#telefone-celular").mask("9999-9999");    $("#telefone-comercial").mask("9999-9999");    $("#cpf").mask("999.999.999-99");                              ///////////////////////////////////////////////////////////////////////////////     // FAQ     $('#itens-faq .titulo').mouseover(function () {     $(this).css('text-decoration', 'underline');     }).mouseout(function(){     $(this).css('text-decoration', 'none');     }).click(function () {     $(this).parents('.pergunta').children('.resposta').slideToggle();     });             /////////////////////////////////////////////////////////////////////////    // Formulario de contato    $('#form-contato').pFormContato({        action: "http://quanta.com.br/ajax.php",        start: function(){            $('#formulario-contato fieldset').hide();            $('#formulario-contato').append('<p class="img-carregando"><span>carregando</span><img  src="http://quanta.com.br/template/img/carregando.gif"/></p>');                    },        success: function(valor){                    $('.img-carregando').remove();                        // Cadastro Ok             if (valor.error == true) {                $('#cadastro-ok').show();                $('#box-contato fieldset').hide();                $('#con-assunto').val('');                $('#con-nome').val('');                $('#con-telefone').val('');                $('#con-email').val('');                $('#con-mensagem').val('');                            }            else {                if (valor.msg == '') {                    alert('Ocorreu algum erro inesperado, Por favor tente de novo ou entre em contato');                }                else {                    alert(valor.msg);                }            }        }            });                        ////////////////////////////////////////////////////////////////////////////////////////    // Banner Index    if ($('#box-destaque .item').size() > 0) {            var index = 0;        var cont = 0;        var total = $('#box-destaque .item').size();        var totalLink = total - 1;                        // Acresento os botoes de navegacao        $('#box-destaque .item').each(function(){            cont++;            elemento = $(this);                                    // Atribui o id do elemento            elemento.attr('id', 'ban-' + cont);                        // Crio o link de navegação            $('#bt-banner').append('<a class="bt-banner png" onclick="clearTimeout(bannerTempo);rotacionarBanner(this.id,' + total + ')" id="bt-' + cont + '">0' + cont + '</a>');                        // Posiciono o link             $('#bt-' + cont).css('left', (90 - (totalLink * 32)));            totalLink = totalLink - 1;                        if (!(cont == total)) {                        }        });                rotacionarBanner("bt-1", total);            }            /////////////////////////////////////////////////////////////////////////////////    //	Botão comentario    $('.botao-comentario').click(function(event){        var post = $(this).parents('.item');        post.children('.form-comentario').toggle();                event.preventDefault(event);        return false;    });        /////////////////////////////////////////////////////////////////////////////////    //	Formulario comentario    $('.comentario-formulario .enviar').click(function(event){                $('.errorPform').remove();        error = 1;        var form = $(this).parents('form');        var id = $(this).parents('form').attr('id');        id = id.replace('form-', '');                        valid = true;                if ($('#com-nome-' + id).val() == "") {            valid = false;            mostraError($('#com-nome-' + id), 'Preenchar o campo', error);            error++;        }                if ($('#com-email-' + id).val() == "") {            valid = false;            mostraError($('#com-email-' + id), 'Preenchar o campo', error);            error++;        }        else {            if (!validaEmail($('#com-email-' + id).val())) {                valid = false;                mostraError($('#com-email-' + id), 'E-mail Inválido', error);                error++;            }        }                if ($('#com-comentario-' + id).val() == "") {            valid = false;            mostraError($('#com-comentario-' + id), 'Preenchar o campo', error);            error++;        }                if (valid == true) {            $(this).parents('form fieldset').hide();            $(this).parents('form').append('<p class="img-carregando"><span>carregando</span><img  src="http://quanta.com.br/template/img/carregando.gif"/></p>');                        $.ajax({                type: "post",                url: 'http://quanta.com.br/ajax.php?act=cadastro-comentario',                data: {                    id: id,                    nome: $('#com-nome-' + id).val(),                    email: $('#com-email-' + id).val(),                    comentario: $('#com-comentario-' + id).val()                },                dataType: 'json',                success: function(valor){                                    form.children('.cadastro-ok').show();                    form.children('.img-carregando').hide();                                                            $('#com-nome-' + id).val('');                    $('#com-email-' + id).val('');                    $('#com-comentario-' + id).val('');                }                            });        }                event.preventDefault(event);        return false;    });            /////////////////////////////////////////////////////////////////////////    // Mostra Formulario     $('.mostrar').live('click', function(event){        $('.form-comentario fieldset').show();        $('#form-contato fieldset').show();		$('#formulario-cadastro fieldset').show();        $('#formcad fieldset').show();        $('#formedit fieldset').show();        $('#cadastro-ok').hide();        $('.cadastro-ok').hide();                event.preventDefault();        return false;    });                    });// Function Rotaciona bannerfunction rotacionarBanner(idBanner, total){    atualElemento = $('#' + idBanner);    atualNumero = atualElemento.attr('id');    atualNumero = parseInt(atualNumero.replace('bt-', ''));    atualElemento = $('#ban-' + atualNumero);        $('.bt-banner').removeClass('ativo');        if (atualNumero == total) {        mostraElemento = $('#ban-1');        $('#bt-' + total).addClass('ativo');        atualNumero = 1;    }    else {        mostraElemento = atualElemento.next();        $('#bt-' + atualNumero).addClass('ativo');        atualNumero++;    }        $('#box-destaque .conteudo .item').css('z-index', 90).fadeOut('fast');    mostraElemento.css('z-index', 100).fadeIn('fast');                bannerTempo = setTimeout('rotacionarBanner("bt-' + atualNumero + '", ' + total + ');', 10000)    return true;}Array.prototype.remove = function(from, to){    var rest = this.slice((to || from) + 1 || this.length);    this.length = from < 0 ? this.length + from : from;    return this.push.apply(this, rest);};function validaEmail(mail){    var er = RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);    if (er.test(mail) == false) {        return false;    }        return true;}// Função p/ Mostrar as mensagens de errorfunction mostraError($campo, msg, error){    // Tamanho do elemento     var wElemento = parseInt($campo.outerWidth());        // Posicao    var posicao = $campo.offset();        // Cria a mensagem error    $('body').append('<div class="errorPform" id="error' + error + '">' + msg + '</div>');        // Posiciona a mensagem de error    $('#error' + error).css({        position: 'absolute',        top: posicao.top - 15,        left: posicao.left + wElemento - 110    });    }
