var clfdUtils = (function (){
    return {}
}());

clfdUtils.formattingDot = function (number) {
    return new Intl.NumberFormat().format(number);
}

clfdUtils.calcPageNo = function (start, length) {
    if (start <= 0) {
        return 1;
    }
    return _.floor(start / length) + 1;
}

clfdUtils.appendHyphenToBirth = function (birth) {
    if (!birth || birth.length !== 8) {
        return birth;
    }
    return birth.substr(0, 4) +
           '-' +
           birth.substr(4, 2) +
           '-' +
           birth.substr(6, 2);
};

clfdUtils.appendHyphenToPhone = function (phone) {
    if (!phone || phone.length !== 11) {
        return phone;
    }
    return phone.substr(0, 3) +
        '-' +
        phone.substr(3, 4) +
        '-' +
        phone.substr(7, 4);
};

clfdUtils.appendHyphenToSaupjaNo = function (saupjaNo) {
    if (!saupjaNo || saupjaNo.length !== 10) {
        return saupjaNo;
    }
    return saupjaNo.substr(0, 3) +
        '-' +
        saupjaNo.substr(3, 2) +
        '-' +
        saupjaNo.substr(5, 5);
};

clfdUtils.appendHyphenToFax = function (fax) {
    if (!fax || fax.length !== 10) {
        return fax;
    }
    return fax.substr(0, 3) +
        '-' +
        fax.substr(3, 3) +
        '-' +
        fax.substr(6, 4);
};

clfdUtils.removeHyphen = function (target) {
    return _.replace(target, /\-/g, '');
};
