﻿// JScript File
function customvalidate()
{
// set var radio_choice to false
var radio_choice = false;
var radio_choice_amenity = false;

if (Ektron.FormBlock.validate(document.getElementById('aspnetForm')))
{

   if ( (document.getElementById('aspnetForm').Email.value.length == 0) &&  (document.getElementById('aspnetForm').PhoneNumber.value.length == 0) )   
   {
    alert('Please enter Email Address or Phone Number');
    return false;
   }
   
   if ( (document.getElementById('aspnetForm').Email.value != document.getElementById('aspnetForm').EmailConfirmation.value) )   
   {
    alert('Email Address and Confirm Email must match');
    return false;
   }
   
   if (document.getElementById('aspnetForm').Type_ofBusiness.selectedIndex == 2)
   {
       // Loop from zero to the one minus the number of radio button selections
        for (counter = 0; counter < document.getElementById('aspnetForm').FoodserviceOperatorSegment.length; counter++)
        {
        if (document.getElementById('aspnetForm').FoodserviceOperatorSegment[counter].checked)
        radio_choice = true; 
        }
        if (!radio_choice)
        {
        // If there were no selections made display an alert box 
        alert("Please select a Foodservice Operator Business Type");
        return false;
        }
    }
    
    if (document.getElementById('aspnetForm').Type_ofBusiness.selectedIndex == 3)
   {
       // Loop from zero to the one minus the number of radio button selections
        for (counter = 0; counter < document.getElementById('aspnetForm').AmenitySegments.length; counter++)
        {
        if (document.getElementById('aspnetForm').AmenitySegments[counter].checked)
        radio_choice_amenity = true; 
        }
        if (!radio_choice_amenity)
        {
        // If there were no selections made display an alert box 
        alert("Please select an Amenity Business Type");
        return false;
        }
    }
    
    
    if (document.getElementById('aspnetForm').Products_ofInterest[6].checked)
    {
        if (document.getElementById('aspnetForm').Products_ofInterestOther.value.length == 0)
        {
        alert('Please enter Products of Interest - Other');
        return false;
        }
    }
    
     if (document.getElementById('aspnetForm').I_Plan_toServeProducts[7].checked)
    {
        if (document.getElementById('aspnetForm').Plan_toServeProductsOther.value.length == 0)
        {
        alert('Please enter Plan to Serve Products - Other');
        return false;
        }
    }


   Ektron.FormBlock.setTargetAction("postback");
   Ektron.FormBlock.setState("__ekFormState", "in");
   document.getElementById('aspnetForm').submit();
}

}

