function textlimit(Obj,maxcount,counter)
{
    function c_len(){
        if(this.value.length > this.maxcount && this.maxcount != 0)
            return false;
        update_count(this);
    }
    function upd_count(){    update_count(this);}
    function update_count(elem){
        if(elem.counter != null){
            cnt = getObj(elem.counter);
            cnt.innerHTML = elem.value.length
    }}
    function check(){
        if (this.value.length  > this.maxcount && this.maxcount != 0)
            this.value = this.value.substr(0,this.maxcount);
        update_count(this);
    }
    Obj.counter   = counter;      Obj.maxcount  = maxcount;
    Obj.onkeypress= c_len;        Obj.onkeydown = upd_count;
    Obj.onkeyup   = check;        Obj.onfocus   = check;
    Obj.onblur    = check;
    Obj.onmouseup = check;

    update_count(Obj);

function getObj( ref ) { if( document.getElementById( ref ) != null )//W3C/
return document.getElementById(ref); else if(document.all[ref]!=null)//IE5/
return document.all[ ref ]; else if( document.layers[ ref ] != null )//NN4/
return document.layers[ref]; else alert('Object "'+ref+'" not Found')//ERR/
}
}


function textlimit2(Obj2,maxcount2,counter2)
{
    function c_len(){
        if(this.value.length > this.maxcount2 && this.maxcount2 != 0)
            return false;
        update_count(this);
    }
    function upd_count(){    update_count(this);}
    function update_count(elem){
        if(elem.counter2 != null){
            cnt = getObj2(elem.counter2);
            cnt.innerHTML = elem.value.length
    }}
    function check(){
        if (this.value.length  > this.maxcount2 && this.maxcount2 != 0)
            this.value = this.value.substr(0,this.maxcount2);
        update_count(this);
    }
    Obj2.counter2   = counter2;      Obj2.maxcount2  = maxcount2;
    Obj2.onkeypress= c_len;        Obj2.onkeydown = upd_count;
    Obj2.onkeyup   = check;        Obj2.onfocus   = check;
    Obj2.onblur    = check;
    Obj2.onmouseup = check;

    update_count(Obj2);

function getObj2( ref ) { if( document.getElementById( ref ) != null )//W3C/
return document.getElementById(ref); else if(document.all[ref]!=null)//IE5/
return document.all[ ref ]; else if( document.layers[ ref ] != null )//NN4/
return document.layers[ref]; else alert('Object "'+ref+'" not Found')//ERR/
}
}



function textlimit3(Obj3,maxcount3,counter3)
{
    function c_len(){
        if(this.value.length > this.maxcount3 && this.maxcount3 != 0)
            return false;
        update_count(this);
    }
    function upd_count(){    update_count(this);}
    function update_count(elem){
        if(elem.counter3 != null){
            cnt = getObj3(elem.counter3);
            cnt.innerHTML = elem.value.length
    }}
    function check(){
        if (this.value.length  > this.maxcount3 && this.maxcount3 != 0)
            this.value = this.value.substr(0,this.maxcount3);
        update_count(this);
    }
    Obj3.counter3   = counter3;      Obj3.maxcount3  = maxcount3;
    Obj3.onkeypress= c_len;        Obj3.onkeydown = upd_count;
    Obj3.onkeyup   = check;        Obj3.onfocus   = check;
    Obj3.onblur    = check;
    Obj3.onmouseup = check;

    update_count(Obj3);

function getObj3( ref ) { if( document.getElementById( ref ) != null )//W3C/
return document.getElementById(ref); else if(document.all[ref]!=null)//IE5/
return document.all[ ref ]; else if( document.layers[ ref ] != null )//NN4/
return document.layers[ref]; else alert('Object "'+ref+'" not Found')//ERR/
}
}

