$(function(){
  //alert ("funciona");		// PARA LOS RESETEAR LOS GASTOS DE ENVIO	$("#carroDireccionAlternativa").hide(); //inicialmente ocultamos el layer de los datos		//$("#gastosEnvioCero").change(function() {
	$("input[name='gastosEnvioCero']").change(function() {										switch ($("input[name='gastosEnvioCero']:checked").val())
		{
			case "MCR":
		  		$("#carroDireccionAlternativa").hide();
		 		break;
			case "habitual":
		  		$("#carroDireccionAlternativa").hide();
		 		break;			case "otro":
		  		$("#carroDireccionAlternativa").show();
		 		break;
		}		
	});    	/// PARA FORMATEAR LOS BUSCADORES
	$("#selectBrand").change(function(){
				$('#selectCategory').empty();
		$('#selectSubCategory').empty();
		
		$.getJSON("Scripts/ajax_busquedas.php",{idMarca: $(this).val()}, function(j){
		
			var options = '';
		
		    for (var i = 0; i < j.length; i++) {
		    	options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
		    }
		
		    $('#selectCategory').html(options);
		    $('#selectCategory option:first').attr('selected', 'selected');
		
		});
	
	 }); 
	
  	$("#selectCategory").change(function(){
    	$('#selectSubCategory').empty();

    	$.getJSON("Scripts/ajax_busquedas.php",{idCategoria: $(this).val()}, function(j){

      		var options = '';

		    for (var i = 0; i < j.length; i++) {
		    	options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
		    }

      		$('#selectSubCategory').html(options);
      		$('#selectSubCategory option:first').attr('selected', 'selected');

    	});
  	});  

});