// JavaScript Document
function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

function validate_mobno(thisform)
{
with (thisform)
  {
  	if (validate_required(mobilenumber,"Mobile Number must be filled out!")==false)
  	{mobilenumber.focus();return false;}

  }
 // alert('Message sent successfully');
}
function validate_sms(thisform)
{
with (thisform)
  {
  	if (validate_required(name,"Name  must be filled out!")==false)
  	{name.focus();return false;}
	if (validate_email(email,"Not a valid e-mail address!")==false)
    {email.focus();return false;}

  }
 // alert('Message sent successfully');
}
function validate_eamil(form)
{

	var email1 = document.getElementById('email').value;
	apos=email1.indexOf("@");
  	dotpos=email1.lastIndexOf(".");
    if (apos<1||dotpos-apos<2)
    {
		alert('Not a valid e-mail address!');
		document.getElementById('email').focus();
	}
	else
	{
		document.getElementById('nlform').action='uprecovery.php';
		document.getElementById('nlform').submit();

	}

 // alert('Message sent successfully');
}

function validate_reg_form(thisform)
{
with (thisform)
  {
	var chk_txtPassword=document.getElementById('txtPassword').value;
	var chk_confirm_password=document.getElementById('confirm_password').value;
	
	var chk_CheckEmail=document.getElementById('CheckEmail');
	var chk_CheckMobile=document.getElementById('CheckMobile');
	var chk_CheckPhone=document.getElementById('CheckPhone');
	var chk_CheckFax=document.getElementById('CheckFax');

  	if (validate_required(txt_name,"Name  must be filled out!")==false)
  	{txt_name.focus();return false;}
	if (validate_required(txtMobile,"Mobile Number be filled out!")==false)
  	{txtMobile.focus();return false;}
	if (validate_email(txtEmail,"Not a valid e-mail address!")==false)
    {txtEmail.focus();return false;}
	if (validate_required(txtDOB,"DOB must be filled out!")==false)
  	{txtDOB.focus();return false;}
	if (validate_required(txt_username,"User Name must be filled out!")==false)
  	{txt_username.focus();return false;}
	if (validate_required(txtPassword,"Password must be filled out!")==false)
  	{txtPassword.focus();return false;}
	if(chk_txtPassword.length<6 || chk_txtPassword.length>8)
	{
		alert("Password charecter not lessthan 6 and more than 8  ");
		return false;
	}
	if (validate_required(confirm_password,"Confirm Password must be filled out!")==false)
  	{confirm_password.focus();return false;}
	
	
	if(chk_txtPassword!=chk_confirm_password)
	{
		alert("Password must be same as Confirm password");
		return false;
	}
	
	if(chk_CheckEmail.checked == true||chk_CheckMobile.checked == true||chk_CheckPhone.checked == true||chk_CheckFax.checked == true)
	{
		return true;
	}
	else
	{
		alert("Please Checkout Communication Preferences");
		return false;
		
	}

  }
 // alert('Message sent successfully');
}
