

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
	
		 //  document.getElementById('validError').innerHTML="Invalid E-mail ID"; 
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID");
		//   document.getElementById('validError').innerHTML="Invalid E-mail ID"; 
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		 //   alert("Invalid E-mail ID");
//document.getElementById('validError').innerHTML="Invalid E-mail ID"; 
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		//    alert("Invalid E-mail ID");
		//	 document.getElementById('validError').innerHTML="Invalid E-mail ID";
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		//    alert("Invalid E-mail ID");
		//	 document.getElementById('validError').innerHTML="Invalid E-mail ID"; 
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		//    alert("Invalid E-mail ID");
		//	 document.getElementById('validError').innerHTML="Invalid E-mail ID";
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
        //   alert("Invalid E-mail ID");
		//   document.getElementById('validError').innerHTML="Invalid E-mail ID"; 
		    return false;
		 }

 		 return true					
	}


 function ValidateEmail(){
  
	var emailID=document.update_email.new_email.value;
	
	if ((emailID==null)||(emailID=="")){
		document.getElementById('validError').innerHTML="Error: Email is empity"; 
		//emailID.focus()
	//	alert(length(emailID))
		return false
	}
	if (echeck(emailID)==false){
		emailID=""
		//emailID.focus()
		document.getElementById('validError').innerHTML="Error: Invalid E-mail ID"; 
		return false
	}
	return true
 }
 
  
  
   function ValidateUpdatePopupForm(){
  
	var emailPopEdit=document.popupUpdateForm.Email.value;
	var familyName=document.popupUpdateForm.familyName.value;
	var firstName=document.popupUpdateForm.firstName.value;
	var lastName=document.popupUpdateForm.lastName.value;
	var address1=document.popupUpdateForm.address1.value;
	
	//var AddressIs=document.popupUpdateForm.AddressIs.value;
	
	//alert (AddressIs);
	if ((familyName==null)||(familyName=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: Family Name is empity"; 
		return false;
	}
	
		if ((firstName==null)||(firstName=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: First Name is empity"; 
		return false;
	}
	
		if ((lastName==null)||(lastName=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: Last Name is empity"; 
		return false;
	}
	
	if ((emailPopEdit==null)||(emailPopEdit=="")){
		return true;
	}
	
	if (echeck(emailPopEdit)==false){
		emailPopEdit="";
		document.getElementById('validPopupEditError').innerHTML="Error: Invalid E-mail ID"; 
		return false;
	}
	
	
		
	 if ((address1==null)||(address1=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: Address is empity"; 
		return false;
	}
	
	
	  	return true;
 
   }
   
   function ValidateUpdatePopupForm2(){
  
	var emailPopEdit=document.popupUpdateForm.Email.value;
	var familyName=document.popupUpdateForm.familyName.value;
	var firstName=document.popupUpdateForm.firstName.value;
	var lastName=document.popupUpdateForm.lastName.value;
	var address1=document.popupUpdateForm.address1.value;
	var city=document.popupUpdateForm.city.value;
	var zip=document.popupUpdateForm.zipCode.value;
	
	//var AddressIs=document.popupUpdateForm.AddressIs.value;
	
	//alert (AddressIs);
	if ((familyName==null)||(familyName=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: Family Name is empity"; 
		return false;
	
	
	}
	
		 if ((firstName==null)||(firstName=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: First Name is empity"; 
		return false;
	}
	
		 if ((lastName==null)||(lastName=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: Last Name is empity"; 
		return false;
	}

	 if ((address1==null)||(address1=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: Address is Empity"; 
		return false;
	}	
	
	if ((city==null)||(city=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: City is Empity"; 
		return false;
	}	
	
	
	if ((zip==null)||(zip=="")){
	    document.getElementById('validPopupEditError').innerHTML="Error: Zip is Empity"; 
		return false;
	}	
	
	
	
	
 if (echeck(emailPopEdit)==false){
		
		
		if ((emailPopEdit==null)||(emailPopEdit=="")){
		return true;
	}else{
	
	emailPopEdit="";
		document.getElementById('validPopupEditError').innerHTML="Error: Invalid E-mail ID"; 
		return false;
	}
		
	}
	
	  	return true;
 
   }
 
    function ValidateEmailSendingPopupForm(){
  
	var emailSubject=document.popupEmailSendingForm.emailSubject.value;
    var emailMessage=document.popupEmailSendingForm.emailMessage.value;

	
	if ((emailSubject==null)||(emailSubject=="")){
	    document.getElementById('validPopupEmailSendingError').innerHTML="Error: Empty Subject"; 
		return false;
	}
	
//	if(AddressIs=="SameAsHeadOfHouse"){
	
		if ((emailMessage==null)||(emailMessage=="")){
	    document.getElementById('validPopupEmailSendingError').innerHTML="Error: Empty Message"; 
		return false;
	}
	
//	}
	
	return true;
 } 
 
