fpper = new Array('fname','lname','email','address','town','zip','comments');
fpp = new Array('First name','Last name','Email','Address','Town','Zip code','Comments on the style');

function test(){
  jechyba= true;
	chyba = '';
	
  for (i=0; i<fpper.length; i++){
		if (document.getElementById(fpper[i]).value==''){
			chyba+=fpp[i] + " is required\n";
			jechyba= false;
			document.getElementById(fpper[i]).className='textram';
		}
		else
			document.getElementById(fpper[i]).className='text';
	}

	if (!document.getElementById("email").value==''){
		if (!jemail(document.getElementById("email").value)){
			document.getElementById("email").className='textram';
			chyba+="Entered email is not in the correct form\n";
			jechyba= false;
		}
			else
				document.getElementById("email").className='text';
	}
	if (!jechyba){
    eror(chyba);
    return false;
  }
}
function eror(chyba){
  alert(chyba+"\n\nPlease fill in the required forms!");
}
function jemail(value){
	mail=/^.+@.+\..{2,4}$/;
	return mail.test(value);
}

fpperro = new Array('f1','f3','f12','f13','f14','f15','f16','f17','f18');
fppro = new Array('Comentarii asupra stilului','Ce termeni','Numele','Prenumele','Adresa','Localitatea','Cod poştal','Judeţul','Email');

function testRO(){
  jechyba= true;
	chyba = '';

  for (i=0; i<fpperro.length; i++){
		if (document.getElementById(fpperro[i]).value==''){
			chyba+=fppro[i] + " este necesar\n";
			jechyba= false;
			document.getElementById(fpperro[i]).className='textram';
		}
		else
			document.getElementById(fpperro[i]).className='text';
	}

	if (!document.getElementById("f18").value==''){
		if (!jemail(document.getElementById("f18").value)){
			document.getElementById("f18").className='textram';
			chyba+="adresa email nu este în format corect\n";
			jechyba= false;
		}
			else
				document.getElementById("f18").className='text';
	}
	if (!jechyba){
    erorRO(chyba);
    return false;
  }
}
function erorRO(chyba){
  alert(chyba+"\n\nVă rugăm să completaţi formularul următor!");
}
