// JavaScript Document




function scr_Submit()
{
	
	if (scr_isInputValid())
	{			
		document.getElementById("contactform").submit()	
	}

}



function scr_isInputValid()
{
		var fine=true
		
		var noBlanks = true
  	var emailsValid = true
  	
  	
		noBlanks = noBlankFields()
		
		if (noBlanks)
		{
			emailsValid = areEmailsValid()
		}	
		fine = (noBlanks && emailsValid)
 		

 	
	return fine

}

function isEmail2(who) 
{
	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i
	return(email.test(who))
}


function areEmailsValid()
{
	
	if (document.getElementById("id_contact_txt_email").value!="")
	{
		 var_email = document.getElementById("id_contact_txt_email").value
		 
     if (!isEmail2(var_email)) 
  	 {
  
      alert("Invalid email address. Please provide with a valid email address.")
  		document.getElementById("id_contact_txt_email").focus()		
  		return false
  	 }
  }
  
  
	return true
}

function noBlankFields()
{

   
 	
  	if (document.getElementById("id_txt_Name").value=="")
  	{
  		alert("Please fill in the 'Name' field.")
  		document.getElementById("id_txt_Name").focus()		
  		return false
  	}
	
    	
  	if (document.getElementById("id_txt_contact_num").value=="")
  	{
  		alert("Please fill in the 'Contact no.' field.")
  		document.getElementById("id_txt_contact_num").focus()		
  		return false
  	}
 
  	if (document.getElementById("id_contact_txt_email").value=="")
  	{
  		alert("Please fill in the 'Email' field.")
  		document.getElementById("id_contact_txt_email").focus()		
  		return false
  	}
  	
  
 
  return true
}




