﻿function textCount(text,long) {
    var area = document.getElementById(text);
    var maxlength = new Number(long);
    if(area.value.length > maxlength) {
        area.value = area.value.substring(0,maxlength);
    }
}

function visibileHome(id) {
    var max = 11; // 3 record = 4
    quanti = 0;
    var elm = document.getElementsByTagName('input');
    for(var i = 0; i < elm.length; i++) {
        if(elm.item(i).id.indexOf("homeChk")!=-1) {
            if(elm.item(i).checked==true)
                quanti++;
        }
    }
    if(quanti == max) id.checked=false;
}

function trim(stringa){
    while (stringa.substring(0,1) == ' '){
        stringa = stringa.substring(1, stringa.length);
    }
    while (stringa.substring(stringa.length-1, stringa.length) == ' '){
        stringa = stringa.substring(0,stringa.length-1);
    }
    return stringa;
}

function redirect(id) {
    parent.document.location.href="UtentiLogin.aspx?url=CorsiOlModuli.aspx?id="+id;
    parent.Shadowbox.close()
}

function currentPage() {
    var sPath = window.location.pathname;
    //var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    sPage = sPage.replace(".aspx","").toLowerCase();
    return sPage;
}

function zeroPad(num,count) {
    var numZeropad = num + '';
    while(numZeropad.length < count) {
        numZeropad = "0" + numZeropad;
    }
    return numZeropad;
}

function disableEnterKey(e)
{
     var key;     
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox     

     return (key != 13);
}
