/* These functions enact the restriction against one-way flights originating in a foreign country
 * where we do not yet have permission.
 *
 * To Add origin-restrictions:
 *    1.  Define a popup warning message that will be displayed if the customer
 *        attempts to purchase a one-way ticket to the restricted city.  Follow
 *        the example of CITY-CODE + '_restrictedPopup' when naming the variable.
 *    2.  Add your city code to the list of restricted city codes in the
 *        array aRestrictedCityList.
 * To Remove origin-restrictions:
 *    1.  Delete the popup message variable for the restricted city.
 *    2.  Remove the city code from the list of restricted city codes  in the
 *        array aRestrictedCityList.
 *
 */

// Define your popup messages here: (EXAMPLE: MBJ)
//MBJ_restrictedPopup= "***Disclaimer***\n\nPurchasing a one way flight to Montego Bay, Jamaica does not guarantee return to originating city. Return service on JetBlue Airways from Sangster International Airport is subject to receipt of Jamaican operating authority and is NOT currently available for purchase except as part of a roundtrip itinerary.\n\nTravel currently must be purchased and originate in the United States only; itineraries that begin in Montego Bay will be available for sale at a later date, pending final government approval."
// ???: Add more here as necessary.



// Update your origin-restrictions here: (EXAMPLE: MBJ)
var aRestrictedCityList = new Array (
	//'MBJ',
	0
	);





/******************************************************************************
 ******************************************************************************/

// helper to compare cityCode against aRestrictedCityList
function IsCityOriginRestricted (cityCode)
{
  for (i=0;i<aRestrictedCityList.length;i++)
  {
    if (aRestrictedCityList[i] && (aRestrictedCityList[i] == cityCode))
      return true;
  }
    
  return false;
}

// Detect and alert certain cities:
function ExcludeFromOrigin (panelID, cityCode)
{
  if ( panelID.match('From') && cityCode )
  {
  	return IsCityOriginRestricted( cityCode );
  }

  return false;
}

function OWAlert(cityCode)
{
  if (IsCityOriginRestricted( cityCode ))
  {
    popupVar = cityCode + '_restrictedPopup';
    if (eval ("typeof(" + popupVar + ") != 'undefined'"))
    {
      alert(eval(popupVar));
      return true;
    }
  }

  return false;
}
