j = jQuery.noConflict();
j(document).ready(function($)
{
	
	/*$("#categoria").change(function(){
		$('#id').html('<option value="">Carregando ...</option>');
		$.post('buscaprodutos.php', { categoria : $(this).val() },function(resposta){
			$('#id').html(resposta);
		 });
	});*/
	
	//Form Pessoa Fisica/Juridica
	$("#pessoajuridica").css("display", "none");
	$("input[name='tipo_pessoa']").click(function() {
		var pessoa = $("input[name='tipo_pessoa']:checked").val();
		if (pessoa == '1') {
			$("#pessoajuridica").css("display", "block");
		} else if (pessoa == '0') {
			$("#pessoajuridica").css("display", "none");
		}
	});
	
	$("#mapa_google").goMap({ 
        markers: [{  
            latitude: -16.68285, 
            longitude: -49.282891,			
            html: { 
                content: 'Auto popup!', 
                popup: false 
            } 
        },{  
            latitude: -16.68285, 
            longitude: -49.282891, 
            html: 'Hello!' 
        }],
		zoom: 18,
		maptype: 'ROADMAP',
        hideByClick: false
    }); 
	
	// Busca por combos
	$("#categoria").change(function(){
		$("#subcategoria").html('<option value="">Carregando ...</option>');
		$.post("pesquisaSubcategoria.php", { categoria : $(this).val() }, function(resposta) {
			$("#subcategoria").html(resposta);
		});
	});
	$("#subcategoria").change(function(){
		$("#id").html('<option value="">Carregando ...</option>');
		$.post("pesquisaProduto.php", { subcategoria : $(this).val() }, function(resposta) {
			$("#id").html(resposta);
		});
	});
	$("#id").change(function(){
		$("#formPesquisaProduto").submit();
	});
			
	$(".atualizaQtd").blur( function () {
		
		$("#formCestaPedido").submit();
		
	}); 

	// Mascaras de entrada
	$('#telefone').mask('(99) 9999-9999');
	$('#celular').mask('(99) 9999-9999');
	$('#cpf').mask('999.999.999-99');
	$('#cnpj').mask('99.999.999/9999-99');
	//$('#rg').mask('99.999.999-99');
	$("#cep").mask("99999-999");
	$('#nascimento').mask('99/99/9999');
	
	$('#formContato').validate(
	{														
		rules: 
		{
			nome: {required: true},
			telefone: {required: true},
			email: {required: true, email: true},
			assunto: {required: true},
			mensagem: {required: true}
			
		},
		messages:
		{
			nome: {required: "Por favor, informe seu Nome."},
			telefone: {required: "Por favor, informe seu Telefone."},
			email: {required: "Por favor, digite um E-mail válido", email: "Por favor, digite um e-mail v&aacute;lido."},
			assunto: {required: "Por favor, informe um Assunto"},
			mensagem: {required: "Por favor, informe uma Mensagem"}
		},
		errorLabelContainer: "#messageBox",
		wrapper: "li"

	});
	
	$("#formPesquisa #area_pesquisa [name='pesquisa']").labelValue("Pesquisar...");
		
	if($('.carrossel ul li').size() > 6)
    {
        $(".carrossel").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			speed: 500,
			circular: true,
			scroll: 6,
			visible: 6
    	});
	}
	
});
