//check mail function
function basicMailCheck(string){
	var err_mail=0, illegalPos=-1;
	var email = string;
	//define illegal chars:
	var illegalChars = new Array(18);
	illegalChars[0] = ',';
	illegalChars[1] = '!';
	illegalChars[2] = '#';
	illegalChars[3] = '$';
	illegalChars[4] = '^';
	illegalChars[5] = '*';
	illegalChars[6] = '+';
	illegalChars[7] = '=';
	illegalChars[8] = ')';
	illegalChars[9] = '(';
	illegalChars[10] = '<';
	illegalChars[11] = '>';
	illegalChars[12] = '{';
	illegalChars[13] = '}';
	illegalChars[14] = ']';
	illegalChars[15] = '[';
	illegalChars[16] = '/';
	illegalChars[17] = '|';
	//STEP 1: check for illegalChars
	for(i=0;i<illegalChars.length;i++){
		illegalPos = email.indexOf(illegalChars[i])*1;
		if(illegalPos>-1){
			//alert(illegalChars[i]);
			return 1;
		}
	}
	//STEP 2: check for e-mail correct structure
	var posAt = (email.indexOf('@')*1);
	var posDot = (email.indexOf('.', posAt)*1);
	var strLength = email.length*1;
	
	if(posAt<2 || posDot<posAt)
		err_mail=1;
	// || (strLength<(posDot+3) || strLength>(posDot+4))
	//end check
	return err_mail;
}

function add_to_newsletter() {
	
	var mail = document.newsletter.mail_newsletter.value;
	var nume = document.newsletter.nume_newsletter.value;
	
	document.newsletter.mail_newsletter.style.backgroundColor='#FFF';
	document.newsletter.mail_newsletter.style.borderColor='#D1CFCF';
	document.newsletter.nume_newsletter.style.backgroundColor='#FFF';
	document.newsletter.nume_newsletter.style.borderColor='#D1CFCF';
	
	
	if(basicMailCheck(mail)) {
		document.newsletter.mail_newsletter.focus();
		document.newsletter.mail_newsletter.style.backgroundColor='#FADADC';
		document.newsletter.mail_newsletter.style.borderColor='#F9CFD1'
		alert('Completati corect adresa de mail!');	
	}
	else if (nume=='') {
		document.newsletter.nume_newsletter.focus();
		document.newsletter.nume_newsletter.style.backgroundColor='#FADADC';
		document.newsletter.nume_newsletter.style.borderColor='#F9CFD1'
		alert('Completati numele dvs.!');	
		}
	else if (confirm('Datele sunt corecte?')) {					
		document.newsletter.submit();
	}
}

function mobile_number(telefon) {
		
}

function formular_aderare() {	

	var nume 		= document.aderare.nume.value;
	var locul_data_nasterii = document.aderare.locul_data_nasterii.value;
	var nationalitate= document.aderare.nationalitate.value;
	var adresa		= document.aderare.adresa.value;
	var cod_postal	= document.aderare.cod_postal.value;
	var localitatea	= document.aderare.localitatea.value;
	var recomandare	= document.aderare.recomandare.value;
	var institutie	= document.aderare.institutie.value;
	var functie 	= document.aderare.functie.value;
	var telefon_direct= document.aderare.telefon_direct.value;
	var mobil 		= document.aderare.mobil.value;	
	var email 		= document.aderare.email.value;
	var statut		= document.aderare.statut.checked; //true or false
 
 	/**/
	document.aderare.email.style.backgroundColor='#F7F7F7';
	document.aderare.email.style.borderColor='#F1F1F1';
	document.aderare.nume.style.backgroundColor='#F7F7F7';
	document.aderare.nume.style.borderColor='#F1F1F1';	
	document.aderare.locul_data_nasterii.style.backgroundColor='#F7F7F7';
	document.aderare.locul_data_nasterii.style.borderColor='#F1F1F1';	
	document.aderare.nationalitate.style.backgroundColor='#F7F7F7';
	document.aderare.nationalitate.style.borderColor='#F1F1F1';	
	document.aderare.adresa.style.backgroundColor='#F7F7F7';
	document.aderare.adresa.style.borderColor='#F1F1F1';	
	document.aderare.cod_postal.style.backgroundColor='#F7F7F7';
	document.aderare.cod_postal.style.borderColor='#F1F1F1';
	document.aderare.localitatea.style.backgroundColor='#F7F7F7';
	document.aderare.localitatea.style.borderColor='#F1F1F1';
	document.aderare.recomandare.style.backgroundColor='#F7F7F7';
	document.aderare.recomandare.style.borderColor='#F1F1F1';
	document.aderare.institutie.style.backgroundColor='#F7F7F7';
	document.aderare.institutie.style.borderColor='#F1F1F1';
	document.aderare.telefon_direct.style.backgroundColor='#F7F7F7';
	document.aderare.telefon_direct.style.borderColor='#F1F1F1';
	document.aderare.mobil.style.backgroundColor='#F7F7F7';
	document.aderare.mobil.style.borderColor='#F1F1F1';
	document.aderare.functie.style.backgroundColor='#F7F7F7';
	document.aderare.functie.style.borderColor='#F1F1F1';

	/**/
	
	 if (basicMailCheck(email)==1) {
		document.aderare.email.focus();
		document.aderare.email.style.backgroundColor='#FADADC';
		document.aderare.email.style.borderColor='#F9CFD1'
		alert('Completati corect adresa de mail!');	
	}
	else if (locul_data_nasterii=='') {
	 		document.aderare.locul_data_nasterii.focus();
			document.aderare.locul_data_nasterii.style.backgroundColor='#FADADC';
			document.aderare.locul_data_nasterii.style.borderColor='#F9CFD1'
			alert('Completati locul si data nasterii!');
	}
	else if (nationalitate=='') {
	 		document.aderare.nationalitate.focus();
			document.aderare.nationalitate.style.backgroundColor='#FADADC';
			document.aderare.nationalitate.style.borderColor='#F9CFD1'
			alert('Completati nationalitatea!');
	}
	else if (adresa=='') {
	 		document.aderare.adresa.focus();
			document.aderare.adresa.style.backgroundColor='#FADADC';
			document.aderare.adresa.style.borderColor='#F9CFD1'
			alert('Completati adresa!');
	}
	else if (cod_postal=='') {
	 		document.aderare.cod_postal.focus();
			document.aderare.cod_postal.style.backgroundColor='#FADADC';
			document.aderare.cod_postal.style.borderColor='#F9CFD1'
			alert('Completati codul postal!');
	}
	else if (localitatea=='') {
	 		document.aderare.localitatea.focus();
			document.aderare.localitatea.style.backgroundColor='#FADADC';
			document.aderare.localitatea.style.borderColor='#F9CFD1'
			alert('Completati localitatea!');
	}
	else if (recomandare=='') {
	 		document.aderare.recomandare.focus();
			document.aderare.recomandare.style.backgroundColor='#FADADC';
			document.aderare.recomandare.style.borderColor='#F9CFD1'
			alert('Completati campul de recomandare!');
	}
	else if (institutie=='') {
	 		document.aderare.institutie.focus();
			document.aderare.institutie.style.backgroundColor='#FADADC';
			document.aderare.institutie.style.borderColor='#F9CFD1'
			alert('Completati institutia!');
	}
	else if (functie=='') {
	 		document.aderare.functie.focus();
			document.aderare.functie.style.backgroundColor='#FADADC';
			document.aderare.functie.style.borderColor='#F9CFD1'
			alert('Completati functia dvs!');
	}
	else if (telefon_direct=='') {
	 		document.aderare.telefon_direct.focus();
			document.aderare.telefon_direct.style.backgroundColor='#FADADC';
			document.aderare.telefon_direct.style.borderColor='#F9CFD1'
			alert('Completati telefonul direct!');
	}
	else if (mobil=='') {
	 		document.aderare.mobil.focus();
			document.aderare.mobil.style.backgroundColor='#FADADC';
			document.aderare.mobil.style.borderColor='#F9CFD1'
			alert('Completati mobil!');
	}	
	else if (document.aderare.statut.checked==false) {
			alert('Trebuie sa fiti de acord cu statutul AAFB');
	}
	else if (confirm('Sunteti sigur?')) {					
		document.aderare.submit();
			}	
}

function formular_contact() {	
	var nume 	= document.contact.nume.value;
	var mesaj = document.contact.mesaj.value;
	var email 	= document.contact.email.value;
	
	/**/
	document.contact.email.style.backgroundColor='#F7F7F7';
	document.contact.email.style.borderColor='#F1F1F1';
	document.contact.nume.style.backgroundColor='#F7F7F7';
	document.contact.nume.style.borderColor='#F1F1F1';
	document.contact.mesaj.style.backgroundColor='#F7F7F7';
	document.contact.mesaj.style.borderColor='#F1F1F1';
	/**/
	
	 if (basicMailCheck(email)==1) {
		document.contact.email.focus();
		document.contact.email.style.backgroundColor='#FADADC';
		document.contact.email.style.borderColor='#F9CFD1'
		alert('Completati corect adresa de mail!');	
	}
	 else if (nume=='') {
	 		document.contact.nume.focus();
			document.contact.nume.style.backgroundColor='#FADADC';
			document.contact.nume.style.borderColor='#F9CFD1'
			alert('Completati numele dvs!');
	}	
	else if (mesaj=='') {
		document.contact.mesaj.focus();
		document.contact.mesaj.style.backgroundColor='#FADADC';
		document.contact.mesaj.style.borderColor='#F9CFD1'
		alert('Completati mesajul dvs.');
	}	
	else if (confirm('Sunteti sigur?')) {					
		document.contact.submit();
			}	
}


