function sendIt() {
	document.post.destinatarNume.value = replaceWhiteSpace(document.post.destinatarNume.value);
	document.post.expeditorSubiect.value = replaceWhiteSpace(document.post.expeditorSubiect.value);
	document.post.expeditorNume.value = replaceWhiteSpace(document.post.expeditorNume.value);
	document.post.expeditorMesaj.value = replaceWhiteSpace(document.post.expeditorMesaj.value);

	//verific numele destinatarului
    if (document.post.destinatarNume.value.length < 2) {
        alert("Nu a fost specificat destinatarul!")
        document.post.destinatarNume.focus();
        return false;
    }

	//verific subiectul
    if (document.post.expeditorSubiect.value.length < 2) {
        alert("Subiectul mesajului este obligatoriu!")
        document.post.expeditorSubiect.focus();
        return false;
    }

    //verific numele expeditorului
    if (document.post.expeditorNume.value.length < 2) {
        alert("Numele dvs. este obligatoriu!")
        document.post.expeditorNume.focus();
        return false;
    }

    // verific formatul emailului
    if ((document.post.expeditorEmail.length == 0) || (document.post.expeditorEmail.value.search(/^[\-\.\w]*@[a-zA-Z0-9][\-\.\w]*\.[a-zA-Z]{2,3}$/) < 0)) {
        alert("Adresa de email este incorecta sau necompletata!");
        document.post.expeditorEmail.focus();
        return false;
    }

    if (document.post.expeditorMesaj.value.length < 2) {
        alert("Mesajul este obligatoriu!")
        document.post.expeditorMesaj.focus();
        return false;
    }

    document.post.submit();
    return true;
	}

	function sendIt2() {
	document.post.expeditorNume.value = replaceWhiteSpace(document.post.expeditorNume.value);

	// verific formatul emailului destinatarului
    if ((document.post.destinatarEmail.length == 0) || (document.post.destinatarEmail.value.search(/^[\-\.\w]*@[a-zA-Z0-9][\-\.\w]*\.[a-zA-Z]{2,3}$/) < 0)) {
        alert("Adresa de email este incorecta sau necompletata!");
        document.post.destinatarEmail.focus();
        return false;
    }

    //verific numele expeditorului
    if (document.post.expeditorNume.value.length < 2) {
        alert("Numele dvs. este obligatoriu!")
        document.post.expeditorNume.focus();
        return false;
    }

    document.post.submit();
    return true;
	}

function testemail() {
	document.recomanda.expeditorNume.value = replaceWhiteSpace(document.recomanda.expeditorNume.value);
	document.recomanda.expeditorSubiect.value = replaceWhiteSpace(document.recomanda.expeditorSubiect.value);

	// verific formatul emailului destinatarului
    if ((document.recomanda.destinatarEmail.length == 0) || (document.recomanda.destinatarEmail.value.search(/^[\-\.\w]*@[a-zA-Z0-9][\-\.\w]*\.[a-zA-Z]{2,3}$/) < 0)) {
        alert("Adresa destinatarului de email este incorecta sau necompletata!");
        document.recomanda.destinatarEmail.focus();
        return false;
    }

	// verific formatul emailului expeditorului
    if ((document.recomanda.expeditorEmail.length == 0) || (document.recomanda.expeditorEmail.value.search(/^[\-\.\w]*@[a-zA-Z0-9][\-\.\w]*\.[a-zA-Z]{2,3}$/) < 0)) {
        alert("Adresa dvs. de email este incorecta sau necompletata!");
        document.recomanda.expeditorEmail.focus();
        return false;
    }

    //verific numele expeditorului
    if (document.recomanda.expeditorNume.value.length < 5) {
        alert("Numele dvs. este obligatoriu!")
        document.recomanda.expeditorNume.focus();
        return false;
    }

	//verific subiectul mesajului
    if (document.recomanda.expeditorSubiect.value.length < 5) {
        alert("Subiectul mesajului este obligatoriu!")
        document.recomanda.expeditorSubiect.focus();
        return false;
    }

    document.recomanda.submit();
    return true;
}

function sendIt_mesaje() {
		document.mesaj.numeMesaj.value = replaceWhiteSpace(document.mesaj.numeMesaj.value);
		document.mesaj.stradaMesaj.value = replaceWhiteSpace(document.mesaj.stradaMesaj.value);
		document.mesaj.localitateMesaj.value = replaceWhiteSpace(document.mesaj.localitateMesaj.value);
		document.mesaj.subiectMesaj.value = replaceWhiteSpace(document.mesaj.subiectMesaj.value);
		document.mesaj.contentMesaj.value = replaceWhiteSpace(document.mesaj.contentMesaj.value);

		//verific numele expeditorului
		if (document.mesaj.numeMesaj.value.length < 2) {
			alert("Va rugam introduceti numele si prenumele.")
			document.mesaj.numeMesaj.focus();
			return false;
		}

		//verific Strada
		if (document.mesaj.stradaMesaj.value.length < 2) {
			alert("Va rugam specificati strada pe care locuiti.")
			document.mesaj.stradaMesaj.focus();
			return false;
		}

		//verific localitatea
		if (document.mesaj.localitateMesaj.value.length < 2) {
			alert("Va rugam specificati localitatea in care locuiti.")
			document.mesaj.localitateMesaj.focus();
			return false;
		}

		// verific formatul emailului
		if ((document.mesaj.emailMesaj.length == 0) || (document.mesaj.emailMesaj.value.search(/^[\-\.\w]*@[a-zA-Z0-9][\-\.\w]*\.[a-zA-Z]{2,3}$/) < 0)) {
			alert("Va rugam introduceti o adresa corecta de email, pe aceasta adresa primiti numarul de inregistrare.");
			document.mesaj.emailMesaj.focus();
			return false;
		}

		//verific subiectul
		if (document.mesaj.subiectMesaj.value.length < 2) {
			alert("Va rugam specificati subiectul mesajului.")
			document.mesaj.subiectMesaj.focus();
			return false;
		}

		if (document.mesaj.contentMesaj.value.length < 2) {
			alert("Va rugam sa completati campul de mesaj.")
			document.mesaj.contentMesaj.focus();
			return false;
		}

		document.mesaj.submit();
		return true;
}

function replaceWhiteSpace(replacetext) {
	replacetext = replacetext.replace(/^\s+/, "");
	replacetext = replacetext.replace(/\s+$/gi, "");
	return replacetext;
}