function check_form_newsletter()
{  
	var email =  document.getElementById( 'email_newsletter' ).value;
	
	if ((email==null)||(email==""))
	{
		alert( 'Trebuie sa introduceti o adresa de e-mail !' );
		return false;
	}
	else if (echeck(email)==false){
		alert("Adresa de email este incorecta.");
		return false;
	}
	return true;
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false;
		 }

 		 return true;				
	}


function ValidateForm()
{
	var error = "";
	
	var email = document.getElementById('email').value;
	var prenume = document.getElementById('prenume').value;
	var nume = document.getElementById('nume').value;
	var subiect = document.getElementById('subiect').value;
	var mesaj = document.getElementById('mesaj').value;
	
   
	
	if ((prenume==null)||(prenume=="")){
		error +="Va rugam introduceti prenumele.\r\n";
	}
	if ((nume==null)||(nume=="")){
		error +="Va rugam introduceti numele.\r\n";
	}
	if ((email==null)||(email=="")){
		error +="Va rugam introduceti adresa de email.\r\n";
	}
	else if (echeck(email)==false){
		error +="Adresa de email este incorecta.\r\n";
	}
	if ((subiect==null)||(subiect=="")){
		error +="Va rugam introduceti subiectul.\r\n";
	}
	if ((mesaj==null)||(mesaj=="")){
		error +="Va rugam introduceti mesajul.\r\n";
	}
	
	if (error == "")
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}

}