function check(radio)
{
	option = -1;
	for(i = radio.length - 1; i > -1; i --)
	{
		if(radio[i].checked)
		{
			option = i;
			i = -1;
		}
	}
	if(option != -1) return true;
	else return false;
}

function trim(str)
{
	while(str.substring(0, 1) == " ") str = str.substring(1, str.length);
	while(str.substring(str.length - 1, str.length) == " ") str = str.substring(0, str.length - 1);
	return str;
}

function validare()
{
	var cssbun = '1px solid #666666';
	var cssrau = '1px solid #cc0000';
	// raspuns
	if(!check(document.form.raspuns))
	{
		alert('Selectati un raspuns!');
		return false;
	}
	// nume
	if(trim(document.form.nume.value) == '')
	{
		alert('Introduceti numele!');
		document.form.nume.focus();
		document.form.nume.style.border = cssrau;
		return false;
	}
	else document.form.nume.style.border = cssbun;
	// prenume
	if(trim(document.form.prenume.value) == '')
	{
		alert('Introduceti prenumele!');
		document.form.prenume.focus();
		document.form.prenume.style.border = cssrau;
		return false;
	}
	else document.form.prenume.style.border = cssbun;
	// email
	var email = trim(document.form.email.value);
	if(email != '' && email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
	{
		alert('E-mail-ul introdus nu este corect!');
		document.form.email.focus();
		document.form.email.style.border = cssrau;
		return false;
	}
	else if(email == '')
	{
		alert('Introduceti adresa de e-mail!');
		document.form.email.focus();
		document.form.email.style.border = cssrau;
		return false;
	}
	else document.form.email.style.border = cssbun;
}
