function checkMaxLength(sender, maxLength)
{
	var counter = document.getElementById(sender.getAttribute('id') + '_counter');	
	if(counter == null)
	{
		counter = document.createElement('div');
		counter.id = sender.getAttribute('id') + '_counter';
		counter.setAttribute('class','TextareaMaxLength');	
		counter.innerHTML = 'Byl překročen maximální počet znaků (' + maxLength + ').';
		sender.parentNode.insertBefore(counter,sender.nextSibling);
		
	}
	var currentLength = sender.value.length;
	if (currentLength > maxLength)
	{
		counter.style.visibility = 'visible';
		counter.style.display = '';
	}
	else
		counter.style.display = 'none';
}	


function OnEnterSubmitForm(e,ControlIdToClick)
{
    var code;
    if (!e) var e = window.event
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if(code&&code==13)
    {
        document.getElementById(ControlIdToClick).click();
        return false;
    }
    else
        return true;    
}

/*
function setMaxLength()
{
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.setAttribute('class','TextareaMaxLength');
	for (var i=0;i<x.length;i++)
	{							
		if (x[i].getAttribute('maxlength'))
		{												
			var counterClone = counter.cloneNode(true);			
			counterClone.id = x[i].getAttribute('id') + '_counter';										
			counterClone.innerHTML = 'Byl překročen maximální počet znaků (' + x[i].getAttribute('maxlength') + ').';
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

window.attachEvent('onload',setMaxLength);

function checkMaxLength()
{
	var maxLength = this.getAttribute('maxlength');
	var counter = document.getElementById(this.getAttribute('id') + '_counter');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
	{
		counter.style.visibility = 'visible';
		counter.style.display = '';
	}
	else
		counter.style.display = 'none';
}	

*/