// Frontend Snippet folder location
var _base = 'assets/snippets/serviciosAjax/';
 
window.addEvent('domready', function(){
		
    lis = $$("#cbo_auto");

	for(i=0;i<lis.length;i++){
        li = lis[i];
 	li.addEvent('change', function(e) {
            e = new Event(e).stop();
      				
      			var url = _base + 'cotizador.php';
      			var pars = Object.toQueryString({
      				  q: url,
                id: this.value
            });
            new Ajax('index-ajax.php', {postBody: pars, update: 'modelo' }).request();
            });
    }
	
	  lis = $$("#cbo_auto2");

	for(i=0;i<lis.length;i++){
        li = lis[i];
 	li.addEvent('change', function(e) {
            e = new Event(e).stop();
      				
      			var url = _base + 'cotizador_pasos.php';
      			var pars = Object.toQueryString({
      				  q: url,
                id: this.value
            });
            new Ajax('index-ajax.php', {postBody: pars, update: 'modelo2' }).request();
            });
    }
	
	
    lis = $$("#marca");

	for(i=0;i<lis.length;i++){
        li = lis[i];
 	li.addEvent('change', function(e) {
            e = new Event(e).stop();
      				
      			var url = _base + 'combos_formularios.php';
      			var pars = Object.toQueryString({
      				  q: url,
	                id: this.value,
	                tipo: 'modelos',
					categoria: document.getElementById('categoria').value
            });
            new Ajax('index-ajax.php', {postBody: pars, update: 'modelo_formulario' }).request();
            });
    }
	
	  lis = $$("#categoria");

	for(i=0;i<lis.length;i++){
        li = lis[i];
 	li.addEvent('change', function(e) {
            e = new Event(e).stop();
      				
      			var url = _base + 'combos_formularios.php';
      			var pars = Object.toQueryString({
      				  q: url,
	                id: this.value,
	                tipo: 'categoria',
					marca: document.getElementById('marca').value
            });
            new Ajax('index-ajax.php', {postBody: pars, update: 'modelo_formulario' }).request();
            });
    }
		
		 lis = $$("#cbo_region");

	for(i=0;i<lis.length;i++){
        li = lis[i];
 	li.addEvent('change', function(e) {
            e = new Event(e).stop();
      				
      			var url = _base + 'combos.php';
      			var pars = Object.toQueryString({
      				  q: url,
                id: this.value,
                tipo: 'comuna'				
            });
            new Ajax('index-ajax.php', {postBody: pars, update: 'comuna' }).request();
            });
    }

    lis = $$("#cbo_marca");

	for(i=0;i<lis.length;i++){
        li = lis[i];
 	li.addEvent('change', function(e) {
            e = new Event(e).stop();
      				
      			var url = _base + 'combos.php';
      			var pars = Object.toQueryString({
      				  q: url,
                id: this.value,
                tipo: 'modelos'
            });
            new Ajax('index-ajax.php', {postBody: pars, update: 'modelo_auto' }).request();
            });
    }
	
	   lis = $$("#cbo_marca");

	for(i=0;i<lis.length;i++){
        li = lis[i];
 	li.addEvent('change', function(e) {
            e = new Event(e).stop();
      				
      			var url = _base + 'buscador.php';
      			var pars = Object.toQueryString({
      				  q: url,
                id: this.value
            });
            new Ajax('index-ajax.php', {postBody: pars, update: 'categoria' }).request();
            });
    }
	
});