function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
} 

function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}  

//form actions on the home page.

      // Global form variable
      var f // the main input form

function updateHiddenDate()
{
  f.date.value = f.Month[f.Month.selectedIndex].value + "/" + f.Day[f.Day.selectedIndex].value + "/" + f.Year[f.Year.selectedIndex].value;
}

function updateHiddenTime()
{
  f.time.value = f.Hour[f.Hour.selectedIndex].value + ":" + f.Minute[f.Minute.selectedIndex].value + " " + f.Suffix[f.Suffix.selectedIndex].value;
}
      // Set up form with correct date / time and initialize global variables
      function init() {
        f = document.frmQuickTrip;
        var d = new Date();

        f.Month.selectedIndex = d.getMonth();
        f.Day.selectedIndex = d.getDate() - 1;
        f.Hour.selectedIndex = d.getHours() % 12 == 0 ? 11 : d.getHours() % 12 - 1;
        f.Minute.selectedIndex = d.getMinutes() / 5;

        if (d.getHours() < 12) {
          f.Suffix.selectedIndex = 0;
        } else {
          f.Suffix.selectedIndex = 1;
        }
	updateHiddenDate();
	updateHiddenTime();
      }

      // Form validation before sending data to server
      function validateForm() {
        if (f.origin.value == "") {
          alert("Starting Point is a required field");
          return false;
        }
        if (f.destination.value == "") {
          alert("Destination is a required field");
          return false;
        }
        return true;
      }

      function updateHiddenDate()
{
  f.Date.value = f.Month[f.Month.selectedIndex].value + "/" + f.Day[f.Day.selectedIndex].value + "/" + f.Year[f.Year.selectedIndex].value;
}

      // Standardization of input to reduce invalid server repsonses
      function standardize(obj) {
        var adrs = obj.value;
        var exceptions = [
          {searchTxt: "P(?:ARK)?\\s*(?:\\&|AND)\\s*R(?:IDE)?",
            replacementTxt: "PARK AND RIDE",
            changeLast: true},
          {searchTxt: "SW METRO",
            replacementTxt: "SOUTHWEST METRO",
            changeLast: true },
          {searchTxt: "ST CLAIR",
            replacementTxt: "SAINT CLAIR",
            changeLast: false },
          {searchTxt: "ST PAUL",
            replacementTxt: "SAINT PAUL",
            changeLast: false },
          {searchTxt: "ST MARYS",
            replacementTxt: "SAINT MARYS",
            changeLast: false },
          {searchTxt: "ST FRANCIS",
            replacementTxt: "SAINT FRANCIS",
            changeLast: false },
          {searchTxt: "ST ANTHONY",
            replacementTxt: "SAINT ANTHONY",
            changeLast: false },
          {searchTxt: "ST ALBANS",
            replacementTxt: "SAINT ALBANS",
            changeLast: false },
          {searchTxt: "ST CROIX",
            replacementTxt: "SAINT CROIX",
            changeLast: false },
          {searchTxt: "W BROADWAY",
            replacementTxt: "WEST BROADWAY",
            changeLast: true },
        
          // verbose directions
          {searchTxt: "NORTH",
            replacementTxt: "N",
            changeLast: false },
          {searchTxt: "SOUTH",
            replacementTxt: "S",
            changeLast: false },
          {searchTxt: "EAST",
            replacementTxt: "E",
            changeLast: false },
          {searchTxt: "WEST",
            replacementTxt: "W",
            changeLast: false },
          {searchTxt: "NORTHEAST",
            replacementTxt: "NE",
            changeLast: false },
          {searchTxt: "NORTHWEST",
            replacementTxt: "NW",
            changeLast: false },
          {searchTxt: "SOUTHEAST",
            replacementTxt: "SE",
            changeLast: false },
          {searchTxt: "SOUTHWEST",
            replacementTxt: "SW",
            changeLast: false },
          
          // replace the word "and"with an ampersand"&"
          {searchTxt: "AND",
            replacementTxt: "&",
            changeLast: false }
        ];
          
        // sort the exceptions so changebacks are done first
        exceptions.sort(function(a,b) { return a.changeLast == true ? 1 : -1 });

        // change to uppercase to make searches simpler
        adrs = " " + adrs.toUpperCase() + " ";
        // make sure there is white space after a comma
        adrs = adrs.replace(/,(\S)/, ", $1");

        // check for exceptions and replace
        for (var i = 0; i < exceptions.length; i++) {
          var re = new RegExp("\\s" + exceptions[i].searchTxt + "(,?)\\s", "g");
          adrs = adrs.replace(re, " " + exceptions[i].replacementTxt + "$1 ");
        }

        // trim whitespace
        adrs = adrs.replace(/^\s+|\s+$/g, "");

        // replace the user input with standardized input
        obj.value = adrs;
      }

	  
//today's date on /serviceInfo/snowReroutes.asp

function todayIs() {
  // Array of day names
  var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
      "Thursday","Friday","Saturday");

  // Array of month Names
  var monthNames = new Array(
      "January","February","March","April","May","June","July",
      "August","September","October","November","December");

  var now = new Date();
  return dayNames[now.getDay()] + ", " + 
      monthNames[now.getMonth()] + " " + 
      now.getDate() + ", " + now.getFullYear();
}

//date in /includes/header.asp and on /index.asp
function dateShort() {
  // Array of day names
  var dayNames = new Array("Sun","Mon","Tue","Wed",
      "Thur","Fri","Sat");

  // Array of month Names
  var monthNames = new Array(
      "Jan","Feb","Mar","Apr","May","June","July",
      "Aug","Sept","Oct","Nov","Dec");

  var now = new Date();
  return dayNames[now.getDay()] + ", " + 
      monthNames[now.getMonth()] + ". " + 
      now.getDate();
}
