String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
//**************************************************************************
function fMenuConfig(){
	document.getElementById("TxtAc").value="CM";
	document.getElementById("Frm").submit();
}
function fFiltrar(){
	document.getElementById("TxtAc").value="F";
	document.getElementById("Frm").submit();
}
//**************************************************************************
function fCancelar(){
	document.getElementById("CH_EV").checked=false;
	document.getElementById("CH_MV").checked=false;
	document.getElementById("CH_AV").checked=false;
	document.getElementById("TxtNom").value="";
	document.getElementById("TxtPass").value="";
	document.getElementById("TxtPass2").value="";
	document.getElementById("TxtFull").value="";
	document.getElementById("CboHab").value="SI";
	document.getElementById("CmdG").value="Guardar";
	document.getElementById("CmdLoad").disabled=true;
	document.getElementById("TxtId").value="";
	document.getElementById("TxtAc").value="";
	document.getElementById("TxtNom").focus();
}
function fGuardar(){
	var Nom=gv("TxtNom");
	var Pass=gv("TxtPass");
	var Pass2=gv("TxtPass2");
	var Emp=gv("CboEmp");
	var Alm=gv("CboAlm");
	var Full=gv("TxtFull");
	var Hab=gv("CboHab");
	if(Nom.trim().length==0){
		alert("Ingrese el nombre de usuario");
		document.getElementById("TxtNom").focus();
		return;
	}
	if(Pass.trim().length==0){
		alert("Ingrese el password");
		document.getElementById("TxtPass").focus();
		return;
	}
	if(Pass2.trim().length==0){
		alert("Ingrese el password nuevamente");
		document.getElementById("TxtPass2").focus();
		return;
	}
	if(Pass!=Pass2){
		alert("Los password son distintos");
		document.getElementById("TxtPass2").focus();
		return;
	}
	if(jVac(Emp,"Seleccione una empresa","CboEmp"))return;
	if(Alm.trim().length==0){
		alert("Seleccione un almacen");
		document.getElementById("CboAlm").focus();
		return;
	}
	if(Full.trim().length==0){
		alert("Ingrese los nombres y apellidos");
		document.getElementById("TxtFull").focus();
		return;
	}	
	if(Hab.trim().length==0){
		alert("Seleccion un estado");
		document.getElementById("CboHab").focus();
		return;
	}
	if(document.getElementById("CmdG").value=="Guardar"){
		SM("G");
	}else{
		SM("M");
	}	
}
/**************************************************************************
	onkeypress="return pulsar(event);"
**************************************************************************/
function pulsar(e) { 	
	var tecla = (document.all) ? e.keyCode :e.which; 
	var Obj=event.srcElement.name;	
	if(Obj=="TxtNom"){
		if(tecla==13){			
			document.getElementById('CmdG').click();			
		}
	}	
	return (tecla!=13); 
} 
//**************************************************************************
function CboEmp_OC(){
	var Emp=gv("CboEmp");
	if(Emp=="TODOS"){
		CBO_FILL("CboAlm","TODOS|",0)
	}else{
		var r=AX("01",Emp);
		if(r=="X"){
			CBO_CLS("CboAlm",1);
		}else{
			CBO_FILL("CboAlm",r,0);
		}
	}
}
