// requires utilities.js for the addOnloadEvent/addOnunloadEvent
  
// re:prefix for all global RailEurope variables
var reMapIcons = [];
var reMapKeyHash = [];
var reMaps = [];
// Public US
reMapKeyHash["publicx.raileurope.com"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShT8IqSE8q6EyJLccf5G6VNWdObA-xTZRWbmexJvt3NjD9vRCmqOl4tl7g";
reMapKeyHash["www.raileurope.com"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRzNAFZJMtiUE5CMtqCc9IclchtXBQtYIXK4E1VZjCsO-Khe31NtJceaA";
reMapKeyHash["publicx.raileurope.com:7976"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRR1RZUO9y6u8m_pckFKrLfI2mWfxScwIGQh_9gCBnIfsIEsB0rZW7KNg";
reMapKeyHash["publicx.raileurope.com:7978"]="ABQIAAAAcqR3d1xk1djKX59fNj1Q9RQWSEWBzwu_6YpBjLCN4_g4pn-u_RT5EAhPTzCEy7AR9WmPNaBbtVPlog";
reMapKeyHash["publicx.raileurope.com:7982"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShQ3zEWo5gPKc84v1Fd7wNImDWmodBSgqPn2kj0WnE6MhW3GePdvlg8NUg";
reMapKeyHash["publicx.raileurope.com:7990"]="ABQIAAAALSzvtw6mKXVv8H8c9rcmExSdK8xtXUTKFcr07K-iLaPKPZP7ThSvMnQ1w4LYdmbwFxAC92bAa_QElA";
reMapKeyHash["publicx.raileurope.com:8080"]="ABQIAAAALSzvtw6mKXVv8H8c9rcmExTLYjQ7gKVqvNHeam41o1Z3rs_xbRTQEARiGHWT9pReRhhzetlTHGB0eQ";
reMapKeyHash["publicx.raileurope.com:8082"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShTs0cvCGPkUaiz-0oeRgcq6x0MeFBQ5H5jSQEARndMMYkZWRsaI3-cu-g";
reMapKeyHash["publicx.raileurope.com:8084"]="ABQIAAAAcqR3d1xk1djKX59fNj1Q9RSRibs8issd8ydoJSO6dAKHmUQ_9BSK1RdmQYKtvDFcD5MA4jkKTIWoMw";
reMapKeyHash["publicx.raileurope.com:8098"]="ABQIAAAAcqR3d1xk1djKX59fNj1Q9RSC_bSrevZp0duhL56iN7d4EDLiPhQTOWv1M8K9aOu6nvU-wj2RhEGMCg";
// Public Canada
reMapKeyHash["publiccax.raileurope.com"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShSysD4tD1US1xqloUcnZcP9BURQTBTCaBp_NgEw0XgVvLS8zyqIGGbHbQ";                   
reMapKeyHash["www.raileurope.ca"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShQhnceF-KdfA0pkDOj1fzzVtwWngxTBLiv9ukd9UR6mNOzxLmwk5QzVFQ";
reMapKeyHash["publiccax.raileurope.com:7976"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShQ03j9PN1hJV4GF3O5JC-dgqKIADBSjLndIgSldQZcrEpDR7x1yNag7uQ";
reMapKeyHash["publiccax.raileurope.com:7982"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShQR2wP4GS64_4F1X39TiTYm0aLN1hQd2yHLb_eE3OxgdKFI86IVtws1_g";
reMapKeyHash["publiccax.raileurope.com:8080"]="ABQIAAAALSzvtw6mKXVv8H8c9rcmExToPR51afKqwNl4zJsVjnptJhFomhScGwdlGj5dUM3N96x9Ate0GwSkQQ";
reMapKeyHash["publiccax.raileurope.com:8082"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShSO0DTax-Q3Flu8rzpo5WRPyBQpbBQ01DeTWENX5uIsxrUvRwzS4ag-WA";
reMapKeyHash["publiccax.raileurope.com:8084"]="ABQIAAAAcqR3d1xk1djKX59fNj1Q9RS9Z07sNSYTdLYxNN2Q1HOr_uMF7RTs8PPByFzym34L44icUF2Mtu-CtQ";
reMapKeyHash["publiccax.raileurope.com:8098"]="ABQIAAAAcqR3d1xk1djKX59fNj1Q9RSfueUS_Cwqy2j5sGiql4KfE0IjLRQycSQOUy0XlDPejaSEVHMT2S5Daw";
// Myswitzerland
reMapKeyHash["myswitzerlandx.raileurope.com"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShSNWZjkdDXwLD9kp0YeoHKDM05C4BTHTHf69rUmDrOAOsrnuchB-sY4UA";
reMapKeyHash["traintickets.myswitzerland.com"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShQRLYC_3Hrmw_rr0yJUiD0VDOW3tRS5pxhQJxhFWPV91h49oklL0oeGHA";
reMapKeyHash["myswitzerlandx.raileurope.com:7976"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRsxbkhQnlukzULF-px0NsZwUqExBSO_t_mcUe_mQjrhVx1I3_Q_sun6Q";
reMapKeyHash["myswitzerlandx.raileurope.com:7982"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRnzaqLmUFwA4z8RQg7yIo3wHBTXhSwvkPBdWh7ZD9HHZKTqZ-zftzOIw";
reMapKeyHash["myswitzerlandx.raileurope.com:8080"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRaIDE4FEcoLmG6puEtal7TlIuVLBTxMUOyCDRi5oov96SkkVWz5C7RSA";
reMapKeyHash["myswitzerlandx.raileurope.com:8082"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRUmNENcTDC_6mYsHDQ04n_lVArUBSn1nuabqAgnQsa134yJTKZQ1_LeA";
reMapKeyHash["myswitzerlandx.raileurope.com:8084"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRUgHVc0i8QBatpjG5zVUWAXKtyaBQtQxB_0RMCUTHh1ElcTzgAqXm8Nw";
reMapKeyHash["myswitzerlandx.raileurope.com:8098"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShQZ_tQQJNIQ5oRs1WsZ1Y1aCyTiaxT37aO2HIvfYxKmo1DFI4Q2ni1L4w";
// Agent  
reMapKeyHash["agentx.raileurope.com"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRlPUGAhMLN-tUlJ0JOM8jTDwxvABStzY1mrt1nQUu9ENu9HI4A3NYlQg";
reMapKeyHash["agent.raileurope.com"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShTrYV_BuhzIK0ekYox01biDYpj3YRQSRgQAYh5nKWv2vgBGgHSW4UT-jQ";
reMapKeyHash["agentx.raileurope.com:7976"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRV0HUvsOpl9Pqo6SMQhE3mdY4BpBRj_cS2tU1tPJpg9uIdrkcgqYL3Dg";
reMapKeyHash["agentx.raileurope.com:7982"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShT9OwLhKvaqdkLutcfQBB9F6ibpTRT6IhcbC3zVLjjDgHa5wlfMllYxoA";
reMapKeyHash["agentx.raileurope.com:8080"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShTIYoO0tM-a3_g_8Sky3gugehr8oxQX2Zh1MLkU8ouHIrrkV0mO8RJP7g";
reMapKeyHash["agentx.raileurope.com:8082"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShTb-i5WapaqqeLyNTA_MGhMtq3yVRSQZe2rJTM8mQTJPygl7gIUCVO4BA";
reMapKeyHash["agentx.raileurope.com:8084"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShQmNKcREmZ1HB8hJFL7am-AK9Nl1BSrhi9pPJTV6UEwjBaO5vqSN1bsBA";
reMapKeyHash["agentx.raileurope.com:8098"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRv3Fys-c5qRuJ7ucLD6gCzAsN26RRt5qSTxRODV79Ar7VQjW9UZto-3Q";
// Agentca
reMapKeyHash["agentcax.raileurope.com"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRAZT-CgH3b8TsxcNKCO9Po1bR2yBRtkABSZz1x2BP2fkhUDrb6ZUm7PA";
reMapKeyHash["agent.raileurope.ca"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShQaz_gMbqM-FnPQv0VgqDGpp1M89xSR5XxXofJBxPVSlKbfhaYb0IxfCA";
reMapKeyHash["agentcax.raileurope.com:7976"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShSpCxYHbKiaGSVVdOG4QmF50kPb1xR-ZttL4mYd4KQMXU5Mcqavp2iqbA";
reMapKeyHash["agentcax.raileurope.com:7982"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShTYFVx8aMl6BZtU0SGnCI4cGO4alhQ0L2ukGmR-gA-GeBIeGPB9itc_Rg";
reMapKeyHash["agentcax.raileurope.com:8080"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShTTomBiteAN0PVkGXHODqPBGagt0BRiu6ZNMJeGVnq0_mL_m-2xZuojXQ";
reMapKeyHash["agentcax.raileurope.com:8082"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShQD1AK3UQDOza_rtOuwNN1-81CjhRTW3q1glk83CYgGlVpA8pejEJPzLg";
reMapKeyHash["agentcax.raileurope.com:8084"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShSneqLnLpuB5GSkMlp9MSYP8MZ8BBTaWZX0LoQA0JWvZi64MQ0LAbLz2Q";
reMapKeyHash["agentcax.raileurope.com:8098"]="ABQIAAAA870VeoE0UwGR_0-gdeBLShRqd_aJ7DaVhYleq3Mb95Tq86YtkhTfyGP6poDulOJb02ATKP9Sigb9SQ";

// Travelocity
reMapKeyHash["travelocityx.raileurope.com:8098"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxQFmPaA_TaI0zFHc6IrFVszN8PDzBRg4YDGYFM0EoYIf05uvcMhlMe9GA";
reMapKeyHash["travelocityx.raileurope.com:8082"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxRgIhZRHQTca3WNi9FXHGwzWe5-4hR9gyMK7CnusumT7YUn7t31ppZTLA";
reMapKeyHash["travelocitycax.raileurope.com:8082"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxRIjjeSqiNg8OFdwcbVME3IhCZvXhRsCiblXUpsL1ZD1Vs5cFrPM0fawQ";

reMapKeyHash["travelocity.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxSKh7mNs4NBGFhoOJTmY9Z9x9NKIBTAMtXNhUptfiQftDTiuJiPKZizwQ";
reMapKeyHash["travelocity.raileurope.ca"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxRSBxuG9RBFWg3wlX1hymATjn1GmxSPFlvsMmcHxwvgTUW5KscyNzsAfg";

// Oct 15 launch cobrands

reMapKeyHash["autoeuropex.raileurope.com:8082"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxTJEqmq8DzlLW2GvvcWJL0DcgzNNhT07uDIVp9VkmP0CzJWN97_V4cRNQ";
reMapKeyHash["autoeurope.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxRdkw869KOdlw-Ppm4UT1mhXF-3uBS6iQJqFMnm_pmhPz24LK4GBWA3Qg";

reMapKeyHash["travelcutscax.raileurope.com:8082"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxQcpOj6y1Ux0fGp8fjsP9z1Kqw8AxQTt5jPQShcieGzNGCm0NFNnZ3nmA";
reMapKeyHash["travelcutsca.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxS5o86tRkdHO83IEOdZhiIiXbS-vhSLtB6dZxFsSdlqY7evCds8UCNnMg";

reMapKeyHash["travelcutsusx.raileurope.com:8082"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxR50aKJAgVhzAMQGBbI2PwWT9Qo2RSDcApunUAOYlx6ZwxVGxOEE2IO_w";
reMapKeyHash["travelcutsus.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxROkQbd0yhZD-UlkEmAlC5GXluDqBSNt0AbZXFuXzjhbwGyHNZDQ59OLA";

reMapKeyHash["vacationsbyrailx.raileurope.com:8082"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxRSGj_4m87VxSI-HE2S5YlnlakNoRQegpsvx25tRwSdwnHTMuMLrW1smQ";
reMapKeyHash["vacationsbyrail.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxSvLj9i72LOQnPgGgxQNvXt1MWAJRRV7T88FsJlycb8Mrd2xrI6PDvNzg";

reMapKeyHash["autoeurope.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxRdkw869KOdlw-Ppm4UT1mhXF-3uBS6iQJqFMnm_pmhPz24LK4GBWA3Qg";
reMapKeyHash["travelcutsca.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxS5o86tRkdHO83IEOdZhiIiXbS-vhSLtB6dZxFsSdlqY7evCds8UCNnMg";
reMapKeyHash["travelcutsus.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxROkQbd0yhZD-UlkEmAlC5GXluDqBSNt0AbZXFuXzjhbwGyHNZDQ59OLA";
reMapKeyHash["vacationsbyrail.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxSvLj9i72LOQnPgGgxQNvXt1MWAJRRV7T88FsJlycb8Mrd2xrI6PDvNzg";

// Oct 29 launch cobrands

reMapKeyHash["aaa.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxRy5CKxNuEjD6OytubuUr48dUM8JRQ5SbY0dMvaiQ6VMWCAOdx76GAnHQ";
reMapKeyHash["aaapublicx.raileurope.com:8082"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxQ9N2UujM9AeBidRMWO8cZhVImaqRSRDLrIubECCvHAW0Gjec9chSIO_w";

reMapKeyHash["aaapubliccax.raileurope.com:8082"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxT_o-Wfrq3TMw3Msf9IGPXNewCHvBQWMjaVab0Ec0Tg1cRwDitM8rt9fA";
reMapKeyHash["aaa.raileurope.ca"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxQ77RLTKGC3ohrAaCBHtCtBDT02SRSaudk-p3RNwx1__a_1YNsp_Np4Bw";

reMapKeyHash["rickstevesx.raileurope.com:8082"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxTW7lO-KgYBV-xDsYRHw32DnsS5TBQSnKyKp1Dxj7tIDH69RG0XXdH0PQ";
reMapKeyHash["ricksteves.raileurope.com"]="ABQIAAAAXV43FzD9UR1_ru5EPXuHAxS_zlhOXC-XPfeKXrT826nMT5WghBQdKww48wfslVsCLgvmFCNkJp19kA";


var reMapKey = getRegMapKey();
// alert("key="+reMapKey);
if (reMapKey == null) {
  alert("There is no Google Maps API key avaiable for this web site " +
    window.location.host +
    ".\nYou can generate a new key at http://code.goo"+
    "gle.com/apis/maps/signup.html");
}
else {
  document.write(unescape("%3Cscript src='http://maps.goo"+
    "gle.com/maps?file=api&amp;v=2&amp;key=" + reMapKey + 
    "' type='text/javascript'%3E%3C/script%3E"));
}
  
// Provides a layer of abstraction to get the REG map key
function getRegMapKey() {
  return reMapKeyHash[window.location.host];
}

/** ======================================================================
 * Adds an icon type to the icon collection
 * ======================================================================*/  
function setupIcons() {
  reMapIcons["start"]= new GIcon(G_DEFAULT_ICON, "/img/maps/colour086.png"); // yellow
  reMapIcons["end"]  = new GIcon(G_DEFAULT_ICON, "/img/maps/colour108.png"); // purple
  reMapIcons["mid"]  = new GIcon(G_DEFAULT_ICON, "/img/maps/colour125.png"); // white  
  reMapIcons[0]=true; // an indicator that the array has been initialized
}
  
/** ======================================================================
 * This fuction serves as an example of the multiple maps on a page.
 * It is called when the page is loaded - uses div id="map0" and id="map1"
 * ======================================================================*/
function mapExample() {
  setupMap(0);
  setupMap(1);
}

/** ======================================================================
 * Creates and draws the map with points and polyline on the given div
 * It is called when the page is loaded
 * ======================================================================*/
function setupMap( index ) {
  if ( reMapKey!=null && GBrowserIsCompatible() ) 
  {
    var divName = "map"+index;
  
    var points = []; // array of points GLatLng(lat,lng)
    points["london"]  = new GLatLng(51.503186376638006,-0.113983154296875);
    points["ashford"] = new GLatLng(51.14510969340906,0.8704948425292969);
    points["dover"]   = new GLatLng(51.114084037020504,1.3128662109375);
    points["calais"]  = new GLatLng(50.91299128345898,1.8051910400390625);
    points["lille"]   = new GLatLng(50.62768660650907,3.044586181640625);
    points["paris"]   = new GLatLng(48.865618158309374,2.3490142822265625);
    
    var stations = [];
    stations["london"]  = '["Train station", "Attriactions", "Hotels"],["<b>St. Pancras train station</b><br/> is located in a central London","There are countless turist attractions<br/> but not limited to  <li>galleries</li><li>museums</li><li>concerts</li>","Seach for hotel in <a href=\\"http://www.raileurope.com/us/hotels/index.htm?countryCode=GB&cityName=London\\">London</a><br/><img src=\\"image.jpg\\"/>"]';
    stations["ashford"] = '<b>Ashford</b> station in England.';
    stations["dover"]   = '<b>Dover</b> station in England.';
    stations["calais"]  = '["Tab label"],["<b>Calais</b> station in France.<br/> has a plain info with no tabs"]';
    stations["lille"]   = '["Train station", "Info"],["<b>Lille</b> station in France.<br/> has a great newly build train terminal<br/>with many great restaurants and caffe shops", "Its the time to decide to go <br>to Paris or Amsterdam"]';
    stations["paris"]   = '["One","Two","Three","Four"],["Tab 1 contents", "Tab 2 contents","Tab 3 contents","Tab 4 contents"]';
  
    // create the markers
    var markers = [];
    markers.push(getMarker('London', 'start', points["london"], stations["london"]));
    markers.push(getMarker('Ashford', 'mid', points["ashford"], stations["ashford"]));
    markers.push(getMarker('Dover', 'mid', points["dover"], stations["dover"]));
    markers.push(getMarker('Calais', 'mid', points["calais"], stations["calais"]));
    markers.push(getMarker('Lille', 'mid', points["lille"], stations["lille"]));
    markers.push(getMarker('Paris', 'end', points["paris"], stations["paris"]));
    
    createMap(divName, markers);
  }
}
  
/** ======================================================================
 * Creates and draws the ptp map with points and polyline on the given div
 * ======================================================================*/  
function createPtpMap( divName, markers) { 
  // create the polyline
  var color = "#10C3F7"; var weight = 5; var opacity = 0.6;
  var polyline = createPolyline(markers, color, weight, opacity);
  var bounds = polyline.getBounds();
  
  // create the map
  var map = new GMap2(document.getElementById(divName));
  map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
  
  // Attached the poliline parameters to map
  map.poliColor = color;
  map.poliWeight = weight;
  map.poliOpacity = opacity;
  
  // Sets the map type
  map.addMapType(G_PHYSICAL_MAP);
  map.setMapType(G_PHYSICAL_MAP);
  
  map.removeMapType(G_NORMAL_MAP);     // removes default road type
  map.removeMapType(G_SATELLITE_MAP);  // removes satelite
  map.removeMapType(G_HYBRID_MAP);     // removes hybrid
  
  // Add controls
  map.addControl(new GSmallMapControl());

  // Draw markers on the map
  for( var marker in markers) {
    map.addOverlay(markers[marker]);
  }
  
  // Draw the polyline
  var drawPoli = (createPtpMap.arguments[2]!=null)? 
    createPtpMap.arguments[2]:  true;
  
  if( drawPoli ) map.addOverlay(polyline);
  
  // Saves map reference
  reMaps.push(map);
  return map;
}
  
/** ======================================================================
 * Creates and draws the map with points and polyline on the given div
 * ======================================================================*/
function createMap(divName, markers) 
{ 
  // alert("Entering createMap with divName="+divName+".")
  // create the polyline
  var color = "#FF0000"; var weight = 6; var opacity = 0.5;
  var polyline = createPolyline(markers, color, weight, opacity);
  var bounds = polyline.getBounds();
  
  // create the map
  var map = new GMap2(document.getElementById(divName));
  map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
  
  // Sets the map type
  map.addMapType(G_PHYSICAL_MAP);
  map.setMapType(G_PHYSICAL_MAP);
  
  // keep the normal map for country name in the overview (small) window
  // map.removeMapType(G_NORMAL_MAP);   // removes default road type
  map.removeMapType(G_SATELLITE_MAP);   // removes satelite
  map.removeMapType(G_HYBRID_MAP);      // removes hybrid
  
  // Add controls
  map.addControl(new GMenuMapTypeControl(true)); // displays selection
  // map.addControl(new GMapTypeControl());    // displays all map types 
  // map.addControl(new GScaleControl());      // displays scale 
  
  //map.addControl(new GLargeMapControl());
  map.addControl(new GSmallMapControl());
  //map.addControl(new GOverviewMapControl());
  var mini = new GOverviewMapControl();   //Set up overview control
  map.addControl(mini);                   //Add overview control 
  mini.hide();                            //minimize overview

  // Sets options
  // map.enableGoogleBar();
  // map.enableScrollWheelZoom();
  
  // Draw markers on the map
  for( var marker in markers) {
    map.addOverlay(markers[marker]);
  }
  
  // Draw the polyline  
  map.addOverlay(polyline);
  
  // Saves map reference
  reMaps.push(map);
  return map;
}
  
/** ======================================================================
 * A function to add a marker for a given city, icon type, point and description
 * Based on the icon type (start, mid, end) a different icon is drawn
 * ======================================================================*/
function getMarker( city, type, point, html ) {
  // alert("Entering getMarker() with city="+city+", type="+type+", point="+ point+", html="+html+".");
  // Create an associative array of GIcons()
  if( reMapIcons.length == 0 ) setupIcons();
  
  var icon = reMapIcons[type];
  var index = html.indexOf("],[");
  if( index == -1) return createMarker(point, icon, html, city);
  
  var labels = html.substring(0, index+1); //alert("labels="+labels);
  var htmls= html.substring(index+2);      //alert("htmls="+htmls);
  return createTabbedMarker(point, icon, eval(htmls), eval(labels), city);
}
  
/** ======================================================================
 * A function to create the marker and set up the event window
 * at specified point with given icon, html and name
 * ======================================================================*/
function createMarker(point, icon, html, name) {
  //creates a marker with specified icon
  var marker = new GMarker(point, {icon:icon, title:name});
  // add event handler for 'click'
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html);
  });
  return marker;
}
  
/** ======================================================================
 * A function to create a tabbed marker and set up the event window,
 * accepts a variable number of tabs, passed in arrays of labels and htmls
 * ======================================================================*/
function createTabbedMarker(point, icon, htmls, labels, name) {
  var marker = new GMarker(point, {icon:icon, title:name});
  GEvent.addListener(marker, "click", function() {
    // adjust the width so that the info window is big enough for many tabs
    if (htmls.length > 2) {
      htmls[0] = '<div style="width:'+htmls.length*88+'px">'+htmls[0] +'</div>';
    }
    var tabs = [];
    for (var i=0; i<htmls.length; i++) {
      tabs.push(new GInfoWindowTab(labels[i],htmls[i]));
    }
    marker.openInfoWindowTabsHtml(tabs);
  });
  return marker;
}
  
/** ======================================================================
 * A function to create a polyline (does not draw one)
 * Accepts an array of markers (not vertexes) and other display arguments
 * ======================================================================*/
function createPolyline(markers, color, weight, opacity) {
  var size = (markers==null)? 0 : markers.length;
  if(size < 2) return;
  
  // This code is for a line with two and more points
  var vertexes = [];
  for( var marker in markers) {
    vertexes.push(markers[marker].getLatLng());
  }
  return new GPolyline( vertexes, color, weight, opacity );
}

