function FullScreenControl() {
}
FullScreenControl.prototype = new GControl();

FullScreenControl.prototype.initialize = function(map) {
var container = document.createElement('div');
var switchDiv = document.createElement('div');
this.setButtonStyle_(switchDiv);
container.appendChild(switchDiv);
switchDiv.appendChild(document.createTextNode('Fullscreen'));

GEvent.addDomListener(switchDiv, 'click', function() {
var mapNode = this.parentNode.parentNode;

var elem_map = document.getElementById(mapNode.id);

var aW = elem_map.offsetWidth;
var aH = elem_map.offsetHeight;

var winW = 0, winH = 0;
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") {
winW = window.innerWidth;
winH = window.innerHeight;
}
if (navigator.appName.indexOf("Microsoft")!=-1) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
}

if(""+elem_map.getAttribute("w") +"x"+elem_map.getAttribute("h") != ""+aW+"x"+aH) {

document.getElementById(elem_map.getAttribute("c")).insertBefore(elem_map, document.getElementById(elem_map.getAttribute("c")).firstChild);
elem_map.style.width = elem_map.getAttribute("w")+"px";
elem_map.style.height = elem_map.getAttribute("h")+"px";
elem_map.style.position = "relative";
elem_map.style.left = "0px";
elem_map.style.top = "0px";
map.checkResize();
this.innerHTML='Fullscreen';
//map.setCenter(boundBox.getCenter(),
//map.getBoundsZoomLevel(boundBox));

} else {
var objBody = document.getElementsByTagName("body").item(0);
objBody.insertBefore(elem_map, objBody.firstChild);
elem_map.style.position = "fixed";

elem_map.style.zIndex = 999;
elem_map.style.width = "100%";
elem_map.style.height = "100%";
elem_map.style.left = "0px";
elem_map.style.top = "0px";
//elem_map.scrollTo();

map.checkResize();
this.innerHTML='Normale';

map.setCenter(map.getCenter(),14);
}

});

map.getContainer().appendChild(container);
return container;
}

// By default, the control will appear in the top left corner of the
// map with 7 pixels of padding.

FullScreenControl.prototype.getDefaultPosition = function() {
return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(7,27));
}

FullScreenControl.prototype.setButtonStyle_ = function(button) {
button.style.color = "#000000";
button.style.backgroundColor = "white";
button.style.font = "small Arial";
button.style.border = "1px outset black";
button.style.padding = "0px";
button.style.textAlign = "center";
button.style.width = "5em";
button.style.cursor = "pointer";
}

