// JavaScript Document

function check_nan(th)
{
	
	if (Trim(th.email.value) == "")
	{
		alert ("Please enter your email !");
		th.email.focus();
		return false;
	}
	if(!emailCheck(Trim(th.email.value)))
	{
		th.email.select();
		return false;
	}
	
	if(th.T1.value == "")
	{
		alert ("Please enter Name!");
		th.T1.focus();
		return false;
	}
	if(th.T2.value == "")
	{
		alert ("Please enter address!");
		th.T2.focus();
		return false;
	}
	if(th.T3.value == "")
	{
		alert ("Please enter City!");
		th.T3.focus();
		return false;
	}
	if(th.T4.value == "")
	{
		alert ("Please enter State!");
		th.T4.focus();
		return false;
	}
	if(th.T5.value == "")
	{
		alert ("Please enter Zip Code!");
		th.T5.focus();
		return false;
	}
}

function check_fam(th)
{
	
	if (Trim(th.email.value) == "")
	{
		alert ("Please enter your email !");
		th.email.focus();
		return false;
	}
	if(!emailCheck(Trim(th.email.value)))
	{
		th.email.select();
		return false;
	}
	
	if(th.T1.value == "")
	{
		alert ("Please enter First Name!");
		th.T1.focus();
		return false;
	}
	if(th.T2.value == "")
	{
		alert ("Please enter Last Name!");
		th.T2.focus();
		return false;
	}
	if(th.T3.value == "")
	{
		alert ("Please enter Partner's First Name!");
		th.T3.focus();
		return false;
	}
	if(th.T4.value == "")
	{
		alert ("Please enter Partner's Last Name!");
		th.T4.focus();
		return false;
	}
	if(th.T5.value == "")
	{
		alert ("Please enter address!");
		th.T5.focus();
		return false;
	}
	if(th.T7.value == "")
	{
		alert ("Please enter City!");
		th.T7.focus();
		return false;
	}
	if(th.T8.value == "")
	{
		alert ("Please enter State!");
		th.T8.focus();
		return false;
	}
	if(th.T9.value == "")
	{
		alert ("Please enter Zip Code!");
		th.T9.focus();
		return false;
	}
	if(th.T10.value == "")
	{
		alert ("Please enter Home Phone!");
		th.T10.focus();
		return false;
	}
}


function emailCheck(s)
{
	if(!(s.match(/^[\w]+([_|\.-][\w]{1,})*@[\w]{2,}([_|\.-][\w]{1,})*\.([a-z]{2,4})$/i) ))
    {
		alert("Please Enter Valid Email Address");
		return false;
	}
	else
	{
		return true;
	}	
}


function Trim(str)
{  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
  return str;
}
