function PresionarBoton(oEvento,sIdElemento){
	var sScript = 'document.getElementById("' + sIdElemento + '").onclick()';	
	OnPressButton(oEvento,13,sScript);
	//OnPressButton(oEvento,32,sScript);
}
function OnPressButton(oEvento,iKeyCode, sScript){
	if (oEvento.keyCode == iKeyCode){
		eval(sScript);
		CancelarEvento(oEvento);
	}
	return;
}
function CancelarEvento(oEvento){
	if (oEvento){
		oEvento.value = false;
		oEvento.returnValue = false;
		oEvento.cancelBubble = true;
	}
}
function OpenPopUp(sPagina, oParametros, iAltura, iAncho){
	return window.showModalDialog('PopUps/' + sPagina, oParametros, 'dialogHeight: ' + iAltura.toString() + 'px; dialogWidth: ' + iAncho.toString() + 'px; edge: Raised; center: Yes; help: No; resizable: No; status: No;');
}

function TextoCambiante(sNombreElemento, sTexto, sScript){
	if (document.getElementById(sNombreElemento).innerHTML == '' || document.getElementById(sNombreElemento).innerHTML == sTexto + '...'){
		document.getElementById(sNombreElemento).innerHTML = sTexto;
	} else {
		document.getElementById(sNombreElemento).innerHTML = document.getElementById(sNombreElemento).innerHTML + '.';
	}
	setTimeout(sScript, 500);
}
function ReemplazarEnCadena(sCadena, sCadenaAReemplazar, sCadenaDeReemplazo){
	while (sCadena.indexOf(sCadenaAReemplazar) != -1){
		sCadena = sCadena.replace(sCadenaAReemplazar,sCadenaDeReemplazo);
	}
	return sCadena;
}
function GetRadioButtonSeleccionado(sNombreRadioButton){
	var oArrElementosRadioButton = document.getElementsByName(sNombreRadioButton);
	for (var i=0; i < oArrElementosRadioButton.length; i++){
		if (oArrElementosRadioButton[i].checked == true){
			return oArrElementosRadioButton[i];
		}
	}
}
function FechaDateDMA(dtFecha){
	if (dtFecha == null){
		return '';
	} else {
		return (dtFecha.getDate().toString().length == 1 ? '0' + dtFecha.getDate().toString() : dtFecha.getDate().toString()) + '/' + ((parseFloat(dtFecha.getMonth()) + 1).toString().length == 1 ? '0' + (parseFloat(dtFecha.getMonth()) + 1).toString() : (parseFloat(dtFecha.getMonth()) + 1).toString()) + '/' + (dtFecha.getFullYear().toString());
	}
}
function FormatDateYMD(dtFecha){
	if (dtFecha == null){
		return '';
	} else {
		return (dtFecha.getFullYear().toString()) + '-' + ((parseFloat(dtFecha.getMonth()) + 1).toString().length == 1 ? '0' + (parseFloat(dtFecha.getMonth()) + 1).toString() : (parseFloat(dtFecha.getMonth()) + 1).toString()) + '-' + (dtFecha.getDate().toString().length == 1 ? '0' + dtFecha.getDate().toString() : dtFecha.getDate().toString());
	}
}
function DateFromTextDMA(sFecha){
	var sDia;
	var sMes;
	var sAno;
	var sSep = '/';
	var iPos1;
	var iPos2;
	if (sFecha == '' || sFecha.indexOf(sSep) == -1) {
		return null;
	} else {	
		iPos1 = sFecha.indexOf(sSep);
		iPos2 = sFecha.indexOf(sSep,iPos1 + 1);
		sDia = sFecha.substring(0, iPos1);
		sMes = sFecha.substring(iPos1 + 1, iPos2);
		sAno = sFecha.substr(iPos2 + 1);
	}	
	var dtTempFecha= new Date(sAno, (parseFloat(sMes) -1) , sDia);
	if (dtTempFecha.getDate() != parseFloat(sDia) || dtTempFecha.getMonth() != parseFloat(sMes) -1 || dtTempFecha.getFullYear() != parseFloat(sAno)){
		return null;
	}
	else{
		return dtTempFecha;
	}
}
function StartsWith(sCadena, sCadenaComienzo){
	if (sCadena == '' || sCadenaComienzo == '' || sCadena.length < sCadenaComienzo.length || sCadena.substr(0,sCadenaComienzo.length) != sCadenaComienzo){
		return false;
	}
	return true;
}
function LimpiarControles(){
	var oTiposElementos = new Array();
	var oElementos;
	var j = 0;
	oTiposElementos[0] = document.getElementsByTagName("input");
	oTiposElementos[1] = document.getElementsByTagName("textarea");
	oTiposElementos[2] = document.getElementsByTagName("select");
	for (var j=0; j < oTiposElementos.length; j++){
		oElementos = oTiposElementos[j];
		for (var i=0; i < oElementos.length; i++){
			if (oElementos[i].getAttribute('type') == 'button' || oElementos[i].getAttribute('type') == 'submit' || oElementos[i].getAttribute('type') == 'reset' || (oElementos[i].getAttribute('name').indexOf('VIEWSTATE') != -1)){
				continue;
			}else if (oElementos[i].getAttribute('type') == 'radio' || oElementos[i].getAttribute('type') == 'checkbox'){
				oElementos[i].checked = false;
			}else if (j==2){
				oElementos[i].selectedIndex = -1;
			}else {
				oElementos[i].value = '';
			}
		}
	}
	return;
}
function ObtenerCantidadSeleccionados(oSelectMultiple){
	var iCantidadSeleccionados = 0;
	for (var i = 0; i <= oSelectMultiple.options.length-1; i++) {
		if (oSelectMultiple.options(i).getAttribute('selected')){
			iCantidadSeleccionados += 1;
		}
	}	
	return iCantidadSeleccionados;
}
function VaciarCombo(oSelect){
	for (var i = oSelect.options.length-1; i >= 0; i--) {
		oSelect.options[i] = null;
	}	
}