String.prototype.trim = function() 
{
	return this.replace(/^\s*|\s(?=\s)|\s*$/g, ""); 
};


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function keyRestrict(e, validchars) {
 var key='', keychar='';
 key = getKeyCode(e);
 if (key == null) return true;
 keychar = String.fromCharCode(key);
 keychar = keychar.toLowerCase();
 validchars = validchars.toLowerCase();
 if (validchars.indexOf(keychar) != -1)
  return true;
 if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
  return true;
 return false;
}

function getKeyCode(e)
{
 if (window.event)
    return window.event.keyCode;
 else if (e)
    return e.which;
 else
    return null;
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=550,left = 340,top = 387');");
}

function popUp_ajutor_marime(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=500,left = 340,top = 387');");
}

function validareCNP(s)
{
	var suma=0;
	if(s.length==13)
	{
		suma=parseInt(s.charAt(0))*2+parseInt(s.charAt(1))*7+parseInt(s.charAt(2))*9+parseInt(s.charAt(3))*1+parseInt(s.charAt(4))*4+parseInt(s.charAt(5))*6+parseInt(s.charAt(6))*3+parseInt(s.charAt(7))*5+parseInt(s.charAt(8))*8+parseInt(s.charAt(9))*2+parseInt(s.charAt(10))*7+parseInt(s.charAt(11))*9;
		suma=suma%11;
		if(suma==10)
		suma=1;
		if(suma==parseInt(s.charAt(12)))
		{ 
			return true;
		}
		else
		{
			return false;
		}

	}
	else
	{
		return false;
	}
}

function trim(str) 
{
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function validare_email(mail)
{
	var x = mail;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else return false;
}

function verificare_formular_cont_existent() {

	var nume	= document.getElementById('log_username').value;
	var parola	= document.getElementById('log_password').value;

	nume		= trim(nume);

	var mesaj		= "";
	var numar_erori = 0;

	//citesc limba
	var limba	= document.getElementById('language_code').value;

	var nume_log_tx		= 0;
	var parola_log_tx	= 0;

	//verificare formular
	//camp Nume utilizator (e-mail)
	if(nume.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Nume utilizator este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Name user field is empty! \n";
		}
		numar_erori += 1;
		nume_log_tx = 1;
	}
	if(validare_email(nume) == false)
	{
		if(limba == 'ro')
		{
			mesaj += "Adresa de email din campul Nume utilizator este incorecta! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The E-mail address is incorrect! \n";
		}
		numar_erori += 1;
		nume_log_tx = 1;
	}
	//campul Parola
	if(parola.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Parola este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Password field is empty! \n";
		}
		numar_erori += 1;
		parola_log_tx = 1;
	}
	if(parola.length < 6)
	{
		if(limba == 'ro')
		{
			mesaj += "Parola trebuie sa fie de minim 6 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The password must contain at least 6 characters! \n";
		}
		numar_erori += 1;
		parola_log_tx = 1;
	}


	if(numar_erori != 0)
	{
		document.getElementById('nume_log_tx').style.color			= '#663083';
		document.getElementById('parola_log_tx').style.color		= '#663083';

		document.getElementById('nume_log_tx').style.fontWeight		= 'normal';
		document.getElementById('parola_log_tx').style.fontWeight	= 'normal';

		if(nume_log_tx == 1)
		{
			document.getElementById('nume_log_tx').style.color			= '#FF0000';
			document.getElementById('nume_log_tx').style.fontWeight		= 'bold';
		}
		
		if(parola_log_tx == 1)
		{
			document.getElementById('parola_log_tx').style.color		= '#FF0000';
			document.getElementById('parola_log_tx').style.fontWeight	= 'bold';
		}
		
		alert(mesaj);

		return false;
	}
	else
	{
		document.frm_login.submit();

		return true;
	}

}

function verificare_formular_cont_nou() {
	var nume 		= document.getElementById('nume').value;
	var prenume 	= document.getElementById('prenume').value;
	var mail 		= document.getElementById('mail').value;
	var parola 		= document.getElementById('parola').value;
	var parola2     = document.getElementById('parola2').value;
	var sex 		= document.getElementById('select').value;
	var telefon 	= document.getElementById('telefon').value;
	var adresa 		= document.getElementById('adresa').value;
	var oras 		= document.getElementById('oras').value;
	var judet 		= document.getElementById('judet').value;
	var zip 		= document.getElementById('zip').value;
	var tara 		= document.getElementById('tara').value;
	var cnp			= document.getElementById('cnp').value;
	var firma 		= document.getElementById('firma').value;
	var cif 		= document.getElementById('cif').value;
	var banca 		= document.getElementById('banca').value;
	var iban 		= document.getElementById('iban').value;
	var reg 		= document.getElementById('reg').value;
	var f_adresa 	= document.getElementById('f_adresa').value;
	var f_oras 		= document.getElementById('f_oras').value;
	var f_judet 	= document.getElementById('f_judet').value;
	var f_zip 		= document.getElementById('f_zip').value;
	var f_tara 		= document.getElementById('f_tara').value;
	
	var stare 	= document.getElementById('stare').value;
	var limba 	= document.getElementById('language_code').value;
	
	nume 		= trim(nume);
	prenume 	= trim(prenume);
	mail 		= trim(mail);
	telefon 	= trim(telefon);
	adresa 		= trim(adresa);
	oras 		= trim(oras);
	judet 		= trim(judet);
	zip 		= trim(zip);
	tara 		= trim(tara);
	cnp			= trim(cnp);
	firma 		= trim(firma);
	cif 		= trim(cif);
	banca 		= trim(banca);
	iban 		= trim(iban);
	reg 		= trim(reg);
	f_adresa 	= trim(f_adresa);
	f_oras 		= trim(f_oras);
	f_judet 	= trim(f_judet);
	f_zip 		= trim(f_zip);
	f_tara 		= trim(f_tara);
	
	var mesaj 		= "";
	var numar_erori = 0;
	
	//definesc variabile pentru numele campurilor verificate
	//dau valoarea 0 la inceput, le afisez avand culoarea mov normal
	var nume_tx 		= 0;
	var prenume_tx 		= 0;
	var email_tx 		= 0;
	var parola_tx 		= 0;
	var parola2_tx		= 0;
	var sex_tx 			= 0;
	var telefon_tx 		= 0;
	var adresa_tx 		= 0;
	var oras_tx 		= 0;
	var judet_tx 		= 0;
	var zip_tx 			= 0;
	var tara_tx 		= 0;
	var cnp_tx			= 0;
	var firma_tx 		= 0;
	var cif_tx 			= 0;
	var banca_tx 		= 0;
	var iban_tx 		= 0;
	var reg_tx 			= 0;
	var f_adresa_tx 	= 0;
	var f_oras_tx 		= 0;
	var f_judet_tx 		= 0;
	var f_zip_tx 		= 0;
	var f_tara_tx 		= 0;
	
	
	//alert(parola.replace(/^\s*(.*?)\s*$/,"$1"))
	
	//verific formularul cont nou
	//campul Nume
	if(nume.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Nume este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Name field is empty! \n";	
		}
		numar_erori += 1;
		nume_tx = 1;
	}
	if(nume.length < 3)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Nume trebuie sa contina minim 3 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Name field must contain at least 3 characters! \n";	
		}
		numar_erori += 1;
		nume_tx = 1;
	}
	//campul Prenume
	if(prenume.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Prenume este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Surname field is empty! \n";	
		}
		numar_erori += 1;
		prenume_tx = 1;
	}
	if(prenume.length < 3)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Prenume trebuie sa contina minim 3 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Surname field must contain at least 3 characters! \n";	
		}
		numar_erori += 1;
		prenume_tx = 1;
	}
	//campul Mail
	if(mail.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Email este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Email field is empty! \n";	
		}
		numar_erori += 1;
		email_tx = 1;
	}
	if(validare_email(mail) == false)
	{
		if(limba == 'ro')
		{
			mesaj += "Adresa de Email este incorecta! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Email address is not correct! \n";	
		}
		numar_erori += 1;
		email_tx = 1;
	}
	var mail_valid = document.getElementById('mail_valid').value;
	if(mail_valid == 'false')
	{
		if(limba == 'ro')
		{
			mesaj += "Adresa de Email exista deja in baza de date! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Email Address is already in database! \n";
		}
		numar_erori += 1;
		email_tx = 1;
	}
	//campul Parola
	if(parola.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Parola este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Password field is empty! \n";
		}
		numar_erori += 1;
		parola_tx = 1;
	}
	if(parola.length < 6)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Parola trebuie sa contina minim 6 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Password field must contain at least 6 characters! \n";	
		}
		numar_erori += 1;
		parola_tx = 1;
	}
	//campul Parola2
	if(parola2.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Parola2 este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Password2 field is empty! \n";
		}
		numar_erori += 1;
		parola2_tx = 1;
	}
	if(parola2.length < 6)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Parola2 trebuie sa contina minim 6 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Password2 field must contain at least 6 characters! \n";	
		}
		numar_erori += 1;
		parola2_tx = 1;
	}
	//campurile Parola si Parola2 sa fie identice
	if(parola != parola2)
	{
		if(limba == 'ro')
		{
			mesaj += "Cele 2 parole nu sunt identice! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The 2 passwords are not the same! \n";
		}
		numar_erori += 1;
		parola_tx = 1;
		parola2_tx = 1;
	}
	//campul Telefon
	if(telefon.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Telefon este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Telephone field is empty! \n";	
		}
		numar_erori += 1;
		telefon_tx = 1;
	}
	if(telefon.length < 10 || isNaN(telefon))
	{
		if(limba == 'ro')
		{
			mesaj += "Verificati daca campul Telefon contine numere si sunt cel putin 10! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "Verify if Telephone field contain only numbers and there are at least 10 numbers! \n";	
		}
		numar_erori += 1;
		telefon_tx = 1;
	}
	//campul Adresa
	if(adresa.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Adresa este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Address field is empty! \n";	
		}
		numar_erori += 1;
		adresa_tx = 1;
	}
	if(adresa.length < 7)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Adresa trebuie sa contina minim 7 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Address field must contain at least 7 characters! \n";	
		}
		numar_erori += 1;
		adresa_tx = 1;
	}
	//campul Oras
	if(oras.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Oras este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Town field is empty! \n";	
		}
		numar_erori += 1;
		oras_tx = 1;
	}
	if(oras.length < 3)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Oras trebuie sa contina minim 3 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Town field must contain at least 3 characters! \n";	
		}
		numar_erori += 1;
		oras_tx = 1;
	}
	//campul Judet
	if(judet.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Judet este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Departament field is empty! \n";	
		}
		numar_erori +=1;
		judet_tx = 1;
	}
	if(judet.length < 3)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Judet trebuie sa contina minim 3 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Departament field must contain at least 3 characters! \n";	
		}
		numar_erori +=1;
		judet_tx = 1;
	}
	//campul Zip
	if(zip.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Zip este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Zip field is empty! \n";	
		}
		numar_erori += 1;
		zip_tx = 1;
	}
	if(zip.length < 3)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Zip trebuie sa contina cel putin 3 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Zip field must contain at least 3 characters! \n";	
		}
		numar_erori += 1;
		zip_tx = 1;
	}
	//campul Tara
	if(tara.length == 0)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Tara este necompletat! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Country field is empty! \n";	
		}
		numar_erori += 1;
		tara_tx = 1;
	}
	if(tara.length < 3)
	{
		if(limba == 'ro')
		{
			mesaj += "Campul Tara trebuie sa contina minim 3 caractere! \n";
		}
		else if(limba == 'en')
		{
			mesaj += "The Country field must contain at least 3 characters! \n";	
		}
		numar_erori += 1;
		tara_tx = 1;
	}

	//campul CNP
	if(validareCNP(cnp)==false) 
	{
		if(limba == 'ro')
		{
			mesaj += "CNP-ul este invalid! \n";
		}
		else
		{
			mesaj += "The CNP field is incorrect! \n";
		}
		numar_erori += 1;
		cnp_tx = 1;
	}
		
	
	if(stare == 1)
	{
		
		//campul Firma
		if(firma.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Firma este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Firm field is empty! \n";	
			}
			numar_erori += 1;
			firma_tx = 1;
		}
		if(firma.length < 3)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Firma trebuie sa contina minim 3 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Firm field must contain at least 3 characters! \n";	
			}
			numar_erori += 1;
			firma_tx = 1;
		}
		//campul Cif
		if(cif.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Cif este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Cif field is empty! \n";	
			}
			numar_erori += 1;
			cif_tx = 1;
		}
		if(cif.length < 3)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Cif trebuie sa contina minim 3 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Cif field must contain at least 3 characters! \n";	
			}
			numar_erori += 1;
			cif_tx = 1;
		}
		//campul Banca
		if(banca.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Banca este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Bank field is empty! \n";	
			}
			numar_erori += 1;
			banca_tx = 1;
		}
		if(banca.length < 3)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Banca trebuie sa contina minim 3 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Bank field must contain at least 3 characters! \n";	
			}
			numar_erori += 1;
			banca_tx = 1;
		}
		//campul Iban
		if(iban.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Iban este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Iban field is empty! \n";	
			}
			numar_erori += 1;
			iban_tx = 1;
		}
		if(iban.length != 24)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Iban trebuie sa contina 24 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Iban field must contain only 24 characters! \n";	
			}
			numar_erori += 1;
			iban_tx = 1;
		}
		//campul Reg Com
		if(reg.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Reg Com este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Reg Com field is empty! \n";	
			}
			numar_erori += 1;
			reg_tx = 1;
		}
		if(reg.length < 3)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Reg Com trebuie sa contina minim 3 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Reg Com field must contain at least 3 characters! \n";	
			}
			numar_erori += 1;
			reg_tx = 1;
		}
		//campul F_adresa
		if(f_adresa.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Adresa este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Address field is empty! \n";	
			}
			numar_erori += 1;
			f_adresa_tx = 1;
		}
		if(f_adresa.length < 3)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Adresa trebuie sa contina minim 3 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Address field must contain at least 3 characters! \n";	
			}
			numar_erori += 1;
			f_adresa_tx = 1;
		}
		//campul F_oras
		if(f_oras.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Oras este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Town field is empty! \n";	
			}
			numar_erori += 1;
			f_oras_tx = 1;
		}
		if(f_oras.length < 3)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Oras trebuie sa contina minim 3 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Town field must contain at least 3 characters! \n";	
			}
			numar_erori += 1;
			f_oras_tx = 1;
		}
		//campul F_judet
		if(f_judet.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Judet este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Departament field is empty! \n";	
			}
			numar_erori += 1;
			f_judet_tx = 1;
		}
		if(f_judet.length < 3)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Judet trebuie sa contina minim 3 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Departament field must contain at least 3 characters! \n";	
			}
			numar_erori += 1;
			f_judet_tx = 1;
		}
		//campul F_zip
		if(f_zip.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Zip este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Zip field is empty! \n";	
			}
			numar_erori += 1;
			f_zip_tx = 1;
		}
		if(f_zip.length < 3)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Zip trebuie sa contina 6 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Zip field must contain 6 characters! \n";	
			}
			numar_erori += 1;
			f_zip_tx = 1;
		}
		//campul F_tara
		if(f_tara.length == 0)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Tara este necompletat! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Country field is empty! \n";	
			}
			numar_erori += 1;
			f_tara_tx = 1;
		}
		if(f_tara.length < 3)
		{
			if(limba == 'ro')
			{
				mesaj += "Campul Tara trebuie sa contina minim 3 caractere! \n";
			}
			else if(limba == 'en')
			{
				mesaj += "The Country field must contain at least 3 characters! \n"	
			}
			numar_erori += 1;
			f_tara_tx = 1;
		}
	}


	
	//Daca am erori nu trimit formul, daca nu am erori trimit formul
	if(numar_erori != 0)
	{
		
		
		
		//afisez toate campurile cu mov normal
		document.getElementById('nume_tx').style.color 			= '#663083';
		document.getElementById('prenume_tx').style.color 		= '#663083';
		document.getElementById('email_tx').style.color 		= '#663083';
		document.getElementById('parola_tx').style.color 		= '#663083';
		document.getElementById('parola2_tx').style.color 		= '#663083';
		document.getElementById('sex_tx').style.color 			= '#663083';
		document.getElementById('telefon_tx').style.color 		= '#663083';
		document.getElementById('adresa_tx').style.color 		= '#663083';
		document.getElementById('oras_tx').style.color 			= '#663083';
		document.getElementById('judet_tx').style.color 		= '#663083';
		document.getElementById('zip_tx').style.color 			= '#663083';
		document.getElementById('tara_tx').style.color 			= '#663083';
		document.getElementById('cnp_tx').style.color			= '#663083';
		if(stare == 1)
		{
			document.getElementById('firma_tx').style.color 		= '#663083';
			document.getElementById('cif_tx').style.color 			= '#663083';
			document.getElementById('banca_tx').style.color 		= '#663083';
			document.getElementById('iban_tx').style.color 			= '#663083';
			document.getElementById('reg_tx').style.color 			= '#663083';
			document.getElementById('f_adresa_tx').style.color 		= '#663083';
			document.getElementById('f_judet_tx').style.color 		= '#663083';
			document.getElementById('f_zip_tx').style.color 		= '#663083';
			document.getElementById('f_tara_tx').style.color 		= '#663083';
			document.getElementById('f_oras_tx').style.color 		= '#663083';
		}
		
		document.getElementById('nume_tx').style.fontWeight 	= 'normal';
		document.getElementById('prenume_tx').style.fontWeight 	= 'normal';
		document.getElementById('email_tx').style.fontWeight 	= 'normal';
		document.getElementById('parola_tx').style.fontWeight 	= 'normal';
		document.getElementById('parola2_tx').style.fontWeight 	= 'normal';
		document.getElementById('sex_tx').style.fontWeight 		= 'normal';
		document.getElementById('telefon_tx').style.fontWeight 	= 'normal';
		document.getElementById('adresa_tx').style.fontWeight 	= 'normal';
		document.getElementById('oras_tx').style.fontWeight 	= 'normal';
		document.getElementById('judet_tx').style.fontWeight 	= 'normal';
		document.getElementById('zip_tx').style.fontWeight 		= 'normal';
		document.getElementById('tara_tx').style.fontWeight 	= 'normal';
		document.getElementById('cnp_tx').style.fontWeight		= 'normal';
		if(stare == 1)
		{
			document.getElementById('firma_tx').style.fontWeight 	= 'normal';
			document.getElementById('cif_tx').style.fontWeight 		= 'normal';
			document.getElementById('banca_tx').style.fontWeight 	= 'normal';
			document.getElementById('iban_tx').style.fontWeight 	= 'normal';
			document.getElementById('reg_tx').style.fontWeight 		= 'normal';
			document.getElementById('f_adresa_tx').style.fontWeight = 'normal';
			document.getElementById('f_judet_tx').style.fontWeight 	= 'normal';
			document.getElementById('f_zip_tx').style.fontWeight 	= 'normal';
			document.getElementById('f_tara_tx').style.fontWeight 	= 'normal';
			document.getElementById('f_oras_tx').style.fontWeight	= 'normal';
		}
		
		//afisez cu rosu bold campurile care au avut erori
		if(nume_tx == 1)
		{
			document.getElementById('nume_tx').style.color 			= '#FF0000';
			document.getElementById('nume_tx').style.fontWeight 	= 'bold'
		}
		if(prenume_tx == 1)
		{
			document.getElementById('prenume_tx').style.color 		= '#FF0000';
			document.getElementById('prenume_tx').style.fontWeight 	= 'bold';
		}
		if(email_tx == 1)
		{
			document.getElementById('email_tx').style.color 		= '#FF0000';
			document.getElementById('email_tx').style.fontWeight 	= 'bold';
		}
		if(parola_tx == 1)
		{
			document.getElementById('parola_tx').style.color 		= '#FF0000';
			document.getElementById('parola_tx').style.fontWeight 	= 'bold';
		}
		if(parola2_tx == 1)
		{
			document.getElementById('parola2_tx').style.color 		= '#FF0000';
			document.getElementById('parola2_tx').style.fontWeight 	= 'bold';
		}
		if(telefon_tx == 1)
		{
			document.getElementById('telefon_tx').style.color 		= '#FF0000';
			document.getElementById('telefon_tx').style.fontWeight 	= 'bold';
		}
		if(adresa_tx == 1)
		{
			document.getElementById('adresa_tx').style.color 		= '#FF0000';
			document.getElementById('adresa_tx').style.fontWeight 	= 'bold';
		}
		if(oras_tx == 1)
		{
			document.getElementById('oras_tx').style.color 			= '#FF0000';
			document.getElementById('oras_tx').style.fontWeight 	= 'bold';
		}
		if(judet_tx == 1)
		{
			document.getElementById('judet_tx').style.color 		= '#FF0000';
			document.getElementById('judet_tx').style.fontWeight 	= 'bold';
		}
		if(zip_tx == 1)
		{
			document.getElementById('zip_tx').style.color 			= '#FF0000';
			document.getElementById('zip_tx').style.fontWeight 		= 'bold';
		}
		if(tara_tx == 1)
		{
			document.getElementById('tara_tx').style.color 			= '#FF0000';
			document.getElementById('tara_tx').style.fontWeight 	= 'bold';
		}
		if(cnp_tx == 1)
		{
			document.getElementById('cnp_tx').style.color			= '#FF0000';
			document.getElementById('cnp_tx').style.fontWeight		= 'bold';
		}
		
		if(stare == 1)
		{
			if(firma_tx == 1)
			{
				document.getElementById('firma_tx').style.color 			= '#FF0000';
				document.getElementById('firma_tx').style.fontWeight 		= 'bold';
			}
			if(cif_tx == 1)
			{
				document.getElementById('cif_tx').style.color 				= '#FF0000';
				document.getElementById('cif_tx').style.fontWeight 			= 'bold';
			}
			if(banca_tx == 1)
			{
				document.getElementById('banca_tx').style.color 			= '#FF0000';
				document.getElementById('banca_tx').style.fontWeight 		= 'bold';
			}
			if(iban_tx == 1)
			{
				document.getElementById('iban_tx').style.color 				= '#FF0000';
				document.getElementById('iban_tx').style.fontWeight 		= 'bold';
			}
			if(reg_tx == 1)
			{
				document.getElementById('reg_tx').style.color 				= '#FF0000';
				document.getElementById('reg_tx').style.fontWeight 			= 'bold';
			}
			if(f_adresa_tx == 1)
			{
				document.getElementById('f_adresa_tx').style.color 			= '#FF0000';
				document.getElementById('f_adresa_tx').style.fontWeight 	= 'bold';
			}
			if(f_oras_tx == 1)
			{
				document.getElementById('f_oras_tx').style.color 			= '#FF0000';
				document.getElementById('f_oras_tx').style.fontWeight 		= 'bold';
			}
			if(f_judet_tx == 1)
			{
				document.getElementById('f_judet_tx').style.color 			= '#FF0000';
				document.getElementById('f_judet_tx').style.fontWeight 		= 'bold';
			}
			if(f_zip_tx == 1)
			{
				document.getElementById('f_zip_tx').style.color 			= '#FF0000';
				document.getElementById('f_zip_tx').style.fontWeight 		= 'bold';
			}
			if(f_tara_tx == 1)
			{
				document.getElementById('f_tara_tx').style.color 			= '#FF0000';
				document.getElementById('f_tara_tx').style.fontWeight 		= 'bold';
			}
		}

		if(numar_erori > 6)
		{
			alert('Va rugam completati toate campurile!');
		}
		else
		{
			alert(mesaj);
		}
		//alert("Numar erori :"+numar_erori+" \n\n"+mesaj);
		
		return false;
	}
	else
	{
		document.frm.submit();	

		return true;
	}
	
	
}

function show_comments()
{
	document.getElementById("comments").style.display = "block";
}

function cmt_peste_3() 
{
	document.getElementById("cmtpeste3").style.display = "block";
	document.getElementById("btn_mmc").style.display = "none";
}

function verifica_form_comment()
{
	if(document.getElementById("cmt_titlu").value!='' && document.getElementById("cmt_text").value!='') 
		{ document.frm_comment.submit(); }
	else
		{ document.getElementById("msg_err_comment").style.display = "block"; }
}

function afisez_comentarii() 
{
	var id_com_hidd = document.getElementById('id_com_hidd').value;
	var tabl_com_hidd = new Array();
	var id_com;
	tabl_com_hidd = id_com_hidd.split(',');

	for(var i=0; i<tabl_com_hidd.length; i++)
	{
		id_com = 'id_com_'+tabl_com_hidd[i];
		document.getElementById(id_com).style.display = 'block';
	}
	document.getElementById('btn_mmc').style.display = 'none';
}

function valideaza_sumar()
{
	if(document.getElementById('acord').checked) 
	{
		document.getElementById('loader').style.display="block";
	    document.getElementById('btn_submit').style.display="none"; 
		window.location='/procesare_comanda/';
	}
	else
	{	
		var lc = document.getElementById('lc').value;
		if (lc=='ro')
		{
			alert('Va rugam sa bifati acordul dvs. pentru politica de confidentialitate');
		}
		else
		{
			alert('Please check if you agree with the confidentiality policy');
		}
	}
}

function inchide_flash()
{
	if(document.getElementById('flashintro'))
	{
		document.getElementById('flashintro').style.display = 'none';
	}
	
}

function white_space(field)
{
     document.getElementById(field).value = (field.value).replace(/^\s*|\s*$/g,'');
}

function verificare_cart()
{
	
}

function valideaza_adresa_mail()
{
	AARead(document.getElementById('srvurl').innerHTML + "/pages/js/verificare_mail.php?mail="+document.getElementById('mail').value, proceseaza_mail, "mail_valid");
}

function proceseaza_mail(data, element)
{
	document.getElementById('mail_valid').value = data;
}

function cauta()
{
	var textfield 	= document.getElementById('textfield').value; 
	var limba 		= document.getElementById('limba').value;
	var srvurl      = document.getElementById('srvurl').innerHTML;
	var textfield	= document.getElementById('textfield').value;

	var cale_redir	= srvurl+'rezultate_cautare/'+textfield+'/';
	
	if(textfield.length < 3) 
	{ 
		if(limba == 'ro') 
		{ 
			alert('Introduceti cel putin 3 caractere in campul de cautare!'); 
		} 
		else if(limba == 'en') 
		{ 
			alert('The Search field must contain at least 3 characters!'); 
		} 
		
		return false;
	} 
	else 
	{ 
		document.getElementById('txt_search').action = cale_redir;
		
		document.txt_search.submit(); 
		
		return true;
	}
}

function sector(a)
{
	if ((a=='1') || (a=='2') || (a=='3') || (a=='4') || (a=='5') || (a=='6'))
	{
		return "sector "+a;
	}
	else
	{
		return a;
	}
}



function valideaza_comanda_fara_cont()
{
	var erori = new Array();
	if (document.getElementById('nume').value.length<6) erori.push(document.getElementById('err_nume').value);
	if (!validare_email(document.getElementById('email').value)) erori.push(document.getElementById('err_mail').value);
	if (document.getElementById('telefon').value.length<10) erori.push(document.getElementById('err_tel').value); 
	if (document.getElementById('adresa').value.length<12) erori.push(document.getElementById('err_adr').value);
	if (!validareCNP(document.getElementById('cnp').value)) erori.push(document.getElementById('err_cnp').value);
	if (!document.getElementById('acord').checked) erori.push(document.getElementById('err_bifa').value); 
	
	if (erori.length>0) alert(erori.join('\n'));
	else document.frm.submit();

}