//// puntos
var xorig=0;
var yorig=0;
var escala=0.0;
var dx=0.0;
var dy=0.0;
 var minxg=0.0;
 var minyg=0.0; maxxg=0.0; maxyg=0.0;
 var indpol=null;
/////common
  var isIE = false;
  var isNav = (navigator.appName.indexOf("Netscape")>=0);
  var isNav47 = false;
  var isNav4 = false;
  var isIE4 = false;
  var is5up = false;

// JavaScript file for general settings
  var mouseX=0;
  var mouseY=0;
  var x1=0;
  var y1=0;
  var x2=0;
  var y2=0;
  var zminx=0;
  var zmaxx=0;
  var zmaxy=0;
  var zminy=0;
  var mapX = 0;
  var mapY = 0;
  var state = "zoom"; // "pan"
  var zooming=false;
  var panning=false;
  var quering=false;
  var pointing=false;
  var bottomBorderHeight = 0;
  var curaux=null;

/////////
var ready = false;
  var theServletPath = "";
  var theJSPPath = "";
  var wmsId = "";
  var minx = -180;
  var maxx = 180;
  var maxy = 90;
  var miny = -90;
  var fullMinx = -180;
  var fullMaxx = 180;
  var fullMaxy = 90;
  var fullMiny = -90;
  var onzoom=false;

var ovWidth=0;
var ovHeight=0;
  var pMinx = -1;
  var pMaxx = -1;
  var pMaxy = -1;
  var pMiny = -1;

  var dmaxx = -1;
  var dmaxy = -1;

  minScale = 0;
  maxScale = 1;

  var cadconex="";

// initial map size
  var iWidth = 440;
  var iHeight = 350;
  var hspc = 35;
  var hspcb =hspc
  var vspc = 155;

  var textact="0";
  var ptoact="0";
  var actrst="";
  var actpto="";
  var cambpto=false;
  var layeract="theMap";
  var layerant="theMap2";
  var auxlayer="";
  var noest="";
  var tipoest="";

  var wrez=-1;
  var hrez=-1;
  var cadcam="";
  var actcambio=false;
  var cadvent="";
  var contl=0;
  var timg;
function setServletVent(str) {
cadvent= str;
}

function setServletPath(str) {
theServletPath = str;
}
function setJSPPath(str) {
theJSPPath = str;
}

function setWmsId(str) {
wmsId = str;
}

function setReady(bool) {
ready = bool;
}

function cargo(){
if(!actcambio) {
contl++;
if (contl==2) {
hideLayer("loadLayer");
}
return;
}
hideLayer("loadLayer");
  hideLayer(layeract);
showLayer(layerant);
  hideLayer("loadLayer");
   x2=0;
x1=0;
y2=0;
y1=0;
panMouse();
auxlayer=layerant;
layerant=layeract;
layeract=auxlayer;
actcambio=false;
cambpto=(ne=="ag" && lyact!="00")||cambpto;
contenidoPto();
}
function contenidoPto(){
    if (cambpto || ptoact=="1") {
      cambpto=false;
      replaceLayerContent("theTop", creaArea());
      fijaMouse();
    }
}
function refreshMap() {
  if (ready) {
cadconex=theServletPath+"?me="+mest;
if (wrez!=-1){
cadconex=cadconex+"&ww="+wrez+"&hh="+hrez;
}
cadconex=cadconex+((indpol==null)?"":("&ip="+indpol))+cadvent;
if (actrst!=""){
cadconex=cadconex+"&rs=1";
actrst="";
      minxgrl=minxg;
      minygrl=minyg;
      maxxgrl=maxxg;
      maxygrl=maxyg;
      calcularEscala();
onzoom=false;
}
if (pMinx!=-1 && pMiny!=-1){
      Zoom(pMinx,pMiny,pMaxx,pMaxy);
cadconex=cadconex+"&zo="+Math.round(pMinx)+"|"+Math.round(pMiny)+"|"+Math.round(pMaxx)+"|"+Math.round(pMaxy);
pMinx=-1;pMiny=-1;
}
if (dmaxx!=-1 && dmaxy!=-1){
      CalculaDespXY(dmaxx,dmaxy);
cadconex=cadconex+"&dx="+Math.round(dmaxx)+"&dy="+Math.round(dmaxy);
dmaxx=-1;dmaxy=-1;
}
cadconex=cadconex+"&at="+textact+"&ap="+ptoact+timg+"&rd="+Math.round(Math.random()*10000);
    //prompt("",cadconex);
showLayer("loadLayer");
actcambio=true;
if (layeract=="theMap"){
if (isNav && is5up)
 document.desta2.onload();
document.desta2.src=cadconex;
}
else{
if (isNav && is5up)
document.desta.onload();
document.desta.src=cadconex;
}
  }
}

function CambiarMAP(ly,ne,lact,texto){
  showLayer("loadLayer");
  cadcam="?me="+mest+"&ly="+ly+"&la="+lact+((texto!=null)?"&t2="+texto:"")+"&at="+textact+"&ne="+((mest=="ag")?"ag":ne)+cadvent;
  document.location=theJSPPath+cadcam;
}

function zoomOut() {
  if (ready) {
pMinx =-iWidth /4;
pMiny =-iHeight/4;
pMaxx =iWidth +(iWidth /4);
pMaxy =iHeight+(iHeight/4);
refreshMap();
  }
}

function setState(newState) {
  if (ready) {
state = newState;
    if (isIE && document.all.theTop) {
    if (state == "pan")
      document.all.theTop.style.cursor = "move";
else if (state == "query")
       document.all.theTop.style.cursor = "hand";
 else
  document.all.theTop.style.cursor = "crosshair";
}
if (state == "restart"){
actrst="act";
refreshMap();
}
if (state == "zoomIn"){
dmaxx = -1;
dmaxy = -1;
}
if (state == "zoomOut"){
dmaxx = -1;
dmaxy = -1;
zoomOut();
}
if (state == "query"){
dmaxx = -1;
dmaxy = -1;
}
  }
}
 function CalculaOrig(){
    xorig = Math.abs(maxxgrl - minxgrl);
    yorig = Math.abs(maxygrl - minygrl);
 }

 function calcularEscala() {
    var e2;
    CalculaOrig();
    escala = iWidth / xorig;
    e2 = (iHeight / yorig);
    if (escala > e2) {escala = e2;};
    dx =  (((xorig * escala - iWidth )/ 2) + minxgrl*escala);
    dy = (((yorig * escala -iHeight)/ 2) + minygrl * escala) + iHeight;


  }

 function CalculaDespXY(despx,despy){
   dx=dx+despx;
   dy=dy+despy;
   minxgrl = dx/escala;
   maxxgrl = (iWidth + dx)/escala;
   minygrl = (dy - iHeight)/escala;
   maxygrl = dy/escala;
}

 function Zoom(x1,y1,x2,y2){
  var t;
   if ((x1 == x2) || (y1 == y2)) return;
   if (x1>x2) { t=x1; x1=x2; x2=t; }
   if (y1>y2) {t=y1;y1=y2;y2=t;}
   minxgrl = (x1 + dx)/escala;
   minygrl = (dy - y2)/escala;
   maxxgrl = (x2 + dx)/escala;
   maxygrl = (dy - y1)/escala;
   onzoom=true;
   calcularEscala();
 }

function creaArea(){
 var cont= '';
 var taminc=1;

 var mx,my,anx,any;
 if (ptoact=="1") {
   cont = '<MAP NAME=mapATMs>';
   for (i=0;i<vx.length; i++){
      mx=Math.round(vx[i]*escala-dx);
      my=Math.round(dy-vy[i]*escala);
if ((Math.abs(anx-mx)<=5 || Math.abs(any-my)<=5)&& parent.lyact=="20") continue;
anx=mx;
any=my;
      if (mx>iWidth ||mx<0 ||my<0 || my>iHeight) continue;
      cont =cont +'<AREA href="#" ALT="'+desc[i]+'" shape="circle" coords="'+mx+','+my+',8" onmouseover="cc()" onclick="return pp('+i+');" onmouseout="rc()">';
   }
 }

if (ne=="ag" && lyact!="00"){
   var vgx;
   var vgy;
   if (ptoact=="0") cont = '<MAP NAME=mapATMs>';
           if (descl.length>100 && onzoom==false) taminc=Math.round(descl.length/100);
   for (j=0;j<descl.length;j=j+taminc){
    vgx=eval("px"+j);
    vgy=eval("py"+j);
    cont =cont +'<area href="#"  ALT="'+descl[j].substring(descl[j].indexOf("|")+1)+'" shape="polygon" onmouseover="cc()" onmouseout="rc()" coords="';

    for (i=0;i<vgx.length; i++){
 mx=Math.round(vgx[i]*escala-dx);
     my=Math.round(dy-vgy[i]*escala);
 if (mx>iWidth ||mx<0 ||my<0 || my>iHeight) continue;
 if(i>0) cont=cont+',';
 cont =cont +mx+','+my;

    }
cont=cont+'">';
   }
 }
  if (ptoact=="1" || (ne=="ag" && lyact!="00")) cont =cont +'</MAP>';

 cont =cont +'<img src="/niveles/nibien/transparent.gif" border="0" '+((ptoact=='1' || (ne=="ag" && lyact!="00"))?'USEMAP="#mapATMs"':'')+' width=100% height=100%>';
//prompt("",cont);
return cont;
}


////////////////////////zoombox
function cc(){
  if (zooming || panning ) return false;
  if (isIE){
 curaux=document.all.theTop.style.cursor;
 document.all.theTop.style.cursor="hand";
  }
  pointing=true;
 return true;
}
function rc(){
//alert(document.all.theTop.style.cursor);
//if (document.all.theTop.style.cursor!=null){
 if (isIE && pointing) document.all.theTop.style.cursor=curaux;
  pointing=false;

}
function pp(ii){
 if (zooming || panning ) return false;
 if ((Math.abs(x2-x1) >5) && (Math.abs(y2-y1) >5)) return false;
 var nnes=((lyact=="00" &&mest!="ag")?"es":"ag");
  if (lyact!="00" && nnes=="ag" && ne=="ag") t2=t2.substring(t2.indexOf("/")+1);
  showLayer("loadLayer");
  re= new RegExp(" ","g");
  var tit=desc[ii];
  tit=tit.replace(re,"%20");
  cadcam="?me="+mest+"&ne="+nnes+"&la="+lyact.substring(0,2)+"&at="+textact+"&t2="+tit+((lyact!="00" &&nnes=="ag")?"/"+t2:"")+"&sp="+vx[ii]+"|"+vy[ii]+cadvent+"&rd=23" //+Math.round(Math.random()*10000);
  parent.document.location.href= theJSPPath+cadcam;
  return false;
}
// prompt('',theJSPPath+cadcam);

function setZoomBoxSettings() {
// Set up event capture for mouse movement
if (isNav && is5up) {
document.captureEvents(Event.MOUSEMOVE);
document.captureEvents(Event.MOUSEDOWN);
document.captureEvents(Event.MOUSEUP);
document.onmousemove = getMouse;
document.onmousedown = mapTool;
document.onmouseup = chkMouseUp;
} else if (isNav4) {
// otherwise the buttons don't work

		getLayer("theTop").captureEvents(Event.MOUSEMOVE);
		getLayer("theTop").captureEvents(Event.MOUSEDOWN);
		getLayer("theTop").captureEvents(Event.MOUSEUP);
		getLayer("theTop").onmousemove = getMouse;
		getLayer("theTop").onmousedown = mapTool;
		getLayer("theTop").onmouseup = chkMouseUp;
	} else {

		document.onmousemove = getMouse;
		document.onmousedown = mapTool;
		document.onmouseup = chkMouseUp;
	}
}

// check for mouseup
function chkMouseUp(e) {
	if (zooming || panning ) {
		if (mouseX<0)
		 	mouseX = 0;
		if (mouseX>iWidth)
			mouseX = iWidth;
		if (mouseY<0)
			mouseY = 0;
		if (mouseY>iHeight)
			mouseY = iHeight;
		mapTool(e);
	}
}

// perform appropriate action with mapTool
function mapTool (e) {
	getImageXY(e);
	if ((!pointing) && (!zooming) && (!panning)  && (mouseX>=0) && (mouseX<iWidth) && (mouseY>=0) && (mouseY<iHeight)) {
		if (state == "pan") {
			startPan(e);
				}else{
				     startZoomBox(e);
				   }
		return false;
	} else if ((!zooming) && (!panning) && (mouseX < 0) &&
		(mouseX >= hspc) && (mouseX <= hspc) &&
		(mouseY >= vspc) && (mouseY <= vspc)) {
		// user clicked ov map
		getOVImageXY(e);
		if ((mouseX>=0) && (mouseX<ovWidth) && (mouseY>=0) && (mouseY<ovHeight)) {
			ovMapClick(mouseX,mouseY);
		}
	} else if (zooming) {
		getMouse(e);
		stopZoomBox(e);
	} else if (panning) {
		getMouse(e);
		stopPan(e);
	}
	return true;
}


function getImageXY(e) {
	//if (document.layers) {
	if (isNav) {
		mouseX=e.pageX;
		mouseY=e.pageY;
	} else {
		mouseX=event.clientX + document.body.scrollLeft;
		mouseY=event.clientY + document.body.scrollTop;
	}
	// subtract offsets from page left and right
	mouseX = mouseX-hspc;
	mouseY = mouseY-vspc;
}

function getOVImageXY(e) {
	if (isNav) {
		mouseX=e.pageX;
		mouseY=e.pageY;
	} else {
		mouseX=event.clientX + document.body.scrollLeft;
		mouseY=event.clientY + document.body.scrollTop;
	}
	// subtract offsets from page minx and maxy
}

// get coordinates on ov map and reset display
function ovMapClick(x,y) {
	var fullWidth = Math.abs(fullMaxx - fullMinx);
	var fullHeight = Math.abs(fullMaxy - fullMiny);
	var ovXincre = fullWidth / ovWidth;
	var ovYincre = fullHeight / ovHeight;
	var ovX = x;
	var ovY = ovHeight - y;
	var ovmapX = ovX * ovXincre + fullMinx;
	var ovmapY = ovY * ovYincre + fullMiny;
	var width = maxx - minx;
	var height = maxy - miny;
	// keep zoom factor
	refreshMap();
}

// get click on OVmap and move display there
function ovMap2Click(e) {
	getOVImageXY(e);
	zooming=false;
	ovMapClick(mouseX,mouseY-2);
}


// get the coords at mouse position
function getMouse(e) {
	window.status="";
	getImageXY(e);
	if (zooming || quering) {
		if (mouseX<0)
		 	mouseX = 0;
		if (mouseX>iWidth)
			mouseX = iWidth;
		if (mouseY<0)
			mouseY = 0;
		if (mouseY>iHeight-bottomBorderHeight)
			mouseY = iHeight-bottomBorderHeight;
		x2=mouseX;
		y2=mouseY;
		setClip();
		return false;
	} else if (panning) {
		x2=mouseX;
		y2=mouseY;
		panMouse();
		return false;
	} else
    	return true;
//	return true;
}

// start zoom in.... box displayed
function startZoomBox(e) {
	getImageXY(e);
	// keep it within the MapImage
	if ((mouseX<iWidth) && (mouseY<iHeight-bottomBorderHeight))
		if (!zooming) {
			x1=mouseX;
			y1=mouseY;
			x2=x1+1;
			y2=y1+1;
			zooming=true;

			clipLayer("zoomBoxTop",x1,y1,x2,y2);
			clipLayer("zoomBoxLeft",x1,y1,x2,y2);
			clipLayer("zoomBoxRight",x1,y1,x2,y2);
			clipLayer("zoomBoxBottom",x1,y1,x2,y2);
			showZoomBox();
		}
	 else {
		if (zooming)
			stopZoomBox(e);
	}
	return false;
}

// clip zoom box layer to mouse coords
function setClip() {
	if (x1>x2) {
		zmaxx=x1;
		zminx=x2;
	} else {
		zminx=x1;
		zmaxx=x2;
	}
	if (y1>y2) {
		zminy=y1;
		zmaxy=y2;
	} else {
		zmaxy=y1;
		zminy=y2;
	}

	if ((x1 != x2) && (y1 != y2)) {
		var ovBoxSize = 1;
		clipLayer("zoomBoxTop",zminx,zmaxy,zmaxx,zmaxy+ovBoxSize);
		clipLayer("zoomBoxLeft",zminx,zmaxy,zminx+ovBoxSize,zminy);
		clipLayer("zoomBoxRight",zmaxx-ovBoxSize,zmaxy,zmaxx,zminy);
		clipLayer("zoomBoxBottom",zminx,zminy-ovBoxSize,zmaxx,zminy);
	}
}

// start pan.... image will move
function startPan(e) {
	getImageXY(e);
	// keep it within the MapImage
	if ((mouseX<iWidth) && (mouseY<iHeight)) {
		if (panning) {
			stopPan(e);
		} else {
			x1=mouseX;
			y1=mouseY
			x2=x1+1;
			y2=y1+1;
			panning=true;
		}
	}
	return false;

}

function stopZoomBox(e) {
	zooming=false;
 	if ((zmaxx <zminx+2) && (zmaxy < zminy+2)) {
		// if the zoom box is too small
	} else {
			pMinx = x1;
			pMiny = y1;
			pMaxx = x2;
			pMaxy = y2;
			hideZoomBox();
			refreshMap();
	}
	return true;
}

// stop moving image.... pan
function stopPan(e) {
	if ((Math.abs(x2-x1) <=5) && (Math.abs(y2-y1) <=5)) {
		// the move is too small
		panning=false;
		return false;
	} else  {

		window.scrollTo(0,0);
		panning=false;
		var width = Math.abs(maxx - minx);
		var height = Math.abs(maxy - miny);
		var tempLeft=minx;
		var tempRight=maxx;
		var tempTop=maxy;
		var tempBottom=miny;
		pixelX = width / iWidth;
		var theY = iHeight - zmaxy;
		pixelY = height / iHeight;
		dmaxx = -(x2-x1);
		dmaxy = (y2-y1);
		refreshMap();
	}

	return true;

}

// move map image with mouse
function panMouse() {
	var xMove = x2-x1;
	var yMove = y2-y1;
	var cLeft = -xMove;
	var cTop = -yMove;
	var cRight = iWidth;
	var cBottom = iHeight;
	if (xMove>0) {
		cLeft = 0;
		cRight = iWidth - xMove;
	}
	if (yMove>0) {
		cTop = 0;
		cBottom = iHeight - yMove;
	}
	clipLayer(layeract,cLeft,cTop,cRight,cBottom);
	moveLayer(layeract,xMove+hspc,yMove+vspc);

	return false;
}

function hideZoomBox() {
	hideLayer("zoomBoxTop");
	hideLayer("zoomBoxLeft");
	hideLayer("zoomBoxRight");
	hideLayer("zoomBoxBottom");
}

function showZoomBox() {
		showLayer("zoomBoxTop");
		showLayer("zoomBoxLeft");
		showLayer("zoomBoxRight");
		showLayer("zoomBoxBottom");
}

//////////////////////////////common
if (isNav) {
  hspc=175;
	vspc=110;
	if (parseFloat(navigator.appVersion)<5){
	  isNav4=true;
  	if (parseFloat(navigator.appVersion)>=4.7)
	  	isNav47=true;
	} else is5up = true;
} else {
		isIE4=true;
		isIE=true;
		if (navigator.appVersion.indexOf("MSIE 5")>0) {
			isIE4 = false;
			is5up = true;
		}
}

// Create a DHTML layer
function createLayer(name, left, top, width, height, visible, content) {
	  var layer;
	  if (isNav4) {
	    document.writeln('<layer name="' + name + '" left=' + left + ' top=' + top + ' width=' + width + ' height=' + height +  ' visibility=' + (visible ? '"show"' : '"hide"') +  '>');
	    document.writeln(content);
	    document.writeln('</layer>');
	    layer = getLayer(name);
	    layer.width = width;
	    layer.height = height; }
	  else {
	    document.writeln('<div id="' + name + '" style="position:absolute; overflow:none; left:' + left + 'px; top:' + top + 'px; width:' + width + 'px; height:' + height + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
	    document.writeln(content);
	    document.writeln('</div>'); }
	  clipLayer(name, 0, 0, width, height);
}

// get the layer object called "name"
function getLayer(name) {
      if (isNav4) return(document.layers[name]);
	  else if (isIE4) {
	  	      if ( eval('document.all.' + name) != null) {
		         layer = eval('document.all.' + name + '.style');
		         return(layer); }
			  else return(null);  }
	  else if (is5up) {
   		      var theObj = document.getElementById(name);
		      return theObj.style;}
	  else return(null);
}

// move layer to x,y
function moveLayer(name, x, y) {
  	var layer = getLayer(name);
	if (layer != null) {
	  	if (isNav4)
    	   layer.moveTo(x, y);
	 	else if (isIE) {
    		    layer.left = x + "px";
   			    layer.top  = y + "px";}
		else {
			layer.height = iHeight - y;
			layer.width	= iWidth - x;
    		layer.left = x + "px";
   			layer.top  = y + "px";	}
	}
}

// set layer background color
function setLayerBackgroundColor(name, color) {
  	var layer = getLayer(name);
	if (layer != null) {
	    if (isNav4)  layer.bgColor = color;
		else layer.backgroundColor = color;
	}
}

// toggle layer to invisible
function hideLayer(name) {
  	var layer = getLayer(name);
	if (layer != null) {
	 	if (isNav4)	layer.visibility = "hide";
		else layer.visibility = "hidden";
	}
}

// toggle layer to visible
function showLayer(name) {
  	var layer = getLayer(name);
	if (layer != null) {
	  	if (isNav4)	layer.visibility = "show";
		else layer.visibility = "visible";
	}
}

// clip layer display to clipleft, cliptip, clipright, clipbottom
function clipLayer(name, clipleft, cliptop, clipright, clipbottom) {
	var layer = getLayer(name);
	if (layer != null) {
  		if (isNav4) {
			layer.clip.left   = clipleft;
			layer.clip.top    = cliptop;
		    layer.clip.right  = clipright;
			layer.clip.bottom = clipbottom;}
		else if (isIE)
			layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
	    else {
     		layer.height = clipbottom - cliptop;
			layer.width	= clipright - clipleft;
			layer.top	= (cliptop+vspc) + "px";
			layer.left	= (clipleft+hspc) + "px";}
	}
}

// replace layer's content with new content
function replaceLayerContent(name, content) {
  if (isNav4) {
     var layer = getLayer(name);
 if (layer != null) {
layer.document.open();
layer.document.writeln(content);
layer.document.close();}
}
  else if (isIE) {
    content = content.replace(/\'/g,"\\'");
  var str = "document.all." + name + ".innerHTML = '" + content + "'";
  eval(str); }
}

function boxIt(theLeft,theTop,theRight,theBottom) {
clipLayer("zoomBoxTop",theLeft,theTop,theRight,theTop+ovBoxSize);
clipLayer("zoomBoxLeft",theLeft,theTop,theLeft+ovBoxSize,theBottom);
clipLayer("zoomBoxRight",theRight-ovBoxSize,theTop,theRight,theBottom);
clipLayer("zoomBoxBottom",theLeft,theBottom-ovBoxSize,theRight,theBottom);
showLayer("zoomBoxTop");
showLayer("zoomBoxLeft");
showLayer("zoomBoxRight");
showLayer("zoomBoxBottom");
}

function alertSize() {
  var myWidth = 0, myHeight = 0;
  var incW=0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
   incW=myWidth>766?((myWidth-iWidth )/2)-110:hspcb
  return incW



}
function ajustaW(){
   hspc=alertSize();   
   moveLayer("theFondo",hspc-3,vspc-3)
   moveLayer("theMap2",hspc,vspc)
   moveLayer("theMap",hspc,vspc)

  moveLayer("zoomBoxTop",hspc,vspc);

  moveLayer("zoomBoxLeft",hspc,vspc);

  moveLayer("zoomBoxRight",hspc,vspc);

  moveLayer("zoomBoxBottom",hspc,vspc);
  moveLayer("loadLayer",hspc+iWidth/2-60,vspc+iHeight/2-12);
  moveLayer("theTop",hspc,vspc);

}

function apaga(){
actrst="act";
refreshMap();
return false;
}

function zoom(){
setState("zoomIn")
return false;
}


function zoomin(){
pMinx =iWidth /4;
pMiny =iHeight/4;
pMaxx =iWidth -(iWidth /4);
pMaxy =iHeight-(iHeight/4);
refreshMap();
return false;
}

function zoomout(){
dmaxx = -1;
dmaxy = -1;
zoomOut();
return false;
}

function imprime(){
window.print();
return false;
}

function desplaza(){
setState("pan")
return false;
}
function point(){
setState("query")
return false;
}

function despxy(x, y)
{
dmaxx=x;
dmaxy=y;
refreshMap();
return false;
}
function textos(){
if (textact=="0") textact="1";
else textact="0";
refreshMap();
return false;
}
function guarda(){
re= new RegExp(" ","g");
var t2a=t2.replace(re,"_");
re= new RegExp("/","g");
t2a=t2a.replace(re,"_");
cadcam="?me="+mest+"&sv="+t2a+cadvent+"&at="+textact+"&ap="+ptoact+timg+"&rd="+Math.round(Math.random()*10000);
parent.document.location.href= theServletPath+cadcam;

return false;
}
function puntos(){
if (ptoact=="0") {
  ptoact="1";
  cambpto=true;
}
else {
  ptoact="0";
  cambpto=true;
  }
refreshMap();
return false;
}

function cambianiv(niv){
if (niv=='E'){
mest="na";
CambiarMAP("00","na","00");
}else
if (niv=='M'){
mest="es";
CambiarMAP("99","es","00");
}else
if (niv=='A'){
mest="ag";
CambiarMAP("99","ag","00");
}
}
function actCapa(edo){
showLayer("loadLayer");
if (edo)
  cadcam="?me="+mest+"&ne=ag&la="+lyact+"&ly="+ly+"&t2="+t2+cadvent+"&at="+textact+"&ap="+ptoact+"&ch=1&rd=23" //+Math.round(Math.random()*10000);
else
  cadcam="?me="+mest+"&ne=es&la="+lyact+"&ly="+ly+"&t2="+t2+cadvent+"&at="+textact+"&ap="+ptoact+"&ch=0&rd=23" //+Math.round(Math.random()*10000);
parent.document.location.replace(theJSPPath+cadcam);
}

