// Javascript validation functions
// http://www.designplace.org/


//function to check empty fields

function isEmpty(field) {

	strfield = field.value 
  //name field
	if (strfield == "" || strfield == null )
    {
	    if (js_lang == 'en')
	    	alert('"'+field.title+'" is a mandatory field.\nPlease amend and retry.')
	    else
	    	alert('Campul "'+field.title+'" este un camp obligatoriu.\nVa rugam completati-l');
	    return true;
    }

    return false;
}


//function to check valid email address
function isValidEmail(strEmail){
	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	strEmail = strEmail.value;

	// search email text for regular exp matches
	if (strEmail.search(validRegExp) == -1) 
	{
    	if (js_lang == 'en' )
   			alert('A valid e-mail address is required.\nPlease amend and retry');
   		else
   			alert('Este nevoie de o adresa de email corecta.\nCorectati si incercati din nou');
		return false;
    } 
    return true; 
}


// verifica ca elementele cu clasa "mandinput" sunt completate

function check_mandatory(form) {
var i;
for( i = 0; i < form.length; i++ ) {
	if(form[i].className == 'mandinput' && isEmpty(form[i]) )	{
		return false;
	}
}

if (!isValidEmail(form.email))
	return false;

return true;
}