
//checks the valability of the code in image
function checkCode(){
	var code=document.getElementById('cod').value;
	var encrCode='';
	for(var i=0;i<code.length;i++){
		if(i)
			encrCode+='.';
		encrCode+=code.charCodeAt(i)
	}	
	if(document.getElementById('encrcode').value==encrCode)
		return true;
	alert('codul introdus nu este corect!');
	return false;
}

//checks that the contact message fields are filled
function checkContact(){
	var fields=new Array('cod','nume-contact','telefon-contact','email-contact');
	for(var i=0;i<fields.length;i++)
		if(document.getElementById(fields[i]).value==''){
			alert('Va rugam sa completati toate campurile formularului');
			return false;
		}
	return checkCode();		
}

function checkAppointaments(){
	var fields=new Array('cod','nume','telefon','email');
	for(var i=0;i<fields.length;i++)
		if(document.getElementById(fields[i]).value==''){
			alert('Va rugam sa completati toate campurile formularului');
			return false;
		}
	return checkCode();		
}

function checkCommand(){
	var fields=new Array('cod','nume','telefon','email','address','location','type','surface');
	for(var i=0;i<fields.length;i++)
		if((document.getElementById(fields[i]).value=='')){
			alert('Va rugam sa completati toate campurile formularului!');
			return false;
		}
		return checkCode();
}

function checkAccount(){
	var fields=new Array('account-username','account-password');
	for(var i=0;i<fields.length;i++)
		if((document.getElementById(fields[i]).value=='')){
			alert('Daca doriti sa va conectati la cotul ACCES PUBLIC, introduceti si la user si la password “public”.');
			return false;
		}
}


