// JavaScript Document
var ShowSpouse = false;
var ShowChild1 = false;
var ShowChild2 = false;
var ShowChild3 = false;
var ShowChild4 = false;
var ShowChild5 = false;
var ShowChild6 = false;
var PopulateSpouse = false;
var PopulateChild1 = false;
var PopulateChild2 = false;
var PopulateChild3 = false;
var PopulateChild4 = false;
var PopulateChild5 = false;
var PopulateChild6 = false;
var ErrorCount = 0;
var OnStep1 = true;
var ErrorDivStyle = "border: 2px solid Red; margin: 1px; background-color: #ffdddd;"
var ErrorDivStyleStep2 = "border: 2px solid Red; margin: 1px; padding: 2px; background-color: #ffdddd;"




function SubmitForm()
{
var Errors = ValidateStep2();
if (Errors === 0)
{
	document.getElementById("quoteform_id").submit();
	
}
else
{
	$('#tblError').show().show();
	
}
	
}


$(document).ready(function(){
    
	
   $("#zip").keypress(function (e)
{
  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {
    //display error message
    //$("#errmsg").html("Digits Only").show().fadeOut("slow");
    return false;
  }
});
   
    $("#phone1").keypress(function (e)
{
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {    
    return false;
  }
});
	
	$("#phone2").keypress(function (e)
{
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {    
    return false;
  }
});
	
	$("#phone3").keypress(function (e)
{
  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
  {    
    return false;
  }
});
	  

  });



function ValidateStep2()
{
	ErrorCount = 0;
	
	if ($('#fname').val() != '' && $('#lname').val() != '')
	{
		$('#row_name').attr('style','');
	}
	else
	{
		$('#row_name').attr('style',ErrorDivStyleStep2);
		ErrorCount++;
	}
	/*
	if ($('#dob_month').val() != 'null' && $('#dob_day').val() != 'null' && $('#dob_year').val() != 'null')
	{
		$('#row_dob').attr('style','');
	}
	else
	{
		$('#row_dob').attr('style',ErrorDivStyleStep2);
		ErrorCount++;
	}*/
	
	if ($('#ddlGender').val() != 0 && $('#ddlAge').val() != 0)
	{
		$('#row_age_gender').attr('style','');
	}
	else
	{
		$('#row_age_gender').attr('style',ErrorDivStyleStep2);
		ErrorCount++;
	}
	
	
	if ($('#investment_amount').val() != 'null')
	{
		$('#row_investment_amount').attr('style','');
	}
	else
	{
		$('#row_investment_amount').attr('style',ErrorDivStyleStep2);
		ErrorCount++;
	}
	

	if ($('#investment_amount').val() != 'null')
	{
		$('#row_investment_amount').attr('style','');
	}
	else
	{
		$('#row_investment_amount').attr('style',ErrorDivStyleStep2);
		ErrorCount++;
	}
	
	if ($('#investment_amount').val() != 'null')
	{
		$('#row_investment_amount').attr('style','');
	}
	else
	{
		$('#row_investment_amount').attr('style',ErrorDivStyleStep2);
		ErrorCount++;
	}
	
	
	
	
	if ($('#state').val() != 'null')
	{
		$('#row_state').attr('style','');

	}
	else
	{
		$('#row_state').attr('style',ErrorDivStyleStep2);
		
		ErrorCount++;
	}

	
	if ( ($('#phone1').val() != '') && ($('#phone2').val() != '') && ($('#phone3').val() != '')  && ($('#phone1').val().length == 3) && ($('#phone2').val().length == 3) && ($('#phone3').val().length == 4))
	{	
			$('#row_phone').attr('style','');
		
	}
	else
	{
		$('#row_phone').attr('style',ErrorDivStyleStep2);		
		ErrorCount++;
	}
	
	
	if ($('#email').val() != '' )
	{
		$('#row_email').attr('style','');
	
		
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var address = $('#email').val();
		

		if(reg.test(address) == false) 
		{
			
			$('#row_email').attr('style',ErrorDivStyleStep2);
	
			ErrorCount++;
		}
		else
		{
			
			$('#row_email').attr('style','');
			
		}
	}
	else
	{
		$('#row_email').attr('style',ErrorDivStyleStep2);
		ErrorCount++;
	}
	
	return ErrorCount;
	
	
}


