function checkPlainText(textBox)
{
	var alphaExp = /^[0-9a-zA-Z±æê³ñó¶¼¿¡ÆÊ£ÑÓ¦¬¯\-\_\,\.\-\_\s\;\:\)\(\?\!\"]+$/;
	
	while (textBox.value.length > 0 && !textBox.value.match(alphaExp)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
}

function checkPlainKomentarzText(textBox)
{
	var alphaExp = /^[0-9a-zA-Z±æê³ñó¶¼¿¡ÆÊ£ÑÓ¦¬¯\-\_\,\.\-\_\s\;\:\)\(\?\!\"]+$/;
	
	while (textBox.value.length > 0 && !textBox.value.match(alphaExp)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
		
	}
	if(textBox.value.length > 2000) { textBox.value = textBox.value.substring(0, 2000) }
}


function checkPlainTextUserName(textBox)
{
	var alphaExp = /^[0-9a-zA-Z\-\_]+$/;
	
	while (textBox.value.length > 0 && !textBox.value.match(alphaExp)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
}


function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}


function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}



function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
/*	if (textBox.value.length == 0) {
		textBox.value = 0;		
	} else {
		textBox.value = parseInt(textBox.value);
	}*/
}



function checkAddKomForm() {
  with (window.document.frmAddKom) {
		checkPlainKomentarzText(txtTresc);
		if (isEmpty(txtNick, 'Wprowad¼ nick')) {
			return;
		}
		else if (isEmpty(txtTresc, 'Wprowad¼ tre¶æ')) {
			return;
		}
		else {
			submit();
		}
	}
	submit();
}