// JavaScript Document

 function file2(fichier)
{
	if(window.XMLHttpRequest) /*FIREFOX*/ xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) /*IE*/  xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else return(false); 
	tmp = Math.random(); 
	xhr_object.open("GET", fichier, false); 
	xhr_object.send(null); 
	if(xhr_object.readyState == 4)
	 return(xhr_object.responseText);
	else 
	return(false);
}
function rnd() {
	ord=Math.random();
	ord=ord*10000000000000000000;
	return ord;
}

// 
function  fct_programmesPrevisionnel( div,a ) {
	 if ( texte = file2( '../programmesPrevisionnels.php?id_rub='+a+'&rnd='+ rnd() ) ) {
	        document.getElementById(div).innerHTML = texte;
	 }
	 
}
function   fct_telechargement( div,a ) {
	/* if ( texte = file2( '../programmesPrevisionnels.php?type=Telechargement&id_rub='+a+'&rnd='+ rnd() ) ) {
	        document.getElementById(div).innerHTML = texte;
	 }
	 */
	 
}

function  fct_filial( idAvenu ) {
	
	 if ( texte = file2( '../stationAvenu.php?avenu='+idAvenu+'&rnd='+ rnd() ) ) {
	        document.getElementById('divStation').innerHTML = texte;
	 }
	 
	 //****Trace en couleur
	 /* Si le navigateur est compatible avec l'API de Google Maps ... */
	if (google.maps.BrowserIsCompatible()) {
  /* ... fichierXML : Fichier au format XML que l'on charge pour l'afficher sur la carte ... */
  // var url= "http://maps.google.fr/maps/ms?ie=UTF8&hl=fr&vps=1&jsv=154c&oe=UTF8&msa=0&msid=115115239782170342035.00045c5d8b68ccf0d0247&output=kml";
	 fichierXML = new google.maps.GeoXml(url);
  /* ... Création d'une nouvelle carte nommée "maCarte" qui s'affichera à l'intérieur de la balise <div> ayant pour identifiant id="EmplacementDeMaCarte" ... */
     maCarte    = new google.maps.Map2(document.getElementById("EmplacementDeMaCarte"));
  /* ... La carte nommée "maCarte" est centrée sur la Latitude 48.159444, la Longitude 0.099907, avec un niveau de zoom égal à 12 ... */
     maCarte.setCenter(new google.maps.LatLng(33.590443,-7.592089), 13);
  /* ... Affiche les boutons et contrôles identiques à ceux que l'on trouve sur http://maps.google.fr ... */
     maCarte.setUIToDefault();
  // Definir la surface a voir 
     GEvent.addListener( maCarte, "move", function() {
     checkBounds();
     });
	 
	 var allowedBounds = new GLatLngBounds( new GLatLng(33.255909,-8.50783), new GLatLng(33.706379,-7.389274) );
        // If the map position is out of range, move it back
     function checkBounds() 
	 {
			// Perform the check and return if OK
			if ( allowedBounds.contains(maCarte.getCenter())) {
			     return;
			}
			// It`s not OK, so find the nearest allowed point and move there
			var C = maCarte.getCenter();
			var X = C.lng();
			var Y = C.lat();
	 
			var AmaxX = allowedBounds.getNorthEast().lng();
			var AmaxY = allowedBounds.getNorthEast().lat();
			var AminX = allowedBounds.getSouthWest().lng();
			var AminY = allowedBounds.getSouthWest().lat();
	 
			if (X < AminX) {X = AminX;}
			if (X > AmaxX) {X = AmaxX;}
			if (Y < AminY) {Y = AminY;}
			if (Y > AmaxY) {Y = AmaxY;}
			//alert ("Restricting "+Y+" "+X);
			maCarte.setCenter(new GLatLng(Y,X));
      }
	  // 
      var mt = maCarte.getMapTypes();
      // Overwrite the getMinimumResolution() and getMaximumResolution() methods
      for (var i=0; i<mt.length; i++) {
         mt[i].getMinimumResolution = function() {return 12;}
        // mt[i].getMaximumResolution = function() {return 18;}
      }
      // fin de la surface à voir
  
	 
     maCarte.addOverlay( fichierXML );
	 if ( newTrace = file2('../trace.php?idAvenu='+idAvenu+'&rnd='+ rnd() ) )
	 {
	     eval( newTrace );
	 }
    } else {
      /* ... affichage du message "Désolé, mais votre navigateur n'est pas compatible avec Google Maps". */
      alert('Désolé, mais votre navigateur n\'est pas compatible avec Google Maps');
    }

	 
	 
	 //***fin 
	 
}

