/* MAPS
------------------------------------------------------------------ */
var Map = {
  
  load_map: function(latitude, longitude, target) {
    if (GBrowserIsCompatible()) {
      this.latlong = new GLatLng(latitude, longitude);
      this.map = new GMap2(document.getElementById(target));
      this.map.removeMapType(G_SATELLITE_MAP);
      this.map.addControl(new GSmallZoomControl());
      this.map.addControl(new GMapTypeControl());
      this.map.setCenter(this.latlong, 15);
      this.map.addOverlay(new GMarker(this.latlong));
      $('.content_map > .enlarge').click(this.handle_enlarge);
    }
  },
  
  handle_enlarge: function(e) {
    e.preventDefault();
    if ($('.content_map').height() < 200) {
      $('a', this).text('Shrink map');
      $('#event_place_map').animate({height:400}, 500, this.re_center_map);
    }
    else {
      $('a', this).text('Enlarge map');
      $('#event_place_map').animate({height:150}, 500, this.re_center_map);
    }
  },
  
  re_center_map: function(e) {
    this.map.checkResize();
    this.map.panTo(this.latlong);
  }
}


/* These vars need to be global
------------------------------------------------------------------ */
time_control = new setupAdControl({'time': 30, 'positions':  {'primary': '#primary_ad .spot'}});
views_control = new setupAdControl({'views': 3, 'positions':  {'primary': '#primary_ad .spot'}});
ad_control = views_control;
no_adcontrol = null;


/* ON LOAD
------------------------------------------------------------------ */
$(function() {
  avatar_init();
  daypart_init();
  module_init();
  // nav_init();
  popup_init();
  // share_init();
  sidebar_calendar_init();
  video_player_init();
  search_init();
  tabbed_content_init();

  $('.carousel_show_one').carousel({show: 1, showPageControls:true});
  $('.carousel_show_two').carousel({show: 2, showPageControls:true});
  
  // remove silly ui-accordian-left/right spans all up in my markup
  $('.module > span').remove();
  // Now that those are gone, this'll work
  $('.module h2:first-child').addClass('top');
  
});
