function check_long() {
	var wordcounter=0;
	for (x=0; x < document.anunt.mesaj.value.length; x++) {
		if ((document.anunt.mesaj.value.charAt(x) == " ") && (document.anunt.mesaj.value.charAt(x-1) != " "))  {
			wordcounter++
		};  
	};	
	if (wordcounter > 40) {
		document.anunt.mesaj.focus();
		alert("Ati depasit numarul maxim de cuvinte !");
		return false;
	};
	if ((document.anunt.mesaj.value.length == 0) || (wordcounter < 3)){
		document.anunt.mesaj.focus();
		alert("Va rugam sa nu introduceti anunturi vide !");
		return false;	
	};
	if (document.anunt.mesaj.value.length > 400) {
		document.anunt.mesaj.focus();
		alert("Ati depasit 400 de caractere !");
		return false;	
	};
	return true;
};

function wordCounter() {
	var wordcounter=0;
	var maxlimit = 40;
	for (x=0; x < document.anunt.mesaj.value.length; x++) {
		if ((document.anunt.mesaj.value.charAt(x) == " ") && (document.anunt.mesaj.value.charAt(x-1) != " "))  {
			wordcounter++
		}; 
		if (wordcounter > 400) {
			document.anunt.cuvram.value = document.anunt.mesaj.value.substring(0, x);
		} else {
			document.anunt.cuvram.value = maxlimit - wordcounter;
		};
	};
};