
var ok=true
function is_char(st)
	{

	for(i=0;i<st.length;i++)
		if((st.charAt(i)<"a" || st.charAt(i)>"z") && (st.charAt(i)!=" "))
			{
			return false
			break
			}
	return true
	}

function is_heb(st)
	{
	for(i=0;i<st.length;i++)
		if((st.charAt(i)<"א" || st.charAt(i)>"ת") && (st.charAt(i)!=" ") && (st.charAt(i)!="-"))
			{
			return false
			break
			}
	return true
	}
	
 
function is_num(st)
	{
	for(i=0;i<st.length;i++)
		if(st.charAt(i)<"0" || st.charAt(i)>"9")
			{
			return false
			break
			}
	return true
	}


function is_empty(st)
	{
	if(st=="")
		return true
	else    return false
	}


function check_name(name)
	{

	
	if(is_empty(name.value))
		{
		alert("נא לכתוב שם פרטי ושם משפחה")
		formi2.name.focus()
		return false
		}
	
	if (is_char(name.value)==false && is_heb(name.value)==false)
		{
		alert("השם מכיל תווים לא מוכרים")
		last.select()
		return false
		}

	

	return true
	}


function check_email(str)
	{
	if(is_empty(str.value))
		{
		alert("נא לכתוב דואר אלקטרוני")
		formi2.Email.focus()
		return false
		}
		
	invalidchars = " /:,;אבגדהוזחטיכלמנסעפצקרשתןףךץ"
				 
		 // be sure there are no illegal chars
			 for (i=0;i<invalidchars.length;i++)
			 {
			 		 badchar = invalidchars.charAt(i)
					 if (str.value.indexOf(badchar,0) > -1 )
					 {	alert("כתובת דואר אלקטרוני לא תקינה")
						str.select()
						return false
						}
				}
						 
		// be sure there is a @		 
			atPos=str.value.indexOf("@",1)
			 if (atPos ==-1)
				 {	alert("כתובת דואר אלקטרוני לא תקינה")
					str.select()
					return false
					}
				 
		//be sure there is only 1 @	 
			 if (str.value.indexOf("@",atPos+1) != -1 )
				{	alert("כתובת דואר אלקטרוני לא תקינה")
					str.select()
					return false
					}
				 
		//is there a period after the @
			 periodPos = str.value.indexOf(".",atPos)
			 if (periodPos == -1 )
				{	alert("כתובת דואר אלקטרוני לא תקינה")
					str.select()
					return false
					}
	
		 //are there at least 2 chars after the period ?
			 if (periodPos + 3 > str.value.length )
				{	alert("כתובת דואר אלקטרוני לא תקינה")
					str.select()
					return false
					}
						
	return true
	}


function check_form()
	{

		if( check_name(document.formi2.Name))
		if( check_email(document.formi2.Email))	
		{		
		if (document.formi2.confirm_privacy_policy.checked==true)
			{
				document.formi2.submit()
				alert("הרשמתכם התקבלה בתודה" + '\n'+"אנא בדקו שמידעון שבתון אינו נכנס לתיבת הספאם שלכם" + '\n'+ "במידה וכן - נא אשרו את הכתובת כחוקית בתוכנת הדואר שלכם")
			}
		if (document.formi2.confirm_privacy_policy.checked==false)
			  alert("אנא סמנו את תיבת האישור ושלחו שנית")		
		}
	
}