// JavaScript Document
//
//  Version: 1.0
//  Date: 1/19/2010
//  Author: Bill Gude, Big Bear Studios
//  Client: Sacramento Bike Hikers
//
//  These functions works with the SigUp.php5 page
//
//  The listener looks for a "onChange" event for the
//  selection dropdown widget (id="goalSet") then calls the function
//  "newGoalSelection" to update the goal field.
//
//  The newGoalSeclection function updates the input text field (id="goal")
//  with the new goal string.


  // NEW GOAL SELECTED FOR DROPDOWN LIST
  //
  //   Functions takes the newly selected dropdown item and updates
  //   the "goals" field on the SignUp.php5 page
  //
  function newGoalSelection()
  {
    
    // clear the span element "targetDate"
    var goalField = document.getElementById("goal");
    var selWidget = document.getElementById("goalList");
    var selectTxt = selWidget.value;
    nTxt = document.createTextNode(selectTxt);
    oTxt = goalField.value;
    goalField.value = selectTxt;
    
  } // newGoalSelection()




// This must run only after page_load
var goalWatchStart =
{
  init: function()
  {
     // Get the Selection field for the goals list
     // alert("goalWatchStart.init:  ");
     var goalSelected = document.getElementById( "goalList" );
     Core.addEventListener( goalSelected, 'change', goalWatchStart.submitListener);

  },  
  submitListener: function(event)
  {
    newGoalSelection();
  } //submitListener.function
} // formWatchStart

Core.start(goalWatchStart);


