
// start functii pentru verificarea corectitudinii datelor introduse in formular
var mail = /^[a-zA-Z0-9]+[-_.\a-zA-Z0-9\.-_]+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
//var mail = /^\w[\w\d]+(\.[\w\d]+)*@\w[\w\d]+(\.[\w\d]+)*\.[a-z]{2,4}$/i;
function verifyEmail(champs) 
{
     reponse = mail.test(champs.value)
//	 alert(reponse);
     if (reponse) 
	 {
         return true;
     }
     else 
	 {         
         return false;
     }
}
function changeCase()
{
	//	alert("da");
	this.document.formular_oferta_pj.email.value = this.document.formular_oferta_pj.email.value.toLowerCase();
}
function changeCase1()
{
	//	alert("da");
	this.document.formular_oferta_pj.email_persoana_contact.value = this.document.formular_oferta_pj.email_persoana_contact.value.toLowerCase();
}


function check_fields()
{
   var ok				= true; // confirmare introducere corecta a datelor
   var err_denumire		= 0; // eroare introducere numele
   var err_cui			= 0; // eroare introducere CNP
   var err_tel			= 0; // eroare introducere telefon societate
   var err_fax			= 0; // eroare introducere fax    
   var err_email		= 0; // eroare introducere email
   var err_tel2			= 0; // eroare introducere telefon persoana de contact  
   var err_email_pers_contact = 0; // eroare introducere email
   	     
   var 	mesaj =   "_______________________________________     \n\n";
	mesaj += "Va rugam sa corectati erorile din lista de mai jos!  \n";
	mesaj += "_______________________________________     \n\n";

	if (this.document.formular_oferta_pj.denumire_societate.value.length == 0 )
	{
		mesaj += " -   Introduceti Denumirea Societatii comerciale.\n";
		err_denumire = 1;
		ok = false;
	}
	if (this.document.formular_oferta_pj.cui.value == "RO__________" )
	{
		mesaj += " -   Introduceti CUI.\n";
		err_cui = 1;
		ok = false;
	}
	

	if (this.document.formular_oferta_pj.telefon.value != "" )
	{
		if (isNaN(this.document.formular_oferta_pj.telefon.value) )
		{
			mesaj += " -   Numarul de telefon al societatii este incorect.\n";
			err_tel = 1;
			ok = false;
		}
	}
	
	if (this.document.formular_oferta_pj.fax.value != "" )
	{
		if (isNaN(this.document.formular_oferta_pj.fax.value))
		{
			mesaj += " -   Numarul de fax este incorect.\n";
			err_fax = 1;
			ok = false;
		}
		
	}		
	
	if (!verifyEmail(this.document.formular_oferta_pj.email) )
	{
		mesaj += " -   Introduceti o adresa de email valida, pentru societate!\n";
		err_email = 1;
		ok = false;
	}

	if (this.document.formular_oferta_pj.telefon_persoana_contact.value != "" )
	{
		if (isNaN(this.document.formular_oferta_pj.telefon_persoana_contact.value) )
		{
			mesaj += " -   Numarul de telefon al persoanei de contact este incorect.\n";
			err_tel2 = 1;
			ok = false;
		}
	}


	if (this.document.formular_oferta_pj.email_persoana_contact.value != "" )
	{
		if  (!verifyEmail(this.document.formular_oferta_pj.email_persoana_contact)  )
		{
			mesaj += " -   Introduceti o adresa de email valida, pentru persoana de contact!\n";
			err_email_pers_contact = 1;
			ok = false;
		}
		
	}
			
   if(ok)
   {
	 return true;
   }
   else
   {
   	 alert(mesaj);

		if(err_denumire == 1)
		{
			this.document.formular_oferta_pj.denumire_societate.select();
			return false;
		}

		if(err_cui == 1)
		{
			document.formular_oferta_pj.cui.select();
			return false;
		}
		
		if(err_tel == 1)
		{
			document.formular_oferta_pj.telefon.select();
			return false;
		}

		if(err_fax == 1)
		{
			document.formular_oferta_pj.fax.select();
			return false;
		}
										
		if(err_email == 1)
		{
			document.formular_oferta_pj.email.select();		
			return false;
		}
					
		if(err_tel2 == 1)
		{
			document.formular_oferta_pj.telefon_persoana_contact.select();
			return false;
		}
		
		if(err_email_pers_contact == 1)
		{
			document.formular_oferta_pj.email_persoana_contact.select();		
			return false;
		}
			
		 return false;
	}

}
// end

