
function theForm_Validator(theForm)
{
 with (document.Form1) {
var maxaddons = document.Form1.hdn_optioncount.value;
var RegtypeOptions = document.Form1.hdn_RegtypeOptions.value;

if((document.Form1.GrandTotalDue.value == 0 || document.Form1.GrandTotalDue.value == "") && document.Form1.dnr_zeropayments == 0){
	alert("You have not selected any sessions / Complementary or non paying registrations cannot be completed using this system")
	return (false)
	}

  var checkOK = "0123456789-.,";
  var checkStr = document.Form1.RegistrationAmt.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"RegistrationAmt\" field.");
    document.Form1.RegistrationAmt.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"RegistrationAmt\" field.");
    document.Form1.RegistrationAmt.focus();
    return (false);
  }

  ////check to make sure they have selected a registration type
  with (document.Form1) {

	if (dnr_RegtypeOptional.value == 1){
  if (RegistrationType_V.options.selectedIndex == 0){
  //message = "Your have not selected a Registration Type";
  //alert(message);
  //document.Form1.RegistrationType.focus();
 // return(false);
  }
  }
  }
  ////check to make sure they have not doubled up on the addons
  with (document.Form1) {

var addonname = ""
selectionarray = new Array
maxaddons = (maxaddons * 1)
addonsselected = 0
for (i = 1;  i < maxaddons+1;  i++){
	addonname = "dnr_AddOn"+i+"_V"
	if( document.Form1[addonname].selectedIndex >0){
	addonsselected = addonsselected + 1
	}
}

if (addonsselected > 10){
alert("Sorry but you can only select a maximum of TEN items from the Day Registrations, Touring and other Activities")
return (false)
}



// check to make sure they have selected an item only once
for (i = 1;  i < maxaddons+1;  i++){
	addonname = "dnr_AddOn"+i+"_V"
	
	selecteditem = document.Form1[addonname].selectedIndex
	selectionarray[i] = document.Form1[addonname].options[selecteditem].value
}

var addonname = ""
for(j = 1; j < maxaddons +1;j++){
countmatch = 0
var addonname = ""
addonname = "dnr_AddOn"+j+"_V"
selecteditem = document.Form1[addonname].selectedIndex
for(i=1;i<selectionarray.length+1; i++){
	if (selecteditem > 0){
	if (document.Form1[addonname].options[selecteditem].value == selectionarray[i]){
		countmatch = countmatch + 1
			}
	}
	}
	if(countmatch > 1){
	message = "You have selected " + document.Form1[addonname].options[selecteditem].value + " more than once"
	alert(message)
	
	return (false)
	}
}

}

for (i = 1;  i < maxaddons+1;  i++){
	addonquant = "AddOnQ"+i
	addonname = "dnr_AddOn"+i+"_V"
	
		selecteditem = document.Form1[addonname].selectedIndex
		quantity = document.Form1[addonquant].value
		
	if (document.Form1[addonname].selectedIndex > 0 && quantity == ""){
	message = "Please enter a quantity for " + document.Form1[addonname].options[selecteditem].value
	alert(message)
	return(false)
	}
	
	
	


  var checkOK = "0123456789,";
  var checkStr = quantity;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (s = 0;  s < checkStr.length;  s++)
  {
    ch = checkStr.charAt(s);
    for (t = 0;  t < checkOK.length;  t++)
      if (ch == checkOK.charAt(t))
        break;
    if (t == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
  message = "Please enter only numeric characters in the " + document.Form1[addonname].options[selecteditem].value + " quantity field"
	alert(message)
    //alert("Please enter only digit characters in the \"AddOnQ1\" field.");
     document.Form1[addonquant].focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1"))
  {
  message = "Please enter a value greater than or equal to \"1\" in the " + document.Form1[addonname].options[selecteditem].value + " quantity field"
    alert(message);
    document.Form1[addonquant].focus();
    return (false);
  }
  
}

//end checking valid quantities

if (RegtypeOptions == 2 || RegtypeOptions == 4){

  if (document.Form1.ArrivalDateH.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Arrival Date\" field.");
    document.Form1.ArrivalDateH.focus();
    return (false);
  }

  var checkOK = "0123456789-/";
  var checkStr = document.Form1.ArrivalDateH.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"/\" characters in the \"Arrival Date\" field.");
    document.Form1.ArrivalDateH.focus();
    return (false);
  }

  if (document.Form1.ArrivalTimeH.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Arrival Time\" field.");
    document.Form1.ArrivalTimeH.focus();
    return (false);
  }

  var checkOK = "0123456789-:";
  var checkStr = document.Form1.ArrivalTimeH.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \":\" characters in the \"Arrival Time\" field.");
    document.Form1.ArrivalTimeH.focus();
    return (false);
  }

  if (document.Form1.DepartureDateH.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Departure Date\" field.");
    document.Form1.DepartureDateH.focus();
    return (false);
  }

  var checkOK = "0123456789-/";
  var checkStr = document.Form1.DepartureDateH.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"/\" characters in the \"Departure Date\" field.");
    document.Form1.DepartureDateH.focus();
    return (false);
  }

  if (document.Form1.DepartureTimeH.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Departure Time\" field.");
    document.Form1.DepartureTimeH.focus();
    return (false);
  }

  var checkOK = "0123456789-:";
  var checkStr = document.Form1.DepartureTimeH.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \":\" characters in the \"Departure Time\" field.");
    document.Form1.DepartureTimeH.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = document.Form1.HotelDepositDue.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"HotelDepositDue\" field.");
    document.Form1.HotelDepositDue.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"HotelDepositDue\" field.");
    document.Form1.HotelDepositDue.focus();
    return (false);
  }
}
if (RegtypeOptions == 3 || RegtypeOptions == 4){
  if (document.Form1.DepartureDate1.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Departure Date\" field.");
    document.Form1.DepartureDate1.focus();
    return (false);
  }

  var checkOK = "0123456789-/";
  var checkStr = document.Form1.DepartureDate1.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"/\" characters in the \"Departure Date\" field.");
    document.Form1.DepartureDate1.focus();
    return (false);
  }

  if (document.Form1.DepartureTime1.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Departure Time\" field.");
    document.Form1.DepartureTime1.focus();
    return (false);
  }

  var checkOK = "0123456789-:";
  var checkStr = document.Form1.DepartureTime1.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \":\" characters in the \"Departure Time\" field.");
    document.Form1.DepartureTime1.focus();
    return (false);
  }

  if (document.Form1.ArrivalDate1.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Arrival Date\" field.");
    document.Form1.ArrivalDate1.focus();
    return (false);
  }

  var checkOK = "0123456789-/";
  var checkStr = document.Form1.ArrivalDate1.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"/\" characters in the \"Arrival Date\" field.");
    document.Form1.ArrivalDate1.focus();
    return (false);
  }

  if (document.Form1.ArrivalTime1.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Arrival Time\" field.");
    document.Form1.ArrivalTime1.focus();
    return (false);
  }

  var checkOK = "0123456789-:";
  var checkStr = document.Form1.ArrivalTime1.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \":\" characters in the \"Arrival Time\" field.");
    document.Form1.ArrivalTime1.focus();
    return (false);
  }

  if (document.Form1.NumberOfTickets1.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"NumberOfTickets1\" field.");
    document.Form1.NumberOfTickets1.focus();
    return (false);
  }

  if (document.Form1.NumberOfTickets1.value.length > 3)
  {
    alert("Please enter at most 3 characters in the \"NumberOfTickets1\" field.");
    document.Form1.NumberOfTickets1.focus();
    return (false);
  }

  var checkOK = "0123456789-,";
  var checkStr = document.Form1.NumberOfTickets1.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"NumberOfTickets1\" field.");
    document.Form1.NumberOfTickets1.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1"))
  {
    alert("Please enter a value greater than or equal to \"1\" in the \"NumberOfTickets1\" field.");
    document.Form1.NumberOfTickets1.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = document.Form1.CostPerTicket1.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"CostPerTicket1\" field.");
    document.Form1.CostPerTicket1.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"CostPerTicket1\" field.");
    document.Form1.CostPerTicket1.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = document.Form1.TravelAmountDue1.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"TravelAmountDue1\" field.");
    document.Form1.TravelAmountDue1.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"TravelAmountDue1\" field.");
    document.Form1.TravelAmountDue1.focus();
    return (false);
  }

  if (document.Form1.DepartureDate2.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Departure Date\" field.");
    document.Form1.DepartureDate2.focus();
    return (false);
  }

  var checkOK = "0123456789-/";
  var checkStr = document.Form1.DepartureDate2.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"/\" characters in the \"Departure Date\" field.");
    document.Form1.DepartureDate2.focus();
    return (false);
  }

  if (document.Form1.DepartureTime2.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Departure Time\" field.");
    document.Form1.DepartureTime2.focus();
    return (false);
  }

  var checkOK = "0123456789-:";
  var checkStr = document.Form1.DepartureTime2.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \":\" characters in the \"Departure Time\" field.");
    document.Form1.DepartureTime2.focus();
    return (false);
  }

  if (document.Form1.ArrivalDate2.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Arrival Date\" field.");
    document.Form1.ArrivalDate2.focus();
    return (false);
  }

  var checkOK = "0123456789-/";
  var checkStr = document.Form1.ArrivalDate2.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \"/\" characters in the \"Arrival Date\" field.");
    document.Form1.ArrivalDate2.focus();
    return (false);
  }

  if (document.Form1.ArrivalTime2.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Arrival Time\" field.");
    document.Form1.ArrivalTime2.focus();
    return (false);
  }

  var checkOK = "0123456789-:";
  var checkStr = document.Form1.ArrivalTime2.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit and \":\" characters in the \"Arrival Time\" field.");
    document.Form1.ArrivalTime2.focus();
    return (false);
  }

  if (document.Form1.NumberOfTickets2.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"NumberOfTickets2\" field.");
    document.Form1.NumberOfTickets2.focus();
    return (false);
  }

  if (document.Form1.NumberOfTickets2.value.length > 3)
  {
    alert("Please enter at most 3 characters in the \"NumberOfTickets2\" field.");
    document.Form1.NumberOfTickets2.focus();
    return (false);
  }

  var checkOK = "0123456789-,";
  var checkStr = document.Form1.NumberOfTickets2.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"NumberOfTickets2\" field.");
    document.Form1.NumberOfTickets2.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1"))
  {
    alert("Please enter a value greater than or equal to \"1\" in the \"NumberOfTickets2\" field.");
    document.Form1.NumberOfTickets2.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = document.Form1.CostPerTicket2.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"CostPerTicket2\" field.");
    document.Form1.CostPerTicket2.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"CostPerTicket2\" field.");
    document.Form1.CostPerTicket2.focus();
    return (false);
  }




  var checkOK = "0123456789-.,";
  var checkStr = document.Form1.TravelAmountDue2.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"TravelAmountDue2\" field.");
    document.Form1.TravelAmountDue2.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"TravelAmountDue2\" field.");
    document.Form1.TravelAmountDue2.focus();
    return (false);
  }
  }
  
	//check to make sure they have selected a hotel - if required
	if(document.Form1.dnr_hotelrequired.value == 1){
		if(document.Form1.hdn_hotelselectname[0].checked){
		 alert("Please select a Hotel or select No accommodation required.");
		return(false);
		}
	}

	if(document.Form1.dnr_showhotels.value == 1){
		if (document.Form1.hdn_hotelselectname[0].checked || document.Form1.hdn_hotelselectname[1].checked)
		{
		
		}else{
		if (document.Form1.BillingMethod.options.selectedIndex == 0){
	  message = "Your have not selected a Billing Method";
	  alert(message);
	    return(false);
		}
		if (document.Form1.ArrivalDateH.value == "" || document.Form1.DepartureDateH.value =="" ){
	  message = "Please enter you Hotel Arrival and Departure Dates";
	  alert(message);
	    return(false);
		}
	  }
	}
	
// check to make sure they have selected an item only once  
  
if (document.Form1.dnr_sessions.value == 1){
  var sessionname = ""
selectionarray = new Array



for (i = 1;  i < document.Form1.maxsessions.value;  i++){
	sessionname = "Session"+i
	selecteditem = document.Form1[sessionname].selectedIndex
	selectionarray[i] = document.Form1[sessionname].options[selecteditem].value
}

var sessionname = ""

for(j = 1; j < document.Form1.maxsessions.value;j++){
countmatch = 0
var sessionname = ""
sessionname = "Session"+j

selecteditem = document.Form1[sessionname].selectedIndex
for(i=1;i<selectionarray.length+1; i++){
	if (selecteditem > 0){
	if (document.Form1[sessionname].options[selecteditem].value == selectionarray[i]){
		countmatch = countmatch + 1
			}
	}
	}
	if(countmatch > 1){
	message = "You have selected " + document.Form1[sessionname].options[selecteditem].value + " more than once"
	alert(message)
	
	return (false)
	}
}

}
 
  
  return (true);
}
}

