function popup(x,y) {
	window.open(x,y,"status=no,scrollbars=yes,resizable=yes,width=500,height=320");
}

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 replaceWhiteSpace(replacetext) {
	replacetext = replacetext.replace(/^\s+/, "");
	replacetext = replacetext.replace(/\s+$/gi, "");
	return replacetext;
}
