// JavaScript Document
function trimStr(str)
  {
     str=(str).replace( /^\s*/, "" );
     str=(str).replace( /\s*$/, "" );
     return str;
  }
  
function checkParish(type)
 {
	 var frm=document.frmparish;
	
	 if(trimStr(frm.phorane.value)=="")
	  {
	     alert("Please select the Forane");
		 frm.phorane.focus();
		 return false;
	  }
	
	 if(trimStr(frm.type.value)=="" | trimStr(frm.type.value)=="0")
	  {
	     alert("Please select the Type");
		 frm.type.focus();
		 return false;
	  }
	 if(trimStr(frm.type.value)=="2")
	  {
	    if(trimStr(frm.parish.value)=="")
		  {
			 alert("Please select the parish");
			 frm.parish.focus();
			 return false;
		  }
		  if(trimStr(frm.grade.value)=="")
		  {
			 alert("Please select the Grade");
			 frm.grade.focus();
			 return false;
		  }
	  }
	 
	 if(trimStr(frm.name.value)=="")
	  {
	     alert("Please enter the name of the parish");
		 frm.name.focus();
		 return false;
	  }
	 
	 if(checkNum(frm.estb)==0)
	   return false;
	 
	 if(trimStr(frm.address.value)=="")
	  {
	     alert("Please enter the address of the parish");
		 frm.address.focus();
		 return false;
	  }  
	 
	 if(trimStr(frm.phone.value)!="")
	  {
	      if(trimStr(frm.phone.value).length<6)
		    {
		       alert("Phone number must contain atleast 6 numbers");
		       frm.phone.focus();
		       return false;
		    }
		  
		  if(!isPhoneNum(trimStr(frm.phone.value)))
		  {
		      alert("Invalid characters in phone number field");
		      frm.phone.focus();
		      return false;
		  } 
	  }   
	
	 if(trimStr(frm.mobile.value)!="")
	  {
	      if(trimStr(frm.mobile.value).length<10)
		    {
		       alert("Mobile number must contain atleast 10 numbers");
		       frm.mobile.focus();
		       return false;
		    }
		  
		  if(!isPhoneNum(trimStr(frm.mobile.value)))
		  {
		      alert("Invalid characters in mobile number field");
		      frm.mobile.focus();
		      return false;
		  } 
	  } 
	
	if(checkEmail(frm.email)==0)
	   return false;	
	if(checkWeb(frm.web)==0)
	   return false;
	if(checkNum(frm.families)==0)
	   return false;
	if(checkNum(frm.population)==0)
	   return false;
	if(checkNum(frm.noncath)==0)
	   return false;
	if(checkNum(frm.nonchrist)==0)
	   return false;
	if(checkNum(frm.distance)==0)
	   return false;
	
	if(checkPhoto(frm.photo)==0)
	   return false;
		
	if(type!="edit")  
	{
	   if(checkLogindetails(frm.login,frm.password)==0)
	     return false;
    }
 }
 
//////////////////////////////////////////////////////////////////////////////////////////////////
function confirmParish()
{
    if(!confirm("Are you sure to remove the selected parishes"))
	 {
	     return false;
	 }
}
//////////////////////////////////////////////////////////////////////////////////////////////////
 function setFilian(val)
 {
    if(val=="2")
	   {
	      filianlayer.style.display="";
		  filianlayer.style.visibility="visible";
	   }
	else
 	  {
	     filianlayer.style.display="none";
		 filianlayer.style.visibility="hidden";
	  }

 }
 
 ////////////////////////////////////////////

 