
function validateEmail(email) {
	var matches = email.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
	return (matches != null && email == matches[0]);
}
function strTrim(str){
  str=str.replace(/(^\s*)|(\s*$)/g, "");
  if (str.length==0){
    return false;
  }
  return true;
} 
 
function checkForm(){
  if(!strTrim(document.all['FromName'].value) || !validateEmail(document.all['email'].value) ||  !validateEmail(document.all['to'].value)){
    alert(' *Please, fill in all mandatory fields and correct Email address');
    return false;
  }   
return true;
}
function CheckRightForm(formname)
{
	if (document.getElementById("first_name").value.length==0)
	{
			alert('Please Fill your name');
			document.getElementById("first_name").focus();		
			return false;
	}
	/*if (document.getElementById("email").value.length==0)
	{
			alert('Please Fill your email');
			document.getElementById("email").focus();		
			return false;
	}*/
	
	if (!validateEmail(document.getElementById("email").value))
	{
			alert('Incorrect Email');
			document.getElementById("email").focus();		
			return false;
	}
	if (document.getElementById("message").value.length==0)
	{
			alert('Please Fill your message');
			document.getElementById("message").focus();		
			return false;
	}
	return true;
}
function SendContactForm(formname)
{
	if (document.getElementById("RecipientName").value=="")
	{
			alert('חובה למלא את שם החבר');
			document.getElementById("RecipientName").focus();		
			return;
	}
	
	
	if (document.getElementById("to").value=="")
	{
			alert('חובה למלא את כתובת הדוא"ל של חברך');
			document.getElementById("to").focus();		
			return;
	}	
		else if((document.getElementById("to").value).match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)==null)	
		{
		alert('כתובת הדוא"ל של חברך אינה תקינה');
			document.getElementById("to").focus();		
			return;
		}
	if (document.getElementById("FromName").value=="")
	{
			alert('חובה למלא את שמך');
			document.getElementById("FromName").focus();		
			return;
	}
	if (document.getElementById("email").value=="")
	{
			alert('חובה למלא את כתובת הדוא"ל שלך');
			document.getElementById("email").focus();		
			return;
	}	
		else if((document.getElementById("email").value).match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)==null)	
		{
		alert('כתובת הדוא"ל אינה תקינה');
			document.getElementById("email").focus();		
			return;
		}	
	else
	{
		//alert(document.getElementById("Country").value);
		//alert ('xxx');
		eval("document.forms['"+formname+"'].submit()");
	}
}


function SendRegistrationForm(formname)
{
	
	 if (document.getElementById("FirstName").value=="")
	{
			alert('Please, fill in First Name');
			document.getElementById("FirstName").focus();		
			return;
	}
	else if (document.getElementById("LastName").value=="")
	{
			alert('Please, fill in Last Name');
			document.getElementById("LastName").focus();		
			return;
	}
	else if (document.getElementById("Institution").value=="")
	{
			alert('Please, fill in Institution');
			document.getElementById("Institution").focus();		
			return;
	}
	else if (document.getElementById("Phone").value=="")
	{
			alert('Please, fill in Phone');
			document.getElementById("Phone").focus();		
			return;
	}
	if (document.getElementById("EmailAddress").value=="")
	{
			alert('Please, fill in Email Address');
			document.getElementById("EmailAddress").focus();		
			return;
	}	
		else if((document.getElementById("EmailAddress").value).match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)==null)	
		{
		alert('Please fill in correct Email');
			document.getElementById("EmailAddress").focus();		
			return;
		}
	if (document.getElementById("Country").value=="choose")
	{
			alert('Please, choose a country');
			document.getElementById("Country").focus();		
			return;
	}
		
	else
	{
		//alert(document.getElementById("Country").value);
		//alert ('xxx');
		eval("document.forms['"+formname+"'].submit()");
	}
}
