function createMarker(point, text) {
 var marker = new GMarker(point);
  
 GEvent.addListener(marker, "click", function() {
  marker.openInfoWindowHtml(text);
 });
 _M.push(marker);
 _T.push(text);
 return marker;
}

function createLine(points, color, opacity, store, flag_show) {
 points.sort(function(p1, p2) {
  return p1.lng() - p2.lng();
 });
 
 var line = new GPolyline(points, color, '3', opacity);
 map.addOverlay(line);
 
 _L[store] = line;
 
 if (flag_show == 1) {
  line.show();
 }
 else {
  line.hide();
 }
 
 return line;
}

function mClick(m_num) {
 _M[m_num].openInfoWindowHtml(_T[m_num]);
}

function setML(m_num, a_or_d) {
 if (a_or_d == -1) {
  _M[m_num].setImage("http://www.google.com/mapfiles/marker.png");
 }
 else if (a_or_d == 0) {
  _M[m_num].setImage("http://www.google.com/mapfiles/markerA.png");
 }
 else {
  _M[m_num].setImage("http://www.google.com/mapfiles/markerD.png");
 }
}

function lClick(ln_hide, ln_show, mn_d, mn_a, nb_bal, nb_stat) {
 for (i = 0; i < nb_bal; i++) {
  i_show=2*i;
  i_hide=2*i+1;
 	_L[i_show].show();
  _L[i_hide].hide();
 }
 _L[ln_hide].hide();
 _L[ln_show].show();
 
 var b = _L[ln_show].getBounds();
 var b_SW = b.getSouthWest();
 var b_NE = b.getNorthEast();
 var m_lat = (b_SW.lat() + b_NE.lat()) / 2;
 var m_lng = (b_SW.lng() + b_NE.lng()) / 2;
 map.panTo(new GLatLng(m_lat, m_lng));
 
 for (i = 0; i < nb_stat; i++) {
  setML(i, -1);
 }
 setML(mn_a, 0);
 setML(mn_d, 1);
}

function resetPosition(nb_bal, nb_stat) {
 map.returnToSavedPosition();
 
 for (i = 0; i < nb_bal; i++) {
  i_show=2*i;
  i_hide=2*i+1;
 	_L[i_show].show();
  _L[i_hide].hide();
 }
 
 for (i = 0; i < nb_stat; i++) {
  setML(i, -1);
 }
}

function showhide(id){
 if (document.getElementById){
  obj = document.getElementById(id);
  if (obj.style.display == "none"){
   obj.style.display = "block";
  }
  else {
   obj.style.display = "none";
  }
 }
} 