//ABRE E FECHA DIV
function abrediv(div){	
	var divs = document.getElementsByTagName('div');	
	for (var i=0; i<divs.length; i++){

	  var divAtual = divs[i];
	  var rel = divAtual.getAttribute('rel');
	  
		if (rel && rel == 'texto'){
			if(divAtual.getAttribute('id') == div){
			if(divAtual.style.display == 'block'){divAtual.style.display = 'none'}
			else{divAtual.style.display = 'block'}}
			else{divAtual.style.display = 'none'}
		}		
	}	
}
/*FILTRO POR MÊS -->LANÇAMENTOS*/
function enviaMes(mes){
	if(document.getElementById("mes_lancamento").value != ''){
		location.href = 'novidades-lancamentos.asp?mes='+mes;
	}
}

function validaLogin(){
	varLogin = document.FrmLogin.login.value;
	varSenha = document.FrmLogin.senha.value;	
	if(varLogin == ''){
		alert("Preencha o campo Login");
		return false;
	}
	if(varSenha == ''){
		alert("Preencha o campo Senha");
		return false;
	}
	return true;
}

function popup(theURL,winName,features) {
	window.open(theURL,winName,features);
}
$(function() {

	$(".fancy").tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fixPNG: true,
		showBody: " - ",
		extraClass: "pretty fancy",
		top: -15,
		left: 5
	});

});

//POPULAÇÃO DE COMBOS DE BUSCA
jQuery(function(){		   
		  
	/*MUDA CBO MARCAS*/	  
	jQuery("select[@name=cboMarca]").change(function(){
		jQuery('select[@name=cboModelo]').html('<option value="">Carregando ...</option>');
		jQuery('select[@name=cboVeiculo]').html('<option value="">Selecione uma marca</option>');				
		jQuery.post('ajaxCboModelo.asp',
			{marca : jQuery(this).val()},
			function(resposta){     
				jQuery('select[@name=cboModelo]').html(resposta);
			}
		);
   });
	
	/*MUDA CBO MODELOS*/	  
	jQuery("select[@name=cboModelo]").change(function(){
		jQuery('select[@name=cboVeiculo]').html('<option value="">Carregando ...</option>');
		jQuery.post('ajaxCboVeiculo.asp',
			{
				modelo : jQuery(this).val(),
				marca : jQuery("select[@name=cboMarca]").val()
			},
			function(resposta){     
				jQuery('select[@name=cboVeiculo]').html(resposta);
			}
		);
   });

	/*REALIZA BUSCA*/	  
	jQuery("select[@name=cboVeiculo]").change(function(){
													   
		jQuery('form#FrmBusca').submit();
		/*													   
		jQuery('#busca_resultado').html('Carregando ...');													   
		jQuery.post('ajaxBuscaResultado.asp',
			{
				veiculo	: jQuery(this).val(),
				modelo	: jQuery("select[@name=cboModelo]").val(),
				marca	: jQuery("select[@name=cboMarca]").val()
			},
			function(resposta){     
				jQuery('#busca_resultado').html(resposta);
			}
		);
		*/
   });
	
	
	/*REMOVE ITEM AO PEDIDO*/	  
	jQuery("input.quantidade").blur(function(){

		intQtd 	= jQuery(this).attr("value");

		jQuery.ajax({

			type: 'POST',

			url: "ajaxCarrinho.asp",

			data: "ProdutoID="+this.id+"&Acao=Atualizar&intQtd="+this.value,
			
			success: function(txt){

				//jQuery($botao).attr("value", txt);
					
			},
			error: function(txt){
				
				alert(txt);
				return false;

			}
		});
		
		return false;

   });

	/*REMOVE ITEM AO PEDIDO*/	  
	jQuery("input[@name=btnCart]").click(function(){

		Acao 	= jQuery(this).attr("value");
		location.href = 'ajaxCarrinho.asp?ProdutoID='+this.id+'&Acao='+Acao;
												  
   });


});

