//*******************************************************************************
// Function: Display Object Visibility
//*******************************************************************************
function displayObj(Obj) {
Obj.style.display = '';
}

function hideObj(Obj) {
Obj.style.display='none';
}

function ShowPopup(page,name,options)
{
	Window = window.open(page,name,options);
}

//*******************************************************************************
// Function: AutoTab For Phone/Fax Numbers
//*******************************************************************************
function autotab(current,to){
    if (current.getAttribute && 
      current.value.length==current.getAttribute("maxlength")) {
        to.focus() 
        }
}


//*******************************************************************************
// Function: Form Validation
//*******************************************************************************

function Form_Validator(theForm)
{
  
  //Validation for the First Name 
  if (theForm.FirstName.value == "")
  {
    alert("Please enter your first name");
    theForm.FirstName.focus();
    return (false);
  }
  
  //Validation for the Last Name 
  if (theForm.LastName.value == "")
  {
    alert("Please enter your last name");
    theForm.LastName.focus();
    return (false);
  }
  
   
  //Validaiton for City, State or ZipCode
  if(  (theForm.Address.value == "") || (theForm.City.value == "") || (theForm.StateID.value == "") || (theForm.ZipCode.value == "") )                           
  {
    alert("Please provide your complete street address including city, state and zip code");
    if (theForm.Address.value == "")  {
		theForm.Address.focus();
	}
	else if (theForm.City.value == "") {
		theForm.City.focus();
	}
	else if (theForm.StateID.value == "") {
		theForm.StateID.focus();
	}
	else if (theForm.ZipCode.value == "") {
		theForm.ZipCode.focus();
	}
	return (false);
  }
   
   //Gender
  if (theForm.GenderID.selectedIndex == "")
  {
    alert("Please select your gender");
    theForm.GenderID.focus();
    return (false);
  }
  
    
  
  //Day Phone Validation
 if( (theForm.DayPhone1.value.length <3) || (theForm.DayPhone2.value.length <3)  || (theForm.DayPhone3.value.length <4) )
 {
   window.alert("Please enter a valid daytime phone number");
   theForm.DayPhone1.focus();
   return false;
 }  
 
  if((isNaN(theForm.DayPhone1.value)) || (isNaN(theForm.DayPhone2.value)) || (isNaN(theForm.DayPhone3.value)) )
 {
   window.alert("Please enter only the numeric values for the daytime phone number");
   theForm.DayPhone1.focus();
   return false;
 }
   
 //Evening Phone Validation 
 if( (theForm.EvePhone1.value.length <3) || (theForm.EvePhone2.value.length <3)  || (theForm.EvePhone3.value.length <4) )
 {
   window.alert("Please enter a valid evening phone number");
   theForm.EvePhone1.focus();
   return false;
 }  
 
 if((isNaN(theForm.EvePhone1.value)) || (isNaN(theForm.EvePhone2.value)) || (isNaN(theForm.EvePhone3.value)) )
 {
   window.alert("Please enter only the numeric values for the evening phone number");
   theForm.EvePhone1.focus();
   return false;
 }  
   
 //Fax Validation 
 if( (isNaN(theForm.Fax1.value)) || (isNaN(theForm.Fax2.value)) || (isNaN(theForm.Fax3.value)) )
 {
   window.alert("Please enter only the numeric values for the fax number");
   theForm.Fax1.focus();
   return false;
 }  
 
 //Email Address Validation 
 if ( (theForm.Email.value == "") )
  {
    alert("Please enter a valid E-mail Address");
    theForm.Email.focus();
    return (false);
  }

  //Best Contact Time
  if ( (theForm.ContactTimeID.selectedIndex < 0) ||(theForm.ContactTimeID.selectedIndex == 0) )
  {
    alert("Please select the best time to contact you.");
    theForm.ContactTimeID.focus();
    return (false);
  }
 
 //Date Of Birth - Validation
 if ( (theForm.BirthMonth.selectedIndex == 0) ||(theForm.BirthDay.selectedIndex == 0) || (theForm.BirthYear.selectedIndex == 0) )
  {
    alert("Please select your date of birth.");
    theForm.BirthMonth.focus();
    return (false);
  }
 
   //Spouse Radio Button 
   if ( (theForm.AnnuityType.selectedIndex==3) && (theForm.include_spouse[0].checked == true) )
   {
   		if ( (theForm.SpouseFirstName.value == "") || (theForm.SpouseLastName.value == ""  ) || (theForm.SBirthMonth.selectedIndex == 0) || (theForm.SBirthDay.selectedIndex == 0) || (theForm.SBirthYear.selectedIndex == 0) )
		{
			 alert("Please provide name and date of birth of your spouse");
			 if (theForm.SpouseFirstName.value == "")
			 {
				theForm.SpouseFirstName.focus();
			 }
			 else if (theForm.SpouseLastName.value == "")
			 {
		 		theForm.SpouseLastName.focus();
			 }
			 else if (theForm.SBirthMonth.value == "")
			 {
				theForm.SBirthMonth.focus();
			 }
			return (false);
		}
		
   }   

//Validation for Annuity Type
 if ( (theForm.AnnuityType.value == "") )
  {
    alert("Please enter Annuity Type");
    theForm.AnnuityType.focus();
    return (false);
  }
  
  //Validation for Customer Interest
 if ( (theForm.Purpose.value == "") )
  {
    alert("Please tell us what you want your annuity to provide");
    theForm.Purpose.focus();
    return (false);
  }

  //Amount
  if ((theForm.Amount.value != "") && (theForm.AmountOther.value != "0.00") && (theForm.AmountOther.value != "")  ){
       alert("Both selections are not allowed.");
       theForm.Amount.focus();
	   return (false);
	}
  else if ((theForm.Amount.value == "") && (theForm.AmountOther.value == "0.00")  ){
       alert("Please select or enter investment amount.");
       theForm.Amount.focus();
	   return (false);
	}	
  else if ((theForm.Amount.value == "") && (theForm.AmountOther.value == "")  ){
       alert("Please select or enter investment amount.");
       theForm.Amount.focus();
	   return (false);
	}
	
    
}

//*******************************************************************************
// Function: Swallow Enter Key
//*******************************************************************************

function enter(nextfield) {
if(window.event && window.event.keyCode == 13) {
  nextfield.focus();
  return false; }
else
  return true;
}

//*******************************************************************************
// Function: Currency Focus
//*******************************************************************************
/*
onChange="displayValue(this.options[selectedIndex].value);"
function displayValue(nickName) {
		document.frmAnnuityQuote.AmountOther.value = nickName;
}
*/
