﻿function ShowHide(objName, visible) {
    if (visible == true) {
        document.getElementById(objName).style.display = 'block';
    }
    else {
        document.getElementById(objName).style.display = 'none';
    }
}

function trim(str) {
    str = str.toString();
    return str.replace(/^\s+|\s+$/g, "");
}
function ltrim(str) {
    str = str.toString();
    return str.replace(/^\s+/, "");
}
function rtrim(str) {
    str = str.toString();
    return str.replace(/\s+$/, "");
}

function OpenUrl(strUrl) {
    window.location = strUrl;
}

function AllowEnteredCharacters(evt, type, obj) {
    var charCode = (evt.which) ? evt.which : evt.keyCode

    switch (type) {
        case 'email':
            //dovolimo vnos 0-9, a-z, A-Z, pomisljaj, podcrtaj, pika, afna
            if ((charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 97 || charCode > 122) && (charCode < 65 || charCode > 90) && charCode != 45 && charCode != 95 && charCode != 46 && charCode != 64)) return false;

            break;

        case 'davcna':
            //dovolimo le vnos 0-9 in črk S, s, I, i; male crke avtomaticno konvertiramo v velike
            if ((charCode > 31 && (charCode < 48 || charCode > 57)) && charCode != 83 && charCode != 115 && charCode != 73 && charCode != 105) return false;

            break;

        case 'numeric':
            //dovolimo le vnos stevilk
            if ((charCode > 31 && (charCode < 48 || charCode > 57))) return false;

            break;

        case 'telefon':
            //dovolimo vnos stevilk, okepaj, zaklepaj, pomisljaj, presledek, plus
            if ((charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 40 && charCode != 41 && charCode != 45 && charCode != 32 && charCode != 43)) return false;

            break;

        case 'text':
            //ne dovolimo apostrof, procent
            if ((charCode > 31 && (charCode == 39 || charCode == 37))) return false;

            break;

        case 'date':
            //dovolimo vnos stevilk, pika
            if ((charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)) return false;

            break;

    }
    return true;
}
