﻿function buscadorTraslado(name) {
	if (name){
		this.name=name;
	}else{
		this.name="xmlDoc";
	}
	//this.XMLHttpComponent = this.getXMLHttpComponentInstance();
    this.xmlDocDestinos = new XMLRemoteRequest("xmlDocTra");
    this.Selector = "TipoClaseProd"
    //this.Etiqueta = "Etiqueta"
 }
   
   
   buscadorTraslado.prototype.ObtenerTipos = function (idzona, idioma, CLPSel){
       this.ClearSelector();
       var cmb = document.getElementById(this.Selector);
        var opt;
        this.xmlDocDestinos.getRemoteDocument("/include/xmlRequest.ashx?action=traList&idzon=" + idzona + "&y=" + Math.random());
        var list = this.xmlDocDestinos.selectNodes("xml/zon")
         opt = document.createElement('option');
         opt.value = -1; 
         if (idioma == "es"){
             opt.innerHTML = 'Todos';
          }
         else { opt.innerHTML = 'All';}
        cmb.appendChild(opt)
        for (i = 0; i < list.length; i++){
            
            opt = document.createElement('option');
            if(CLPSel == list[i].getAttribute('idzon')) opt.selected = 'selected';
            opt.value = list[i].getAttribute('idzon'); 
            opt.innerHTML = list[i].getAttribute('nombrezon');
            cmb.appendChild(opt);
        }
        
        document.getElementById(this.Selector).style.display = 'block';
    }
    
    

    buscadorTraslado.prototype.ClearSelector = function (){
    var longitud = document.getElementById(this.Selector).options.length;
        for (i = 0; i < longitud; i++){
            document.getElementById(this.Selector).options[0] = null;
        }
    }
 
    buscadorTraslado.prototype.CambiarTexto = function (mensaje){
        document.getElementById(this.Etiqueta).value = mensaje;
    }