function trim(val)
{
    var lc = 0
    var rc = 0
    for (i = 0; i < val.length; i++)
        if (val.charAt(i) == ' ')
            lc++
        else
            break

    for (i = val.length - 1; i >= 0; i--)
        if (val.charAt(i) == ' ')
            rc++
        else
            break

    return val.substr(lc, val.length - rc - lc)
}

function isDate(val)
{
    var re = /^(\d{1,2})\.(\d{1,2})\.(\d{4})$/
    val += ''

    if (!val.search(re)) 
    {
        var MatchStr = val.replace(re,'$1,$2,$3')
        var Matches = MatchStr.split(',')
        if (0+Matches[0] < 1 || 0+Matches[0] > 31) return false
        if (0+Matches[1] < 1 || 0+Matches[1] > 12) return false
        if (Matches[0].length == 1) Matches[0] = '0' + Matches[0]
        if (Matches[1].length == 1) Matches[1] = '0' + Matches[1]
        val = Matches.join('.')

        return val
    }
    else {
        return false
    }
}

function isInteger(val)
{
    var re = /^\d+$/
    val += ''

    if (!val.search(re)) {
        return true
    }
    else {
        return false
    }
}

function isFloat(val)
{
    var re = /^(\d+)?(\.\d+)?$/
    val += ''

    if (!val.search(re)) {
        return true
    }
    else {
        return false
    }
}

function isHttpUrl(val)
{
    var re = /^http(s?):\/\/[a-zA-Z0-9\.]+(\.[a-zA-Z]{2,})$/
    val += ''

    if (!val.search(re)) {
        return true
    }
    else {
        return false
    }
}

function isMail(val)
{
    var re = /^[a-zA-Z0-9\-\_\.]{2,}@[A-Za-z0-9\_\-\.]{2,}\.[A-Za-z]{2,4}$/
    val += ''

    if (!val.search(re)) {
        return true
    }
    else {
        return false
    }
}

function isHex(val)
{
    var re = /^[\dA-Fa-f]+$/
    val += ''

    if (!val.search(re)) {
        return true
    }
    else {
        return false
    }
}