
function validateEmail(email) {
	var matches = email.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
	return (matches != null && email == matches[0]);
}
function strTrim(str){
  str=str.replace(/(^\s*)|(\s*$)/g, "");
  if (str.length==0){
    return false;
  }
  return true;
}  
function validateTelepnone(Number){
    var stripped = Number.replace(/[\(\)\.\-\ ]/g, '');
//strip out acceptable non-numeric characters
   if (isNaN(parseInt(stripped))){ 
     return false;
   }	 
	 
	if (Number.length < 10)
		return false;
	return true;
} 
 
function checkBackUp(){
  if( !strTrim(document.all['first_name'].value)) {
    alert('first name is required');
	document.all['first_name'].focus();
    return false;
  }
  if( !strTrim(document.all['last_name'].value)) {
    alert('last name is required');
	document.all['last_name'].focus();
    return false;
  }
  if(!validateTelepnone(document.all['phone'].value)) {
    alert('phone number is required');
	document.all['phone'].focus();
    return false;
  }
    if(!validateEmail(document.all['user_email'].value)) {
    alert('E-mail Address is required');
	document.all['user_email'].focus();
    return false;
  }
  
  if(!strTrim(document.all['State'].value)) {
    alert('State Field is reqired');
	document.all['State'].focus();
    return false;
  }
 //document.NumeratorForm.submit();
  return true;
}

function check(){
  if( !strTrim(document.all['first_name'].value)) {
    alert('first name is required');
	document.all['first_name'].focus();
    return false;
  }
  if( !strTrim(document.all['last_name'].value)) {
    alert('last name is required');
	document.all['last_name'].focus();
    return false;
  }
	  if(!strTrim(document.all['State'].value)) {
    alert('State Field is reqired');
		document.all['State'].focus();
    return false;
  }

	if (document.all['country1'].value == "972")/*israel */
	{
			document.all['phone'].value = document.all['city_ddlb'].value + "-" + document.all['phone1'].value;
	}
	else
	{
	
		if (document.getElementById("ddlb").style.display == 'none')
				{
				document.all['phone'].value = "012-" + document.all['country1'].value + document.all['city_ipt'].value +document.all['phone1'].value;
				/* alert("ddlbnone"); */
				}
		else
				{
				document.all['phone'].value = "012-" + document.all['country1'].value + document.all['city_ddlb'].value +document.all['phone1'].value;
				/* alert("ddlb_block"); */
				}
	}
	
	//cell_phone
	if (document.all['phone2'].value != "")
	{
	if (document.all['country2'].value == "972")/*israel */
	{
			document.all['cellPhone'].value = document.all['city_ddlb2'].value + document.all['phone2'].value;
	}
	else
	{
	
		if (document.getElementById("ddlb2").style.display == 'none')
				{
				document.all['cellPhone'].value = "012-" + document.all['country2'].value + document.all['city_ipt2'].value +document.all['phone2'].value;
				/* alert("ddlbnone"); */
				}
		else
				{
				document.all['cellPhone'].value = "012-" + document.all['country2'].value + document.all['city_ddlb2'].value +document.all['phone2'].value;
				/* alert("ddlb_block"); */
				}
	}
	}
	
		//Fax
	if (document.all['phone3'].value != "")
	{
	if (document.all['country3'].value == "972")/*israel */
	{
			document.all['fax'].value = document.all['city_ddlb3'].value + document.all['phone3'].value;
	}
	else
	{
	
		if (document.getElementById("ddlb3").style.display == 'none')
				{
				document.all['fax'].value = "012-" + document.all['country3'].value + document.all['city_ipt3'].value +document.all['phone3'].value;
				/* alert("ddlbnone"); */
				}
		else
				{
				document.all['fax'].value = "012-" + document.all['country3'].value + document.all['city_ddlb3'].value +document.all['phone3'].value;
				/* alert("ddlb_block"); */
				}
	}
	}
		
  if(!validateTelepnone(document.all['phone'].value)) {
    alert('phone number is required');
		document.all['phone1'].focus();
    return false;
  }
    if(!validateEmail(document.all['user_email'].value)) {
    alert('E-mail Address is required');
		document.all['user_email'].focus();
    return false;
  }
	
 //document.NumeratorForm.submit();
  return true;
}
