var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
        if (window.event&&event.srcElement.value.length>=maxlength)
                return false
                else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
                        var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
                        if (pressedkey.test(String.fromCharCode(e.which)))
                                e.stopPropagation()
                }
}

function countlimit(maxlength,e,placeholder){
        var theform=eval(placeholder)
        var lengthleft=maxlength-theform.value.length
        var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
        if (window.event||e.target&&e.target==eval(placeholder)){
                if (lengthleft<0)
                        theform.value=theform.value.substring(0,maxlength)
                        placeholderobj.innerHTML=lengthleft
        }
}


function pokazlimit(pole,limit){
        var limit_text='<font color=#b50101><span id="'+pole.toString()+'">'+limit+'</span></font>'
        if (document.all||ns6)
                document.write(limit_text)
                if (document.all){
                        eval(pole).onkeypress=function(){ return restrictinput(limit,event,pole)}
                        eval(pole).onkeyup=function(){ countlimit(limit,event,pole)}
                }
                else if (ns6){
                        document.body.addEventListener('keypress', function(event) { restrictinput(limit,event,pole) }, true); 
                        document.body.addEventListener('keyup', function(event) { countlimit(limit,event,pole) }, true); 
                }
}

function countlimit2(maxlength,e,placeholder){
        var theform=eval(placeholder)
        var lengthleft=theform.value.length
        var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
        if (window.event||e.target&&e.target==eval(placeholder)){
                if (lengthleft<0)
                        theform.value=theform.value.substring(0,maxlength)
                        placeholderobj.innerHTML=lengthleft
        }
}


function pokazlimit2(pole,limit){
        var limit_text='<font color=#b50101><span id="'+pole.toString()+'">0</span></font>'
        if (document.all||ns6)
                document.write(limit_text)
                if (document.all){
                        eval(pole).onkeypress=function(){ return restrictinput(limit,event,pole)}
                        eval(pole).onkeyup=function(){ countlimit2(limit,event,pole)}
                }
                else if (ns6){
                        document.body.addEventListener('keypress', function(event) { restrictinput(limit,event,pole) }, true); 
                        document.body.addEventListener('keyup', function(event) { countlimit2(limit,event,pole) }, true); 
                }
}

var copytoclip=1
function HighlightAll(theField) {
        var tempval=eval("document."+theField)
        tempval.focus()
        tempval.select()
        if (document.all&&copytoclip==1){
                therange=tempval.createTextRange()
                therange.execCommand("Copy")
                window.status="Zawartosc podswietlona i skopiowana do schowka"
                setTimeout("window.status=''",1800)
        }
}

