function $get(id) {
  return document.getElementById(id);
}
function selectDate(theDate) {
  $get('theDate').value = theDate;
  setTimeout('document.theForm.submit()',100);
}
function selectRide(rideTime,rideId) {
  document.theForm.action = 'ride.asp';
  $get('theTime').value = rideTime;
  $get('theTrain').value = rideId;
  //alert($get('theTrain').value+' '+rideId);
  setTimeout('document.theForm.submit()',100);
}
function selectType(rideType) {
  //alert(this.theForm.innerHTML);
  $get('theType').value = rideType;
  setTimeout('document.theForm.submit()',100);
  //alert($get('theType').value);
}
function checkOption(elem) {
  var index = elem.selectedIndex;
  if(index == 0) {
    alert('Select a ticket before proceeding');
  } else {
    var option = elem.options[index];
    document.theForm.price.value = option.value;
    document.theForm.t1.value = 'r-Ticket Type;' + option.innerHTML;
  }
}
function checkRate(rateIndex) {
  var seats = $get('seats').value*1;
  var qty = $get('qty').value*1;
  if(qty <= seats) {
    if(rateIndex == 0) {
      alert('Please select a ticket first.');
      return(false);
    }
  } else {
    alert('There are only '+seats+' seats remaining, please lower the number of seats you are requesting, or choose another ride time.')
    return(false);
  }
  return(true);
}
function help(id) {
  var elem = $get(id);
  var content = $get('content');
  content.innerHTML = elem.innerHTML;
  popDiv('modalDiv');
}
function popDiv(elemId) {
  var theDiv = document.getElementById(elemId);
  var theBackground = document.getElementById('backgroundDiv');
  theDiv.style.display = '';
  theBackground.style.display = '';
  theDiv.className = 'center';
  if(document.all) {
    theBackground.style.top = document.documentElement.scrollTop;
    window.onscroll = function () {
      theBackground.style.top = document.documentElement.scrollTop;
    };
    theDiv.style.left = (document.body.clientWidth - theDiv.style.width.replace('px',''))/2 + "px";
    theDiv.style.top = ((document.documentElement.clientHeight - theDiv.style.height.replace('px',''))/2 + document.documentElement.scrollTop) + "px";
    theBackground.style.position = 'absolute';
  }else {
    theDiv.style.left = (window.innerWidth - theDiv.style.width.replace('px',''))/2 + "px";
    theDiv.style.top = ((window.innerHeight - theDiv.style.height.replace('px',''))/2 + document.documentElement.scrollTop) + "px";
  }
}

function closeDiv(elemId) {
  var theDiv = document.getElementById(elemId);
  var theBackground = document.getElementById('backgroundDiv');
  theDiv.style.display = 'none';
  theBackground.style.display = 'none';
}

