function http_request() {
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function nodoCadena(nodo,nombre){
	try{		
		return nodo.getElementsByTagName(nombre)[0].firstChild.nodeValue;
	}
	catch(ex){
		return "";
	}
}

function nodoNumerico(nodo,nombre){
	try{	
		return parseInt(nodo.getElementsByTagName(nombre)[0].firstChild.nodeValue);
	}catch(e){
		return "-";
	}
}

function nodoCadenaHtml(nodo,nombre){
	try{		
		return nodo.getElementsByTagName(nombre)[0].firstChild.nodeValue;
	}
		catch(ex){
	}
}

/*function nodoNumericoHtml(){
	
}*/

function nodoValor(nodo,pos){
	try{
		return nodo[pos].firstChild.nodeValue;
	}catch(e){
		return "&nbsp;";
	}
}

function nodoAtributo(nodo,nomAtrib){
	
	try{
		return nodo.getAttribute(nomAtrib);
	}catch(e){
		return "";
	}	
}


// Get, Set de valores

function getCampo(id){
	return document.getElementById(id);
}


function getValor(id){
	return document.getElementById(id).value;
}

function setValor(id,valor){
	document.getElementById(id).value = valor;
}

function textoCmb(id){
	cmb = getCampo(id);
	txt=cmb.options[cmb.selectedIndex].text;
	return txt;
}

function seleccionCmbValor(idCmb,valor){
	var cmb = getCampo(idCmb);
	for(var i=0;i<cmb.options.length;i++){
		if (cmb.options[i].value == valor){
			cmb.selectedIndex=i;
			//i=cmb.options.length;
			continue;
		}
	}
}

function eliminarElementoCmb(idCmb,valor){
	var cmb = getCampo(idCmb);
	for(var i=0;i<cmb.options.length;i++){
		if (cmb.options[i].value == valor){
			cmb.remove(i);
			//i=cmb.options.length;
			break;
		}
	}
}

function agregarElementoCmb(idCmb,pos,valor,texto){
	var cmb = getCampo(idCmb);
	cmb.add(new Option(texto,valor),pos);
}

// -----------------  Operacion con cadenas  ---------------------
function Trim(s){
	// Quita los espacios del principio y del final
	return LTrim(RTrim(s));
}

function LTrim(s){
	// Devuelve una cadena sin los espacios del principio
	var i=0;
	var j=0;	
	// Busca el primer caracter <> de un espacio
	for(i=0; i<=s.length-1; i++){
		if(s.substring(i,i+1) != ' '){
			j=i;
			break;
		}
	}
	return s.substring(j, s.length);
}

function RTrim(s){
	// Quita los espacios en blanco del final de la cadena
	var j=0;	
	// Busca el �ltimo caracter <> de un espacio
	for(var i=s.length-1; i>-1; i--){
		if(s.substring(i,i+1) != ' '){
			j=i;
			break;
		}
	}
	return s.substring(0, j+1);
}

function getElemento(IDElemento){
	return document.getElementById(IDElemento);
	
}

