/*
* @name       itinerary.js
* @updated    20th July 2008
* 
* Description
* Itinerary routeens to switch between days 
*/

// Globals
var map         = null;
var geocoder    = null;

/*
* @name       initItinerary();
*
* Description
* 
*/
function initItinerary() {  
  if(GBrowserIsCompatible()) { 
    map      = new GMap2(document.getElementById('googlemap'));
    geocoder = new GClientGeocoder();
  }
}

/*
* @name       changeItinerary(number, max, address, description);
*
* Description
* Changes the day and map details
*/
function changeItinerary(number, max, address, description) {  
  // Hide all days
  for(i=1; i<=max; i++) {
    document.getElementById('day' + i).style.display = 'none';
  }
  
  // Show relevant day
  document.getElementById('day' + number).style.display = 'block';
    
  // Do map location
  if(geocoder) {
    geocoder.getLatLng(
      address, 
      function (point) {
        if(!point) {
        
        } else {
          var marker = new GMarker(point);    
          map.setCenter(point, 5);
          map.setMapType(G_HYBRID_MAP);
          map.addControl(new GLargeMapControl());    
          map.addOverlay(marker);
          marker.openInfoWindowHtml(description);
        } 
      }
    ); 
  }

  return true;
}


function hideItinerary(number) { 

// Hide relevant day
  document.getElementById('day' + number).style.display = 'none';
  return true;
}