﻿function buscadorServicio(name) {
	if (name){
		this.name=name;
	}else{
		this.name="xmlDoc";
	}
	//this.XMLHttpComponent = this.getXMLHttpComponentInstance();
    this.xmlDocTipos = new XMLRemoteRequest("xmlDocSer");
    this.Selector = "TipoClaseProd"
    //this.Etiqueta = "Etiqueta"
 }
   
   
   buscadorServicio.prototype.ObtenerTipos = function (idzona, idCLP, idioma,conTodos){
       this.ClearSelector();
       var cmb = document.getElementById(this.Selector);
        var opt;
        if (conTodos == 'undefined'){
            this.xmlDocTipos.getRemoteDocument("/include/xmlRequest.ashx?action=serList&idzon=" + idzona + "&idCLP=" + idCLP   + "&y=" + Math.random());
        }
        else {
          this.xmlDocTipos.getRemoteDocument("/include/xmlRequest.ashx?action=serListTar&idzon=" + idzona + "&idCLP=" + idCLP   + "&y=" + Math.random());
        }
        
        var list = this.xmlDocTipos.selectNodes("xml/tiposer")
//         opt = document.createElement('option');
//         opt.value = 0; 
//         if (idioma == "es"){
//             opt.innerHTML = '--';
//          }
//         else { opt.innerHTML = '--';}
//        cmb.appendChild(opt)
        for (i = 0; i < list.length; i++){
            
            opt = document.createElement('option');
            opt.value = list[i].getAttribute('idtiposer'); 
            opt.innerHTML = list[i].getAttribute('nombretiposer');
            cmb.appendChild(opt);
        }
        
        document.getElementById(this.Selector).style.display = 'block';
    }



    buscadorServicio.prototype.ClearSelector = function() {
        var longitud = document.getElementById(this.Selector).options.length;
        for (i = 0; i < longitud; i++) {
            document.getElementById(this.Selector).options[0] = null;
        }
    }
 
    buscadorServicio.prototype.CambiarTexto = function (mensaje){
        document.getElementById(this.Etiqueta).value = mensaje;
    }
