// JavaScript Document

var map 		= null;
var geocoder 	= null;
    // A TextualZoomControl is a GControl that displays textual "Zoom In"
    // and "Zoom Out" buttons (as opposed to the iconic buttons used in
    // Google Maps).
function fermer()
{
	document.getElementById("tab_icones").style.visibility 	= "hidden";
	document.getElementById("zoomin").style.visibility 		= "hidden";
	document.getElementById("zoomout").style.visibility 	= "hidden";
	document.getElementById("imprimer").style.visibility 	= "hidden";
	document.getElementById("fermer").style.visibility 		= "hidden";
	document.getElementById("map").style.visibility 		= "hidden";
	GUnload();
}

function loadmap(address,pharmacie,la,lo) {

	if (GBrowserIsCompatible()) {
		document.getElementById("map").style.visibility 		= "visible";
		document.getElementById("map").style.width 				= "500px"; 
		document.getElementById("map").style.height 			= "270px"; 
		document.getElementById("map").style.position 			= "relative";
		document.getElementById("map").style.align 				= "center";		
		
		map 		= new GMap2(document.getElementById("map"));
	   	// map.addControl(new TextualZoomControl());
		geocoder 	= new GClientGeocoder();
		showAddress(address,pharmacie,la,lo);
	}
}


function showAddress(address,pharmacie,la,lo) {
	
	map.setCenter(new GLatLng(la, lo), 15); 
	//	var myicon=new GIcon(G_DEFAULT_ICON);
	//myicon.image="pharmacie.gif";
	var point = new GLatLng(la, lo);
	map.setCenter(point, 15);
		  
	// var marker = new GMarker(point);
	var myicon = new GIcon(G_DEFAULT_ICON);
	//myicon.image="pharmacie.gif";
	myicon.iconSize=new GSize(19,33);
	var marker = new GMarker(point,myicon);
			  
	// marker.setImage("http://209.50.232.139/~wwwlesp/new/img/pharmacie1.png");
    map.addOverlay(marker);
			 
	// map.addControl(new GMapTypeControl());

	marker.openInfoWindowHtml(pharmacie + " " + address);
	
	document.getElementById("tab_icones").style.visibility = "visible";
	document.getElementById("tab_icones").style.width = "50px"; 

	document.getElementById("zoomin").style.visibility = "visible";
	document.getElementById("zoomin").style.width = "30px"; 
	document.getElementById("zoomin").style.height = "30px"; 
	
	document.getElementById("zoomout").style.visibility = "visible";
	document.getElementById("zoomout").style.width = "30px"; 
	document.getElementById("zoomout").style.height = "30px"; 

	document.getElementById("imprimer").style.visibility = "visible";
	document.getElementById("imprimer").style.width = "30px"; 
	document.getElementById("imprimer").style.height = "30px"; 

}

function imprime_zone(titre, obj) {
	// Définie la zone à imprimer
	var zi = document.getElementById(obj).innerHTML;
	
	// Ouvre une nouvelle fenetre
	var f = window.open("", "ZoneImpr", "height=500, width=600,toolbar=0, menubar=0, scrollbars=1, resizable=1,status=0, location=0, left=10, top=10");
	
	// Définit le Style de la page
	f.document.body.style.color = '#000000';
	f.document.body.style.backgroundColor = '#FFFFFF';
	f.document.body.style.padding = "10px";
	
	// Ajoute les Données
	f.document.title = titre;
	f.document.body.innerHTML += "" + zi + "";
	
	// Imprime et ferme la fenetre
	f.window.print();
	f.window.close();
	return true;
}

/**
 * MapIconMaker v1.0
 * Copyright (c) 2008 Pamela Fox
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. 
 *
 *
 *  Author: Pamela Fox
 *
 *  This gives you static function(s) for creating dynamically sized and
 *  colored marker icons using the Charts API marker output.
 */

var MapIconMaker = {};

MapIconMaker.createMarkerIcon = function(opts) {
  var width = opts.width || 32;
  var height = opts.height || 32;
  var primaryColor = opts.primaryColor || "#ff0000";
  var strokeColor = opts.strokeColor || "#000000";
  var cornerColor = opts.cornerColor || "#ffffff";
   
  var baseUrl = "http://chart.apis.google.com/chart?cht=mm";
  var iconUrl = baseUrl + "&chs=" + width + "x" + height + 
      "&chco=" + cornerColor.replace("#", "") + "," + primaryColor.replace("#", "") + "," + strokeColor.replace("#", "") + "&ext=.png";
  var icon = new GIcon(G_DEFAULT_ICON);
  icon.image = iconUrl;
  icon.iconSize = new GSize(width, height);
  icon.shadowSize = new GSize(Math.floor(width*1.6), height);
  icon.iconAnchor = new GPoint(width/2, height);
  icon.infoWindowAnchor = new GPoint(width/2, Math.floor(height/12));
  icon.printImage = iconUrl + "&chof=gif";
  icon.mozPrintImage = iconUrl + "&chf=bg,s,ECECD8" + "&chof=gif";
  var iconUrl = baseUrl + "&chs=" + width + "x" + height + 
      "&chco=" + cornerColor.replace("#", "") + "," + primaryColor.replace("#", "") + "," + strokeColor.replace("#", "");
  icon.transparent = iconUrl + "&chf=a,s,ffffff11&ext=.png";

  icon.imageMap = [
      width/2, height,
      (7/16)*width, (5/8)*height,
      (5/16)*width, (7/16)*height,
      (7/32)*width, (5/16)*height,
      (5/16)*width, (1/8)*height,
      (1/2)*width, 0,
      (11/16)*width, (1/8)*height,
      (25/32)*width, (5/16)*height,
      (11/16)*width, (7/16)*height,
      (9/16)*width, (5/8)*height
  ];
  for (var i = 0; i < icon.imageMap.length; i++) {
    icon.imageMap[i] = parseInt(icon.imageMap[i]);
  }

  return icon;
}


