﻿// cst501-mapas_castefa.js - Copyright (c) 2006-2010 by Juan Rodríguez & Begues Internet, s.l.

var resenas=[]; var point=""; var i=0;
var IconoUno=new GIcon(); IconoUno.iconSize=new GSize(1,1); IconoUno.shadowSize=new GSize(1,1); IconoUno.iconAnchor=new GPoint(1,1); IconoUno.infoWindowAnchor=new GPoint(1,1);
var IconoDos=new GIcon(); IconoDos.iconSize=new GSize(32,32); IconoDos.shadowSize=new GSize(56,32); IconoDos.iconAnchor=new GPoint(16,32); IconoDos.infoWindowAnchor=new GPoint(16,0);
var vCDC=0; var vGB=0; var vSC=1; var vOMC=1; var vGKH=0; var svPresente;

function posOverview(x,y) {
var overview=document.getElementById("MapaGoogle_overview"); 
if (overview) {document.getElementById("MapaGoogle").appendChild(overview);  overview.firstChild.firstChild.style.left="4px";  overview.firstChild.firstChild.style.top="4px"} else {setTimeout(posOverview, 50)} }

function MapasDC(mapa) { 
if (self.innerHeight) {ancho=self.innerWidth; alto=self.innerHeight}
else if (document.documentElement && document.documentElement.clientHeight) {ancho=document.documentElement.clientWidth; alto=document.documentElement.clientHeight}
else if (document.body) {ancho=document.body.clientWidth; alto=document.body.clientHeight}
ancho=parseInt(ancho); // alert(ancho);
alto=parseInt(alto);
document.getElementById("MapaGoogle").style.height=alto -100 +"px";
document.getElementById("MapaGoogle").style.left=(ancho -(ancho*75/100) )/2 +"px";
document.getElementById("DivDerecha").style.left=(ancho -220) /2 +"px";
document.getElementById("UnMomento").style.left=(ancho -220) /2 +"px";
document.getElementById("MarquesinaFlotante").style.left=(ancho -220) /2 +"px";
document.getElementById("MdC").style.top=alto -100 +"px";
document.getElementById("MdC").style.left=(ancho -434) /2 +"px";
document.getElementById("BandaPie").style.top=alto -95 +"px";
document.getElementById("BandaPie").style.left=(ancho -(ancho*75/100) )/2 +"px";
document.getElementById("OpcOP").selectedIndex=0;
document.getElementById("OpcOM").selectedIndex=0;
if (mapa==510) {adsManager.enable(); document.getElementById("Nomenclator").selectedIndex=0};
if (mapa==520) {adsManager.enable(); document.getElementById("MapaGoogle").style.visibility="visible"; MapaGoogle.setCenter(new GLatLng(41.2799333, 1.9765547), 14, G_NORMAL_MAP); document.getElementById("MenuEmpresas").selectedIndex=0; MapaRefUno()};
if (mapa==522) {adsManager.enable(); CastelldefelsMundo()};
if (mapa==550) {adsManager.enable(); document.getElementById("Extranjero").selectedIndex=0; document.getElementById("Espana").selectedIndex=0; document.getElementById("Catalunya").selectedIndex=0 };
if (mapa==560) {adsManager.enable(); document.getElementById("SitiosIn").selectedIndex=0; document.getElementById("SitiosOut").selectedIndex=0 };
if (mapa==570) {vOMC=0};
}

function ExpandirMapa() {
Hueco=(ancho - 220 -(ancho*75/100)) /3;
document.getElementById("MapaGoogle").style.left=Hueco +"px";
document.getElementById("MapaGoogle").style.visibility="visible";
document.getElementById("BandaPie").style.left=Hueco+"px";
document.getElementById("MdC").style.visibility="hidden";
document.getElementById("BandaPie").style.visibility="visible";
document.getElementById("DivDerecha").style.top=0+"px";
document.getElementById("DivDerecha").style.left=ancho -Hueco -220+"px";
document.getElementById("DivDerecha").style.padding=0 +"px";
document.getElementById("DivDerecha").style.background="none";
document.getElementById("DivDerecha").style.border="none";
document.getElementById("DivDerecha2").style.visibility="visible";
document.getElementById("DivDerecha2").style.display="inline";
MFPos=200; RetirarMarquesinaFlotante(); MapaGoogle.addControl(dcOMC); posOverview(0,0) }

MFPos=0; MFRetirada=0;
function RetirarMarquesinaFlotante() {
document.getElementById("MarquesinaFlotante").style.visibility="visible";
if (MFPos > 5) {document.getElementById("MarquesinaFlotante").style.top=MFPos +"px"; document.getElementById("MarquesinaFlotante").style.left=MFPos+95 +"px"; MFPos=MFPos -10; setTimeout("RetirarMarquesinaFlotante()",20)} 
MFRetirada=1}

function OtrasPaginas() {
if (document.getElementById("OpcOP").value=="none") {document.getElementById("OpcOP").selectedIndex=0; return};
window.location.href=(document.getElementById("OtrasPaginas").OpcOP.options[document.getElementById("OtrasPaginas").OpcOP.selectedIndex].value);
document.getElementById("OtrasPaginas").OpcOP.selectedIndex="0"}

function OtrosMapas() {
if (document.getElementById("OpcOM").value=="none") {document.getElementById("OpcOM").selectedIndex=0; return};
window.location.href=(document.getElementById("OtrosMapas").OpcOM.options[document.getElementById("OtrosMapas").OpcOM.selectedIndex].value);
document.getElementById("OtrosMapas").OpcOM.selectedIndex="0"}

function AcercarZoom(){
MapaGoogle.zoomIn(); MapaGoogle.setCenter(point);
MapaActivo=MapaGoogle.getCurrentMapType().getName(); MActivo=MapaActivo.toUpperCase(); ZActual=MapaGoogle.getZoom();
MA1= "Mapas en el Directorio de Castelldefels.\n\nActualmente está visualizando la modalidad de "+MActivo+"\nen su nivel de zoom máximo ("+ZActual+").";
MA2= "\n\n Si desea un mayor detalle en el mapa, puede cambiar a:"; 
MASat="\n - SATÉLITE (zoom máximo 20)"; MAHib="\n - HÍBRIDO (zoom máximo 19)"; MAMap="\n - MAPA (zoom máximo 17)"; MARel="\n - RELIEVE (zoom máximo 15)";
if ( ( MapaActivo=="Satélite" ) && (ZActual ==20) ) {alert(MA1+"\n\nGracias.") };
if ( ( MapaActivo=="Relieve" ) && (ZActual >=15) ) {alert(MA1+MA2+MASat+MAHib+MAMap+"\n\nGracias.") };
if ( ( MapaActivo=="Híbrido" ) && (ZActual >=19) ) {alert(MA1+MA2+MASat+"\n\nGracias.") };
if ( ( MapaActivo=="Mapa" ) && (ZActual >=17) ) {alert(MA1+MA2+MASat+MAHib+"\n\nGracias.") } }

function AlejarZoom(){
MapaGoogle.zoomOut(); MapaGoogle.setCenter(point);
MapaActivo=MapaGoogle.getCurrentMapType().getName(); MActivo=MapaActivo.toUpperCase(); ZActual=MapaGoogle.getZoom();
if (ZActual ==0) {alert("Mapas en el Directorio de Castelldefels.\n\nActualmente está visualizando la modalidad de "+MActivo+"\nen su nivel de zoom mínimo ("+ZActual+").\n\nGracias.") } }

function Acercar(i) {MapaGoogle.zoomIn(); 
if (MapaGoogle.getZoom() >=0) {document.getElementById("resOpc").innerHTML=opc_ac_al};
if (MapaGoogle.getZoom() >=17) {document.getElementById("resOpc").innerHTML=opc_al} }

function Alejar(i)  {MapaGoogle.zoomOut(); 
if (17 >= MapaGoogle.getZoom()) {document.getElementById("resOpc").innerHTML=opc_ac_al};
if (12 >= MapaGoogle.getZoom()) {document.getElementById("resOpc").innerHTML=opc_ac} }

// Botones verticales
function BotonesMapasGoogle() {}
BotonesMapasGoogle.prototype=new GControl();
BotonesMapasGoogle.prototype.initialize = function(MapaGoogle) {
var container=document.createElement("div"); container.style.padding="3px"; container.style.border="2px #576969 solid";
var MapaNormal=document.createElement("div"); this.setButtonStyle_(MapaNormal); container.appendChild(MapaNormal); MapaNormal.appendChild(document.createTextNode("Mapa")); 
MapaNormal.style.background="#800000"; GEvent.addDomListener(MapaNormal, "click", function() {MapaGoogle.setMapType(G_NORMAL_MAP)});
var MapaSatelite=document.createElement("div"); this.setButtonStyle_(MapaSatelite); container.appendChild(MapaSatelite); MapaSatelite.appendChild(document.createTextNode("Satélite"));
GEvent.addDomListener(MapaSatelite, "click", function() {MapaGoogle.setMapType(G_SATELLITE_MAP)});
var MapaHibrido=document.createElement("div"); this.setButtonStyle_(MapaHibrido); container.appendChild(MapaHibrido); MapaHibrido.appendChild(document.createTextNode("Híbrido"));
GEvent.addDomListener(MapaHibrido, "click", function() {MapaGoogle.setMapType(G_HYBRID_MAP)});
var MapaRelieve=document.createElement("div"); this.setButtonStyle_(MapaRelieve); container.appendChild(MapaRelieve); MapaRelieve.appendChild(document.createTextNode("Relieve"));
GEvent.addDomListener(MapaRelieve, "click", function() {MapaGoogle.setMapType(G_PHYSICAL_MAP)});
var BotonOpciones = document.createElement("div"); this.setButtonStyle_(BotonOpciones); container.appendChild(BotonOpciones); BotonOpciones.appendChild(document.createTextNode("Opciones")); BotonOpciones.style.marginTop="20px";
GEvent.addDomListener(BotonOpciones, "click", function() {document.getElementById("Bloque700").innerHTML=bom; aBloque(700); ConfigActual()});
if (svPresente==1) {
var BotonSvInfo=document.createElement("div"); this.setButtonStyle_(BotonSvInfo); container.appendChild(BotonSvInfo); BotonSvInfo.appendChild(document.createTextNode("Ayuda"));
GEvent.addDomListener(BotonSvInfo, "click", function() {GestionarAviso(120)}); }

GEvent.addDomListener(MapaGoogle, "maptypechanged", function() {
vGCMT=MapaGoogle.getCurrentMapType().getName();
MapaNormal.style.background="#234"; MapaSatelite.style.background="#234"; MapaHibrido.style.background="#234"; MapaRelieve.style.background="#234";
if (vGCMT=="Mapa") {MapaNormal.style.background="#800000"};
if (vGCMT=="Satélite") {MapaSatelite.style.background="#800000"};
if (vGCMT=="Híbrido") {MapaHibrido.style.background="#800000"};
if (vGCMT=="Relieve") {MapaRelieve.style.background="#800000"};  });
MapaGoogle.getContainer().appendChild(container); return container }

BotonesMapasGoogle.prototype.getDefaultPosition = function() {return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10, 10)) }

BotonesMapasGoogle.prototype.setButtonStyle_ = function(button) {
button.style.color="#BFD6E3"; button.style.backgroundColor="#234"; button.style.font="8pt Verdana"; button.style.border="2px #BFD6E3 solid";
button.style.padding="2px"; button.style.marginBottom="3px"; button.style.textAlign="center"; button.style.width="75px"; button.style.cursor="pointer"}

// Botón de Opciones
var dcOMC=new GOverviewMapControl(new GSize(160,160));
var dcSC=new GScaleControl();

function VolverCastelldefels(opc) {
if (opc==1) {MapaGoogle.setCenter(new GLatLng(41.27993505, 1.97659492), 14, G_NORMAL_MAP); ConfigActual()};
if (opc==2) {MapaGoogle.setCenter(new GLatLng(41.27993505, 1.97659492), 14, G_SATELLITE_MAP); ConfigActual()};
if (opc==3) {MapaGoogle.setCenter(new GLatLng(41.27993505, 1.97659492), 14, G_HYBRID_MAP); ConfigActual()};
if (opc==4) {MapaGoogle.setCenter(new GLatLng(41.27993505, 1.97659492), 14, G_PHYSICAL_MAP); ConfigActual()};  }

function ActivarCZ() {MapaGoogle.enableContinuousZoom(); MapaGoogle.enableDoubleClickZoom(); ConfigActual()}
function AnularCZ() {MapaGoogle.disableContinuousZoom(); ConfigActual()}
function ActivarSWZ() {MapaGoogle.enableScrollWheelZoom(); ConfigActual()}
function AnularSWZ() {MapaGoogle.disableScrollWheelZoom(); ConfigActual()}
function ActivarDCZ() {MapaGoogle.enableDoubleClickZoom(); ConfigActual()}
function AnularDCZ() {MapaGoogle.disableDoubleClickZoom(); ConfigActual()}
function ActivarGB() {document.getElementById("MarquesinaFlotante").style.visibility="hidden"; MapaGoogle.enableGoogleBar(); vGB=1; ConfigActual()}
function AnularGB() {document.getElementById("MarquesinaFlotante").style.visibility="visible"; MapaGoogle.disableGoogleBar(); vGB=0; ConfigActual()}
function ActivarCDC() {GEvent.addListener(MapaGoogle, "mousemove", function(point){var latLngStr8=point.lat().toFixed(8) + ', ' + point.lng().toFixed(8); var latLngStr7=point.lat().toFixed(7) + ', ' + point.lng().toFixed(7); document.getElementById("Bloque690").options[0].text=latLngStr8; document.getElementById("Bloque690").options[1].text=latLngStr7}); aBloque(690); vCDC=1; ConfigActual() }
function AnularCDC() {cBloque(690); vCDC=0; ConfigActual()}
function ActivarSC() {MapaGoogle.addControl(dcSC); vSC=1; ConfigActual()}
function AnularSC() {MapaGoogle.removeControl(dcSC); vSC=0; ConfigActual()}
function ActivarDragging() {MapaGoogle.enableDragging(); ConfigActual()}
function AnularDragging() {MapaGoogle.disableDragging(); ConfigActual()}
function ActivarOMC() {MapaGoogle.addControl(dcOMC); posOverview(0,0); vOMC=1; ConfigActual()}
function AnularOMC() {MapaGoogle.removeControl(dcOMC); vOMC=0; ConfigActual()}
function ActivarIW() {MapaGoogle.enableInfoWindow(); ConfigActual()}
function AnularIW() {MapaGoogle.disableInfoWindow(); ConfigActual()}
function ActivarGKH() {new GKeyboardHandler(MapaGoogle); vGKH=1; ConfigActual()}
function ConfigBaseMapas() {VolverCastelldefels(1); ActivarCZ(); ActivarSWZ(); ActivarDCZ(); AnularGB(); AnularCDC(); ActivarSC(); ActivarDragging(); ActivarOMC(); ActivarIW()}

function ConfigActual() {
vGCMT=MapaGoogle.getCurrentMapType().getName(); document.getElementById("GCMT").innerHTML=vGCMT;
vGZL=MapaGoogle.getZoom(); document.getElementById("GZL").innerHTML=vGZL;
vCZ=MapaGoogle.continuousZoomEnabled(); if (vCZ==true) {document.getElementById("CZ").innerHTML="Sí"} else {document.getElementById("CZ").innerHTML="No"};
vSWZ=MapaGoogle.scrollWheelZoomEnabled(); if (vSWZ==1) {document.getElementById("SWZ").innerHTML="Sí"} else {document.getElementById("SWZ").innerHTML="No"};
vDCZ=MapaGoogle.doubleClickZoomEnabled(); if (vDCZ==true) {document.getElementById("DCZ").innerHTML="Sí"} else {document.getElementById("DCZ").innerHTML="No"};
if (vCDC==1) {document.getElementById("CDC").innerHTML="Sí"} else {document.getElementById("CDC").innerHTML="No"};
vDragging=MapaGoogle.draggingEnabled(); if (vDragging==true) {document.getElementById("Dragging").innerHTML="Sí"} else {document.getElementById("Dragging").innerHTML="No"};
if (vSC==1) {document.getElementById("SC").innerHTML="Sí"} else {document.getElementById("SC").innerHTML="No"};
if (vGB==1) {document.getElementById("GB").innerHTML="Sí"} else {document.getElementById("GB").innerHTML="No"};
if (vOMC==1) {document.getElementById("OMC").innerHTML="Sí"} else {document.getElementById("OMC").innerHTML="No"};
vIW=MapaGoogle.infoWindowEnabled(); if (vIW==true) {document.getElementById("IW").innerHTML="Sí"} else {document.getElementById("IW").innerHTML="No"};
if (vGKH==1) {document.getElementById("GKH").innerHTML="Sí"} else {document.getElementById("GKH").innerHTML="No"};
return}

// Mostrar div
function aBloque(num) {document.getElementById("Bloque"+num).style.height="auto";document.getElementById("Bloque"+num).style.display="block"; document.getElementById("Bloque"+num).style.visibility="visible"}
function cBloque(num) {document.getElementById("Bloque"+num).style.height=1+"px"; document.getElementById("Bloque"+num).style.visibility="hidden"; document.getElementById("Bloque"+num).style.display="none"}

function AperturaLinkExterno() { 
if (!document.getElementsByTagName) return; 
var anchors = document.getElementsByTagName("a"); 
for (var i=0; i < anchors.length; i++) {
var anchor=anchors[i]; 
if (anchor.getAttribute("rel") && anchor.getAttribute("rel") == "WE") {alert("WebExterna: " +anchor +""); anchor.target="self"}  
if (anchor.getAttribute("rel") && anchor.getAttribute("rel") == "nofollow") {alert("nofollow: " +anchor +""); anchor.target="self"}  }  }

// Boton de opciones en mapas
bom ='<h2>Configuración de este mapa</h2>';
bom +='<table class="Tabla">';
bom +='<tr><td class="tdsubtit">Prestaciones del mapa</td><td class="tdsubtit">Actual</td><td class="tdsubtit" colspan="3">Opciones</td></tr>';
bom +='<tr><td>Centrar el mapa en Castelldefels</td><td id="GCMT"></td><td><a href="#" onclick="VolverCastelldefels(1)" title="Volver a Castelldefels, mapa normal">mapa</a></td><td><a href="#" onclick="VolverCastelldefels(2)" title="Volver a Castelldefels, mapa satélite">satélite</a></td></tr>';
bom +='<tr><td></td><td></td><td><a href="#" onclick="VolverCastelldefels(3)" title="Volver a Castelldefels, mapa híbrido">híbrido</a></td><td><a href="#" onclick="VolverCastelldefels(4)" title="Volver a Castelldefels, mapa relieve">relieve</a></td></tr>';
bom +='<tr><td>Nivel de zoom actual</td><td id="GZL"></td></tr>';
bom +='<tr><td>Zoom progresivo</td><td id="CZ"></td><td><a href="#" onclick="ActivarCZ()" title="Activar zoom progresivo">activar</a></td><td><a href="#" onclick="AnularCZ()" title="Anular zoom progresivo">anular</a></td></tr>';
bom +='<tr><td>Zoom con la rueda del ratón</td><td id="SWZ"></td><td><a href="#" onclick="ActivarSWZ()" title="Activar zoom con la rueda del ratón">activar</a></td><td><a href="#" onclick="AnularSWZ()" title="Anular zoom con la rueda del ratón">anular</a></td></tr>';
bom +='<tr><td>Zoom con dobleclic del ratón</td><td id="DCZ"></td><td><a href="#" onclick="ActivarDCZ()" title="Activar zoom con doble clic">activar</a></td><td><a href="#" onclick="AnularDCZ()" title="Anular zoom con doble clic">anular</a></td></tr>';
bom +='<tr><td>Coordenadas</td><td id="CDC"></td><td><a href="#" onclick="ActivarCDC()" title="Activar visión contínua de coordenadas">ver</a></td><td><a href="#" onclick="AnularCDC()" title="Anular visión contínua de coordenadas">ocultar</a></td></tr>';
bom +='<tr><td>Escala del mapa</td><td id="SC"></td><td><a href="#" onclick="ActivarSC()" title="Activar escala">ver</a></td><td><a href="#" onclick="AnularSC()" title="Anular escala">ocultar</a></td></tr>';
bom +='<tr><td>Arrastre del mapa</td><td id="Dragging"></td><td><a href="#" onclick="ActivarDragging()" title="Activar arrastre del mapa">activar</a></td><td><a href="#" onclick="AnularDragging()" title="Anular arrastre del mapa">anular</a></td></tr>';
bom +='<tr><td>Buscar en el mapa</td><td id="GB"></td><td><a href="#" onclick="ActivarGB()" title="Activar cuadro de búsqueda">activar</a></td><td><a href="#" onclick="AnularGB()" title="Anular cuadro de busqueda">anular</a></td></tr>';
bom +='<tr><td>Ventana posicional mapa visible</td><td id="OMC"></td><td><a href="#" onclick="ActivarOMC()" title="Activar ventana posicional mapa visible">activar</a></td><td><a href="#" onclick="AnularOMC()" title="Anular ventana posicional mapa visible">anular</a></td></tr>';
bom +='<tr><td>Ventanas emergentes de información</td><td id="IW"></td><td><a href="#" onclick="ActivarIW()" title="Activar ventanas emergentes de información">activar</a></td><td><a href="#" onclick="AnularIW()" title="Anular ventanas emergentes de información">anular</a></td></tr>';
bom +='<tr><td>Control del mapa por teclado</td><td id="GKH"></td><td><a href="#" onclick="ActivarGKH()" title="Activar control del mapa por teclado">activar</a></td><td>--</td></tr>';
bom +='<tr><td class="tdconcepto"><a href="#" onclick="ConfigBaseMapas()">Restaurar configuración por defecto</a></td></tr>';
bom +='</table>';
bom +='<div id="Bloque99"><a class="cerrar" href="#" onclick="cBloque(700)">Cerrar</a><br /><br /></div>'; 