/*
 * Map zoom controller
 * Extends GControl
 */

function ZoomController() {}

ZoomController.prototype = new GControl();

ZoomController.prototype.initialize = function(map) {	
	var container = document.createElement("div");  
					
	var moveUpDiv = document.createElement("div"); 
	this.setButtonStyleMoveUpDiv(moveUpDiv);  
	container.appendChild(moveUpDiv);  
	
	GEvent.addDomListener(moveUpDiv, "click", function() {    
		map.panDirection(0, +1);
	});
					
	var leftRightDiv = document.createElement("div");
	this.setDivStyleLeftRightDiv(leftRightDiv);
					
	var moveLeftDiv = document.createElement("div"); 
	this.setButtonStyleMoveLeftDiv(moveLeftDiv);  
	leftRightDiv.appendChild(moveLeftDiv);   
	
	GEvent.addDomListener(moveLeftDiv, "click", function() {    
		map.panDirection(+1, 0);
	}); 
					
	var moveRightDiv = document.createElement("div"); 
	this.setButtonStyleMoveRightDiv(moveRightDiv);  
	leftRightDiv.appendChild(moveRightDiv);   
	
	GEvent.addDomListener(moveRightDiv, "click", function() {    
		map.panDirection(-1, 0);
	}); 
					
	container.appendChild(leftRightDiv); 
					
	var moveDownDiv = document.createElement("div"); 
	this.setButtonStyleMoveDownDiv(moveDownDiv);  
	container.appendChild(moveDownDiv); 
	  
	GEvent.addDomListener(moveDownDiv, "click", function() {    
		map.panDirection(0, -1);
	}); 
					
	var zoomInDiv = document.createElement("div"); 
	this.setButtonStyleZoomInDiv(zoomInDiv);  
	container.appendChild(zoomInDiv);   
	
	GEvent.addDomListener(zoomInDiv, "click", function() {    
		map.zoomIn();  
	}); 
					
	var zoomOutDiv = document.createElement("div");  
	this.setButtonStyleZoomOutDiv(zoomOutDiv); 
	container.appendChild(zoomOutDiv); 
	
	GEvent.addDomListener(zoomOutDiv, "click", function() {   
		map.zoomOut(); 
	});  
					
	map.getContainer().appendChild(container); 
					
	return container;
	
};


ZoomController.prototype.getDefaultPosition = function() { 
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(8, 8));
};

ZoomController.prototype.setDivStyleLeftRightDiv = function(div) {
	var op = navigator.appName.toLowerCase(); 
	
	if (op == 'microsoft internet explorer') { 
		div.style.styleFloat = "left";
	} else {
		div.style.cssFloat = "left";
	}
	
	div.style.height = "16px";
	div.style.margin = "0px";
	div.style.padding = "0px";
};
	
ZoomController.prototype.setButtonStyleMoveUpDiv = function(button) {
	button.style.background = "url(/eiendomsbasen/html/assets/graphics/map/up.gif) no-repeat";  
	button.style.width = "16px";
	button.style.height = "16px";
	button.style.marginBottom = "0px";
	button.style.paddingBottom = "0px";
	button.style.marginLeft = "16px";
	button.title = "Mot nord";
}
				
ZoomController.prototype.setButtonStyleMoveLeftDiv = function(button) {
	var op = navigator.appName.toLowerCase();  
	if (op == 'microsoft internet explorer') { 
		button.style.styleFloat = "left";
	} else {
		button.style.cssFloat = "left";
	}  
	
	button.style.background = "url(/eiendomsbasen/html/assets/graphics/map/left.gif) no-repeat";
	button.style.width = "16px";
	button.style.height = "16px";
	button.title = "Mot vest";
}
	
ZoomController.prototype.setButtonStyleMoveRightDiv = function(button) {
	var op = navigator.appName.toLowerCase(); 

	if (op == 'microsoft internet explorer') { 
		button.style.styleFloat = "left";
	} else {
		button.style.cssFloat = "left";
	} 
	
	button.style.background = "url(/eiendomsbasen/html/assets/graphics/map/right.gif) no-repeat";
	button.style.width = "16px";
	button.style.height = "16px";
	button.style.marginLeft = "16px";
	button.title = "Mot øst";	
}
	
ZoomController.prototype.setButtonStyleMoveDownDiv = function(button) {
	var op = navigator.appName.toLowerCase(); 
	
	if (op == 'microsoft internet explorer') { 
		button.style.clear = "left";
	} else {
		button.style.clear = "left";
	} 
	
	button.style.background = "url(/eiendomsbasen/html/assets/graphics/map/down.gif) no-repeat";  
	button.style.width = "16px";
	button.style.height = "16px";
	button.style.marginLeft = "16px";
	button.style.marginBottom = "8px";
	button.title = "Mot sør";
}
	
ZoomController.prototype.setButtonStyleZoomInDiv = function(button) {
	button.style.background = "url(/eiendomsbasen/html/assets/graphics/map/in.gif) no-repeat";  
	button.style.width = "16px";
	button.style.height = "16px";
	button.style.marginLeft = "16px";
	
	var op = navigator.appName.toLowerCase(); 
		if (op == 'microsoft internet explorer') { 
			button.style.marginBottom = "0px";
		} else {
			button.style.marginBottom = "3px";
		}
		button.title = "Zoom inn"; 	
}
	
ZoomController.prototype.setButtonStyleZoomOutDiv = function(button) {
	button.style.background = "url(/eiendomsbasen/html/assets/graphics/map/out.gif) no-repeat";  
	button.style.width = "16px";
	button.style.height = "16px";
	button.style.marginLeft = "16px";
	button.title = "Zoom ut";
}
			