
  
   function fillInput(xml, objectToModify, objectToHide) {
    try{
	    if (objectToModify.type == "text"){
	       RellenaTextBox(xml, objectToModify, null);
	    }
	    else if (objectToModify.type == "select-one" || objectToModify.type == "select-multiple"  ) {
	        RellenaSelect(xml, objectToModify, "");
	        
	        if (objectToModify.options.length <= 1 && objectToModify.options[0].value == 0){
	            //only contains --selecciona --
	            SetVisibleDependentObject(objectToHide, false);
	            }
	        else{
	            SetVisibleDependentObject(objectToHide, true);
	            }
	        }
	    else if (objectToModify.tagName == "DIV"){
	        RellenaDiv(xml, objectToModify);
	        }
	    }
	    catch(e){}
    };
        
        
        
function RellenaDiv(xml, objDiv) {
    var texto = "";
    try {
        if (xml.childNodes.length > 0) {
            var nodes = xml.getElementsByTagName('anyType');
            if (nodes.length > 0) {
                objDiv.innerHtml = "";
                for(i=0; i<nodes.length; i++){
			        if (nodes[i].childNodes.length >= 2)
			            texto += "<a href='javascript:selectAddress(\"" + nodes[i].childNodes[0].firstChild.nodeValue + "\", \"" + nodes[i].childNodes[1].firstChild.nodeValue + "\");'>" + nodes[i].childNodes[1].firstChild.nodeValue + "</a><br>";
                };
            }
        }
        if (texto == "") {
            if (document.layers) objDiv.visibility="hide";
            else objDiv.style.visibility="hidden";
        }
        else {
            objDiv.innerHTML = texto;
            if (document.layers) objDiv.visibility="show";
            else objDiv.style.visibility="visible";
        }
        return;
    }
    catch(e) {
    }
};
 
function Gettext(node){
    var isIE = false;
    if (window.ActiveXObject){
        isIE = true;
    }
    if(isIE){
        return node.text;
    }else{
        return node.textContent;
    } 
};
 

function RellenaMapa(xml, objDiv, objHidden) {
	var texto = "";
	try {
		if (xml.childNodes.length > 0) {
			var nodes = xml.getElementsByTagName('string');
			  objDiv.innerHtml = "";
			 if (nodes.length > 0) { 
			   texto+=  Gettext(nodes[0])
						}
					   } 
		
		if (texto == "") { 
		objDiv.style.display = "none";
		objHidden.value = "";
		}
		else {
			objDiv.innerHTML = texto;
			objHidden.value = texto;
			objDiv.style.display = "";
		}
		return;
	}
	catch(e) {
	}
};
 

function RellenaTextBox(xml, objText, objHidden) {
    var texto = "";
    var id = 0;
    try {
        if (xml.childNodes.length > 0) {
	        var nodes = xml.getElementsByTagName('anyType');
            if (nodes.length > 0) {
                for (i=0;i<nodes.length;i++){
                    if ( nodes[i].getElementsByTagName('Key')[0].firstChild.nodeValue > 0){
                        texto =   nodes[i].getElementsByTagName('Value')[0].firstChild.nodeValue;
                        id = nodes[i].getElementsByTagName('Key')[0].firstChild.nodeValue;
                    }
                }
            }
        }
    }
    catch(e){
        texto = '';
        id = 0;
    }
    if (objText != null)
        if (typeof(objText) != "undefined")
            if (objText.type == "text")
                objText.value = texto;
    if (objHidden != null)
        if (typeof(objHidden) != "undefined")
            if (objHidden.type == "hidden")
                objHidden.value = id;
};


	        
function RellenaSelect(xml, obj, selectText) {
    try {
        if (xml.childNodes.length > 0) {
	        var nodes = xml.getElementsByTagName('anyType');
	      
            if (nodes.length > 0) {
                obj.options.length = 0;
                
                for(i=0; i<nodes.length; i++){
                
                    var oOption = document.createElement("OPTION");
                  
				    
		            if (nodes[i].childNodes.length >= 2) {
				        
				        oOption.value =  nodes[i].getElementsByTagName('Key')[0].firstChild.nodeValue;
				        oOption.text =  nodes[i].getElementsByTagName('Value')[0].firstChild.nodeValue;
				  
				          if(( oOption.value != 0)||(obj.type != "select-multiple")){
	                       obj.options.add(oOption);
	                    }
				    } 
                }
                return;
            }
        }
        obj.options.length = 0;
        var oOption = document.createElement("OPTION");
        obj.options.add(oOption);
        oOption.value = 0;
        oOption.innerText = "";
    }
    catch(e) {
        obj.options.length = 0;
        var oOption = document.createElement("OPTION");
	    obj.options.add(oOption);
	    oOption.value = 0;
	    oOption.innerText = "";
    }
};




function SetVisibleDependentObject(objDependent, visible) {
    try {
        if (objDependent != null)
        {
            objDependent.style.display = (visible) ? "block" : "none";
        }
    }
    catch(e) {
   }
};

        function ddlclear () {
               this.options.length=0;
               if (this.depending) this.depending.clear();
                if (this.clearcallback) this.clearcallback();
                }
                
                


// -------------------------------------------------------------------
    // moveAllOptions(select_object,select_object[,autosort(true/false)[,regex]])
    //  Move all options from one select box to another.
    // -------------------------------------------------------------------
    function moveAllOptions(from,to) {
        selectAllOptions(from);
	    if (arguments.length==2) {
		    moveSelectedOptions(from,to);
		}
	    else if (arguments.length==3) {
		    moveSelectedOptions(from,to,arguments[2]);
		}
	    else if (arguments.length==4) {
		    moveSelectedOptions(from,to,arguments[2],arguments[3]);
		}
		
	 };
	 
	// -------------------------------------------------------------------
    // selectAllOptions(select_object)
    //  This function takes a select box and selects all options (in a 
    //  multiple select object). This is used when passing values between
    //  two select boxes. Select all options in the right box before 
    //  submitting the form so the values will be sent to the server.
    // -------------------------------------------------------------------
    function selectAllOptions(obj) {
       
	    if (!hasOptions(obj)) { return; }
	    for (var i=0; i<obj.options.length; i++) {
		    obj.options[i].selected = true;
		    }
	    };

	// -------------------------------------------------------------------
    // moveSelectedOptions(select_object,select_object[,autosort(true/false)[,regex]])
    //  This function moves options between select boxes. Works best with
    //  multi-select boxes to create the common Windows control effect.
    //  Passes all selected values from the first object to the second
    //  object and re-sorts each box.
    //  If a third argument of 'false' is passed, then the lists are not
    //  sorted after the move.
    //  If a fourth string argument is passed, this will function as a
    //  Regular Expression to match against the TEXT or the options. If 
    //  the text of an option matches the pattern, it will NOT be moved.
    //  It will be treated as an unmoveable option.
    //  You can also put this into the <SELECT> object as follows:
    //    onDblClick="moveSelectedOptions(this,this.form.target)
    //  This way, when the user double-clicks on a value in one box, it
    //  will be transferred to the other (in browsers that support the 
    //  onDblClick() event handler).
    // -------------------------------------------------------------------
    function moveSelectedOptions(from,to) {
        // Unselect matching options, if required
	    if (arguments.length>3) {
		    var regex = arguments[3];
		    if (regex != "") {
			unSelectMatchingOptions(from,regex);
			}
		}
	    // Move them over
	    if (!hasOptions(from)) { return; }
	    for (var i=0; i<from.options.length; i++) {
		    var o = from.options[i];
		    if (o.selected) {
			    if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
			    var oOption = document.createElement("OPTION");
			    oOption.value = o.value;
			    oOption.text = o.text;
                to.options.add(oOption);
			    //to.options[index] = new Option( o.text, o.value, false, false);
			 }
		 }
	    // Delete them from original
	    for (var i=(from.options.length-1); i>=0; i--) {
		    var o = from.options[i];
		    if (o.selected) {
		        
			        from.options[i] = null;
			}
		}
	    if ((arguments.length<3) || (arguments[2]==true)) {
		    sortSelect(from);
		    sortSelect(to);
		}
	    from.selectedIndex = -1;
	    to.selectedIndex = -1;
	 };
	 
	// -------------------------------------------------------------------
    // unSelectMatchingOptions(select_object,regex)
    //  This function Unselects all options that match the regular expression
    //  passed in. 
    // -------------------------------------------------------------------
    function unSelectMatchingOptions(obj,regex) {
        selectUnselectMatchingOptions(obj,regex,"unselect",false);
        };
    	

	 // -------------------------------------------------------------------
     // selectUnselectMatchingOptions(select_object,regex,select/unselect,true/false)
     //  This is a general function used by the select functions below, to
     //  avoid code duplication
     // -------------------------------------------------------------------
    function selectUnselectMatchingOptions(obj,regex,which,only) {
	    if (window.RegExp) {
		    if (which == "select") {
			    var selected1=true;
			    var selected2=false;
			    }
		    else if (which == "unselect") {
			    var selected1=false;
			    var selected2=true;
			    }
		    else {
			    return;
			    }
		    var re = new RegExp(regex);
		    if (!hasOptions(obj)) { return; }
		    for (var i=0; i<obj.options.length; i++) {
			    if (re.test(obj.options[i].text)) {
				    obj.options[i].selected = selected1;
				    }
			    else {
				    if (only == true) {
					    obj.options[i].selected = selected2;
					    }
				    }
			    }
		    }
	    };
	    // -------------------------------------------------------------------
        // hasOptions(obj)
        //  Utility function to determine if a select object has an options array
        // -------------------------------------------------------------------
        function hasOptions(obj) {
	        if (obj!=null && obj.options!=null) { return true; }
	        return false;
	        };
	    // -------------------------------------------------------------------
        // sortSelect(select_object)
        //   Pass this function a SELECT object and the options will be sorted
        //   by their text (display) values
        // -------------------------------------------------------------------
        function sortSelect(obj) {
	        var o = new Array();
	        if (!hasOptions(obj)) { return; }
	        for (var i=0; i<obj.options.length; i++) {
		        o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
		        }
	        if (o.length==0) { return; }
	        o = o.sort( 
		        function(a,b) { 
			        if ((a.text+"") < (b.text+"")) { return -1; }
			        if ((a.text+"") > (b.text+"")) { return 1; }
			        return 0;
			        } 
		        );

	        for (var i=0; i<o.length; i++) {
		        obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
		        }
	        };
	        
	        
	   