var current_tab = "infos";
var GM;

function init_googemap(lat, long){
  GM = new GoogleMap();
  GM.Map_type_control = false;
  GM.Zoom = 12;
  GM.Load();
  
  if(lat != "" && long != ""){
    points = new GLatLng(lat, long);
    GM.Map.setCenter(points);
    GM.Map.addOverlay(new GMarker(points));
  }
}

function display_map(lat, long){
  small_map = document.getElementById('small-map');
  big_map = document.getElementById('big-map');
  map_container = document.getElementById('map-container');
  map = document.getElementById('map');

  big_map.innerHTML = '';

  /* on ajoute le noeud dans le grand cadre */
  big_map.appendChild(map_container);
  big_map.style.display = 'block';

  map.style.width = '450px';
  map.style.height = '350px';

  /* on affiche le lien de fermeture */
  big_map.getElementsByTagName('a')[0].style.display = 'none';
  big_map.getElementsByTagName('a')[1].style.display = 'block';

  init_googemap(lat, long);

  return false;
}

function hide_map(lat, long){
  small_map = document.getElementById('small-map');
  big_map = document.getElementById('big-map');
  map_container = document.getElementById('map-container');
  map = document.getElementById('map');

  big_map.style.display = 'none';
  big_map.innerHTML = '';

  /* on ajoute le noeud dans le petit cadre */
  small_map.appendChild(map_container);
  small_map.style.display = 'block';

  map.style.width = '150px';
  map.style.height = '100px';

  /* on affiche le lien d'ouverture */
  small_map.getElementsByTagName('a')[0].style.display = 'block';
  small_map.getElementsByTagName('a')[1].style.display = 'none';

  init_googemap(lat, long);

  return false;
}

function init_tabs(tabs_container){
  if(!document.getElementById(tabs_container)) return false;
  
  // Récupere le nom dans l'url de l'onglet à afficher
  var Url = location.href;
  start   = Url.indexOf('#');
  if(start != -1)
    Tab     = Url.substr(start+1);
  else
    Tab     = false;
  //==========================================
  
  display_tab((Tab) ? Tab : current_tab);
  
  Tabs = document.getElementById(tabs_container).getElementsByTagName('a');
  for(var i=0 ; i < Tabs.length ; i++){
    Tabs[i].onclick = function(){
      this.blur();
      
      start = this.href.indexOf('#');
      if(start != -1) tab = this.href.substr(start+1);
      display_tab(tab);
    }
  }
}

function display_tab(tab){
  document.getElementById(current_tab+'_content').style.display = "none";
  document.getElementById(tab+'_content').style.display = "block";
  
  document.getElementById(current_tab+'_tab').className = '';
  document.getElementById(tab+'_tab').className = "select";
  
  current_tab = tab;
}