/*
 * Map type controller
 * Extends GControl
 */

function TypeController() {}	

TypeController.prototype = new GControl();
			
TypeController.prototype.initialize = function(map) {
	
	var container2 = document.createElement("div");  
					
	var normalMapDiv = document.createElement("div"); 
	this.setButtonStyleNormalMapDiv(normalMapDiv);  
	container2.appendChild(normalMapDiv);  
					
	GEvent.addDomListener(normalMapDiv, "click", function() {    
		map.setMapType(G_NORMAL_MAP);
	}); 
					
	var satelliteMapDiv = document.createElement("div"); 
	this.setButtonStyleSatelliteMapDiv(satelliteMapDiv);  
	container2.appendChild(satelliteMapDiv);   
					
	GEvent.addDomListener(satelliteMapDiv, "click", function() {    
		map.setMapType(G_SATELLITE_MAP);  
	}); 
					
	var hybridMapDiv = document.createElement("div");  
	this.setButtonStyleHybridMapDiv(hybridMapDiv); 
	container2.appendChild(hybridMapDiv); 
					
	GEvent.addDomListener(hybridMapDiv, "click", function() {   
		map.setMapType(G_HYBRID_MAP); 
	}); 
					 
	map.getContainer().appendChild(container2); 
					
	return container2;					
}
				
TypeController.prototype.getDefaultPosition = function() { 
	return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(8, 8));
}
				
TypeController.prototype.setButtonStyleNormalMapDiv = 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/map.gif) no-repeat";
	button.style.width = "42px";
	button.style.height = "19px";
	button.title = "Vis som normalt kart";
}
				
TypeController.prototype.setButtonStyleSatelliteMapDiv = 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/satellite.gif) no-repeat";
	button.style.width = "93px";
	button.style.height = "19px";
	button.style.marginLeft = "8px";
	button.title = "Vis som satelittbilde";
}
				
TypeController.prototype.setButtonStyleHybridMapDiv = 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/hybrid.gif) no-repeat";
	button.style.width = "82px";
	button.style.height = "19px";
	button.style.marginLeft = "8px";
	button.title = "Vis som kombinert kart/satelittbilde";
}
		