/**
* pvControlBar.js
* Nicolas Bastien 
* Novembre 2007
*/

/******************************************************************************************************************
**
**							BIBLIOTHEQUE POUR PERSONALISER LA BARRE DE CONTROLE DE GOOGLE MAP											
**
*******************************************************************************************************************/


function pvControlBar() {};

pvControlBar.prototype = new GControl();
		
/**
* Initialisation création des boutons, ajout des actions
*
*/
pvControlBar.prototype.initialize = function(map) {

	var container = document.createElement("div");

	//Création des balises img
	var moveUpArrow 	= document.createElement("img");
	var moveDownArrow 	= document.createElement("img");
	var moveLeftArrow 	= document.createElement("img");
	var moveRightArrow 	= document.createElement("img");
	var zoomInArrow 	= document.createElement("img");
	var zoomOutArrow 	= document.createElement("img");
	
	//Ajout des src
	moveUpArrow.src 	= dossierImages+"img/modules/cartographie/arrowup.png";
	moveDownArrow.src 	= dossierImages+"img/modules/cartographie/arrowdown.png";
	moveLeftArrow.src 	= dossierImages+"img/modules/cartographie/arrowleft.png";
	moveRightArrow.src 	= dossierImages+"img/modules/cartographie/arrowright.png";
	zoomInArrow.src 	= dossierImages+"img/modules/cartographie/zoomin.png";
	zoomOutArrow.src	= dossierImages+"img/modules/cartographie/zoomout.png";
	
	//Définition des styles
	this.setButtonStyle_(moveUpArrow);		moveUpArrow.style.marginLeft	= "9px";
	this.setButtonStyle_(moveDownArrow); 	moveDownArrow.style.marginLeft	= "9px";
	this.setButtonStyle_(moveLeftArrow);
	this.setButtonStyle_(moveRightArrow); 	moveRightArrow.style.marginLeft	= "3px";
	this.setButtonStyle_(zoomInArrow); 		zoomInArrow.style.marginLeft	= "9px";
	this.setButtonStyle_(zoomOutArrow); 	zoomOutArrow.style.marginLeft	= "9px";
	
	//Ajout des boutons au container
	container.appendChild(moveUpArrow);	
	container.appendChild(document.createElement("br")); 
	container.appendChild(moveLeftArrow);	
	container.appendChild(moveRightArrow);	
	container.appendChild(document.createElement("br")); 
	container.appendChild(moveDownArrow);	
	container.appendChild(document.createElement("br")); 
	container.appendChild(zoomInArrow);
	container.appendChild(document.createElement("br")); 	
	container.appendChild(zoomOutArrow);	
	
	//Ajout des listenner
	GEvent.addDomListener(moveUpArrow,   "click", function() {moveDirection('up');});	
	GEvent.addDomListener(moveDownArrow, "click", function() {moveDirection('down');});
	GEvent.addDomListener(moveLeftArrow, "click", function() {moveDirection('left');});
	GEvent.addDomListener(moveRightArrow,"click", function() {moveDirection('right');});
	GEvent.addDomListener(zoomInArrow,   "click", function() {
															if(updatingMode){
																return;
															}															
															map.zoomIn();
													});
	GEvent.addDomListener(zoomOutArrow,  "click", function() {
															if(updatingMode){
																return;
															}															
															map.zoomOut();
													});	
	
	//Changement du z-index pour passer au dessus du layer du mode drag&zoom
	container.style.cssText = 'z-index:200;';
	
	//Ajout du container au div de la map
	map.getContainer().appendChild(container);
	return container;
};


// Positionnement de la barre sur la map		
pvControlBar.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
};

// Sets the proper CSS for the given button element.
pvControlBar.prototype.setButtonStyle_ = function(button) {
	button.style.cssText = 'width:15px;height:15px;cursor:pointer;z-index:200;margin-bottom:2px;';  
};

