﻿var map = 0 ;
var mx = new Array(),htmlx = new Array();
var Pestanya = "" ;

function sobreenllass(t)
{
  if (Pestanya == "Fotos") 
  {
    var id = "f" + t.id.toString().substring(1) ;
    foto = document.getElementById(id) ;
    foto.style.backgroundColor="#FABF00" ;
  }
  else
  {
    try
    {
      GEvent.trigger(mx[t.id.toString().substring(1)], "click") ;
    } catch(e)
    {
    };
  }
}
function foraenllass(t)
{
  if (Pestanya == "Fotos")
  {
    var id = "f" + t.id.toString().substring(1) ;
    foto = document.getElementById(id) ;
    foto.style.backgroundColor="white" ;
  }
}
function sobrefoto(t)
{
  var id = "a" + t.id.toString().substring(1) ;
  enllass =  document.getElementById(id) ;
  enllass.style.backgroundColor="#FABF00";
}
function forafoto(t)
{
  var id = "a" + t.id.toString().substring(1) ;
  enllass =  document.getElementById(id) ;
  enllass.style.backgroundColor="white";
}
function Activa(que)
{
  // alert ("Activa(" + que + ")") ;
  var tabMapa = document.getElementById("TabMapa") ;
  var tabFotos = document.getElementById("TabFotos") ;
  var pMapa = document.getElementById("PMapa") ;
  var pFotos = document.getElementById("PFotos") ;
  if (que == "Mapa")
  {
    tabMapa.style.display="block" ;
    tabFotos.style.display="none" ;
    pMapa.className = "TabIndex on" ;
    pFotos.className = "TabIndex" ;
    if (map == 0)
      pinta_mapa () ;
  }
  else
  {
    tabMapa.style.display="none" ;
    tabFotos.style.display="block" ;
    pMapa.className = "TabIndex" ;
    pFotos.className = "TabIndex on" ;
  }
  Pestanya = que ;
}
function e(id,lat,lng,titol,cfoto,amp,alt,alt_div)
{
  mx[id] = new GMarker(new GLatLng(lat,lng), {title:titol, clickable:true});
  map.addOverlay(mx[id]) ;
  htmlx[id] = "<div class=\"m\" style=\"height:" + (alt_div+10) + "px;\"><h5>" + titol + "<\/h5><a href=\"element.php?e=" + id + "\"><img alt=\"" + titol + "\" src=\"fotos/mini/" + cfoto + ".jpeg\" style=\"width:" + amp + "px;height:" + alt + "px;\"><br\/>Vés-hi<\/a><\/div>" ;
  GEvent.addListener(mx[id], "click", function() { mx[id].openInfoWindowHtml(htmlx[id]);});
}
function load_municipi() 
{ 
  var i,enllass,foto ;
  Activa('Fotos') ;
  for (i = 0 ; i < elems.length ; i++)
  {
    enllass = document.getElementById("a" + elems[i]) ;
    foto = document.getElementById("f" + elems[i]) ;    
    enllass.onmouseover = function() {sobreenllass(this)} ;
    enllass.onmouseout = function() {foraenllass(this)} ;
    foto.onmouseover = function() {sobrefoto(this)} ;
    foto.onmouseout = function() {forafoto(this)} ;
  }
}