//------- For formvalidation In line javascript---//
 function checkValidation()
{

var aname=document.getElementById('aname');
var cname=document.getElementById('cname');
var adob=document.getElementById('adob');
var cdob=document.getElementById('cdob');
var aaddress=document.getElementById('aaddress');
var acity=document.getElementById('acity');
var astate=document.getElementById('astate');
var azip=document.getElementById('azip');
var ayear_at=document.getElementById('ayear_at');
var ahpho=document.getElementById('ahpho');
var aopho=document.getElementById('aopho');
var amail=document.getElementById('amail');
var asocial=document.getElementById('asocial');
var aemp=document.getElementById('aemp');
var aocc=document.getElementById('aocc');
var aincome=document.getElementById('aincome');
var caddress=document.getElementById('caddress');
var ccity=document.getElementById('ccity');
var cstate=document.getElementById('cstate');
var czip=document.getElementById('czip');
var cyear_at=document.getElementById('cyear_at');
var add_p1=document.getElementById('add_p1');
var add_p2=document.getElementById('add_p2');
var city_p1=document.getElementById('city_p1');
var city_p2=document.getElementById('city_p2');
var pro_p1=document.getElementById('pro_p1');
var pro_p2=document.getElementById('pro_p2');
var zip_p1=document.getElementById('zip_p1');
var zip_p2=document.getElementById('zip_p2');
var chpho=document.getElementById('chpho');
var copho=document.getElementById('copho');
var cmail=document.getElementById('cmail');
var csocial=document.getElementById('csocial');
var cemp=document.getElementById('cemp');
var cocc=document.getElementById('cocc');
var cincome=document.getElementById('cincome');


if(aname.value=='')
	{    
	alert("Please Fill Applicant's Name");
	ActivateTab('tab-container','0');
	aname.focus();
	return false;
	}

   if(adob.value=='')
	{    
	alert("Please Enter Applicant's Date of Birth");
	ActivateTab('tab-container','0');
	adob.focus();
	return false;
	}
  
	if(aaddress.value=='')
	{    
	alert("Please Enter Applicant's Address");
	ActivateTab('tab-container','0');
	aaddress.focus();
	return false;
	}
	
	if(acity.value=='')
	{    
	alert("Please Enter Applicant's City");
	ActivateTab('tab-container','0');
	acity.focus();
	return false;
	}
    
	if(astate.value=='')
	{    
	alert("Please Enter Applicant's Province");
	ActivateTab('tab-container','0');
	astate.focus();
	return false;
	}

	if(azip.value=='')
	{    
	alert("Please Enter Applicant's Zip");
	ActivateTab('tab-container','0');
	azip.focus();
	return false;
	}
	if(ayear_at.checked==true) //start of less then 3 year validations//
	{     
		 if(add_p1.value=='')
		  {
			  alert("Please Enter Applicant's Previous Address ");
			  ActivateTab('tab-container','0');
			  add_p1.focus();
			  return false;
		  }
		   if(city_p1.value=='')
		  {
			  alert("Please Enter Applicant's Previous City ");
			  ActivateTab('tab-container','0');
			  city_p1.focus();
			  return false;
		  }
		  if(pro_p1.value=='')
		  {
			  alert("Please Enter Applicant's Province  ");
			  ActivateTab('tab-container','0');
			  pro_p1.focus();
			  return false;
		  }
		  if(zip_p1.value=='')
		  {
			  alert("Please Enter Applicant's Previous City  Zip Code");
			  ActivateTab('tab-container','0');
			  zip_p1.focus();
			  return false;
		  }
	} 

  // End of less Then 3 years validations
	if(ahpho.value=='')
	{    
	alert("Please Enter Applicant's Home Phone Number");
	ActivateTab('tab-container','0');
	ahpho.focus();
	return false;
	}
	if(aopho.value=='')
	{    
	alert("Please Enter Applicant's Office Phone Number");
	ActivateTab('tab-container','0');
	aopho.focus();
	return false;
	}
	// Email validations
	if(amail.value=='')
	{    
	alert("Please Enter Applicant's Email Address");
	ActivateTab('tab-container','0');
	amail.focus();
	return false;
	}
	else 
	 {
		 if(checkemaila()==false)
		 {
		ActivateTab('tab-container','0');	 
		document.getElementById('amail').focus();
		return false;
	     }
	 } 
	 //Email Validation end

	if(asocial.value=='')
	{    
	alert("Please Enter Applicant's Social Insurance Number");
	ActivateTab('tab-container','0');
	asocial.focus();
	return false;
	}
	if(aemp.value=='')
	{    
	alert("Please Enter Applicant's Employer Details");
	ActivateTab('tab-container','0');
	aemp.focus();
	return false;
	}
	if(aocc.value=='')
	{    
	alert("Please Enter Applicant's Occupation");
	ActivateTab('tab-container','0');
	aocc.focus();
	return false;
	}
	if(aincome.value=='')
	{    
	alert("Please Enter Applicant's Annual Income");
	ActivateTab('tab-container','0');
	aincome.focus();
	return false;
	}
	
  // Start of  Co-Applicant //
    if(cname.value!=='') // Start of Co-Applicant Conditions
	{    
		 if(cdob.value=='')
		{    
		alert("Please Enter Co-Applicant's Date of Birth");
		ActivateTab('tab-container','0');
		cdob.focus();
		return false;
		}
			
        if(caddress.value=='')
		{    
		alert("Please Enter Co-Applicant's Address");
		ActivateTab('tab-container','0');
		caddress.focus();
		return false;
		}

        if(ccity.value=='')
			{    
			alert("Please Enter Co-Applicant's City");
			ActivateTab('tab-container','0');
			ccity.focus();
			return false;
			}
		
		if(cstate.value=='')
			{    
			alert("Please Enter Co-Applicant's Province ");
			ActivateTab('tab-container','0');
			cstate.focus();
			return false;
			}
		if(czip.value=='')
			{    
			alert("Please Co-Applicant's Zip Code");
			ActivateTab('tab-container','0');
			czip.focus();
			return false;
			}

         if(cyear_at.checked==true) // start of Request Field Less Than 3 years 
		    { 
			  if(add_p2.value=='')
				{    
				 alert("Please Enter  Co-Applicant's Previous Address");
				 ActivateTab('tab-container','0');
				 add_p2.focus();
				 return false;
				}
			   
			if(city_p2.value=='')
				{    
				alert("Please Enter  Co-Applicant's Previous City");
				ActivateTab('tab-container','0');
				city_p2.focus();
				return false;
				} 
			
		    if(zip_p2.value=='')
				{    
				alert("Please Enter  Co-Applicant's Previous Zip Code");
				ActivateTab('tab-container','0');
				zip_p2.focus();
				return false;
				}
			 
			 if(pro_p2.value=='')
				{    
				alert("Please Enter  Co-Applicant's Province");
				ActivateTab('tab-container','0');
				pro_p2.focus();
				return false;
				}
		  }// End
     if(chpho.value=='')
	{    
	alert("Please Enter Co-Applicant's Home Phone Number");
	ActivateTab('tab-container','0');
	chpho.focus();
	return false;
	}
	if(copho.value=='')
	{    
	alert("Please Enter Co-Applicant's Office Phone Number");
	ActivateTab('tab-container','0');
	copho.focus();
	return false;
	}
	if(cmail.value=='')
	{    
	alert("Please Enter Co-Applicant's Email");
	ActivateTab('tab-container','0');
	cmail.focus();
	return false;
	}
	else 
	 {
		 if(checkemaila()==false)
		 {
		ActivateTab('tab-container','0');	 
		document.getElementById('cmail').focus();
		return false;
	     }
	 } 
	if(csocial.value=='')
	{    
	alert("Please Enter Co-Applicant's Social Insurance Number");
	ActivateTab('tab-container','0');
	csocial.focus();
	return false;
	}
	if(cemp.value=='')
	{    
	alert("Please Enter Co Applicant's Employer Details");
	ActivateTab('tab-container','0');
	cemp.focus();
	return false;
	}
	
	if(cocc.value=='')
	{    
	alert("Please Enter Co-Applicant's Occupation");
	ActivateTab('tab-container','0');
	cocc.focus();
	return false;
	}
	if(cincome.value=='')
	{    
	alert("Please Enter Co-Applicant's Annual Income");
	ActivateTab('tab-container','0');
	cincome.focus();
	return false;
	}

    }     // End
	if(document.getElementById('term').checked == false)
	{    
	alert("Please Select Terms and Conditions");
	return false;
	}
	
  // End Of Co-Applicant//
}
function checkemaila()
{
	var str=document.getElementById('amail').value
	var filter=/^.+@.+\..{2,3}$/
	if (filter.test(str))
	testresultsa=true
	else
	{
		alert("Please input a valid Applicant's email address!")
		testresultsa=false
	}
	return (testresultsa)

}


