function ofcheckNum(asValue) {
    asValue=of_trim(asValue);
    if (asValue=='' || asValue==null) return asValue;
    for (var i=0; i < asValue.length && asValue.charAt(i)!='-'; i++) ;
    if (i==asValue.length && i>1) { // asumimos ultimo campo como digito verificador
        var lsRUT="", lsDV="", lsRUTAccum="";
        lsRUT=asValue.substring(0, asValue.length - 1);
        liStrLen=lsRUT.length;
        for (liIndex=0; liIndex<liStrLen; liIndex++) {
            lsCurrChar=lsRUT.charAt(liIndex);
            if (lsCurrChar!='.' && lsCurrChar!=';' && lsCurrChar!=',' && lsCurrChar!=' ') 
                lsRUTAccum += lsCurrChar;
        }
		lsDV=asValue.substring(asValue.length - 1, asValue.length);
        asValue=lsRUTAccum+"-"+lsDV;
    } else if (asValue.length > 0) {
        var lsRUT="", lsDV="", lsRUTAccum="";
        lsRUT=asValue.substring(0, i);
        liStrLen=lsRUT.length;
        for (liIndex=0; liIndex<liStrLen; liIndex++) {
            lsCurrChar=lsRUT.charAt(liIndex);
            if (lsCurrChar!='.' && lsCurrChar!=';' && lsCurrChar!=',' && lsCurrChar!=' ') 
                lsRUTAccum += lsCurrChar;
        }
		lsDV=asValue.substring(asValue.length - 1, asValue.length);
        asValue=lsRUTAccum+"-"+lsDV;
    }
    return asValue;
}
function ofCheckId(theForm) {
	var L_Msg_Text='Por favor, ingresar su R.U.T y su clave secreta.';
	if (theForm.elements["irut"].value == '' || theForm.elements["ikey"].value == '' ||
	theForm.elements["irut"].value == '0' || theForm.elements["irut"].value == '0-0') {
		theForm.irut.focus();
		alert(L_Msg_Text);
		return false;
	}
	else {
		po_rut=new rutCLASS(theForm.elements["irut"].value);
		if (po_rut.of_isRUT()==0) { theForm.irut.focus();alert("R.U.T incorrecto, intente de nuevo."); return false;}
		if (po_rut.of_checkDV()==0) { theForm.irut.focus();alert("Digito Verificador incorrecto, intente de nuevo."); return false;}
		theForm.elements["?.iformaction"].value='.ilogin';
		return true;
	}
}
function ofCleanForm(theForm) {
  theForm.elements["irut"].value="";
  theForm.elements["ikey"].value="";
  theForm.irut.focus();
}
function ofLossKey(theForm,theURL,theValue) {
	if (theForm.elements["irut"].value == '' || theForm.elements["irut"].value == null || theForm.elements["irut"].value =='0-0' ) 
	{
		theForm.irut.focus();
		alert('Debe ingresar previamente su R.U.T.');
		return false;
	}
	po_rut=new rutCLASS(theForm.elements["irut"].value);
	if (po_rut.of_isRUT()==0) { theForm.irut.focus();alert("R.U.T incorrecto, intente de nuevo."); return;}
	if (po_rut.of_checkDV()==0) { theForm.irut.focus();alert("Digito Verificador incorrecto, intente de nuevo.");return;}
	theForm.elements["?.iformaction"].value=theValue;
	if (theValue==".ilogin" || theValue==".iloss")
	{
		theForm.elements["indice"].value=theURL;
		theForm.submit();
		return true;
	}
	if (theValue==".iloss")
	{
		theForm.elements["indice"].value=theURL;
		parent.location.replace('ideudas?indice='+theURL+'&irut='+theForm.elements["irut"].value+'&?.iformaction='+theValue);
		return true;
	}
}
function ofFormIDeudasSubmit(theForm,theURL,theValue) {
	theForm.elements["?.iformaction"].value=theValue;
	theForm.elements["indice"].value=theURL;
//	theForm.submit();
	parent.location.replace('ideudas?indice='+theURL+'&?.iformaction='+theValue);
}

