
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 checkNextPatition(){
if(!strTrim(document.all['bank_name'].value)){
alert("יש למלא שם בנק");
return false;
}
if(document.all['salary'].value=="" || isNaN(document.all['salary'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['self_deposit'].value=="" || isNaN(document.all['self_deposit'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['deposit'].value=="" || isNaN(document.all['deposit'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['self_widrow'].value=="" || isNaN(document.all['self_widrow'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['widrow'].value=="" || isNaN(document.all['widrow'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['self_pay_var'].value=="" || isNaN(document.all['self_pay_var'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['pay_var'].value=="" || isNaN(document.all['pay_var'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['credit'].value=="" || isNaN(document.all['credit'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['auto'].value=="" || isNaN(document.all['auto'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['self_cross_transfer'].value=="" || isNaN(document.all['self_cross_transfer'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['cross_transfer'].value=="" || isNaN(document.all['cross_transfer'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['self_transfer_inline'].value=="" || isNaN(document.all['self_transfer_inline'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['transfer_inline'].value=="" || isNaN(document.all['transfer_inline'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}
if(document.all['self_other'].value=="" || isNaN(document.all['self_other'].value)){
alert("יש למלא ערך מספרי בשדה");
return false;
}


}
function checkPatition(){
//alert("");
 if(!strTrim(document.all['first_name'].value) || !strTrim(document.all['last_name'].value)){
    alert(' חובה למלא שם פרטי ושם משפחה');
    return false;
  }  
return true;
}


function SendComplaintForm(formname)
{
		if (document.getElementById("full_name").value=="")
	{
			alert('יש למלא שם מלא');
			document.getElementById("full_name").focus();		
			return;
	}
	
	else if (document.getElementById("address").value=="")
	{
			alert('יש למלא כתובת מלאה');
			document.getElementById("address").focus();		
			return;
	}
	else if (document.getElementById("phone").value=="")
	{
			alert('יש למלא מספר טלפון להתקשרות');
			document.getElementById("phone").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;
		}
	
	if (document.getElementById("business_name").value=="")
	{
			alert('יש למלא את שם העסק');
			document.getElementById("business_name").focus();		
			return;
	}
	else if (document.getElementById("business_address").value=="")
	{
			alert('יש למלא את כתובת בית העסק');
			document.getElementById("business_address").focus();		
			return;
	}		
	else if (document.getElementById("business_phone").value=="")
	{
			alert('יש למלא את מספר הטלפון של בית העסק');
			document.getElementById("business_phone").focus();		
			return;
	}		
	else if (document.getElementById("product_name").value=="")
	{
			alert('יש למלא את שם המוצר או השירות');
			document.getElementById("product_name").focus();		
			return;
	}	
	else if (document.getElementById("event_day_option1").value=="")
	{
			alert('יש למלא את תאריך יום הרכישה');
			document.getElementById("event_day_option1").focus();		
			return;
	}	
		else if (document.getElementById("event_month_option1").value=="")
	{
			alert('יש למלא את תאריך חודש הרכישה');
			document.getElementById("event_month_option1").focus();		
			return;
	}	
		else if (document.getElementById("event_year_option1").value=="")
	{
			alert('יש למלא את תאריך שנת הרכישה');
			document.getElementById("event_year_option1").focus();		
			return;
	}	
	if (document.getElementById("request_from_business").value=="")
	{
			alert('יש למלא את דרישתך מבית העסק');
			document.getElementById("request_from_business").focus();		
			return;
	}	

	
	return true
}


	

function SendRegistrationForm()
{


	 if (document.getElementById("first_name").value=="")
	{
			alert('Please, fill in First Name');
			document.getElementById("first_name").focus();		
			return false;
	}
	else if (document.getElementById("last_name").value=="")
	{
			alert('Please, fill in Last Name');
			document.getElementById("last_name").focus();		
			return false;
	}
	if (document.getElementById("email").value=="")
	{
			alert('Please fill in correct Email');
			document.getElementById("email").focus();		
			return false;
	}	
		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('Please fill in correct Email');
			document.getElementById("email").focus();		
			return false;
		}
		else if (document.getElementById("company").value=="")
	{
			alert('Please, fill in Company');
			document.getElementById("company").focus();		
			return false;
	}


		
	if (document.getElementById("country").value=="Select Country")
	{
			alert('Please, choose a Country');
			document.getElementById("country").focus();		
			return false;
	}
	
				if (document.getElementById("subject").value=="")
	{
			alert('Please, fill in Subject');
			document.getElementById("subject").focus();		
			return false;
	}	
	
	
		if (document.getElementById("Application").value=="")
	{
			alert('Please, fill in Application');
			document.getElementById("Application").focus();		
			return false;
	}	
	

	

		if (document.getElementById("hear_about_CONTROP").value=="none" && document.getElementById("Other_hear_about_CONTROP").value=="")
	{			
			alert('Please, choose How did you hear about CONTROP?');
			return false;
			document.getElementById("hear_about_CONTROP").focus();		
			
	}		

		if (document.getElementById("hear_about_CONTROP").value=="Other" && document.getElementById("Other_hear_about_CONTROP").value=="")
	{			
			alert('Please, choose How did you hear about CONTROP?');
			return false;
			document.getElementById("Other_hear_about_CONTROP").focus();		
			
	}		
	
	
			return true;
	
}
