function verifica_factura() {
	ok=1;
	var x='';
	var error="";
	if(!document.getElementById('fiscal_code').value) {
		ok=0;
		error=error+"<br>Campul Cod fiscal nu a fost completat";
	}
	else{
		x=document.getElementById('fiscal_code').value;
		for (i=0;i<x.length;i++) {
			if (x.charAt(i) == ' ') {
				ok = 0;
				error=error+"<br>Campul Cod fiscal nu trebuie sa contina spatii";
				break;
			}
		}
		
	}
	if(!document.getElementById('jcod').value) {
		ok=0;
		error=error+"<br>Campul Nr. Reg. Com. nu a fost completat";
	}
	else{
		x=document.getElementById('jcod').value;
		for (i=0;i<x.length;i++) {
			if (x.charAt(i) == ' ') {
				ok = 0;
				error=error+"<br>Campul Nr. Reg. Com. nu trebuie sa contina spatii";break;
			}
		}
		
	}
	if(!document.getElementById('cont').value) {
		ok=0;
		error=error+"<br>Campul Cont IBAN nu a fost completat";
	}
	else{
		x=document.getElementById('cont').value;
		for (i=0;i<x.length;i++) {
			if (x.charAt(i) == ' ') {
				ok = 0;
				error=error+"<br>Campul Cont IBAN nu trebuie sa contina spatii";break;
			}
		}
		
	}
	if(!document.getElementById('banca').value) {
		ok=0;
		error=error+"<br>Campul Banca nu a fost completat";
	}
	if(!document.getElementById('locality').value) {
		ok=0;
		error=error+"<br>Campul Localitate nu a fost completat";
	}
	if(!document.getElementById('caddress').value) {
		ok=0;
		error=error+"<br>Campul Adresa nu a fost completat";
	}
	
	if(!document.getElementById('ccod_postal').value) {
		ok=0;
		error=error+"<br>Campul Cod postal nu a fost completat";
	}
	else{
		x=document.getElementById('ccod_postal').value;
		for (i=0;i<x.length;i++) {
			if (x.charAt(i) == ' ') {
				ok = 0;
				error=error+"<br>Campul Cod postal nu trebuie sa contina spatii";break;
			}
		}
		
	}
	
	if(!document.getElementById('ctel').value) {
		ok=0;
		error=error+"<br>Campul Telefon nu a fost completat";
	}
	else{
		x=document.getElementById('ctel').value;
		for (i=0;i<x.length;i++) {
			if (x.charAt(i) == ' ') {
				ok = 0;
				error=error+"<br>Campul Telefon nu trebuie sa contina spatii";break;
			}
		}
		
	}
	if(!document.getElementById('email').value) {
		ok=0;
		error=error+"<br>Campul Email nu a fost completat";
	}
	else{
		var x =	document.getElementById('email').value;
		var at="@";
		var dot=".";
		var lat=x.indexOf(at);
		var lstr=x.length;
		var ldot=x.indexOf(dot);
		ok2=1;
		
		for (i=0;i<x.length;i++) {
			if (x.charAt(i) == ' ')
				ok2 = 0;
		}
		if (!ok2)
		{
			
			ok=0;
			error=error+"<br>Campul email nu trebuie sa contina spatii";
		}
		if (x.indexOf(at) ==- 1)
		{
			ok2=0;
		}
	
	    if (x.indexOf(at) == -1 || x.indexOf(at) == 0 || x.indexOf(at) == lstr)
		{
			ok2=0;
		}
	
		if (x.indexOf(dot) == -1 || x.indexOf(dot) == 0 || x.indexOf(dot) == lstr)
		{
			ok2=0;
		}
		if (x.indexOf(at,(lat+1)) != -1 )
		{
			ok2=0;
		}
		if (x.substring(lat-1,lat) == dot || x.substring(lat+1,lat+2) == dot)
		{
			ok2=0;
		}
	
		if (x.indexOf(dot,(lat+2)) == -1)
		{
			ok2=0;
		}
			
		if (x.indexOf(" ") != -1)
		{
			ok2=0;
		}	
		if(ok2=="0") {
		error=error+"<br>Campul email nu contine o adresa de email valida";
		
		}
		
	}
	if(ok==0) {
		document.getElementById('erroare').innerHTML=error;
		return false;
	}
	
	return true;
}
function mbm_verifica_nume() {
//	alert("intra");
	if(document.getElementById('nume_cabinet').value) {
		var nume = 	document.getElementById('nume_cabinet').value;
		nume = nume.toLowerCase();
		for(i=0;i<nume.length;i++) {
			var tst = parseInt(nume.charCodeAt(i));
			if(tst !=32) {
				if(tst<97 || tst>122){
					if(tst<48 || tst>57) {
						ok=0;
			
						alert("FOLOITI DOAR A-Z,a-z,0-9, si ' ' pentru numele cabinetului sau lasati campul liber daca nu doriti sa fie modificat");
						return false;
					}
				}
			}
		}
	}
	return true;
}
function mbm_verifica() {
	var ok =1;
	var error="";

	if(!document.getElementById('nume').value) {
		ok=0;
		error=error+"<br>Campul nume nu a fost completat";
	}
	else {
		var nume = 	document.getElementById('nume').value;
		nume = nume.toLowerCase();
		for(i=0;i<nume.length;i++) {
			var tst = parseInt(nume.charCodeAt(i));
			if(tst !=32) {
				if(tst<97 || tst>122){
					if(tst<48 || tst>57) {
						ok=0;
			
						error=error+"FOLOITI DOAR A-Z,a-z,0-9, si ' '";
						break;
					}
				}
			}
		}
	}
	if(!document.getElementById('telefon').value) {
		ok=0;
		error=error+"<br>Campul telefon nu a fost completat";
	}
	if(!document.getElementById('adresa').value) {
		ok=0;
		error=error+"<br>Campul adresa nu a fost completat";
	}
	if(!document.getElementById('email').value) {
		
		ok=0;
		error=error+"<br>Campul email nu a fost completat";
	}
	else {
		
		var x =	document.getElementById('email').value;
		var at="@";
		var dot=".";
		var lat=x.indexOf(at);
		var lstr=x.length;
		var ldot=x.indexOf(dot);
		ok2=1;
		
		for (i=0;i<x.length;i++) {
			if (x.charAt(i) == ' ')
				ok2 = 0;
		}
		if (!ok2)
		{
			
			ok=0;
			error=error+"<br>Campul email nu trebuie sa contina spatii";
		}
		if (x.indexOf(at) ==- 1)
		{
			ok2=0;
		}
	
	    if (x.indexOf(at) == -1 || x.indexOf(at) == 0 || x.indexOf(at) == lstr)
		{
			ok2=0;
		}
	
		if (x.indexOf(dot) == -1 || x.indexOf(dot) == 0 || x.indexOf(dot) == lstr)
		{
			ok2=0;
		}
		if (x.indexOf(at,(lat+1)) != -1 )
		{
			ok2=0;
		}
		if (x.substring(lat-1,lat) == dot || x.substring(lat+1,lat+2) == dot)
		{
			ok2=0;
		}
	
		if (x.indexOf(dot,(lat+2)) == -1)
		{
			ok2=0;
		}
			
		if (x.indexOf(" ") != -1)
		{
			ok2=0;
		}	
		if(ok=="0") {
		error=error+"<br>Campul email nu contine o adresa de email valida";
		
		}
	}
	if(ok=="0") {	
		document.getElementById('error').innerHTML = error;
		return false;
	}
	return true;
}
function validate_registration()
{
		y = document.getElementById("eroare").style;
		y.visibility = "hidden";
		y = document.getElementById("p_nume").style;
		y.color = "black";
		y = document.getElementById("p_prenume").style;
		y.color = "black";
		y = document.getElementById("p_user").style;
		y.color = "black";
		y = document.getElementById("p_parola").style;
		y.color = "black";
		y = document.getElementById("p_repass").style;
		y.color = "black";
		
		y = document.getElementById("p_email").style;
		y.color = "black";
		
		
		var x = document.getElementById("nume").value;
		var error = 1;
		var nume_eroare = "";
		var error_1 = 0;
		var error_2 = 0;
		var error_3 = 0;
		if (!x)
		{
			y = document.getElementById("p_nume").style;
			y.color = "red";
			error = 0;
		}
		var x = document.getElementById("prenume").value;
		if (!x)
		{
			y = document.getElementById("p_prenume").style;
			y.color = "red";
			error = 0;
		}
		var x = document.getElementById("username").value;
		if (!x)
		{
			y = document.getElementById("p_user").style;
			y.color = "red";
			error = 0;
		}
		else 
		{
			if (x.length < 6 || x.length > 20 )
			{
				z = document.getElementById("p_user").style;
				z.color = "red";
				if (!error_2)
				{
					nume_eroare = nume_eroare + " Dimensiunea campurilor * trebuie sa fie cuprinsa intre 6 si 20 <br/>";
					error_2 = 1;
				}
				error = 0;  
			}
			ok=1;
			for (i=0;i<x.length;i++)
				if (x.charAt(i) == ' ')
					ok = 0;
			if (!ok)
			{
				y = document.getElementById("p_user").style;
				y.color = "red"; 
				if (!error_1)
				{
					nume_eroare = nume_eroare + " Campurile nu trebuie sa contina spatii<br/> ";
					error_1 = 1;
				}
				error = 0;
				
			}
		}
		var x = document.getElementById("pass").value;
		if (!x)
		{
			y = document.getElementById("p_parola").style;
			y.color = "red";
			error = 0;
		}
		if (x) 
		{
			if (x.length < 6 || x.length > 20)
			{
				z = document.getElementById("p_parola").style;
				z.color = "red";
				if (!error_2)
				{
					nume_eroare = nume_eroare + " Dimensiunea campurilor * trebuie sa fie cuprinsa intre 6 si 20<br/> ";
					error_2 = 1;
				}
				error = 0;
			}
		
			else 
			{
				var z = document.getElementById("re_pass").value;
				if (!z)
				{
					y = document.getElementById("p_repass").style;
					y.color = "red";
					error = 0;
				}
				else if (x != z)
				{
						
						z = document.getElementById("p_parola").style;
						z.color = "red";
						y = document.getElementById("p_repass").style;
						y.color = "red";
						if (!error_3)
						{
							nume_eroare = "Campurile Parola si Reintroduceti parola trebuie sa coincida <br/>" ;
							error_3 = 1;
						}
						error = 0;
				}
			}
		}
		
		var x = document.getElementById("email").value;
		if (!x)
		{
				y = document.getElementById("p_email").style;
				y.color = "red";
				error = 0; 
		}
		else 
		{
			var at="@";
			var dot=".";
			var lat=x.indexOf(at);
			var lstr=x.length;
			var ldot=x.indexOf(dot);
			ok=1;
			for (i=0;i<x.length;i++)
				if (x.charAt(i) == ' ')
					ok = 0;
			if (!ok)
			{
				
				y = document.getElementById("p_email").style;
				y.color = "red"; 
				nume_eroare = nume_eroare + " Campurile nu trebuie sa contina spatii <br/>";
				error_1 = 1;
				error = 0;
			}
			if (x.indexOf(at) ==- 1)
			{
				y = document.getElementById("p_email").style;
				y.color = "red";
				error = 0; 
			}
	
			if (x.indexOf(at) == -1 || x.indexOf(at) == 0 || x.indexOf(at) == lstr)
			{
				y = document.getElementById("p_email").style;
				y.color = "red";
				error = 0; 
			}
	
			if (x.indexOf(dot) == -1 || x.indexOf(dot) == 0 || x.indexOf(dot) == lstr)
			{
				y = document.getElementById("p_email").style;
				y.color = "red";
				error = 0; 
			}
	
			if (x.indexOf(at,(lat+1)) != -1 )
			{
				y = document.getElementById("p_email").style;
				y.color = "red";
				error = 0; 
			}
	
			if (x.substring(lat-1,lat) == dot || x.substring(lat+1,lat+2) == dot)
			{
				y = document.getElementById("p_email").style;
				y.color = "red";
				error = 0; 
			}
	
			if (x.indexOf(dot,(lat+2)) == -1)
			{
				y = document.getElementById("p_email").style;
				y.color = "red";
				error = 0; 
			}
			
			if (x.indexOf(" ") != -1)
			{
				y = document.getElementById("p_email").style;
				y.color = "red";
				error = 0; 
			}		
		}
		
	if (!error)
	{
			
		p = "<p style='color:red;' >"+nume_eroare+"</p>";
		document.getElementById("eroare").innerHTML = p;
		y = document.getElementById("eroare").style;
		y.visibility = "visible";
		 return false;
	}
	return true;
}