﻿
function checkForm()
{
if (document.getElementById("firstName").value =="" )
  {alert("אנא הזן שם פרטי")}
else if  (document.getElementById("lastName").value =="" )
   {alert("אנא הזן שם משפחה")}
else if  (document.getElementById("email").value =="" )
   {alert("אנא הזן כתובת אי-מייל")}

else if(!validmail (document.getElementById("email").value))
	{
		 {alert("כתובת אי-מייל אינה תקינה")} 
        document.getElementById("email").focus();
	}
else       
document.getElementById("frmContact").submit();
}


function validmail(){
												invalidchar="/:;'"
												var Email=document.getElementById("email").value
												if(document.getElementById("email").value == ""){
												return false;
												}
												
													for (i=0;i<invalidchar.length;i++){
													   badchar=invalidchar.charAt(i)
													   if (Email.indexOf(badchar,0)>-1){
													   return false;
													   
														   }
														}
														atpos=Email.indexOf("@",1)
														if (atpos==-1){
														 return false;
														}
														if (Email.indexOf("@",atpos+1)!= -1){
														return false;
												}
												return true
							}


function init() {
// get the input Cleaned Up 
document.getElementById("firstName").value ="" ;
document.getElementById("lastName").value ="" ;
document.getElementById("email").value=""

// see if it came from the send page 
if (location.href.indexOf("ok")!=-1){
    // dont show Contact and lightbox
    document.getElementById("scr1").style.display="none"
    document.getElementById("scr2").style.display="none"
    document.getElementById("send").style.display="none"
    document.getElementById("form").innerHTML="<span class='thanks'>תודה על פנייתך</span>"
    
}
 

}
window.onload = init; 
