// JavaScript Document

function ResetRecherche()
{
  document.forms['formNavSearch'].elements['fieldSearch'].value = '';
}

function LaunchOnload(path,boolAnnonce)
{
  //if (boolAnnonce == '1'){  AfficheAnnonce(path); }
  boutique();
  initializeGoogleMap();
}

function refresh_boutique()
{     
code_html = '<a href="'+pictures[chiffre]+'" target="_blank"><img class="BoutiqueAccueil" src="'+pictures[chiffre]+'"><\/a>';
document.getElementById("tdBoutique").innerHTML = code_html;

	if(chiffre == longueur)
        { chiffre = 0; }
        else
        { chiffre++; }
changement = 3;
//durée d'affichage d'une bannière en secondes
window.setTimeout("refresh_boutique()", (changement*1000));
}

function boutique()
{ 
pictures = new Array();
if (self.location.href.indexOf("localhost:8008") > 0 )
{
  path = 'http://localhost:8008/arlexv/donnees/boutique/';
}
else if(self.location.href.indexOf("www2") > 0 )
{
  path = 'http://www2.arlexv.org/donnees/boutique/';
}
else
{
  path = 'http://www.arlexv.org/donnees/boutique/';
}

pictures[0] = path+'polo_ntk.jpg';
pictures[1] = path+'polo_rose.jpg';
longueur = pictures.length-1;
chiffre = 0;

 refresh_boutique();

}
      

function initializeGoogleMap()
{
  if (GBrowserIsCompatible()) 
  {
    map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(43.623, 1.409), 11);
    map.addControl(new GLargeMapControl3D());
    map.addControl(new GScaleControl());
    map.addControl(new GMapTypeControl());
    map.addControl(new GOverviewMapControl());
    map.setUIToDefault();
     
    geocoder = new GClientGeocoder();
  }

  showAddress();

}

function showAddress() 
{
  commune = document.getElementById("js_commune").value; 
  address = document.getElementById("js_address").value;
  name = document.getElementById("js_name").value;
  tel = document.getElementById("js_tel").value;
  mail = document.getElementById("js_mail").value;
  //imgPath = document.getElementById("js_imgPath").value;
  
  if (geocoder) {
    geocoder.getLatLng(
      address,
      function(point) {
        if (!point) {
          alert(address + " not found");
        } else {
          //map.setCenter(point, 13);
          var marker = new GMarker(point);
          map.addOverlay(marker);

          // As this is user-generated content, we display it as
          // text rather than HTML to reduce XSS vulnerabilities.
          var infoText = name + "<br>" + tel + "<br>" + mail + "<br>" + address + '&nbsp;' + commune/*+ "<br><img src=\""+imgPath+"\" width=\"150\" >"*/;
          GEvent.addListener(marker, "click", function(){marker.openInfoWindow(infoText);marker.hidePopup(); });
          //marker.openInfoWindow(document.createTextNode(infoText));
          marker.openInfoWindow(infoText);              
        }
      }
    );
  }
}
