//FUNCIONES

//Control para guardar una posicion y volver
function MDControl2(){}
 
MDControl2.prototype = new GControl();

MDControl2.prototype.initialize = function(map) {

	var container = document.createElement("div");
	var savepos= document.createElement("div");
	savepos.className= "MDbuttons";
	savepos.title= "Guarde posición y nivel de Zoom Actual";
	container.appendChild(savepos);
	savepos.appendChild(document.createTextNode("Guardar"));

	GEvent.addDomListener(savepos, "click", function() {
		savepos.className = "MDbuttonsHighlight";
		var center = map.getCenter(); var zoom = map.getZoom();
		saved.splice(0,2,center,zoom);
		alert("Posición Almacenada: "+center.toUrlValue()+"\nNivel de Zoom: "+zoom);
	});
	
	var tosaved=document.createElement("div");
	tosaved.className = "MDbuttons";
	tosaved.title= "Volver a la posición Guardada";
	container.appendChild(tosaved);
	tosaved.appendChild(document.createTextNode("Volver"));
	
	GEvent.addDomListener(tosaved, "click", function(){
		if(saved.length > 0){
			map.setZoom(saved[1]);
			map.panTo(saved[0]);
		}
		tosaved.className = "MDbuttonsHighlight";		
	});
	
	MDControl2.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7,50));
	}
	
	GEvent.addDomListener(savepos, "mouseout", function() {
	 savepos.className = "MDbuttons";
	});
	
	GEvent.addDomListener(tosaved, "mouseout", function() {
	 tosaved.className = "MDbuttons";
	}); 
	
	map.getContainer().appendChild(container);
	return container;		
}


<!-- Boton para solo volver a la posicion inicial -->
function MDControlBotonVolver(center) { }

MDControlBotonVolver.prototype = new GControl();
MDControlBotonVolver.prototype.initialize = function(map) {

var botonVolver=document.createElement("div");
 botonVolver.className= "MDbuttons";
 botonVolver.title= "Volver a la posición Inicial";
 botonVolver.appendChild(document.createTextNode("Volver"));

 GEvent.addDomListener(botonVolver, "click", function() {
 map.panTo(center);
 botonVolver.className="MDbuttonsHighlight";
 });

 GEvent.addDomListener(botonVolver, "mouseout", function() {
 botonVolver.className="MDbuttons";
 });

 map.getContainer().appendChild(botonVolver);

 return botonVolver;
 }

 MDControlBotonVolver.prototype.getDefaultPosition = function() {
 return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7,50));
}
<!-- Fin boton volver -->


//funciones del div con los checkboxes
function hideAll() {
  var boxes = document.getElementsByName("mark");
  for(var i = 0; i < boxes.length; i++) {
	if(boxes[i].checked) {
	boxes[i].checked = false;
	switchLayer(false, layers[i].obj);
	chosen.push(i);
    }
  }
}

function checkChecked() {
var boxes = document.getElementsByName("mark");
	for(var i = 0; i < boxes.length; i++) {
		if(boxes[i].checked) return true;
	}
	return false;
}

function switchLayer(checked, layer) {
var boxlink = document.getElementById("boxlink");
var box = document.getElementById("box");

if(checked){
	map.addOverlay(layer);
	// Reset chosen array
	chosen.length = 0;
	/* Highlight the link and
	* make the button font bold.*/
	box.className="highlight";
	boxlink.className="highlight";
}
else {
	map.removeOverlay(layer);
	/* Reset the link and the button
	* if all checkboxes were unchecked.*/
	if(!checkChecked()) {
	boxlink.blur();
	boxlink.className="";
    box.className="";
	}
}
}

function toggleLayers() {

	if(chosen.length > 0 ) {
	var copy = chosen.slice();
	for(var i = 0; i < copy.length; i++) {
	var index = parseInt(copy[i]);
	switchLayer(true, layers[index].obj);
	document.getElementsByName("mark")[index].checked = true;
	}
	}
	else {
	hideAll();
	}
}

//........FIN


//para el alto dinamico del mapa

function cargaAlto(){
	
	height_res=screen.height-250;
	//un minimo de 300 por si se usan netbooks y todas esas cosas chiquitas.
	if (height_res < 300){
		height_res = 300;
	}
	
	alto=height_res+"px";
/* 
	hay que hacer esta forma porque IE tiene problemas para usar el comando
	setAttribute ¬ ¬
*/
	divMapa=document.getElementById("map");
	cssStyle="width:96%; height:"+alto+"; border:1px solid #0066CC;";
	
	if (navigator.appName == "Microsoft Internet Explorer"){
		var styleData = cssStyle;
		divMapa.style.setAttribute('cssText', styleData);
	}else{
		divMapa.setAttribute("style",cssStyle);
	}
		
}	

//........FIN

