function LoginFormat()
{
    this.LONG_PIN = 8;
    this.LONG_DNI = 11;
    this.LONG_USR = 20;

    this.FILL_PIN = "0";
    this.FILL_DNI = "0";
    this.FILL_USR = " ";

    this.formatPIN = LoginFormat_formatPIN;
    this.formatDNI = LoginFormat_formatDNI;
    this.formatUSR = LoginFormat_formatUSR;
    this.completarCarIzq = LoginFormat_completarCarIzq;
    this.completarCarDer = LoginFormat_completarCarDer;
}

function LoginFormat_formatPIN( pin )
{
    if ( pin.length > this.LONG_PIN ) return pin.substring( pin.length - this.LONG_PIN );
    else return this.completarCarIzq( pin, this.FILL_PIN, this.LONG_PIN );
}

function LoginFormat_formatDNI( dni )
{
    if ( dni.length > this.LONG_DNI ) return dni.substring( dni.length - this.LONG_DNI );
    else return this.completarCarIzq( dni, this.FILL_DNI, this.LONG_DNI );
}

function LoginFormat_formatUSR( usr )
{
    if ( usr.length > this.LONG_USR ) return usr.substring( usr.length - this.LONG_USR );
    else return this.completarCarDer( usr, this.FILL_USR, this.LONG_USR );
}

function LoginFormat_completarCarIzq( s, c, l )
{
    var res = s;

    while ( res.length < l )
            res = c + res;

    return res;
}

function LoginFormat_completarCarDer( s, c, l )
{
    var res = s;

    while ( res.length < l )
            res += c;

    return res;
}