function ExtMapTypeControl(opt_opts){this.options=opt_opts||{}};ExtMapTypeControl.prototype=new GControl();ExtMapTypeControl.prototype.initialize=function(map){var container=document.createElement("div");var me=this;var mapTypes=map.getMapTypes();var mapTypeDivs=me.addMapTypeButtons_(map);GEvent.addListener(map,"addmaptype",function(){var newMapTypes=map.getMapTypes();var newMapType=newMapTypes.pop();var newMapTypeDiv=me.createButton_(newMapType.getName());newMapTypeDiv.setAttribute('title',newMapType.getAlt());mapTypes.push(newMapType);mapTypeDivs.push(newMapTypeDiv);me.resetButtonEvents_(map,mapTypeDivs);container.appendChild(newMapTypeDiv)});GEvent.addListener(map,"removemaptype",function(){for(var i=0;i<mapTypeDivs.length;i++){GEvent.clearListeners(mapTypeDivs[i],"click");container.removeChild(mapTypeDivs[i])}mapTypeDivs=me.addMapTypeButtons_(map);me.resetButtonEvents_(map,mapTypeDivs);for(var i=0;i<mapTypeDivs.length;i++){container.appendChild(mapTypeDivs[i])}});for(var i=0;i<mapTypeDivs.length;i++){container.appendChild(mapTypeDivs[i])}map.getContainer().appendChild(container);return container};ExtMapTypeControl.prototype.addMapTypeButtons_=function(map){var me=this;var mapTypes=map.getMapTypes();var mapTypeDivs=new Array();var finnishNames=new Object;finnishNames['Terrain']="Maasto";finnishNames['Map']="Kartta";finnishNames['Satellite']="Satelliitti";finnishNames['Hybrid']="Hybridi";var finnishAltTexts=new Object;finnishAltTexts['Terrain']="Näytä maaston muodot tiekartassa";finnishAltTexts['Map']="Näytä tiekartta";finnishAltTexts['Satellite']="Näytä satelliittikuva";finnishAltTexts['Hybrid']="Näytä Hybridi";for(var i=0;i<mapTypes.length;i++){if(finnishNames[mapTypes[i].getName()]!=undefined){mapTypeDivs[i]=me.createButton_(finnishNames[mapTypes[i].getName()]);mapTypeDivs[i].setAttribute('title',finnishAltTexts[mapTypes[i].getName()])}else{mapTypeDivs[i]=me.createButton_(mapTypes[i].getName());mapTypeDivs[i].setAttribute('title',mapTypes[i].getAlt())}}me.resetButtonEvents_(map,mapTypeDivs);return mapTypeDivs};ExtMapTypeControl.prototype.resetButtonEvents_=function(map,mapTypeDivs){var me=this;var mapTypes=map.getMapTypes();for(var i=0;i<mapTypeDivs.length;i++){var otherDivs=new Array;for(var j=0;j<mapTypes.length;j++){if(j!=i){otherDivs.push(mapTypeDivs[j])}}me.assignButtonEvent_(mapTypeDivs[i],map,mapTypes[i],otherDivs)}GEvent.addListener(map,"maptypechanged",function(){var divIndex=0;var mapType=map.getCurrentMapType();for(var i=0;i<mapTypes.length;i++){if(mapTypes[i]==mapType){divIndex=i}}GEvent.trigger(mapTypeDivs[divIndex],"click")})};ExtMapTypeControl.prototype.createButton_=function(text){var buttonDiv=document.createElement("div");this.setButtonStyle_(buttonDiv);buttonDiv.style.cssFloat="left";buttonDiv.style.styleFloat="left";var textDiv=document.createElement("div");textDiv.appendChild(document.createTextNode(text));textDiv.style.width="6em";buttonDiv.appendChild(textDiv);return buttonDiv};ExtMapTypeControl.prototype.assignButtonEvent_=function(div,map,mapType,otherDivs){var me=this;GEvent.addDomListener(div,"click",function(){for(var i=0;i<otherDivs.length;i++){me.toggleButton_(otherDivs[i].firstChild,false)}me.toggleButton_(div.firstChild,true);map.setMapType(mapType)})};ExtMapTypeControl.prototype.toggleButton_=function(div,boolCheck){div.style.fontWeight=boolCheck?"bold":"";div.style.backgroundColor=boolCheck?"#741c00":"#fffce4";div.style.color=boolCheck?"#fffce4":"#741c00";var shadows=["Top","Left","Bottom","Right"];var shadowColors=boolCheck?["#460d00","#460d00","#bc4400","#bc4400"]:["#f8f2da","#f8f2da","#cdbca3","#cdbca3"];for(var j=0;j<shadows.length;j++){div.style["border"+shadows[j]]="1px solid "+shadowColors[j]}};ExtMapTypeControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,90))};ExtMapTypeControl.prototype.setButtonStyle_=function(button){button.style.color="#741c00";button.style.backgroundColor="#fffce4";button.style.font="small Arial";button.style.border="1px solid black";button.style.padding="0px";button.style.margin="0px";button.style.textAlign="center";button.style.fontSize="12px";button.style.cursor="pointer"};
function ExtMapTypeControl2(opt_opts){this.options=opt_opts||{}};ExtMapTypeControl2.prototype=new GControl();ExtMapTypeControl2.prototype.initialize=function(map){var container=document.createElement("div");var me=this;var mapTypes=map.getMapTypes();var mapTypeDivs=me.addMapTypeButtons_(map);GEvent.addListener(map,"addmaptype",function(){var newMapTypes=map.getMapTypes();var newMapType=newMapTypes.pop();var newMapTypeDiv=me.createButton_(newMapType.getName());newMapTypeDiv.setAttribute('title',newMapType.getAlt());mapTypes.push(newMapType);mapTypeDivs.push(newMapTypeDiv);me.resetButtonEvents_(map,mapTypeDivs);container.appendChild(newMapTypeDiv)});GEvent.addListener(map,"removemaptype",function(){for(var i=0;i<mapTypeDivs.length;i++){GEvent.clearListeners(mapTypeDivs[i],"click");container.removeChild(mapTypeDivs[i])}mapTypeDivs=me.addMapTypeButtons_(map);me.resetButtonEvents_(map,mapTypeDivs);for(var i=0;i<mapTypeDivs.length;i++){container.appendChild(mapTypeDivs[i])}});for(var i=0;i<mapTypeDivs.length;i++){container.appendChild(mapTypeDivs[i])}map.getContainer().appendChild(container);return container};ExtMapTypeControl2.prototype.addMapTypeButtons_=function(map){var me=this;var mapTypes=map.getMapTypes();var mapTypeDivs=new Array();var finnishNames=new Object;finnishNames['Terrain']="Maasto";finnishNames['Map']="Kartta";finnishNames['Satellite']="Satelliitti";finnishNames['Hybrid']="Hybridi";var finnishAltTexts=new Object;finnishAltTexts['Terrain']="Näytä maaston muodot tiekartassa";finnishAltTexts['Map']="Näytä tiekartta";finnishAltTexts['Satellite']="Näytä satelliittikuva";finnishAltTexts['Hybrid']="Näytä Hybridi";for(var i=0;i<mapTypes.length;i++){if(finnishNames[mapTypes[i].getName()]!=undefined){mapTypeDivs[i]=me.createButton_(finnishNames[mapTypes[i].getName()]);mapTypeDivs[i].setAttribute('title',finnishAltTexts[mapTypes[i].getName()])}else{mapTypeDivs[i]=me.createButton_(mapTypes[i].getName());mapTypeDivs[i].setAttribute('title',mapTypes[i].getAlt())}}me.resetButtonEvents_(map,mapTypeDivs);return mapTypeDivs};ExtMapTypeControl2.prototype.resetButtonEvents_=function(map,mapTypeDivs){var me=this;var mapTypes=map.getMapTypes();for(var i=0;i<mapTypeDivs.length;i++){var otherDivs=new Array;for(var j=0;j<mapTypes.length;j++){if(j!=i){otherDivs.push(mapTypeDivs[j])}}me.assignButtonEvent_(mapTypeDivs[i],map,mapTypes[i],otherDivs)}GEvent.addListener(map,"maptypechanged",function(){var divIndex=0;var mapType=map.getCurrentMapType();for(var i=0;i<mapTypes.length;i++){if(mapTypes[i]==mapType){divIndex=i}}GEvent.trigger(mapTypeDivs[divIndex],"click")})};ExtMapTypeControl2.prototype.createButton_=function(text){var buttonDiv=document.createElement("div");this.setButtonStyle_(buttonDiv);buttonDiv.style.cssFloat="left";buttonDiv.style.styleFloat="left";var textDiv=document.createElement("div");textDiv.appendChild(document.createTextNode(text));textDiv.style.width="6em";buttonDiv.appendChild(textDiv);return buttonDiv};ExtMapTypeControl2.prototype.assignButtonEvent_=function(div,map,mapType,otherDivs){var me=this;GEvent.addDomListener(div,"click",function(){for(var i=0;i<otherDivs.length;i++){me.toggleButton_(otherDivs[i].firstChild,false)}me.toggleButton_(div.firstChild,true);map.setMapType(mapType)})};ExtMapTypeControl2.prototype.toggleButton_=function(div,boolCheck){div.style.fontWeight=boolCheck?"bold":"";div.style.backgroundColor=boolCheck?"#741c00":"#fffce4";div.style.color=boolCheck?"#fffce4":"#741c00";var shadows=["Top","Left","Bottom","Right"];var shadowColors=boolCheck?["#460d00","#460d00","#bc4400","#bc4400"]:["#f8f2da","#f8f2da","#cdbca3","#cdbca3"];for(var j=0;j<shadows.length;j++){div.style["border"+shadows[j]]="1px solid "+shadowColors[j]}};ExtMapTypeControl2.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,10))};ExtMapTypeControl2.prototype.setButtonStyle_=function(button){button.style.color="#741c00";button.style.backgroundColor="#fffce4";button.style.font="small Arial";button.style.border="1px solid black";button.style.padding="0px";button.style.margin="0px";button.style.textAlign="center";button.style.fontSize="12px";button.style.cursor="pointer"};

