function FormValidator(){
	var title = document.getElementById('question_subject');
	var text = document.getElementById('question_content');
	var nick = document.getElementById('nick');
	
	// Check each input in the order that it appears in the form!

	if(title_lengthRestriction(title, 3)){
		if(text_lengthRestriction(text, 1)){
			if(nick_lengthRestriction(nick, 1)){	
				document.question.submit();
			}
		}
	}
	return false;

}

function title_lengthRestriction(elem, min){
	var uInput = elem.value;
	uInput=uInput.replace(/ /g, "");
	if(uInput.length >= min){
		return true;
	}
	else {
		if (uInput.length == 0) {
			alert("Nevyplnili ste názov príspevku.");
			elem.focus();
			return false;
		}
		if (uInput.length < min) {
		alert("Názov príspevku musí obsahovať viac ako 2 znaky.");
		elem.focus();
		return false;
		}
	}
}

function text_lengthRestriction(elem, min){
	var uInput = elem.value;
	uInput=uInput.replace(/ /g, "");
	if(uInput.length >= min){
		return true;
	}
	else {
		if (uInput.length == 0) {
			alert("Zadajte prosím text príspevku.");
			elem.focus();
			return false;
		}
	}
}

function nick_lengthRestriction(elem, min){
	var uInput = elem.value;
	uInput=uInput.replace(/ /g, "");
	if(uInput.length >= min){
		return true;
	}
	else {
		if (uInput.length == 0) {
			alert("Zadajte prosím Váš nick.");
			elem.focus();
			return false;
		}
	}
}

function SearchWord(){
	if (document.getElementById('word').value.length<=2) {
		alert ('Zadajte prosím minimálne 3 znaky');
		document.getElementById('word').focus();
	}
	else {
		document.searchslovo.submit();
		/*word=document.getElementById('searchforum').value;
		document.location.href='index.php?page=gynekologicka-poradna&word='+word+'#forum';*/
	}
}

