﻿function ucallfirst(str) {

    var newstr = '';
    var temp = str.split(' ');

    for (var i = 0; i < temp.length; i++) {
        if (i == 0) {
            newstr += ucfirst(temp[i]);
        } else {
            newstr += ' ' + ucfirst(temp[i]);
        }
    }
    return newstr;
}

function ucfirst(str) {
    firstChar = str.substring(0, 1);
    remainChar = str.substring(1);

    firstChar = firstChar.toUpperCase();
    remainChar = remainChar.toLowerCase();

    return firstChar + remainChar
}

function lcall(str) {

    var newstr = '';
    var temp = str.split(' ');

    for (var i = 0; i < temp.length; i++) {
        if (i == 0) {
            newstr += lc(temp[i]);
        } else {
            newstr += ' ' + lc(temp[i]);
        }
    }
    return newstr;
}

function AddDots(id) {
    var newinitials = '';
    var initials = noWhiteSpace(getVal(id));
    initials = initials.replace(/\W+/g, '');
    initials = initials.toUpperCase();
    for (i = 0; i < initials.length; i++) {
        newinitials += initials.substr(i, 1) + '.';
    }
    return newinitials;
}

function noWhiteSpace(s) {
    if ((s == null) || (typeof (s) != 'string') || !s.length) return ''; return s.replace(/\s+/g, '');
}

function lc(str) {
    firstChar = str.substring(0, 1);
    remainChar = str.substring(1);

    firstChar = firstChar.toLowerCase();
    remainChar = remainChar.toLowerCase();

    return firstChar + remainChar
}

function getVal(id) {
    return document.getElementById(id).value;
}

function setVal(id, val) {
    document.getElementById(id).value = val;
}