/**
* pvTypeControlBar.js
* Nicolas Bastien 
* Novembre 2007
*/

/******************************************************************************************************************
**
**							BIBLIOTHEQUE POUR PERSONALISER LA BARRE DE TYPE DE GOOGLE MAP											
**
*******************************************************************************************************************/


function pvTypeControlBar() {};

pvTypeControlBar.prototype = new GControl();
		
/**
* Initialisation création des boutons, ajout des actions
*
*/
pvTypeControlBar.prototype.initialize = function(map) {

	var container = document.createElement("div");


	//Création des balises img
	var containerPlan 		= document.createElement("div");
	var containerSatellite 	= document.createElement("div");
	var containerMixte 		= document.createElement("div");
	var buttonPlan 			= document.createElement("div");
	var buttonSatellite 	= document.createElement("div");
	var buttonMixte 		= document.createElement("div");

	var styleButtonSelected = 'border-style: solid; border-color: rgb(52, 86, 132) rgb(108, 157, 223) rgb(108, 157, 223) rgb(52, 86, 132); border-width: 1px; font-size: 12px; font-weight: bold;';
	var styleButtonDefault  = 'border-style: solid; border-color: white rgb(176, 176, 176) rgb(176, 176, 176) white; border-width: 1px; font-size: 12px;';

	containerPlan.title		= 'Afficher un plan de ville';
	containerSatellite.title= 'Afficher les images satellite';
	containerMixte.title	= 'Afficher les images satellite avec le nom des rues';

	buttonPlan.innerHTML 		= 'Plan';	
	buttonSatellite.innerHTML 	= 'Satellite';
	buttonMixte.innerHTML 		= 'Mixte';
	
	//Définition des styles
	containerPlan.style.cssText 	 = 'border: 1px solid black; position: absolute; background-color: white; text-align: center; width: 5em; cursor: pointer; right: 10.2em;';
	containerSatellite.style.cssText = 'border: 1px solid black; position: absolute; background-color: white; text-align: center; width: 5em; cursor: pointer; right: 5.1em;';
	containerMixte.style.cssText 	 = 'border: 1px solid black; position: absolute; background-color: white; text-align: center; width: 5em; cursor: pointer; right: 0em;';
		
	buttonPlan.style.cssText 		= styleButtonSelected;
	buttonSatellite.style.cssText 	= styleButtonDefault;
	buttonMixte.style.cssText 		= styleButtonDefault;

	
	containerPlan.appendChild(buttonPlan);
	containerSatellite.appendChild(buttonSatellite);
	containerMixte.appendChild(buttonMixte);
	
	//Ajout des boutons au container
	container.appendChild(containerPlan);	
	container.appendChild(containerSatellite);	
	container.appendChild(containerMixte);	

	
	//Ajout des listenner
	GEvent.addDomListener(buttonPlan, "click", function() {
		buttonPlan.style.cssText = styleButtonSelected;
		buttonSatellite.style.cssText = styleButtonDefault;
		buttonMixte.style.cssText = styleButtonDefault;
		map.setMapType(G_NORMAL_MAP);
	});	
	GEvent.addDomListener(buttonSatellite, "click", function() {
		buttonPlan.style.cssText = styleButtonDefault;
		buttonSatellite.style.cssText = styleButtonSelected;
		buttonMixte.style.cssText = styleButtonDefault;
		map.setMapType(G_SATELLITE_MAP);
	});
	GEvent.addDomListener(buttonMixte, "click", function() {
		buttonPlan.style.cssText = styleButtonDefault;
		buttonSatellite.style.cssText = styleButtonDefault;
		buttonMixte.style.cssText = styleButtonSelected;
		map.setMapType(G_HYBRID_MAP);
	});

	
	//Changement du z-index pour passer au dessus du layer du mode drag&zoom
	container.style.cssText = 'color: black; font-family: Arial,sans-serif; font-size: small; width: 200px; height: 19px;z-index:200;';
	
	//Ajout du container au div de la map
	map.getContainer().appendChild(container);
	return container;
};


// Positionnement de la barre sur la map		
pvTypeControlBar.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
};

