var SMAP_URL_PREFIX="http://"; var SMAP_URL_PREFIX="http://"; SMAP_SERVER_HOST="mapserver4.sigisweb.net"; var SMAP_CLIENT_HOST="mapserver4.sigisweb.net"; var SMAP_CLIENT_PATH="/smap-2.2.2/client"; var SMAP_SERVER_PATH="/smap-2.2.2/server/php";  var SMAP_DEFAULT_VECTOR_MAP="SMapa-3.0.0.map";  var SMAP_DEFAULT_IMAGE_MAP="SMapaRaster.map"; var SMAP_TILE_UNAVAILABLE=SMAP_URL_PREFIX + SMAP_CLIENT_HOST + SMAP_CLIENT_PATH + "/images/blue.png"; var SMAP_IMAGES_PATH=SMAP_URL_PREFIX + SMAP_CLIENT_HOST + SMAP_CLIENT_PATH + "/images/"; var SMAP_CONTROLS_PATH=SMAP_URL_PREFIX + SMAP_CLIENT_HOST + SMAP_CLIENT_PATH + "/images/controls/"; var SMAP_CSS_PATH=SMAP_URL_PREFIX + SMAP_CLIENT_HOST + SMAP_CLIENT_PATH + "/css/"; var DEFAULT_TIMER_REFRESH_DL=1000; var WAIT_FOR_REFRESH_DL=1000; var SMAP_MAP_IMAGE_GENERATOR=SMAP_URL_PREFIX + SMAP_SERVER_HOST + SMAP_SERVER_PATH + "/SMapGenerator.php"; var TILE_PARSER_PATH=SMAP_URL_PREFIX + SMAP_SERVER_HOST + SMAP_SERVER_PATH + "/SMapImageServer.php"; var DOWNLOAD_ZIP_PATH=SMAP_URL_PREFIX + SMAP_SERVER_HOST + SMAP_SERVER_PATH + "/downloadzip.php"; var MAPSERVER_GESTOR_DL=SMAP_URL_PREFIX + SMAP_SERVER_HOST + SMAP_SERVER_PATH + "/SDynamicLayerGenerator.php"; var SMAP_SERVER_PATH=SMAP_URL_PREFIX + SMAP_SERVER_HOST + SMAP_SERVER_PATH + "/SServer.php"; 
SIcon=function(point, ssize, imagePath, withTansparency, SLabelObject) { this.path=null; this.image=null; this.posLatLong=null; this.posXY=null; this.left=null; this.top=null; this.size=null; this.originalSize=null; this.map=null; this.container=null; this.minLevel=null; this.maxLevel=null; this.isScalable=null; this.pivot=null; this.infoCallout=null; this.isOff=false; this.xOffSet=0; this.yOffSet=0; this.posLatLong=point; this.size=new SSize(ssize.width, ssize.height); this.originalSize=new SSize(ssize.width, ssize.height); this.path=imagePath; this.isScalable=false; this.minLevel=1; this.maxLevel=19; this.showLabel=true; this.SLabelObject=(SLabelObject&&SLabelObject.setSize&&SLabelObject.moveTo&&SLabelObject.remove)?SLabelObject:null; this.createImage(0, 0, this.size); this.image.style.zIndex=3; var path=this.path; if (withTansparency) { this.image.onload=function() { if (this.runtimeStyle&&/\.png$/.test(this.src.toLowerCase())) { if (this.runtimeStyle.filter=="") { this.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + path + "',sizingMethod='scale')"; this.src=SMAP_IMAGES_PATH + "blank.gif"; } } }; } this.posXY=new SGeoPoint(0,0); this.image.src=this.path; this.map=null; }; SIcon.prototype.remove=function() { this.path=null; this.posLatLong=null; this.posXY=null; this.size=null; this.map=null; this.image.onload=""; if (this.infoCallout) { this.infoCallout.close(); } this.infoCallout=null; SEvent.deattachDOM(this.image, "mousedown", this.honmousedown); SEvent.deattachDOM(this.image, "click", this.honmouseclick); SEvent.deattachDOM(this.image, "mouseover", this.honmouseover); SEvent.deattachDOM(this.image, "mouseout", this.honmouseout); SEvent.deattachDOM(this.image, "dblclick", this.honmousedblclick); SEvent.RemoveListener(this.listenerLevel); SEvent.RemoveListener(this.listenerResize); SEvent.RemoveListener(this.listenerTryZoom); if (this.SLabelObject) { this.SLabelObject.remove(); } this.container.removeChild(this.image); this.container=null; this.image=null; }; SIcon.prototype.setMinLevel=function(value) { this.minLevel=value; }; SIcon.prototype.setMaxLevel=function(value) { this.maxLevel=value; }; SIcon.prototype.setScalable=function(value) { this.isScalable=!value?false:true; }; SIcon.prototype.setIconSize=function() { if (this.isScalable&&this.map) { var dif=this.maxLevel - this.minLevel; var xfactor=this.map.GetLevel()  * this.originalSize.width / dif; var yfactor=this.map.GetLevel()  * this.originalSize.height / dif; xfactor=(this.originalSize.width/5)+xfactor; yfactor=(this.originalSize.height/5)+yfactor; this.size.width=Math.floor(xfactor>this.originalSize.width?this.originalSize.width:xfactor); this.size.height=Math.floor(yfactor>this.originalSize.height?this.originalSize.height:yfactor); this.image.style.width=toPixel(this.size.width); this.image.style.height=toPixel(this.size.height); } }; SIcon.prototype.setMapReference=function(map, container) { this.map=map; this.container=container; this.container.appendChild(this.image); if (this.map.GetLevel() >=this.minLevel && this.map.GetLevel() <=this.maxLevel) { this.image.style.display=""; this.isOff=false; this.SetDegreePosition(this.posLatLong, 0, 0); } else { if (this.infoCallout) { this.infoCallout.close(); this.infoCallout=null; }   this.image.style.display="none"; this.isOff=true; }  if (this.SLabelObject) { this.SLabelObject.appendTo(container); }  this.listenerLevel=SEvent.Bind(this.map, "OnMapChangeLevel",this, this.reubicate); this.listenerResize=SEvent.Bind(this.map, "OnMapResize",this, this.reubicate); this.listenerTryZoom=SEvent.Bind(this.map, "OnMapTryZoom",this, this.reubicate); }; SIcon.prototype.SetDegreePosition=function(point, xOffSet, yOffSet) { if (this.map) { var xOffSet=parseInt(xOffSet); var yOffSet=parseInt(yOffSet); var point=new SGeoPoint(point.X, point.Y); this.posLatLong=new SGeoPoint(point.X, point.Y); var pixelPoint=this.map.getPixelOnGrid(this.posLatLong ); this.SetPixelPosition(pixelPoint.X, pixelPoint.Y, xOffSet, yOffSet); } }; SIcon.prototype.SetPixelPosition=function(left, top) { var left=!left?0:parseInt(left); var top=!top?0:parseInt(top); this.setIconSize(); switch(this.pivot) { case "up": this.xOffSet=0; this.yOffSet=0; this.posXY.X=left-this.size.width/2; this.posXY.Y=top; break; case "left": this.xOffSet=this.size.width/2; this.yOffSet=(this.size.height/2)*-1; this.posXY.X=left; this.posXY.Y=top-this.size.height/2; break; case "center": this.xOffSet=0; this.yOffSet=(this.size.height/2)*-1; this.posXY.X=left-this.size.width/2; this.posXY.Y=top-this.size.height/2; break; case "right": this.xOffSet=(this.size.width/2)*-1; this.yOffSet=(this.size.height/2)*-1; this.posXY.X=left-this.size.width; this.posXY.Y=top-this.size.height/2;   this.pivot=1; break; case "down": default: this.xOffSet=0; this.yOffSet=(this.size.height)*-1; this.posXY.X=left-this.size.width/2; this.posXY.Y=top-this.size.height;    } this.left=this.posXY.X; this.top=this.posXY.Y; this.image.style.left=toPixel(this.left); this.image.style.top=toPixel(this.top); if (this.SLabelObject) { var x1=((this.left + (this.size.width/2))-(this.SLabelObject.width/2)); var y1=(this.top + this.size.height); this.SLabelObject.moveTo(x1, y1); } this.image.style.zIndex=98; }; SIcon.prototype.setTooltip=function(value) { this.image.title=value; }; SIcon.prototype.setDockAlignment=function(sPivot) { this.pivot=sPivot; }; SIcon.prototype.getAlign=function() { switch(this.pivot) { case "up": case "left": case "center":     case "right": return this.pivot; case "down": default: return "down"; } }; SIcon.prototype.showInfoWindow=function(size, content) { if (this.map) { this.infoCallout=this.map.openWindow(this.posLatLong, size, content); var x=this.posXY.X + (this.size.width/2); var y=this.posXY.Y; this.infoCallout.setPixelPosition(new SGeoPoint(x, y)); this.infoCallout.setOffSet(this.xOffSet, this.yOffSet); return (this.infoCallout); } }; SIcon.prototype.createImage=function(x, y, size) { this.image=document.createElement('IMG');   this.image.style.position="absolute"; this.image.style.border="0px solid gray"; this.image.style.left=toPixel(x); this.image.style.top=toPixel(y); this.image.style.width=toPixel(this.size.width); this.image.style.height=toPixel(this.size.height); this.image.width=this.size.width; this.image.height=this.size.height; this.image.style.display=""; SwitchCursor(this.image, "pointer"); SetSelectableStatus(this.image, "off"); this.honmousedown=SEvent.attachDOM(this.image, 'mousedown', function(e){ var e=!e?event:e; var retVal=this.cancelBehaviour(e); this.x=e;  return (this.cancelBehaviour(e)); }, this); this.honmousedblclick=SEvent.attachDOM(this.image, 'dblclick', function(e){ var e=!e?event:e; return (this.cancelBehaviour(e)); }, this); this.honmouseclick=SEvent.attachDOM(this.image, 'click', this.onclick, this); this.honmouseover=SEvent.attachDOM(this.image, 'mouseover', this.onmouseover, this); this.honmouseout=SEvent.attachDOM(this.image, 'mouseout', this.onmouseout, this); };  SIcon.prototype.cancelBehaviour=function(e) { if(e.srcElement ) { e.cancelBubble=true; e.returnValue=false; } else if(e.preventDefault) { e.stopPropagation(); e.preventDefault(); } return false; }; SIcon.prototype.reubicate=function(level) { if (this.map) { if (level) { if (level >=this.minLevel && level <=this.maxLevel) { this.image.style.display=""; if (this.SLabelObject&&this.showLabel) { this.SLabelObject.setVisibility(""); }     else if (this.SLabelObject&&!this.showLabel) { this.SLabelObject.setVisibility("none"); }     this.isOff=false; this.SetDegreePosition(this.posLatLong, 0,0); } else { this.image.style.display="none"; this.isOff=true; if (this.SLabelObject) { this.SLabelObject.setVisibility("none"); }     if (this.infoCallout) { this.infoCallout.close(); this.infoCallout=null; } } } else { this.image.style.display=""; if (this.SLabelObject&&this.showLabel) { this.SLabelObject.setVisibility(""); }     else if (this.SLabelObject&&!this.showLabel) { this.SLabelObject.setVisibility("none"); }     this.isOff=false; this.SetDegreePosition(this.posLatLong, 0,0); } } }; SIcon.prototype.onclick=function() { SEvent.Trigger(this, "onclick") }; SIcon.prototype.onmouseover=function() { SEvent.Trigger(this, "onmouseover"); }; SIcon.prototype.onmouseout=function() { SEvent.Trigger(this, "onmouseout"); }; SIcon.prototype.getLatLong=function() { return this.posLatLong; }; SIcon.prototype.setLabelVisibility=function(value) { value=!value?false:true; this.showLabel=value; if (this.SLabelObject&&this.showLabel) { this.SLabelObject.setVisibility(""); }  else if (this.SLabelObject&&!this.showLabel) { this.SLabelObject.setVisibility("none"); } }; 
SHttpRequest=function() { this._url=null; this._method=null; this._async=true; this._username=null; this._passw=null; var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >=5)  try {   xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");  } catch (e) {   try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");   } catch (E) { xmlhttp=false;   }  } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {   xmlhttp=new XMLHttpRequest(); } this.request=xmlhttp; }; SHttpRequest.prototype.Open=function(UrlString, Method, Async, Username, Password) { if (this.request) { this._url=UrlString; Method=!Method?null:Method.toUpperCase(); switch(Method) { case "POST": case "GET": this._method=Method; break; default: this._method="POST"; } this._async=!Async? true:Async; this._username=!Username?null:Username; this._passw=!Password?null:Password; } }; SHttpRequest.prototype.Send=function(Parameters, functionHandler) { if (this._method!="POST") { this._url=this._url +"?"+Parameters+"&"+  new Date().getTime( ); Parameters=!ie?null:""; } this.request.open(this._method, this._url, this._async, this._username, this._passw); this.request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); this.request.setRequestHeader("Cache-Control", "no-cache"); this.request.setRequestHeader("Pragma", "no-cache"); this.request.setRequestHeader("Expires", "-1"); if (functionHandler) { this.request.onreadystatechange=functionHandler; } this.request.send(Parameters); }; SHttpRequest.prototype.Abort=function() { this.request.abort(); }; 
STimer=function Timer(npause)  { this._pauseTime=typeof npause=="undefined" ? 1000 : npause; this._timer=null; this._isStarted=false; this._isTimeOut=false; this._isInterval=false; }; STimer.prototype.startTimeout=function (ref, aFunction) {  if (typeof(aFunction)!="function"||!ref) { return false; } if (this.isStarted()) { this.stop(); } var args=new Array(); if (arguments.length > 2) { for (i=2;i<arguments.length;i++) { args.push(arguments[i]); } }  this._isTimeOut=true; this._isInterval=false; this._timer=this.setTimeout(ref, aFunction, this._pauseTime, args); this._isStarted=true; return this._isStarted; }; STimer.prototype.startInterval=function (ref, aFunction)  { if (typeof(aFunction)!="function"||!ref) { return null; } var args=new Array(); if (arguments.length > 2) { for (i=2;i<arguments.length;i++) { args.push(arguments[i]); } } if (this.isStarted()) { this.stop(); } this._isInterval=true; this._isTimeOut=false; this._timer=this.setInterval(ref, aFunction, this._pauseTime, args); this._isStarted=true; return this._isStarted; }; STimer.prototype.setTimeout=function(oref, func, pause,  args) { var myRef=this; var timId=window.setTimeout(function(){func.apply(oref, args); myRef.stop(); myRef=null;},pause); return timId }; STimer.prototype.setInterval=function(oref, func, interval, args) { var intervalId=window.setInterval(function(){func.apply(oref, args)}, interval); return intervalId; }; STimer.prototype.stop=function ()  { if (this._timer !=null) { if(this._isInterval) { window.clearInterval(this._timer); } else { window.clearTimeout(this._timer); } } this._isStarted=false; }; STimer.prototype.isStarted=function ()  { return this._isStarted; }; STimer.prototype.getPauseTime=function ()  { return this._pauseTime; }; STimer.prototype.setPauseTime=function (nPauseTime)  { this._pauseTime=nPauseTime; }; STimer.prototype.getType=function() { var retVal=null; if(this._isInterval) { retVal="interval"; } else if(this._isTimeout) { retVal="timeout"; } return retVal; }; 
SRange=function() { this.value=1; this.minimum=1; this.maximum=100; this.step=1; }; SRange.prototype.setExtent=function (extent)  { if (this._extent !=extent)  { if (extent < 0) { this._extent=0; } else if (this._value + extent > this._maximum) { this._extent=this._maximum - this._value; } else { this._extent=extent; } if (!this._isChanging && typeof this.onchange=="function") { this.onchange(); } } }; SRange.prototype.value=null; SRange.prototype.minimum=null; SRange.prototype.maximum=null; SRange.prototype.step=null; SRange.prototype.setValue=function (newValue) { newValue=parseFloat(newValue); if (isNaN(newValue)) { return; } var oldValue=this.value; if (oldValue !=newValue)  { if (newValue > this.maximum) { this.value=this.maximum; } else if (newValue < this.minimum) { this.value=this.minimum; } else { this.value=newValue; } if(oldValue!=this.value) { this.onchange(oldValue, this.value); } } }; SRange.prototype.getValue=function() { return this.value; }; SRange.prototype.setMinimum=function (minimum) { minimum=parseFloat(minimum); if (isNaN(minimum)) { return; } if (this.minimum !=minimum) { this.minimum=minimum; if (minimum > this.value) { this.setValue(minimum); } if (minimum > this.maximum) { this.setMaximum(minimum); this.setValue(minimum) } } }; SRange.prototype.setStep=function (value) { value=parseFloat(value); if (isNaN(value)) { return; } if (this.step !=value) { this.step=value; if (value > (this.maximum-this.minimum)) { this.step=this.maximum-this.maximum; this.setValue(this.minimum); } } }; SRange.prototype.getStep=function() { return this.step; }; SRange.prototype.getMinimum=function() { return this.minimum; }; SRange.prototype.setMaximum=function(maximum) { maximum=parseFloat(maximum); if (isNaN(maximum)) { return; } if (this.maximum !=maximum) { this.maximum=maximum;   if (maximum < this.value) { this.setValue(maximum); } if (maximum < this.minimum) { this.setMinimum(maximum); this.setValue(this.maximum); }   } }; SRange.prototype.getMaximum=function () { return this.maximum; }; SRange.prototype.up=function() { this.setValue(this.value + this.step) }; SRange.prototype.down=function() { this.setValue(this.value - this.step) }; SRange.prototype.onchange=function(oldValue, newValue) { SEvent.Trigger(this, "onchange", oldValue, newValue); }; 
SListener=function(objSource,eventName,listenerFn) { this.Instance=objSource; this.EventName=eventName; this.ListenerFunction=listenerFn; return this; }; SListener.prototype.Instance=null; SListener.prototype.EventName=null; SListener.prototype.ListenerFunction=null; SEvent=function() { }; SEvent.prototype.AddListener=function(objSource, eventName, listenerFn) { var _propName=this.GetPropertyName(eventName);  if(objSource[_propName]) { objSource[_propName].push(listenerFn); } else { objSource[_propName]=[listenerFn]; } return new SListener(objSource, eventName, listenerFn); }; SEvent.prototype.AddInternalListener=function(objSource, eventName, listenerFn) { var _propName=this.GetInternalPropertyName(eventName); if(objSource[_propName]) { objSource[_propName].push(listenerFn); } else { objSource[_propName]=[listenerFn]; } return new SListener(objSource, eventName, listenerFn); }; SEvent.prototype.Bind=function(objSource, eventName, targetObject, targetEvent) { var _function=this.CallBack(targetObject, targetEvent); var oListener=this.AddListener(objSource, eventName, _function); return oListener; }; SEvent.prototype.InternalBind=function(objSource, eventName, targetObject, targetEvent) { var _function=this.CallBack(targetObject, targetEvent); var oListener=this.AddInternalListener(objSource, eventName, _function); return oListener; }; SEvent.prototype.RemoveListener=function(listener) { try { var eprop=this.GetPropertyName(listener.EventName); var _list=listener.Instance[eprop]; for(var i=0;i<_list.length;i++) { if(_list[i]==listener.ListenerFunction) { _list[i]=null; _list.splice(i,1); return; } } } catch(e) { } }; SEvent.prototype.RemoveInternalListener=function(listener) { var eprop=this.GetInternalPropertyName(listener.EventName); var _list=listener.Instance[eprop]; try { for(var i=0;i<_list.length;i++) { if(_list[i]==listener.ListenerFunction) { _list[i]=null; _list.splice(i,1); return; } } } catch(e) { } }; SEvent.prototype.ClearListeners=function(objSource, eventName) { var eprop=this.GetPropertyName(eventName); objSource[eprop]=null; }; SEvent.prototype.ClearInternalListeners=function(objSource, eventName) { var eprop=this.GetInternalPropertyName(eventName); objSource[eprop]=null; }; SEvent.prototype.Trigger=function(objSource, eventName) { var _propName=this.GetPropertyName(eventName); var src=objSource[_propName]; if(src&&src.length>0) { var arr=[]; for(var i=2;i<arguments.length;i++) { arr.push(arguments[i]); } for(var i=0;i<src.length;i++) { var _current_src=src[i]; if(_current_src) { try { _current_src.apply(objSource,arr); } catch(h) { } } } } }; SEvent.prototype.InternalTrigger=function(objSource, eventName) { var _propName=this.GetInternalPropertyName(eventName); var src=objSource[_propName]; if(src&&src.length>0) { var arr=[]; for(var i=2;i<arguments.length;i++) { arr.push(arguments[i]); } for(var i=0;i<src.length;i++) { var _current_src=src[i]; if(_current_src) { try { _current_src.apply(objSource,arr); } catch(h) { } } } } }; SEvent.prototype.CallBack=function(targetObject, targetEvent) { var _function=function() { return targetEvent.apply(targetObject, arguments); }; return _function; }; SEvent.prototype.GetPropertyName=function(eventName) { return "_ExtEvent__"+eventName; }; SEvent.prototype.GetInternalPropertyName=function(eventName) { return "_InternalSEvent__"+eventName; }; SEvent.prototype.attachDOM=function (oTarget, sEventType, fnHandler, oRef) { if (!oTarget) return; if (arguments.length>3) { var args=new Array(); args.push(null); for (var i=4;i<arguments.length;i++) { args.push(arguments[i]);  } var func=function (e){ args[0]=e; fnHandler.apply(oRef, args); }; } else { var func=fnHandler; } if (oTarget.addEventListener)  { oTarget.addEventListener(sEventType, func, false); } else if (oTarget.attachEvent) { oTarget.attachEvent("on" + sEventType, func); } else { oTarget["on" + sEventType]=func; } oTarget=null; return func; }; SEvent.prototype.deattachDOM=function (oTarget, sEventType, fnHandler) { if (!oTarget) return; if (oTarget.removeEventListener) { oTarget.removeEventListener(sEventType, fnHandler, false); } else if (oTarget.detachEvent) { oTarget.detachEvent("on" + sEventType, fnHandler); } else { oTarget["on" + sEventType]=null; } }; SEvent=new SEvent(); 
SGeoPoint=function(x,y) { if ( (typeof(x)=="number") && (typeof(y)=="number") ) { this.X=x; this.Y=y; } else { this.X=null; this.Y=null; } }; SGeoPoint.prototype.X=null; SGeoPoint.prototype.Y=null; SGeoPoint.prototype.ToString=function() { var n=1/2; var delimiter=","; var s=new String(n); var re=new RegExp(delimiter,"gi"); if ( s.indexOf(delimiter)==-1 ) { return "("+this.X+","+this.Y+")"; } else { var xc=new String(this.X); var yc=new String(this.Y); return "("+xc.replace(re,".")+","+yc.replace(re,".")+")"; } }; SGeoPoint.prototype.Equal=function(point) { if ( (typeof(point.X)=="number") && (typeof(point.Y)=="number") ) { if ( (point.X==this.X) && (point.Y==this.Y) ) { return true; } else { return false; } } else { return false; } }; SGeoPoint.prototype.GetPointsDistance=function(point) { return Math.sqrt(Math.pow((this.X-point.X),2)+Math.pow((this.Y-point.Y),2)); }; SGeoPoint.prototype.Slope=function(point) { if ( (typeof(point.X)=="number") && (typeof(point.Y)=="number") ) { if ( (point.Y - this.Y)==0 ) { return 0; } else { return (point.Y - this.Y)/(point.X - this.X); } } else { return false; } }; SGeoPoint.prototype.Angle=function(point) { if ( (typeof(point.X)=="number") && (typeof(point.Y)=="number") ) { var x1=point.X - this.X; var y1=point.Y - this.Y; var x2=1; var y2=0; var modp1=Math.abs( Math.sqrt( Math.pow(x1,2)+Math.pow(y1,2) ) ); var modp2=Math.abs( Math.sqrt( Math.pow(x2,2)+Math.pow(y2,2) ) ); var a=0; var la=0; var lb=0; if ( (modp1*modp2)==0 ) { a=0; } else { a=Math.acos( ( x1*x2 + y1*y2) / (modp1*modp2) ); } var la=( this.X - x2 ) * point.Y - ( this.Y - y2 ) * point.X; var lb=( this.X - x2 ) * y2 - ( this.Y - 0 ) * x2; if ( la - lb > 0) { a=Math.abs(a - 2*Math.PI); } return a*180/Math.PI; } else { return false; } }; SGeoPoint.prototype.GetRelativePosition=function(refPoint) { var _cy=""; var _cx=""; if(this.X < refPoint.X) { _cx="west"; } else if(this.X > refPoint.X) { _cx="east"; } else { _cx=""; } if(this.Y < refPoint.Y) { _cy="north"; } else if(this.Y > refPoint.Y) { _cy="south"; } else { _cy=""; } return  (_cy + _cx); }; 
SDirCalc=function SDirCalc(level,idx,idy,objSIL,objSDT,dir_separator,img_type) { this.SIL; this.SDT; this.idx; this.idy; this.dirPath; this.img_type; this.level; this.dir_separator; this.image_name; if (level==objSIL.GetLevel()) { this.SIL=objSIL; this.SDT=objSDT; this.idx=idx; this.idy=idy; this.dirPath=this.CalcDirPath(dir_separator); this.img_type=img_type; this.level=level; this.dir_separator=dir_separator; this.image_name=this.idx + "_" + this.idy; } else { return null; } }; SDirCalc.prototype.CalcDirPath=function(dir_separator) { var dirLevel=1; var path=""; var i=1; var idx_pre; var idy_pre; var fdx_pre; var fdy_pre; var ndx_pre; var ndy_pre; var numFilesByDir=this.SIL.GetNumFiles()/this.SDT.GetNumDirsBranchLevel(dirLevel); while ( numFilesByDir >=1 ) { if (dirLevel==1) { ntix=this.SIL.GetNumXFiles(); ntiy=this.SIL.GetNumYFiles(); d=this.SDT.GetNumCombineDirsLevel(dirLevel); fdx=ntix/d; fdy=ntiy/d; ndx=Math.ceil(this.idx/fdx); ndy=Math.ceil(this.idy/fdy); nd=ndx +"_"+ ndy; path=path + dir_separator + nd; numFilesByDir=numFilesByDir/this.SDT.GetNumDirsBranchLevel(dirLevel+1); dirLevel=dirLevel+1; i=i+1; idx_pre=this.idx; idy_pre=this.idy; fdx_pre=fdx; fdy_pre=fdy; ndx_pre=ndx; ndy_pre=ndy; } else { idx=idx_pre-((ndx_pre-1)*fdx_pre); idy=idy_pre-((ndy_pre-1)*fdy_pre); d=this.SDT.GetNumCombineDirsLevel(dirLevel); fdx=fdx_pre/d; fdy=fdy_pre/d; ndx=Math.ceil(idx/fdx); ndy=Math.ceil(idy/fdy); nd=ndx +"_"+ ndy; path=path + dir_separator + nd; numFilesByDir=numFilesByDir/this.SDT.GetNumDirsBranchLevel(dirLevel+1); dirLevel=dirLevel+1; i=i+1; idx_pre=idx; idy_pre=idy; fdx_pre=fdx; fdy_pre=fdy; ndx_pre=ndx; ndy_pre=ndy; } } return path + dir_separator; }; SDirCalc.prototype.GetPath=function() { return this.dir_separator + this.level + this.dirPath; }; SDirCalc.prototype.GetImageName=function() { return this.image_name; }; SDirCalc.prototype.GetImagePath=function() { return this.dir_separator + this.level + this.dirPath + this.idx + "_" + this.idy + "." + this.img_type; }; SDirCalc.prototype.GetMaxXCoor=function() { return ( ( (this.idx - this.SIL.GetMinYid()) )/(this.SIL.GetXFactor()) )+ (this.SIL.GetMinYgrade()) + (1/this.SIL.GetXFactor()); }; SDirCalc.prototype.GetMaxYCoor=function () { return  ( ( (this.idy - this.SIL.GetMinYid() ) )/(this.SIL.GetYFactor()) )+ (this.SIL.GetMinXgrade()) + (1/this.SIL.GetYFactor()); }; SDirCalc.prototype.GetMinXCoor=function() { return ( ( (this.idx - this.SIL.GetMinXid()) )/(this.SIL.GetXFactor()) )+ (this.SIL.GetMinYgrade()); }; SDirCalc.prototype.GetMinYCoor=function() { return ( ( (this.idy - this.SIL.GetMinYid()) )/(this.SIL.GetYFactor()) )+ (this.SIL.GetMinXgrade()); }; 
SDirTree=function SDirTree() { this.initLevel=1; this.endLevel=1; this.numLevels=1; }; SDirTree.prototype.AddLevel=function(numLevels) { this.numLevels=numLevels; this.endLevel=numLevels; }; SDirTree.prototype.GetNumDirs=function() { return this.GetNumDirsLevels(this.initLevel,this.endLevel); }; SDirTree.prototype.GetNumDirsLevel=function(level) { if (this.numLevels < level ) { this.AddLevel(level-this.numLevels); } if ( level > 0 ) { return this.GetNumCombineDirsLevel(level*2)*this.GetNumDirsBranchLevel(level-1); } else { return null; } }; SDirTree.prototype.GetNumDirsLevels=function(initLevel,endLevel) { if ( initLevel <=endLevel ) { var sum=0; var stack=1; for ( j=initLevel ; j <=endLevel; j++ ) { for ( i=initLevel ; i <=j ; i++ ) { stack=stack * this.GetNumDirsBranchLevel(i); } sum=sum + stack; } return stack; } else { return null; } }; SDirTree.prototype.GetNumDirsBranchLevel=function(level) { if (this.numLevels < level ) { this.AddLevel(level-this.numLevels); } return this.GetNumCombineDirsLevel(level*2); }; SDirTree.prototype.GetNumCombineDirsLevel=function(level) { this.AddLevel(level); return Math.pow(2,level); }; SDirTree.prototype.GetNumInitLevel=function() { return this.initLevel; }; SDirTree.prototype.GetNumEndLevel=function() { return this.endLevel; }; SDirTree.prototype.GetNumLevels=function() { return this.numLevels; }; 
SImagesLevel=function SImagesLevel(level) { this.minXgrade=-180; this.maxXgrade=180; this.minYgrade=-180; this.maxYgrade=180; this.minXid=1; this.maxXid=0; this.minYid=1; this.maxYid=0; this.Xgrades=0; this.Ygrades=0;  this.numXFiles=0; this.numYFiles=0; this.level=0; this.imageWidth=0; this.imageHeight=0; this.level=level; this.Xgrades=this.maxXgrade - this.minXgrade; this.Ygrades=this.maxYgrade - this.minYgrade; this.imageWidth=this.Xgrades*Math.pow(2,-(level-1)); this.imageHeight=this.Ygrades*Math.pow(2,-(level-1)); this.numXFiles=Math.pow(2,level-1); this.numYFiles=Math.pow(2,level-1); this.maxXid=Math.pow(2,level-1); this.maxYid=Math.pow(2,level-1); }; SImagesLevel.prototype.FactorK=function(idMin,idMax,coorMin,coorMax) { return ((idMax+1)-idMin)/(coorMax-coorMin); }; SImagesLevel.prototype.GetImageWidth=function() { return this.imageWidth; }; SImagesLevel.prototype.GetImageHeight=function() { return this.imageHeight; }; SImagesLevel.prototype.GetLevel=function() { return this.level; }; SImagesLevel.prototype.GetNumXFiles=function() { return this.numXFiles; }; SImagesLevel.prototype.GetNumYFiles=function() { return this.numYFiles; }; SImagesLevel.prototype.GetNumFiles=function() { return this.numXFiles*this.numYFiles; }; SImagesLevel.prototype.GetXFactor=function() { return this.FactorK(1,this.GetNumXFiles(),this.minXgrade,this.maxXgrade); }; SImagesLevel.prototype.GetYFactor=function() { return this.FactorK(1,this.GetNumYFiles(),this.minYgrade,this.maxYgrade); }; SImagesLevel.prototype.GetMinXgrade=function() { return this.minXgrade; }; SImagesLevel.prototype.GetMinYgrade=function() { return this.minYgrade; }; SImagesLevel.prototype.GetMinXid=function() { return this.minXid; }; SImagesLevel.prototype.GetMinYid=function() { return this.minYid; }; 
SConvers=function SConvers(objSIL) { this.SIL=objSIL; };  SConvers.prototype.GetMaxXCoor=function(idx) { return ( ( (idx - this.SIL.GetMinYid()) )/(this.SIL.GetXFactor()) )+(this.SIL.GetMinYgrade()) + (1/this.SIL.GetXFactor()); }; SConvers.prototype.GetMaxYCoor=function(idy) { return ( ( (idy - this.SIL.GetMinYid()) )/(this.SIL.GetYFactor()) )+(this.SIL.GetMinXgrade()) + (1/this.SIL.GetYFactor()); }; SConvers.prototype.GetMinXCoor=function(idx) { return ( ( (idx - this.SIL.GetMinXid()) )/(this.SIL.GetXFactor()) )+ (this.SIL.GetMinYgrade()); }; SConvers.prototype.GetMinYCoor=function(idy) { return ( ( (idy - this.SIL.GetMinYid()) )/(this.SIL.GetYFactor()) )+ (this.SIL.GetMinXgrade()); }; SConvers.prototype.GetMaxXId=function(coorx) { return Math.ceil(  this.SIL.GetXFactor()*(coorx - this.SIL.GetMinXgrade()) + this.SIL.GetMinXid() ); }; SConvers.prototype.GetMaxYId=function(coory) { return Math.ceil(  this.SIL.GetYFactor()*(coory - this.SIL.GetMinYgrade()) + this.SIL.GetMinYid() ); }; SConvers.prototype.GetMinXId=function(coorx) { return Math.floor(  this.SIL.GetXFactor()*(coorx - this.SIL.GetMinXgrade()) + this.SIL.GetMinXid() ); }; SConvers.prototype.GetMinYId=function(coory) { return Math.floor(  this.SIL.GetYFactor()*(coory - this.SIL.GetMinYgrade()) + this.SIL.GetMinYid() ); }; 
SGeoBox=function(xmin,ymin,xmax,ymax) { if ( (typeof(xmin)=="number") && (typeof(ymin)=="number") && (typeof(xmax)=="number") && (typeof(ymax)=="number") ) { this.Xmin=xmin; this.Ymin=ymin; this.Xmax=xmax; this.Ymax=ymax; } else { this.Xmin=null; this.Ymin=null; this.Xmax=null; this.Ymax=null; } }; SGeoBox.prototype.Xmin=null; SGeoBox.prototype.Ymin=null; SGeoBox.prototype.Xmax=null; SGeoBox.prototype.Ymax=null; SGeoBox.prototype.ToString=function() { var n=1/2; var delimiter=","; var s=new String(n); var re=new RegExp(delimiter,"gi"); if ( s.indexOf(delimiter)==-1 ) { return "("+ this.Xmin +","+ this.Ymin +","+ this.Xmax +","+ this.Ymax +")"; } else { var xminc=new String(this.Xmin); var yminc=new String(this.Ymin); var xmaxc=new String(this.Xmax); var ymaxc=new String(this.Ymax); return "("+ xminc.replace(re,".") +","+ yminc.replace(re,".") +","+ xmaxc.replace(re,".") +","+ ymaxc.replace(re,".") +")"; } }; SGeoBox.prototype.Equal=function(box) { if ( (typeof(box.Xmin)=="number") && (typeof(box.Ymin)=="number") && (typeof(box.Xmax)=="number") && (typeof(box.Ymax)=="number") ) { if ( (box.Xmin==this.Xmin) && (box.Ymin==this.Ymin) && (box.Xmax==this.Xmax) && (box.Ymax==this.Ymax)) { return true; } else { return false; } } else { return false; } }; SGeoBox.prototype.GetWidth=function() { return Math.abs(this.Xmax-this.Xmin); }; SGeoBox.prototype.GetHeight=function() { return Math.abs(this.Ymax-this.Ymin); }; SGeoBox.prototype.GetCenter=function() { var paux=new SGeoPoint(0,0); paux.X=(this.Xmax-this.Xmin)/2 + this.Xmin; paux.Y=(this.Ymax-this.Ymin)/2 + this.Ymin; return paux; }; SGeoBox.prototype.Intersects=function(box) {   return box.GetWidth()> 0 && box.GetHeight() > 0 && this.GetWidth() > 0 && this.GetHeight() > 0 && box.Xmin <=this.Xmax && box.Xmax >=this.Xmin && box.Ymin <=this.Ymax && box.Ymax >=this.Ymin; }; SGeoBox.prototype.IsWithin=function(box) {   return box.GetWidth() > 0 && box.GetHeight() > 0       && this.GetWidth() > 0       && this.GetHeight() > 0       && box.Xmin >=this.Xmin       && box.Xmax <=this.Xmax       && box.Ymin >=this.Ymin       && box.Ymax <=this.Ymax; }; SGeoBox.prototype.Contains=function(point) {   return this.GetWidth() > 0  && this.GetHeight() > 0 && point.X <=this.Xmax && point.X >=this.Xmin && point.Y >=this.Ymin && point.Y <=this.Ymax; }; 
SGeoTool=function() { }; SGeoTool.prototype.PixelToCoor=function(point,box,width,height) { var paux=new SGeoPoint(0,0); paux.X=box.Xmin+((box.Xmax - box.Xmin)*(point.X/width)); paux.Y=box.Ymin+((box.Ymax - box.Ymin)*(1-(point.Y/height))); return paux; }; SGeoTool.prototype.CoorToPixel=function(point,box,width,height) { var paux=new SGeoPoint(0,0); paux.X=((point.X-box.Xmin)*width)/(box.Xmax-box.Xmin); paux.Y=((((point.Y-box.Ymin)*height)/(box.Ymax-box.Ymin)-height)*-1); return paux; }; 
STile=function(container, xid, yid, level, left, top, mapType) { this.xId=xid; this.yId=yid; this.level=level; this.left=left; this.top=top; this.mapType=mapType; this.image=null; this.container=container; this.trys=0; this.timer=new STimer(1000); this.tmrDelay=new STimer(20); this.bindedOnLoad=null; this.bindedOnError=null; this.bindedOnAbort=null; SetSelectableStatus(this.container, "off"); this.wunload=SEvent.attachDOM(window, 'unload', this.destroy, this); this.createImage(); this.configureImage(xid, yid, level, left, top); this.useCache=true; }; STile.prototype.xId=null; STile.prototype.yId=null; STile.prototype.level=null; STile.prototype.left=null; STile.prototype.top=null; STile.prototype.size=null; STile.prototype.image=null; STile.prototype.container=null; STile.prototype.trys=null; STile.prototype.timer=null; STile.prototype.bindedOnLoad=null; STile.prototype.bindedOnError=null; STile.prototype.bindedOnAbort=null; STile.prototype.wunload=null; STile.prototype.tmrDelay=null; STile.prototype.onload=function() { ChangeOpacity(this.image, 100); if (this.timer) { this.timer.stop(); } this.trys=0; this.useCache=true; }; STile.prototype.onerror=function() { if (this.trys < 100) { if (this.timer) { this.timer.stop(); } this.trys++; if (this.trys >=3) { this.useCache=false; } this.timer.startTimeout(this, this.configureImage); } else { this.timer.stop(); this.noImage(); this.unBind(); this.trys=0; } }; STile.prototype.destroy=function() { try { if (this.timer) { this.timer.stop(); } this.xId=null; this.yId=null; this.level=null; this.left=null; this.top=null; this.timer=null; this.trys=null; this.container.removeChild(this.image); this.unBind(); this.image=null; this.container=null; SEvent.deattachDOM(window, 'unload', this.wunload); } catch(e) { } }; STile.prototype.unBind=function() { if (this.bindedOnLoad) { SEvent.deattachDOM(this.image, 'load', this.bindedOnLoad); } if (this.bindedOnError) { SEvent.deattachDOM(this.image, 'error', this.bindedOnError); } if (this.bindedOnAbort) { SEvent.deattachDOM(this.image, 'abort', this.bindedOnAbort); } }; STile.prototype.configureImage=function(xid, yid, level, left, top) { if (typeof(xid)!="undefined"&&typeof(yid)!="undefined"&&typeof(level)!="undefined") { this.xId=xid; this.yId=yid; this.level=level; } ChangeOpacity(this.image, 0); if (typeof(left)!="undefined"&&typeof(top)!="undefined") { this.moveTo(left, top) } this.unBind(); this.bindedOnLoad=SEvent.attachDOM(this.image, 'load', this.onload, this); this.bindedOnError=SEvent.attachDOM(this.image, 'error', this.onerror, this); this.bindedOnAbort=SEvent.attachDOM(this.image, 'abort', this.onerror, this); this.tmrDelay.stop(); var sim=new SImagesLevel(this.level); if (this.xId>0 && this.yId >0 && this.xId <=sim.numXFiles && this.yId <=sim.numYFiles ) { this.tmrDelay.startTimeout(this, this.assignImage); } else { this.noImage(); } }; STile.prototype.assignImage=function() { var srcString=TILE_PARSER_PATH; srcString +='?'; srcString +='LEVEL='+this.level; srcString +='&IDX='+this.xId + '&IDY='+this.yId; srcString +='&MAPNAME=' + this.mapType.getMapFile(); srcString +='&IMGTYPE=' + this.mapType.getImagesExtension(); if (typeof(SMAP_IMAGE_CACHE)!="undefined") { srcString +='&CACHE=FALSE';  } if (!this.useCache) { srcString +="&" + new Date().getTime(); } try { this.image.src=srcString; this.tmrDelay.stop(); } catch(e) { this.tmrDelay=null; } }; STile.prototype.createImage=function(x, y) { this.image=document.createElement('IMG');   this.image.style.position="absolute"; this.image.style.border="0px none gray"; this.image.style.left=toPixel(this.left); this.image.style.top=toPixel(this.top); this.image.style.width=toPixel(this.mapType.getTileSize()); this.image.style.height=toPixel(this.mapType.getTileSize()); this.image.style.zIndex=0; this.image.style.display=""; ChangeOpacity(this.image, 0); this.container.appendChild(this.image); };  STile.prototype.moveTo=function(x, y) { x=Math.round(x); y=Math.round(y); if(this.left!=x||this.top!=y) { this.left=x; this.top=y; this.image.style.left=toPixel(this.left); this.image.style.top=toPixel(this.top); } }; STile.prototype.noImage=function() { this.image.src=SMAP_TILE_UNAVAILABLE; ChangeOpacity(this.image, 100); this.image.style.display=""; }; STile.prototype.getExtend=function() { var xMin=new SConvers(new SImagesLevel(this.level)).GetMinXCoor(this.xId); var yMin=new SConvers(new SImagesLevel(this.level)).GetMinYCoor(this.yId-1); var xMax=new SConvers(new SImagesLevel(this.level)).GetMaxXCoor(this.xId+1); var yMax=new SConvers(new SImagesLevel(this.level)).GetMaxYCoor(this.yId); return (new SGeoBox(xMin, yMin, xMax, yMax)); }; STile.prototype.getLevel=function() { return this.level; }; STile.prototype.setMapType=function(mapType) { this.mapType=mapType; }; 
SSize=function(width, height) { this.width=typeof(width) !="number"?0:width; this.height=typeof(height) !="number"?0:height; }; SSize.prototype.width=null; SSize.prototype.height=null; SSize.prototype.getCenter=function() { var xp=this.width/2; var yp=this.height/2; return new SGeoPoint(xp, yp); }; SSize.prototype.ToString=function() { return ("("+this.width + ", " + this.height+")"); }; 
function SwitchCursor(sourceElement, cursor) { try { sourceElement.style.cursor=cursor; } catch(c) { if(cursor=="pointer") { SwitchCursor(sourceElement,"hand"); } } }; function SDebug(str, left, top, width, height) { var did="debugWindowLayer"; var dname="debugWindowLayer"; width=!width?300:parseInt(width); height=!height?512:parseInt(height); if (document.all) { left=!left?(document.body.clientWidth - width)-10:parseInt(left); } else { left=!left?(parseInt(document.width) - width)-10:parseInt(left); } top=!top?10:parseInt(top); var debugLayer=document.getElementById(did); if (!debugLayer) { debugLayer=document.createElement('DIV'); debugLayer.id=did; debugLayer.name=dname; debugLayer.style.position="absolute"; debugLayer.style.backgroundColor="black"; debugLayer.style.border="solid blue 1px"; debugLayer.style.left=left+"px"; debugLayer.style.top=top+"px"; debugLayer.style.width=width+"px"; debugLayer.style.height=height+"px"; debugLayer.style.zIndex="100"; debugLayer.style.color="white"; debugLayer.style.font='normal  8pt tahoma'; debugLayer.style.overflow="auto"; debugLayer.style.visibility="visible"; debugLayer.innerHTML="<b>Debug Window Console</b><br><b>Doble Click para ocultar la c&oacute;nsola</b>"; window.document.body.appendChild(debugLayer); debugLayer.ondblclick=function(){debugLayer.style.visibility="hidden";}; } else { debugLayer.style.visibility="visible"; } if(!str) { str=""; } debugLayer.innerHTML="<li>" + str + "</li>" +debugLayer.innerHTML; }; function ChangeOpacity(obj, val) { if(val>=100) { val=99; } obj.style.filter="alpha(opacity="+val+")"; val*=0.01; obj.style.KHTMLOpacity=val; obj.style.MozOpacity=val; obj.style.opacity=val; }; function SetSelectableStatus(obj, status) { try { if (!status||status=="off") { obj.unselectable="on"; obj.style.MozUserFocus="none"; obj.style.MozUserSelect="none";    } else { obj.unselectable="off"; obj.style.MozUserFocus=""; obj.style.MozUserSelect="";    } } catch(e) { } }; function CreateIframe(container, id, size, axis, visible, position, unit){ var ifra=document.createElement("iframe"); switch(unit) { case "percent": ifra.style.width=toPercent(size.width); ifra.style.height=toPercent(size.height); break; default: ifra.style.width=toPixel(size.width); ifra.style.height=toPixel(size.height); } ifra.style.position=(!position||position=="")?"relative":position; ifra.style.top=toPixel(axis.Y); ifra.style.left=toPixel(axis.X); if (id&&id!="") { ifra.id=id; ifra.name=id;  } ifra.style.display=!visible?"none":""; container.appendChild(ifra); return ifra; }; function CreateDIV(container, id, size, axis, zindex, overflow, backColor, borderColor, backImage) { var oDiv=document.createElement('div'); if (backColor) { oDiv.style.backgroundColor=backColor; } if (backImage) { oDiv.style.backgroundImage="url('"+ backImage +"')"; } if (axis.X==null||axis.Y==null) { oDiv.style.position='relative'; } else { oDiv.style.position='absolute'; oDiv.style.left=toPixel(axis.X); oDiv.style.top=toPixel(axis.Y); } oDiv.id=id; if (axis.width!=null) { oDiv.style.width=toPixel(size.width); } if (axis.height!=null) { oDiv.style.height=toPixel(size.height); } if (zindex!=null) { oDiv.style.zIndex=zindex; } oDiv.style.overflow=(!overflow||overflow=="hidden")?"hidden":"visible"; return container.appendChild(oDiv); }; function toPixel(value) { return (parseInt(value)+"px"); }; function toPercent(value) { value=!value?0:value; value=typeof(value)!="number"?0:value; value=value<0?0:value; value=value>100?100:value; return (value+"%"); }; function alignLeft(obj, value) { obj.style.right=""; obj.style.left=toPixel(value); }; function alignTop(obj, value) { obj.style.bottom=""; obj.style.top=toPixel(value); }; function alignRight(obj, value) { obj.style.left=""; obj.style.right=toPixel(value); }; function alignBottom(obj, value) { obj.style.top=""; obj.style.bottom=toPixel(value); }; function Ea(event, mainElement) { if(typeof event.offsetX!="undefined") { var targ=event.target||event.srcElement; var pos=wd(targ, mainElement); return (new SGeoPoint(event.offsetX+pos.X,event.offsetY+pos.Y)); } else if(typeof event.pageX!="undefined") { var pos=jb(mainElement); return (new SGeoPoint(event.pageX-pos.X,event.pageY-pos.Y)); } else { return (new SGeoPoint(0,0)); } }; function wd(a,b) { var c={"X":0,"Y":0}; while(a&&a!=b){ c.X+=a.offsetLeft; c.Y+=a.offsetTop; a=a.offsetParent; } return c; }; function jb(a) { var b={"X":0,"Y":0}; while(a){ b.X+=a.offsetLeft; b.Y+=a.offsetTop; a=a.offsetParent; } return b; }; if (window.Node && Node.prototype && !Node.prototype.contains) { Node.prototype.contains=function (arg) { return !!(this.compareDocumentPosition(arg) & 16); } } 
SCaptureEntry=function(element) { if (element&&typeof(element)=="object") { this.htmlElement=element; this.contextmenuHandler=SEvent.attachDOM(element, 'contextmenu', function(e){  if (e.preventDefault) { e.preventDefault(); return false; } }); this.mdownHandler=SEvent.attachDOM(element, 'mousedown', this.eventDetecter, this); this.moverHandler=SEvent.attachDOM(element, 'mouseover', this.eventDetecter, this); this.mupHandler=SEvent.attachDOM(element, 'mouseup', this.eventDetecter, this); this.moutHandler=SEvent.attachDOM(element, 'mouseout', this.eventDetecter, this); this.kdownHandler=SEvent.attachDOM(document, 'keydown', this.eventDetecter, this); this.kupHandler=SEvent.attachDOM(document, 'keyup', this.eventDetecter, this); this.mdblclickHandler=SEvent.attachDOM(element, 'dblclick', this.eventDetecter, this); this.wunloadHandler=SEvent.attachDOM(window, 'unload', this.eventDetecter, this); } }; SCaptureEntry.prototype.cancelBehaviour=function(e) { if(e.cancelBubble ) { e.cancelBubble=true; e.returnValue=false; } else if(e.preventDefault) { e.preventDefault(); } return false; }; SCaptureEntry.prototype.destroy=function() { try { SEvent.deattachDOM(this.htmlElement, 'contextmenu', this.contextmenuHandler); SEvent.deattachDOM(this.htmlElement, 'mousedown', this.mdownHandler); SEvent.deattachDOM(this.htmlElement, 'mouseover', this.moverHandler); SEvent.deattachDOM(this.htmlElement, 'mouseup', this.mupHandler); SEvent.deattachDOM(this.htmlElement, 'mouseout', this.moutHandler); SEvent.deattachDOM(document, 'keydown', this.kdownHandler); SEvent.deattachDOM(document, 'keyup', this.kupHandler); SEvent.deattachDOM(this.htmlElement, 'dblclick', this.mdblclickHandler); SEvent.deattachDOM(window, 'dblclick', this.wunloadHandler); this.htmlElement=null; this.contextmenuHandler=null; this.mdownHandler=null; this.moverHandler=null; this.mupHandler=null; this.moutHandler=null; this.kdownHandler=null; this.kupHandler=null; this.mdblclickHandler=null; this.wunloadHandler=null; } catch(e) { } }; SCaptureEntry.prototype.eventDetecter=function(e) { var e=!e?event:e; switch(e.type) { case 'contextmenu': return this.cancelBehaviour(e); break; case 'mousedown': this.mupHandler=SEvent.attachDOM(document, 'mouseup', this.eventDetecter, this); this.mmoveHandler=SEvent.attachDOM(document, 'mousemove', this.eventDetecter, this); if (this.htmlElement.focus) { this.htmlElement.focus(); } SEvent.InternalTrigger(this, "onmousedown", e); break; case 'mouseup': if (this.mupHandler&&this.mmoveHandler) { SEvent.deattachDOM(document, 'mouseup', this.mupHandler); SEvent.deattachDOM(document, 'mousemove', this.mmoveHandler); SEvent.InternalTrigger(this, "onmouseup", e); this.mupHandler=null; this.mmoveHandler=null; } break; case 'mousemove': SEvent.InternalTrigger(this, "onmousemove", e); break; case 'mouseover': this.focus=true; SEvent.InternalTrigger(this, "onmouseover", e); case 'mouseout': this.focus=false; SEvent.InternalTrigger(this, "onmouseout", e); break; case 'mouseout': SEvent.InternalTrigger(this, "onmouseover", e); break; case 'keydown': var altKey=e.altKey||e.altLeft?true:false; var ctrlKey=e.ctrlKey||e.ctrlLeft?true:false; var shiftKey=e.shiftKey||e.shiftLeft?true:false; SEvent.InternalTrigger(this, "onkeydown", e.keyCode, altKey, ctrlKey, shiftKey); break; case 'keyup': if (e.srcElement) { var fireE=(e.srcElement==this.htmlElement||e.srcElement.contains(this.htmlElement)); } else if(e.target) { var fireE=(e.target==this.htmlElement||e.target.contains(this.htmlElement)); } if (fireE) { var altKey=e.altKey||e.altLeft?true:false; var ctrlKey=e.ctrlKey||e.ctrlLeft?true:false; var shiftKey=e.shiftKey||e.shiftLeft?true:false;    SEvent.InternalTrigger(this, "onkeyup", e.keyCode, altKey, ctrlKey, shiftKey); } break; case 'dblclick': SEvent.InternalTrigger(this, "onmousedblclick", e); break; case 'unload': this.destroy(); break; } }; 
SCallOut=function(container, mapReference) { if (!container) { return; } if (mapReference) { this.map=mapReference; this.listenerLevel=SEvent.Bind(this.map, "OnMapChangeLevel",this, this.mapchangelevel); this.listenerResize=SEvent.Bind(this.map, "OnMapResize",this, this.mapchangelevel); this.listenerTryZoom=SEvent.Bind(this.map, "OnMapTryZoom",this, this.mapchangelevel); this.listenerClick=SEvent.Bind(this.map, "OnMapClick",this, this.mapclick); } this.htmlElement=null; this.htmlElementmousemove=null; this.containerIsSet=true; this.container=container; this.hbtnClose=null; this.window=new Object(); this.shadow=new Object(); this.window.nwName='iw_nw.png'; this.window.nName='iw_n.png'; this.window.neName='iw_ne.png'; this.window.eName='iw_e.png'; this.window.seName='iw_se0.png'; this.window.sName='iw_s0.png'; this.window.pointerName='iw_tap.png'; this.window.swName='iw_sw0.png'; this.window.wName='iw_w.png'; this.window.cName='iw_c.png'; this.window.closeName='close.gif'; this.window.textContent=null; this.shadow.nwName='iws_nw.png'; this.shadow.nName='iws_n.png'; this.shadow.neName='iws_ne.png'; this.shadow.eName='iws_e.png'; this.shadow.seName='iws_se.png'; this.shadow.sName='iws_s.png'; this.shadow.pointerName='iws_tap.png'; this.shadow.swName='iws_sw.png'; this.shadow.wName='iws_w.png'; this.shadow.cName='iws_c.png'; this.window.size=new SSize(0, 0); this.shadow.size=new SSize(0, 0); this.shadow.left=0; this.shadow.top=0; this.shadow.scaleFactor=2; this.window.pixelPos=new SGeoPoint(0,0); this.window.pixelBox=new SGeoBox(0, 0, 0, 0); this.xOffSet=0; this.yOffSet=0; this.latlong=new SGeoPoint(0,0); this.window.closeTooltip="Cerrar"; }; SCallOut.prototype.setTextContent=function(text) { if (!text||typeof(text)!="string") { text=""; } this.window.textContent=text; var node=document.createTextNode(this.window.textContent); this.window.content.appendChild(node); }; SCallOut.prototype.setHtmlContent=function(html) { if (!html||typeof(html)!="string") { html=""; } this.window.textContent=html; this.window.content.innerHTML=this.window.textContent; }; SCallOut.prototype.setOffSet=function(x, y) { this.xOffSet=x; this.yOffSet=y; try { this.htmlElement.style.top=toPixel(this.pixelPos.Y + this.yOffSet ); this.htmlElement.style.left=toPixel(this.pixelPos.X + this.xOffSet); } catch(e) { alert(e.description); } }; SCallOut.prototype.setWindowSize=function(width, height) { width=Math.floor(width); height=Math.floor(height); if(this.window.size.width!=width||this.window.size.height!=height) {  this.window.size.width=width; this.window.size.height=height; this.shadow.size.width=width; this.shadow.size.height=height/3; this.shadow.left=20; this.shadow.top=0; if (this.htmlElement) { this.htmlElement.style.width=toPixel(this.window.size.width); this.htmlElement.style.height=toPixel(this.window.size.height); } if (this.shadow.container) { alignBottom(this.shadow.container,0); alignLeft(this.shadow.container, 20); this.shadow.container.style.width=toPixel(this.shadow.size.width); this.shadow.container.style.height=toPixel(this.shadow.size.height); } } };  SCallOut.prototype.createWindow=function(x, y, w, h) { if (!this.containerIsSet) { return; } w=(Math.floor(w)<148)?148:Math.floor(w); h=(Math.floor(h)<70)?70:Math.floor(h); x=Math.floor(x); y=Math.floor(y); this.htmlElement=this.createDIV(x, y, w, h); this.htmlElement.style.display="none"; this.htmlElement.style.zIndex=99; this.htmlElementmousemove=SEvent.attachDOM(this.htmlElement, 'mousemove', this.filterMouse, this, false); this.window.container=this.createDIV(0, 0, w, h); this.setWindowSize(w, h); this.window.nw=this.createImage(this.window.nwName, 0,0,25,25); this.window.n=this.createImage(this.window.nName, 25,0,(this.window.size.width - 50),25); this.window.ne=this.createImage(this.window.neName, (this.window.size.width - 25),0,25,25); this.window.e=this.createImage(this.window.eName, (this.window.size.width - 25),25,25,(this.window.size.height - 50)); this.window.se=this.createImage(this.window.seName, (this.window.size.width - 25),(this.window.size.height - 25),25,96); this.window.s=this.createImage(this.window.sName, 123,(this.window.size.height - 25),(this.window.size.width - 148),96); this.window.pointer=this.createImage(this.window.pointerName, 25,(this.window.size.height - 25),98,96); this.window.sw=this.createImage(this.window.swName, 0,(this.window.size.height - 25),25,96); this.window.w=this.createImage(this.window.wName, 0,25,25,(this.window.size.height - 50)); this.window.c=this.createImage(this.window.cName, 25,25,(this.window.size.width - 50),(this.window.size.height - 50)); this.window.closeButton=this.createImage(this.window.closeName, 0,0,14,13); this.window.content=this.createDIV(15, 10, (this.window.size.width - 38), (this.window.size.height - 20)); this.window.content.style.overflow="hidden"; alignRight(this.window.closeButton, 10); alignTop(this.window.closeButton, 10); this.window.container.appendChild(this.window.nw); this.window.container.appendChild(this.window.n); this.window.container.appendChild(this.window.ne); this.window.container.appendChild(this.window.e); this.window.container.appendChild(this.window.se); this.window.container.appendChild(this.window.s); this.window.container.appendChild(this.window.pointer); this.window.container.appendChild(this.window.sw); this.window.container.appendChild(this.window.w); this.window.container.appendChild(this.window.c); this.window.container.appendChild(this.window.closeButton); this.window.container.appendChild(this.window.content); this.eventsAsign(); this.htmlElement.appendChild(this.window.container); if (this.shadow.container) { this.htmlElement.appendChild(this.shadow.container); } this.container.appendChild(this.htmlElement); this.htmlElement.style.zIndex=99; this.window.content.style.zIndex=1; this.window.pixelPos.X=x; this.window.pixelPos.Y=y; this.calculateBox();  this.formatCloseButton(); this.htmlElement.style.zIndex=99; this.htmlElement.style.display=""; SEvent.Trigger(this, "open"); SEvent.Trigger(this, "OnWindowOpen"); }; SCallOut.prototype.setCoordPosition=function(point) { if (this.map&&point) { this.latlong=point; this.pixelPos=this.map.getPixelOnGrid(this.latlong); this.setPixelPosition(this.pixelPos); } }; SCallOut.prototype.setPixelPosition=function(point) { var top=(this.window.size.height - 30) + 96; var left=35; point.X-=left; point.Y-=top; if (!this.window.pixelPos.Equal(point)) { this.htmlElement.style.display="none"; this.window.pixelPos.X=point.X; this.window.pixelPos.Y=point.Y; this.htmlElement.style.top=toPixel(this.window.pixelPos.Y); this.htmlElement.style.left=toPixel(this.window.pixelPos.X); this.calculateBox(); SEvent.Trigger(this, "move"); SEvent.Trigger(this, "OnWindowMove"); this.htmlElement.style.display=""; } }; SCallOut.prototype.calculateBox=function() { this.window.pixelPos.X=parseInt(this.htmlElement.style.left); this.window.pixelPos.Y=parseInt(this.htmlElement.style.top); this.window.size.height=parseInt(this.htmlElement.style.height); this.window.size.width=parseInt(this.htmlElement.style.width); this.window.pixelBox.Xmin=this.window.pixelPos.X; this.window.pixelBox.Ymin=this.window.pixelPos.Y + (this.window.size.height + 96); this.window.pixelBox.Xmax=this.window.pixelPos.X + this.window.size.width; this.window.pixelBox.Ymax=this.window.pixelPos.Y;  }; SCallOut.prototype.eventsAsign=function() { this.window.nwonmousedown=SEvent.attachDOM(this.window.nw, 'mousedown', this.filterMouse, this, true); this.window.nwonmouseclick=SEvent.attachDOM(this.window.nw, 'click', this.filterMouse, this, true); this.window.nwonmousedblclick=SEvent.attachDOM(this.window.nw, 'dblclick', this.filterMouse, this, true); this.window.nonmousedown=SEvent.attachDOM(this.window.n, 'mousedown', this.filterMouse, this, true); this.window.nonmouseclick=SEvent.attachDOM(this.window.n, 'click', this.filterMouse, this, true); this.window.nonmousedblclick=SEvent.attachDOM(this.window.n, 'dblclick', this.filterMouse, this, true); this.window.neonmousedown=SEvent.attachDOM(this.window.ne, 'mousedown', this.filterMouse, this, true); this.window.neonmouseclick=SEvent.attachDOM(this.window.ne, 'click', this.filterMouse, this, true); this.window.neonmousedblclick=SEvent.attachDOM(this.window.ne, 'dblclick', this.filterMouse, this, true); this.window.eonmousedown=SEvent.attachDOM(this.window.e, 'mousedown', this.filterMouse, this, true); this.window.eonmouseclick=SEvent.attachDOM(this.window.e, 'click', this.filterMouse, this, true); this.window.eonmousedblclick=SEvent.attachDOM(this.window.e, 'dblclick', this.filterMouse, this, true); this.window.seonmousedown=SEvent.attachDOM(this.window.se, 'mousedown', this.filterMouse, this, true); this.window.seonmouseclick=SEvent.attachDOM(this.window.se, 'click', this.filterMouse, this, true); this.window.seonmousedblclick=SEvent.attachDOM(this.window.se, 'dblclick', this.filterMouse, this, true); this.window.sonmousedown=SEvent.attachDOM(this.window.s, 'mousedown', this.filterMouse, this, false); this.window.sonmouseclick=SEvent.attachDOM(this.window.s, 'click', this.filterMouse, this, false); this.window.sonmousedblclick=SEvent.attachDOM(this.window.s, 'dblclick', this.filterMouse, this, false); this.window.pointeronmousedown=SEvent.attachDOM(this.window.pointer, 'mousedown', this.filterMouse, this, false); this.window.pointeronmouseclick=SEvent.attachDOM(this.window.pointer, 'click', this.filterMouse, this, false); this.window.pointeronmousedblclick=SEvent.attachDOM(this.window.pointer, 'dblclick', this.filterMouse, this, false); this.window.swonmousedown=SEvent.attachDOM(this.window.sw, 'mousedown', this.filterMouse, this, true); this.window.swonmouseclick=SEvent.attachDOM(this.window.sw, 'click', this.filterMouse, this, true); this.window.swonmousedblclick=SEvent.attachDOM(this.window.sw, 'dblclick', this.filterMouse, this, true); this.window.wonmousedown=SEvent.attachDOM(this.window.w, 'mousedown', this.filterMouse, this, true); this.window.wonmouseclick=SEvent.attachDOM(this.window.w, 'click', this.filterMouse, this, true); this.window.wonmousedblclick=SEvent.attachDOM(this.window.w, 'dblclick', this.filterMouse, this, true); this.window.conmousedown=SEvent.attachDOM(this.window.c, 'mousedown', this.filterMouse, this, true); this.window.conmouseclick=SEvent.attachDOM(this.window.c, 'click', this.filterMouse, this, true); this.window.conmousedblclick=SEvent.attachDOM(this.window.c, 'dblclick', this.filterMouse, this, true); this.window.closeonmousedown=SEvent.attachDOM(this.window.closeButton, 'mousedown', this.filterMouse, this, true); this.window.closeonmousedblclick=SEvent.attachDOM(this.window.closeButton, 'dblclick', this.filterMouse, this, true); this.window.contentonmousedown=SEvent.attachDOM(this.window.content, 'mousedown', this.filterMouse, this, true); this.window.contentonmousedblclick=SEvent.attachDOM(this.window.content, 'dblclick', this.filterMouse, this, true); }; SCallOut.prototype.autoPositionCallOut=function() {    var box=this.getPixelBox();    var mapEextend=this.map.GetMapExtend();    var min=this.map.getLatLongFromPixel(new SGeoPoint(box.Xmin, box.Ymin));    var max=this.map.getLatLongFromPixel(new SGeoPoint(box.Xmax, box.Ymax));    var pmax=null;    var pmin=null;    var xP2=0;    var xP1=0;    var yP2=0;    var yP1=0; if (!mapEextend.IsWithin(new SGeoBox(min.X, min.Y, max.X, max.Y))) { var mapSize=new SSize(this.map.mapPixelWidth, this.map.mapPixelHeight);      pmax=this.map.getPixelFromLatLong(new SGeoPoint(max.X, max.Y));      pmin=this.map.getPixelFromLatLong(new SGeoPoint(min.X, min.Y));     if (pmax.X > mapSize.width)     {      if (this.window.size.width<mapSize.width)      {      xP2=mapSize.width - 30;      xP1=pmax.X;            }      else      {      xP2=30;      xP1=pmin.X;            }     }     else if(pmin.X < 0)     {      xP2=30;      xP1=pmin.X;     }     else     {      xP2=pmin.X;      xP1=pmin.X;     }     if (pmax.Y < 0)     { if (this.window.size.height<mapSize.height)      {      yP2=30;      yP1=pmax.Y;      }      else      {      yP2=mapSize.height-15;      yP1=pmin.Y;            }          }     else if(pmin.Y > mapSize.height)     {      yP2=mapSize.height - 30;      yP1=pmin.Y;     }     else     {      yP2=pmin.Y;      yP1=pmin.Y;     }     this.map.FlyMapCenter(new SGeoPoint(xP1, yP1), new SGeoPoint(xP2, yP2)); } }; SCallOut.prototype.formatCloseButton=function() { SwitchCursor(this.window.closeButton, "pointer"); this.hbtnClose=SEvent.attachDOM(this.window.closeButton, "click", this.close, this); this.window.closeButton.title=this.window.closeTooltip; }; SCallOut.prototype.getPixelBox=function() { return (this.window.pixelBox); }; SCallOut.prototype.showCloseButton=function() { this.window.closeButton.style.display=""; }; SCallOut.prototype.hideCloseButton=function() { this.window.closeButton.style.display="none"; }; SCallOut.prototype.close=function() { if (this.map) { SEvent.RemoveListener(this.listenerLevel); SEvent.RemoveListener(this.listenerClick); this.map=null; }  try { this.window.container.removeChild(this.window.nw); this.window.container.removeChild(this.window.n); this.window.container.removeChild(this.window.ne); this.window.container.removeChild(this.window.e); this.window.container.removeChild(this.window.se); this.window.container.removeChild(this.window.s); this.window.container.removeChild(this.window.pointer); this.window.container.removeChild(this.window.sw); this.window.container.removeChild(this.window.w); this.window.container.removeChild(this.window.c); this.window.container.removeChild(this.window.closeButton); this.window.container.removeChild(this.window.content); this.htmlElement.removeChild(this.window.container); this.container.removeChild(this.htmlElement); SEvent.deattachDOM(this.window.nw, 'mousedown', this.window.nwonmousedown); SEvent.deattachDOM(this.window.nw, 'click', this.window.nwonmouseclick); SEvent.deattachDOM(this.window.nw, 'dblclick', this.window.nwonmousedblclick); SEvent.deattachDOM(this.window.n, 'mousedown', this.window.nonmousedown); SEvent.deattachDOM(this.window.n, 'click', this.window.nonmouseclick); SEvent.deattachDOM(this.window.n, 'dblclick', this.window.nonmousedblclick); SEvent.deattachDOM(this.window.ne, 'mousedown', this.window.neonmousedown); SEvent.deattachDOM(this.window.ne, 'click', this.window.neonmouseclick); SEvent.deattachDOM(this.window.ne, 'dblclick', this.window.neonmousedblclick); SEvent.deattachDOM(this.window.e, 'mousedown', this.window.eonmousedown); SEvent.deattachDOM(this.window.e, 'click', this.window.eonmouseclick); SEvent.deattachDOM(this.window.e, 'dblclick', this.window.eonmousedblclick); SEvent.deattachDOM(this.window.se, 'mousedown', this.window.seonmousedown); SEvent.deattachDOM(this.window.se, 'click', this.window.seonmouseclick); SEvent.deattachDOM(this.window.se, 'dblclick', this.window.seonmousedblclick); SEvent.deattachDOM(this.window.s, 'mousedown', this.window.sonmousedown); SEvent.deattachDOM(this.window.s, 'click', this.window.sonmouseclick); SEvent.deattachDOM(this.window.s, 'dblclick', this.window.sonmousedblclick); SEvent.deattachDOM(this.window.pointer, 'mousedown', this.window.pointeronmousedown); SEvent.deattachDOM(this.window.pointer, 'click', this.window.pointeronmouseclick); SEvent.deattachDOM(this.window.pointer, 'dblclick', this.window.pointeronmousedblclick); SEvent.deattachDOM(this.window.sw, 'mousedown', this.window.swonmousedown); SEvent.deattachDOM(this.window.sw, 'click', this.window.swonmouseclick); SEvent.deattachDOM(this.window.sw, 'dblclick', this.window.swonmousedblclick); SEvent.deattachDOM(this.window.w, 'mousedown', this.window.wonmousedown); SEvent.deattachDOM(this.window.w, 'click', this.window.wonmouseclick); SEvent.deattachDOM(this.window.w, 'dblclick', this.window.wonmousedblclick); SEvent.deattachDOM(this.window.c, 'mousedown', this.window.conmousedown); SEvent.deattachDOM(this.window.c, 'click', this.window.conmouseclick); SEvent.deattachDOM(this.window.c, 'dblclick', this.window.conmousedblclick); SEvent.deattachDOM(this.window.closeButton, 'mousedown', this.window.closeonmousedown); SEvent.deattachDOM(this.window.closeButton, 'dblclick', this.window.closeonmousedblclick); SEvent.deattachDOM(this.window.content, 'mousedown', this.window.contentonmousedown); SEvent.deattachDOM(this.window.content, 'dblclick', this.window.contentonmousedblclick); this.window.nw.onload=""; this.window.n.onload=""; this.window.ne.onload=""; this.window.e.onload=""; this.window.se.onload=""; this.window.s.onload=""; this.window.pointer.onload=""; this.window.sw.onload=""; this.window.w.onload=""; this.window.c.onload=""; this.window.closeButton.onload=""; this.window.content.onload=""; this.window.nw=null; this.window.n=null; this.window.ne=null; this.window.e=null; this.window.se=null; this.window.s=null; this.window.pointer=null; this.window.sw=null; this.window.w=null; this.window.c=null; this.window.closeButton=null; this.window.content=null; this.window.nwonmousedown=null; this.window.nwonmouseclick=null; this.window.nwonmousedblclick=null; this.window.nonmousedown=null; this.window.nonmouseclick=null; this.window.nonmousedblclick=null; this.window.neonmousedown=null; this.window.neonmouseclick=null; this.window.neonmousedblclick=null; this.window.eonmousedown=null; this.window.eonmouseclick=null; this.window.eonmousedblclick=null; this.window.seonmousedown=null; this.window.seonmouseclick=null; this.window.seonmousedblclick=null; this.window.sonmousedown=null; this.window.sonmouseclick=null; this.window.sonmousedblclick=null; this.window.pointeronmousedown=null; this.window.pointeronmouseclick=null; this.window.pointeronmousedblclick=null; this.window.swonmousedown=null; this.window.swonmouseclick=null; this.window.swonmousedblclick=null; this.window.wonmousedown=null; this.window.wonmouseclick=null; this.window.wonmousedblclick=null; this.window.conmousedown=null; this.window.conmouseclick=null; this.window.conmousedblclick=null; this.window.closeonmousedown=null; this.window.closeonmousedblclick=null; this.window.contentonmousedown=null; this.window.contentonmouseclick=null; this.window.contentonmousedblclick=null; this.window.container=null; this.window=null; this.container=null; } catch(e) { } SEvent.Trigger(this, "close"); SEvent.Trigger(this, "OnWindowClose"); }; SCallOut.prototype.createShadow=function() { this.shadow.container=this.createDIV(0, 0, 0, this.shadow.size.height); var minx=0; var wHeight=280; this.shadow.nw=this.createImage(this.shadow.nwName, 280/this.shadow.scaleFactor,0,70,30, true); this.shadow.w=this.createImage(this.shadow.wName, 0, 0,360,280, true); this.shadow.sw=this.createImage(this.shadow.swName, minx,((30/this.shadow.scaleFactor)+(wHeight/this.shadow.scaleFactor)),70,60, true); this.shadow.pointer=this.createImage(this.shadow.pointerName, 30,155,140,60, true); this.shadow.s=this.createImage(this.shadow.sName, 180/this.shadow.scaleFactor,((30/this.shadow.scaleFactor)+(wHeight/this.shadow.scaleFactor)),(this.shadow.size.width/this.shadow.scaleFactor),(60/this.shadow.scaleFactor), true); this.shadow.divw=this.createDIV(-(this.shadow.size.width-this.shadow.size.height), 30, 360, this.shadow.size.height-30); this.shadow.divw.style.overflow="hidden"; this.shadow.divw.style.border="1px solid red"; this.shadow.container.appendChild(this.shadow.divw); this.shadow.container.appendChild(this.shadow.nw); this.shadow.container.appendChild(this.shadow.s); this.shadow.container.appendChild(this.shadow.pointer); this.shadow.container.appendChild(this.shadow.sw); this.shadow.divw.appendChild(this.shadow.w); }; SCallOut.prototype.createDIV=function (x, y, w, h) { var oDiv=document.createElement('DIV'); oDiv.style.position="absolute"; oDiv.style.left=toPixel(x); oDiv.style.top=toPixel(y); oDiv.style.width=toPixel(w); oDiv.style.height=toPixel(h); return (oDiv); }; SCallOut.prototype.createImage=function(src, x, y, w, h) { var path=SMAP_IMAGES_PATH + src; var image=document.createElement('IMG');   image.style.position="absolute"; image.style.border="0px solid gray"; image.style.left=toPixel(x); image.style.top=toPixel(y); image.style.width=toPixel(w); image.style.height=toPixel(h); image.width=w; image.height=h; image.style.zIndex=0; image.style.display=""; SetSelectableStatus(image, "off"); image.onload=function() { if (this.runtimeStyle&&/\.png$/.test(this.src.toLowerCase())) { if (this.runtimeStyle.filter=="") { this.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + path + "',sizingMethod='scale')"; this.src=SMAP_IMAGES_PATH + "blank.gif"; } } }; image.src=path; SetSelectableStatus(this.image, "off"); return (image); };  SCallOut.prototype.filterMouse=function(e, prevent) { var e=!e?event:e; if (prevent) { if(e.srcElement ) { e.cancelBubble=true; e.returnValue=false; } else if(e.preventDefault) { e.stopPropagation(); e.preventDefault(); } return false; } switch(e.type) { case "mousemove": case "click": case "dblclick": case "mousedown": break; default:  var a=1; } }; SCallOut.prototype.mapchangelevel=function(level) { if (this.map) { this.htmlElement.style.display="none"; this.setCoordPosition(this.latlong); this.setOffSet(this.xOffSet, this.yOffSet); this.htmlElement.style.zIndex=99; this.htmlElement.style.display=""; }  }; SCallOut.prototype.mapclick=function(point) { if (this.map) { this.close(); }  }; 
var S_VECTOR_MAP="S_VECTOR_MAP"; var S_SATELLITE_MAP="S_SATELLITE_MAP"; var S_HYBRID_MAP="S_HYBRID_MAP"; SMapType=function(name, mapFile, imagesExtension, tileSize) { this.setName(name); this.setMapFile(mapFile); this.setImagesExtension(imagesExtension); this.setTileSize(tileSize); }; SMapType.prototype.tileSize=null; SMapType.prototype.mapName=null; SMapType.prototype.name=null; SMapType.prototype.imagesExtension=null; SMapType.prototype.setMapFile=function(mapFile) { if (mapFile&&typeof(mapFile)=="string") { this.mapName=mapFile; } }; SMapType.prototype.getMapFile=function() { return this.mapName; }; SMapType.prototype.setName=function(name) { if (name&&typeof(name)=="string") { this.name=name; } }; SMapType.prototype.getName=function() { return this.name; }; SMapType.prototype.setImagesExtension=function(ext) { if (ext&&typeof(ext)=="string") { this.imagesExtension=ext.toUpperCase(); } else { this.imagesExtension="PNG"; } }; SMapType.prototype.getImagesExtension=function() { return this.imagesExtension; }; SMapType.prototype.setTileSize=function(size) { if (size&&typeof(size)=="number") { this.tileSize=size; } else { this.tileSize=256; } }; SMapType.prototype.getTileSize=function() { return this.tileSize; }; 
function SMapSpecifications() { this.key="###"; this.paths=new Array(); this.timers=new Array(); this.zoomRange=null; this.mapTypes=Array( new SMapType(S_VECTOR_MAP, SMAP_DEFAULT_VECTOR_MAP, "PNG24", 256), new SMapType(S_SATELLITE_MAP, SMAP_DEFAULT_IMAGE_MAP, "PNG24", 256) ); this.timers["DL_MIN_AUTO_REFRESH"]="1000"; this.timers["DL_WAIT_FOR_REFRESH"]="1500"; this.zoomRange=new SRange(); this.zoomRange.setMinimum(1); this.zoomRange.setMaximum(19); this.zoomRange.setStep(1); }; SMapSpecifications.prototype.setSmapServer=function(path) { if (path&&typeof(path)=="string") { this.paths["SMAP_SERVER"]=path; } }; SMapSpecifications.prototype.setControlsPath=function(path) { if (path&&typeof(path)=="string") { this.paths["CONTROLS"]=path; } }; SMapSpecifications.prototype.setImagesPath=function(path) { if (path&&typeof(path)=="string") { this.paths["IMAGES"]=path; } }; SMapSpecifications.prototype.setCssPath=function(path) { if (path&&typeof(path)=="string") { this.paths["CSS"]=path; } }; SMapSpecifications.prototype.setTileServerPath=function(path) { if (path&&typeof(path)=="string") { this.paths["TILES_SERVER"]=path; } }; SMapSpecifications.prototype.setDynamicLayerServer=function(path) { if (path&&typeof(path)=="string") { this.paths["DL_SERVER"]=path; } };  
function SGrid(){}; SGrid.prototype.slideStart=null; SGrid.prototype.endPanPos=null; SGrid=function(father, mapType, containerWidth, containerHeight) { this.slideStart=new SGeoPoint(0, 0); this.endPanPos=new SGeoPoint(0, 0);  this.mapType=mapType; this.topLeftTile=new Object(); this.CaptureEntry=new SCaptureEntry(father); this.htmlElement=father; this.pageXCounter=0; this.pageYCounter=0; this.dragPoint=new SGeoPoint(0,0); this.dragging=false; this.mousePosition=new SGeoPoint(0,0); this.savedPosition=new SGeoPoint(0,0);  this.lastDown=new SGeoPoint(0,0);  this.mouseIsDown=false; this.clickStartTime=null; this.clickStartPos=new SGeoPoint(0,0); this.originalCursor='default';  this.wmuot=null; this.wunload=null; this.mdownBinded=null; this.mupBinded=null; this.mmoveBinded=null; this.mdblclickBinded=null; this.panDistance=new SSize(0,0); this.timerSlide=null; this.slideEnd=new SGeoPoint(0,0); this.dragdisabledForZoom=false; this.tilePaddingOffset=new SSize(0,0); this.timerRotate=new STimer(1); this.pointCoorCenter=new SGeoPoint(0,0); this.pointPixelCenter=new SGeoPoint(0,0); this.htmlElement.style.display="block"; SwitchCursor(this.htmlElement,this.originalCursor); father.parentNode.style.overflow="hidden"; father.parentNode.style.display="block"; if(father.parentNode.style.position!="absolute") { father.parentNode.style.position="relative"; } if(!containerWidth||!containerHeight) { containerWidth=father.parentNode.clientWidth; containerHeight=father.parentNode.clientHeight;    } father.oncontextmenu=function(){ return false; }; this.viewSize=new SSize(parseInt(containerWidth), parseInt(containerHeight)); var factor=1.7; var columns=Math.ceil((this.viewSize.width*factor)/this.mapType.getTileSize()); var rows=Math.ceil((this.viewSize.height*factor)/this.mapType.getTileSize()); this.cols=columns<3?3:columns; this.rows=rows<3?3:rows; this.left=parseInt(this.htmlElement.style.left); this.top=parseInt(this.htmlElement.style.top); this.width=this.cols * this.mapType.getTileSize(); this.height=this.rows * this.mapType.getTileSize(); this.pixelExtend=new SGeoBox(0,0,0,0); this.idExtend=new SGeoBox(0,0,0,0); this.aTiles=new Array(); this.dragDisabled=false; this.clickDisabled=false; this.keyboardDisabled=false; this.tilePaddingOffset.width=this.mapType.getTileSize() - (this.viewSize.width/this.cols); this.tilePaddingOffset.height=this.mapType.getTileSize() - (this.viewSize.height/this.rows); this.mousedownBinded=SEvent.InternalBind(this.CaptureEntry, "onmousedown", this, this.mouseDown); this.mupBinded=SEvent.InternalBind(this.CaptureEntry, "onmouseup", this, this.mouseUp); this.mmoveBinded=SEvent.InternalBind(this.CaptureEntry, "onmousemove", this, this.mouseMove); this.moverBinded=SEvent.InternalBind(this.CaptureEntry, "onmouseover", this, this.mouseOver); this.mdblclickBinded=SEvent.InternalBind(this.CaptureEntry, "onmousedblclick", this, this.mouseDblClick); this.kUpBinded=SEvent.InternalBind(this.CaptureEntry, "onkeyup", this, this.keyUp); this.kDownBinded=SEvent.InternalBind(this.CaptureEntry, "onkeydown", this, this.keyDown); this.wmuot=SEvent.attachDOM(window, 'mouseout', this.onWindowMouseOut, this); this.wunload=SEvent.attachDOM(window, 'unload', this.destroy, this); this.frame=CreateIframe(document.body, "prueba", new SSize(0,0), new SGeoPoint(-200,-200), "hidden", "absolute"); }; SGrid.prototype.recalculateTileMeasurements=function() { this.DeleteTiles(); SwitchCursor(this.htmlElement,this.originalCursor); var containerWidth=this.htmlElement.parentNode.clientWidth; var containerHeight=this.htmlElement.parentNode.clientHeight;    this.viewSize=new SSize(containerWidth, containerHeight); var factor=1.7; var columns=Math.ceil((this.viewSize.width*factor)/this.mapType.getTileSize()); var rows=Math.ceil((this.viewSize.height*factor)/this.mapType.getTileSize()); this.cols=columns<3?3:columns; this.rows=rows<3?3:rows; this.left=parseInt(this.htmlElement.style.left); this.top=parseInt(this.htmlElement.style.top); this.width=this.cols * this.mapType.getTileSize(); this.height=this.rows * this.mapType.getTileSize(); this.tilePaddingOffset.width=this.mapType.getTileSize() - (this.viewSize.width/this.cols); this.tilePaddingOffset.height=this.mapType.getTileSize() - (this.viewSize.height/this.rows); this.pixelExtend=new SGeoBox(0,0,0,0); this.idExtend=new SGeoBox(0,0,0,0); }; SGrid.prototype.Center=function(xDisplacement, yDisplacement) { var gridLeft=(this.viewSize.width - this.width)/2; var gridTop=(this.viewSize.height - this.height)/2; this.moveTo(gridLeft + xDisplacement, gridTop + yDisplacement); }; SGrid.prototype.CreateGrid=function(startXID, startYID, level, mapType, xDisplacement, yDisplacement) { var tile=null; this.DeleteTiles(); if (mapType) { this.mapType=mapType; } if (startXID==null||startYID==null||level==null) { startXID=0; startYID=0; level=1; } xDisplacement=!xDisplacement?0:xDisplacement; yDisplacement=!yDisplacement?0:yDisplacement; this.level=level; this.Center(xDisplacement, yDisplacement); for (var i=0; i<this.rows; i++) { this.aTiles.push([]); for (var j=0; j<this.cols; j++) { tile=new STile(this.htmlElement, (startXID + j), (startYID - i), this.level, (j*this.mapType.getTileSize()), (i*this.mapType.getTileSize()), this.mapType); this.aTiles[i].push(tile); tile=null; } } this.topLeftTile.left=parseInt(this.aTiles[0][0].left); this.topLeftTile.top=parseInt(this.aTiles[0][0].top); this.RotateTiles(); }; SGrid.prototype.rebuild=function(startXID, startYID, level, mapType, xDisplacement, yDisplacement) { var tile=null; if (mapType) { this.mapType=mapType; } if (startXID==null||startYID==null||level==null) { startXID=0; startYID=0; level=1; } xDisplacement=!xDisplacement?0:xDisplacement; yDisplacement=!yDisplacement?0:yDisplacement; this.level=level; this.Center(xDisplacement, yDisplacement); for (var i=0; i<this.rows; i++) { for (var j=0; j<this.cols; j++) { var tile=this.aTiles[i][j]; tile.setMapType(this.mapType); tile.configureImage((startXID + j), (startYID - i), this.level, (j*this.mapType.getTileSize()), (i*this.mapType.getTileSize()), this.mapType); } } this.topLeftTile.left=parseInt(this.aTiles[0][0].left); this.topLeftTile.top=parseInt(this.aTiles[0][0].top); this.RotateTiles(); }; SGrid.prototype.DeleteTiles=function() { try { if (this.aTiles.length>0) { for (var i=0; i<this.rows; i++) { for (var j=0; j<this.cols; j++) { this.aTiles[i][j].destroy(); this.aTiles[i][j]=null; } } } } catch(e) { }  this.aTiles=null; this.aTiles=new Array();   }; SGrid.prototype.destroy=function() { try { this.DeleteTiles(); SEvent.deattachDOM(window, 'mouseout', this.wmuot); SEvent.deattachDOM(window, 'unload', this.wunload); SEvent.RemoveInternalListener(this.mmoveBinded);   SEvent.RemoveInternalListener(this.mdblclickBinded); document.body.removeChild(this.frame); this.wmuot=null; this.wunload=null;   this.htmlElement=null; this.aTiles=null; this.frame=null; } catch(e) { }   }; SGrid.prototype.moveTo=function(x,y) { x=Math.floor(x); y=Math.floor(y); if(this.left!=x||this.top!=y) {  this.left=x; this.top=y; this.htmlElement.style.left=toPixel(this.left); this.htmlElement.style.top=toPixel(this.top); } };  SGrid.prototype.CalculateExtend=function() { this.pixelExtend.Xmin=(((this.aTiles[0][0].xId * this.mapType.getTileSize())-this.mapType.getTileSize()) + Math.abs(this.getAbsoluteLeft())); this.pixelExtend.Xmax=this.pixelExtend.Xmin+this.viewSize.width; this.pixelExtend.Ymax=(((this.aTiles[0][0].yId * this.mapType.getTileSize())))- Math.abs(this.getAbsoluteTop()); this.pixelExtend.Ymin=this.pixelExtend.Ymax-this.viewSize.height; this.idExtend.Xmin=this.aTiles[0][0].xId; this.idExtend.Ymin=this.aTiles[this.rows-1][0].yId; this.idExtend.Xmax=this.aTiles[0][this.cols - 1].xId; this.idExtend.Ymax=this.aTiles[0][this.cols - 1].yId; }; SGrid.prototype.getIdGridExtend=function() { return (this.idExtend); }; SGrid.prototype.getViewPixelExtend=function() { return (this.pixelExtend); };  SGrid.prototype.getCoorGridExtend=function() { var idCoorExtend=new SGeoBox(0,0,0,0); idCoorExtend.Xmin=this.GetCoor(this.idExtend.Xmin-1); idCoorExtend.Ymin=this.GetCoor(this.idExtend.Ymin-1); idCoorExtend.Xmax=this.GetCoor(this.idExtend.Xmax); idCoorExtend.Ymax=this.GetCoor(this.idExtend.Ymax); return (idCoorExtend); }; SGrid.prototype.getCoorViewExtend=function() { var idCoorExtend=new SGeoBox(0,0,0,0); idCoorExtend.Xmin=this.GetCoor(this.pixelExtend.Xmin,this.mapType.getTileSize()); idCoorExtend.Xmax=this.GetCoor(this.pixelExtend.Xmax,this.mapType.getTileSize()); idCoorExtend.Ymin=this.GetCoor(this.pixelExtend.Ymin,this.mapType.getTileSize()); idCoorExtend.Ymax=this.GetCoor(this.pixelExtend.Ymax,this.mapType.getTileSize()); return (idCoorExtend); };  SGrid.prototype.setCenterPixelId=function() { this.pointPixelCenter.X=this.pixelExtend.Xmin+(this.viewSize.width/2); this.pointPixelCenter.Y=this.pixelExtend.Ymin+(this.viewSize.height/2);  }; SGrid.prototype.setCenterCoor=function() { this.pointCoorCenter.X=this.GetCoor(this.pointPixelCenter.X,this.mapType.getTileSize()); this.pointCoorCenter.Y=this.GetCoor(this.pointPixelCenter.Y,this.mapType.getTileSize()); };  SGrid.prototype.GetCoor=function(id,limite) { if(!limite) { var limite=1; } var sim=new SImagesLevel(this.level); sim.numXFiles=sim.numXFiles *limite; sim.numYFiles=sim.numYFiles *limite; var scon=new SConvers(sim); var coor=scon.GetMaxXCoor(id); return coor; };  SGrid.prototype.getAbsoluteLeft=function() { return (this.left + this.topLeftTile.left); }; SGrid.prototype.getAbsoluteTop=function() { return (this.top + this.topLeftTile.top); }; SGrid.prototype.RotateTiles=function() { var peticion=false; while(this.getAbsoluteLeft() >- this.tilePaddingOffset.width) { this.rotateLeft(); peticion=true; } while(this.getAbsoluteLeft() <- this.tilePaddingOffset.width*this.cols) { this.rotateRight(); peticion=true; } while(this.getAbsoluteTop() >- this.tilePaddingOffset.height) { this.rotateUp(); peticion=true; } while(this.getAbsoluteTop() <- this.tilePaddingOffset.height*this.rows) { this.rotateDown(); peticion=true; }   this.CalculateExtend(); if(peticion==true) { this.getImage(); } }; SGrid.prototype.getImage=function() { var optionalargs=""; if (typeof(OWTILEDS)!="undefined") { optionalargs="&OWTILEDS=TRUE"+ "&" + new Date().getTime(); } this.frame.src=SMAP_SERVER_PATH+"?IDX1="+this.getIdGridExtend().Xmin+"&IDY1="+this.getIdGridExtend().Ymin+"&IDX2="+this.getIdGridExtend().Xmax+"&IDY2="+this.getIdGridExtend().Ymax+"&LEVEL="+this.level+"&MAPNAME="+this.mapType.getMapFile()+"&IMGTYPE="+this.mapType.getImagesExtension()+"&TSIZEP="+this.mapType.getTileSize()+ optionalargs; }; SGrid.prototype.rotateLeft=function() { var cols=this.cols-1; var tile=null; this.topLeftTile.left -=this.mapType.getTileSize(); this.enumerateX--; for (var i=0; i<this.rows; i++) { tile=this.aTiles[i][cols]; tile.configureImage(this.aTiles[i][0].xId-1, tile.yId, this.level, this.topLeftTile.left, tile.top); var lastCol=this.aTiles[i].pop(); this.aTiles[i].unshift(lastCol); lastCol=null; tile=null }   }; SGrid.prototype.rotateRight=function() { var cols=this.cols-1; var tile=null; this.topLeftTile.left +=this.mapType.getTileSize(); var newpos=this.topLeftTile.left + (this.mapType.getTileSize()*cols); this.enumerateX++; for (var i=0; i<this.rows; i++) { tile=this.aTiles[i][0]; tile.configureImage(this.aTiles[i][cols].xId+1, tile.yId, this.level, newpos, tile.top); var firstCol=this.aTiles[i].shift(); this.aTiles[i].push(firstCol); firstCol=null; tile=null; }   }; SGrid.prototype.rotateUp=function() { var rows=this.rows-1; var tile=null; this.topLeftTile.top -=this.mapType.getTileSize(); for (var i=0; i<this.cols; i++) { tile=this.aTiles[rows][i]; tile.configureImage(tile.xId, this.aTiles[0][i].yId+1, this.level, tile.left, this.topLeftTile.top); }   var lastRow=this.aTiles.pop(); this.aTiles.unshift(lastRow); lastRow=null; tile=null; };  SGrid.prototype.rotateDown=function() { var tile=null; var rows=this.rows-1; this.topLeftTile.top +=this.mapType.getTileSize(); var newpos=this.topLeftTile.top + (this.mapType.getTileSize()*rows); for (var i=0; i<this.cols; i++) { tile=this.aTiles[0][i]; tile.configureImage(tile.xId, this.aTiles[rows][i].yId-1, this.level, tile.left, newpos); }  var firstRow=this.aTiles.shift(); this.aTiles.push(firstRow); firstRow=null; tile=null; }; SGrid.prototype.mouseDown=function(e) { var button=e.button?e.button:e.which; if (e.preventDefault) { e.preventDefault(); } if (button==2) { this.dragging=false; return false; } this.dragPoint.X=e.clientX; this.dragPoint.Y=e.clientY; if (this.htmlElement.setCapture) { this.htmlElement.setCapture(); } if(!this.dragdisabledForZoom) { this.firstmove=true; SEvent.InternalTrigger(this, "onmousedown", Ea(e,this.htmlElement)); if (this.savedPosition.X==0||this.savedPosition.Y==0) { this.savedPosition.X=this.dragPoint.X; this.savedPosition.Y=this.dragPoint.Y; } this.posOnDown=new SGeoPoint(this.left, this.top); this.clickStartTime=(new Date()).getTime(); this.clickStartPos.X=e.clientX; this.clickStartPos.Y=e.clientY; } else if(this.dragdisabledForZoom) { this.zoomPivot=Ea(e,this.htmlElement.parentNode); }   }; SGrid.prototype.mouseUp=function(e) { SwitchCursor(this.htmlElement,this.originalCursor); var button=e.button?e.button:e.which; if (button==2) { this.dragging=false; SEvent.InternalTrigger(this, "onmouserightclick", Ea(e,this.htmlElement.parentNode)); return false; }  if(document.releaseCapture) { document.releaseCapture(); } if(this.dragdisabledForZoom&&!this.zoomPivot.Equal(Ea(e,this.htmlElement.parentNode))) { this.deactivateZoomRectangle();  SEvent.InternalTrigger(this, "onzoomrectangle", this.zoomRectangle); return; } else if(this.dragdisabledForZoom&&this.zoomPivot.Equal(Ea(e,this.htmlElement.parentNode))) { this.deactivateZoomRectangle();   SEvent.InternalTrigger(this, "onzoomrectangleclick", Ea(e,this.htmlElement.parentNode)); } this.dragging=false; SEvent.InternalTrigger(this, "onmouseup", Ea(e,this.htmlElement));  var instant=(new Date()).getTime(); if(instant - this.clickStartTime<=500 && (Math.abs(this.clickStartPos.X - e.clientX) <=2 && Math.abs(this.clickStartPos.Y - e.clientY) <=2)) { this.mouseClick(e); } if((Math.abs(this.clickStartPos.X - e.clientX) > 0 || Math.abs(this.clickStartPos.Y - e.clientY) >0)) { SEvent.InternalTrigger(this, "onenddrag"); } }; SGrid.prototype.mouseClick=function(e) { if (!this.clickDisabled) { SEvent.InternalTrigger(this, "onclick", Ea(e,this.htmlElement));  } }; SGrid.prototype.mouseOver=function(e) { this.mousePosition.X=e.clientX; this.mousePosition.Y=e.clientY; SEvent.InternalTrigger(this, "onmouseover", this.mousePosition); }; SGrid.prototype.mouseMove=function(e) { this.mousePosition.X=e.clientX; this.mousePosition.Y=e.clientY; if (!this.dragging&&this.firstmove) { this.firstmove=false; this.dragging=true;  SEvent.InternalTrigger(this, "onstartdrag", this.dragPoint); } if (this.dragging&&!this.dragDisabled&&!this.dragdisabledForZoom) { var xp=this.left + (e.clientX - this.dragPoint.X); var yp=this.top + (e.clientY - this.dragPoint.Y); this.moveTo(xp, yp); if (this.panSiner) { this.cancelSlide(); } var x=new STimer(1); x.startTimeout(this, this.RotateTiles); this.savedPosition.X=this.dragPoint.X; this.savedPosition.Y=this.dragPoint.Y;    this.dragPoint.X=this.mousePosition.X; this.dragPoint.Y=this.mousePosition.Y; x=null; SwitchCursor(this.htmlElement,"move"); SEvent.InternalTrigger(this, "ondraggin"); } else if(this.dragdisabledForZoom) { var onViewport=false; SwitchCursor(this.htmlElement,"nw-resize");  if (e.srcElement&&this.htmlElement.parentNode.contains(e.srcElement)) { onViewport=true;  } else if(e.target&&this.htmlElement.parentNode.contains(e.target)) { onViewport=true; } if (!onViewport) { return;  } var p=Ea(e,this.htmlElement.parentNode); var w=0; var h=0; var x=0; var y=0; var height=p.Y - this.zoomPivot.Y; var width=p.X -  this.zoomPivot.X; if (width>0 && height<0) { w=Math.abs(width); h=Math.abs(height); x=this.zoomPivot.X; y=this.zoomPivot.Y - h; } else if(width<0 && height<0) { w=Math.abs(width); h=Math.abs(height); x=p.X; y=p.Y; } else if(width<0 && height>0) { w=Math.abs(width); h=Math.abs(height); x=p.X; y=p.Y-h; } else if(width>0 && height>0) { w=Math.abs(width); h=Math.abs(height); x=this.zoomPivot.X; y=this.zoomPivot.Y; } if (typeof(h)!="number"|| typeof(w)!="number"||typeof(x)!="number"||typeof(y)!="number") { return; } this.zoomRectangleLayer.style.top=toPixel(y); this.zoomRectangleLayer.style.left=toPixel(x); this.zoomRectangleLayer.style.width=toPixel(w);   this.zoomRectangleLayer.style.height=toPixel(h); this.zoomRectangleLayerShadow.style.top=toPixel(y+1); this.zoomRectangleLayerShadow.style.left=toPixel(x+1); this.zoomRectangleLayerShadow.style.width=toPixel(w);   this.zoomRectangleLayerShadow.style.height=toPixel(h); if (!this.zoomRectangle) { this.zoomRectangle=new SGeoBox(0,0,0,0); } this.zoomRectangle.Xmin=x; this.zoomRectangle.Ymin=(y+h); this.zoomRectangle.Xmax=(x+w); this.zoomRectangle.Ymax=y; } }; SGrid.prototype.mouseDblClick=function(e) { if (this.dragDisabled) { return; } var xp=this.left + (e.clientX); var yp=this.top + (e.clientY);   var point1=Ea(e,this.htmlElement); point1.X=point1.X + this.left; point1.Y=point1.Y + this.top; var point2=new SGeoPoint(this.viewSize.width/2, this.viewSize.height/2); SEvent.InternalTrigger(this, "ondblclick", Ea(e,this.htmlElement)); this.slide(point1,point2); }; SGrid.prototype.onWindowMouseOut=function(e) { if(!e.relatedTarget&&this.dragging) { this.mouseUp(e); } };  SGrid.prototype.slide=function(startPoint, endPoint) { var xDistance=Math.round(endPoint.X)-Math.round(startPoint.X); var yDistance=Math.round(endPoint.Y)-Math.round(startPoint.Y); var lineDistance=Math.sqrt(xDistance*xDistance+yDistance*yDistance); var lineJump=Math.max(5, (lineDistance/30)); this.panSiner=new SDashedWay(lineJump); this.panSiner.reset(); this.panDistance.width=xDistance; this.panDistance.height=yDistance; this.slideStart=new SGeoPoint(this.left,this.top); this.slideEnd.X=this.left+xDistance; this.slideEnd.Y=this.top+yDistance; this.dragging=true; this.dragDisabled=true; SEvent.InternalTrigger(this, "onstartdrag"); this.doSlide(); }; SDashedWay=function(ticks) { this.ticks=ticks; this.tick=0; this.canceled=false; }; SDashedWay.prototype.reset=function() { this.tick=0; }; SDashedWay.prototype.cancel=function() { this.canceled=true; }; SDashedWay.prototype.next=function() { this.tick++; var a=Math.PI*(this.tick/this.ticks-0.5); return(Math.sin(a)+1)/2; }; SDashedWay.prototype.more=function() { return this.tick<this.ticks; }; SGrid.prototype.doSlide=function(){ try { var a=this.panSiner.next(); if(this.panSiner.more()) { this.moveTo(this.slideStart.X+this.panDistance.width*a,this.slideStart.Y+this.panDistance.height*a); this.timerSlide=new STimer(10); this.timerSlide.startTimeout(this, this.doSlide); SEvent.InternalTrigger(this, "ondraggin");     } else { if (!this.panSiner.canceled) { this.moveTo(this.slideEnd.X, this.slideEnd.Y); this.RotateTiles(); this.dragging=false; this.dragDisabled=false; SEvent.InternalTrigger(this, "onenddrag"); } this.panSiner=null; this.timerSlide=null; } } catch(e) { this.cancelSlide(); } }; SGrid.prototype.cancelSlide=function() { if(this.timerSlide) { this.timerSlide.stop(); this.panSiner.cancel(); SEvent.InternalTrigger(this, "onenddrag"); } };  SGrid.prototype.setMapType=function(mapType) { this.mapType=mapType; };  SGrid.prototype.reconfigureImages=function() { for (var i=0; i<this.rows; i++) { for (var j=0; j<this.cols; j++) { tile=this.aTiles[i][j]; tile.setMapType(this.mapType); tile.configureImage(tile.xId, tile.yId, this.level, tile.left, tile.top); } } };  SGrid.prototype.keyDown=function(keyCode, altKey, ctrlKey, shiftKey) { if (!this.keyboardDisabled) { switch(keyCode) { case 16: this.activateZoomRectangle(); break; } }  }; SGrid.prototype.activateZoomRectangle=function() { if (!this.dragdisabledForZoom&&!this.dragging) { this.zoomPivot=null; this.dragdisabledForZoom=true; this.dragDisabled=true; this.zoomRectangleLayerShadow=this.CreateLayer(this.htmlElement.parentNode, 0,0, 99, -100,-100, "", "black"); this.zoomRectangleLayer=this.CreateLayer(this.htmlElement.parentNode, 0,0, 99, -100,-100, "", "white"); this.zoomRectangleLayer.style.border="3px dashed white"; this.zoomRectangleLayer.style.fontSize="0px"; this.zoomRectangleLayer.style.overflow="hidden"; this.zoomRectangleLayerShadow.style.border="3px dashed black"; this.zoomRectangleLayerShadow.style.overflow="hidden"; this.zoomRectangleLayerShadow.style.fontSize="0px";   } }; SGrid.prototype.deactivateZoomRectangle=function() { try{ this.dragdisabledForZoom=false; this.dragDisabled=false; this.htmlElement.parentNode.removeChild(this.zoomRectangleLayer); this.htmlElement.parentNode.removeChild(this.zoomRectangleLayerShadow); this.zoomRectangleLayer=null; this.zoomRectangleLayerShadow=null; SwitchCursor(this.htmlElement,this.originalCursor); } catch(e) { } }; SGrid.prototype.CreateLayer=function (baselayer,width,height,prioridad,x, y,color,bordercolor) { var oDiv=document.createElement('div'); oDiv.style.backgroundColor=color; oDiv.style.position='absolute'; oDiv.style.left=toPixel(x); oDiv.style.top=toPixel(y); oDiv.style.width=toPixel(width); oDiv.style.height=toPixel(height); oDiv.style.zIndex=prioridad; baselayer.appendChild(oDiv); return oDiv; }; SGrid.prototype.keyUp=function(keyCode, altKey, ctrlKey, shiftKey) { if (!this.keyboardDisabled) { var from=null; switch(keyCode) { case 38: case 104: from=new SGeoPoint(this.viewSize.width/2, 0); break; case 40: case 98: from=new SGeoPoint(this.viewSize.width/2, this.viewSize.height); break; case 37: case 100: from=new SGeoPoint(0, this.viewSize.height/2); break; case 39: case 102: from=new SGeoPoint(this.viewSize.width, this.viewSize.height/2); break; case 103: from=new SGeoPoint(0, 0); break; case 105: from=new SGeoPoint(this.viewSize.width, 0); break; case 97: from=new SGeoPoint(0, this.viewSize.height); break; case 99: from=new SGeoPoint(this.viewSize.width, this.viewSize.height); break; case 16: this.deactivateZoomRectangle(); break; case 107: SEvent.InternalTrigger(this, "onzoominkey"); break; case 109: SEvent.InternalTrigger(this, "onzoomoutkey"); break; } if (from) { var to=new SGeoPoint(this.viewSize.width/2, this.viewSize.height/2); this.slide(from, to); } } }; 
SLayer=function (container, name, width, height, mapref) { if (mapref) { this.mapref=mapref; } this.isVisible=true; this.container=container; this.name=name; this.timer=null; this.srid=null; this.request=null; this.size=new SSize(); this.size.width=width; this.size.height=height; this.timerFactor=1000; this.createImage(0,0); this.wunload=SEvent.attachDOM(window, 'unload', this.destroy, this); return this; }; SLayer.prototype.container=null; SLayer.prototype.image=null; SLayer.prototype.name=null; SLayer.prototype.timer=null; SLayer.prototype.request=null; SLayer.prototype.zIndex=0; SLayer.prototype.mapFileName=null; SLayer.prototype.mapFileLayer=null; SLayer.prototype.mapServer=null; SLayer.prototype.serverPort=80; SLayer.prototype.dataSource=null; SLayer.prototype.geomField=null; SLayer.prototype.filter=null; SLayer.prototype.opacity=100; SLayer.prototype.refreshTime=null; SLayer.prototype.left=0; SLayer.prototype.top=0; SLayer.prototype.isVisible=null; SLayer.prototype.wunload=null; SLayer.prototype.type=0; SLayer.prototype.size=null; SLayer.prototype.debug=false; SLayer.prototype.useCache=true; SLayer.prototype.timerFactor=null; SLayer.prototype.setParserFeatures=function(server, port, file) { this.parserServer=server; this.serverPort=port; this.parserFile=file; this.type=1; }; SLayer.prototype.setParserParams=function(params) { this.parseFilter=params; }; SLayer.prototype.withCache=function(flag) { this.useCache=!flag?false:true; }; SLayer.prototype.setSRID=function(value) { this.srid=value; }; SLayer.prototype.setMapFileFeatures=function(file, mapLayer) { this.mapFileName=file; this.mapFileLayer=mapLayer; this.type=2; }; SLayer.prototype.setDatabaseFeatures=function(dataSource, geometryField, filter) { this.dataSource=dataSource; this.geomField=geometryField; this.filter=filter; this.type=2; }; SLayer.prototype.setOpacity=function(value) { value=!value?100:parseInt(value); if (value>100 || value< 0) { value=100; }  this.opacity=value; ChangeOpacity(this.image, this.opacity); }; SLayer.prototype.bringToFront=function() { this.image.style.zIndex=this.getMaxzIndex(); }; SLayer.prototype.getMaxzIndex=function() { var maxZIndex=0; for (var i=0; i< this.image.parentNode.childNodes.length-1; i++)  { var elem=this.image.parentNode.childNodes[i]; if ((elem.style.zIndex > maxZIndex) && (elem!=this.image)) { maxZIndex=elem.style.zIndex; elem.style.zIndex=elem.style.zIndex-1; } } maxZIndex++; if (maxZIndex>100) { maxZIndex=100; } return maxZIndex; }; SLayer.prototype.setRefresh=function(value) { if (this.timer) { this.timer.stop(); this.timer=null; } if (value==null||parseInt(value)<=0) { value=0; } else { if ((parseInt(value)*this.timerFactor)<DEFAULT_TIMER_REFRESH_DL) { value=DEFAULT_TIMER_REFRESH_DL; } else { value=parseInt(value)*this.timerFactor; } } this.refreshTime=value; if (this.refreshTime=="NaN") { this.refreshTime=0; } if (!this.timer&&this.refreshTime>0) { this.timer=new STimer(this.refreshTime);   this.timer.startTimeout(this, this.update) } }; SLayer.prototype.buildRequest=function() { var req=""; var prefix=""; var extend=this.mapref.Grid.getCoorGridExtend(); switch(this.type) { case 1: if (this.parserServer) { prefix +="http://" + this.parserServer; } if (this.serverPort) { prefix +=(this.serverPort!=80?(":"+this.serverPort):("")); } prefix=prefix + "" + this.parserFile; if (this.parseFilter) { req=req + "&" + this.parseFilter; } req=req + "&w=" + this.size.width; req=req + "&h=" + this.size.height; req=req + "&xmin=" + extend.Xmin; req=req + "&ymin=" + extend.Ymin; req=req + "&xmax=" + extend.Xmax; req=req + "&ymax=" + extend.Ymax; break; case 2: req +="mf=" + this.mapFileName; req +="&l=" + this.mapFileLayer; req +="&g=" + this.geomField; req +="&ds=" + this.dataSource; req +="&f=" + this.filter; req +="&w=" + this.size.width; req +="&h=" + this.size.height; req +="&xmin=" + extend.Xmin; req +="&ymin=" + extend.Ymin; req +="&xmax=" + extend.Xmax; req +="&ymax=" + extend.Ymax; if (this.srid!=null) { req +="&srid=" + this.srid; } prefix=MAPSERVER_GESTOR_DL; break;     default: break; } if (this.debug) { req=req + "&debug=on"; SDebug(prefix +"?"+ req); } extend=null; ext_string=null; if (!this.useCache) { req=req + "&ips=" + new Date().getTime(); } return (prefix +"?"+ req); }; SLayer.prototype.setDebugMode=function(value) { this.debug=!value?false:true; }; SLayer.prototype.setDataFilter=function(filter) { if (this.type==2&&this.dataSource&&this.geomField&&this.filter!=filter) { this.filter=filter;  } }; SLayer.prototype.setVisibility=function(value) { var newVal=!value?false:true; if (this.isVisible==newVal) { return; } this.isVisible=newVal; if (!this.isVisible) { this.stopTimer(); } this.update(); }; SLayer.prototype.update=function() { this.image.style.display="none"; var tx=new STimer(200); tx.startTimeout(this, this.forceupdate); }; SLayer.prototype.forceupdate=function() { try { if (this.isVisible) { this.iOnLoad=SEvent.attachDOM(this.image, "load", function(){ this.image.style.display=""; SEvent.deattachDOM(this.image, "load", this.iOnLoad); if (this.refreshTime>0) { this.setRefresh(this.refreshTime/this.timerFactor); } }, this); this.iOnAbort=SEvent.attachDOM(this.image, "abort", function(){ this.image.style.display="none"; SEvent.deattachDOM(this.image, "error", this.iOnAbort); if (this.refreshTime>0) { this.setRefresh(this.refreshTime/this.timerFactor); } }, this); this.image.src=this.buildRequest(); }   } catch(e) { } }; SLayer.prototype.createImage=function(x, y) { this.image=document.createElement('IMG');   this.image.style.position="absolute"; this.image.style.border="0px none gray"; this.image.style.left=toPixel(x); this.image.style.top=toPixel(y); this.image.style.width=toPixel(this.size.width); this.image.style.height=toPixel(this.size.height); this.image.style.zIndex=0; this.image.style.display="none"; this.container.appendChild(this.image); };  SLayer.prototype.destroy=function() { try { this.container.removeChild(this.image); this.container=null; this.image.onload=null; this.image=null; if (this.timer) { this.timer.stop(); } this.timer=null; SEvent.deattachDOM(window, 'unload', this.wunload); this.mapref=null; this.wunload=null; } catch(e) { } }; SLayer.prototype.stopTimer=function() { if (this.timer) { this.timer.stop(); } }; 
function SConfirmWindow(container, text) { this.container=container; this.width=0; this.height=0; this.left=0; this.top=0; this.width=0; this.height=0; this.left=0; this.top=0; this.retVal=0; this.fontColor=""; this.backColor=""; this.fontFamily=""; this.fontSize=""; this.handlerOkClick=null; this.handlerCancelClick=null; this.createInterface(); this.applyStyles(); this.setBackColor("#FFFFFF"); this.setFontColor("#000000"); this.setFont("Verdana, Arial, Helvetica, sans-serif", 10); if (text) { this.setMessage(text); } }; SConfirmWindow.prototype.createInterface=function() { this.htmlElement=this.createDIV(new SSize(330, 300), "pixel", 0, 0, null, null, "pixel"); ChangeOpacity(this.htmlElement, 70); this.textContainer=this.createDIV(new SSize(95, 80), "percent", 3, 2, null, null, "percent"); this.ButtonsContainer=this.createDIV(new SSize(180, 30), "pixel", null, null, 5, 5, "pixel"); this.OkButton=this.createButton("Aceptar"); this.CancelButton=this.createButton("Cancelar"); this.ButtonsContainer.appendChild(this.OkButton); this.ButtonsContainer.appendChild(this.CancelButton); this.htmlElement.appendChild(this.textContainer); this.htmlElement.appendChild(this.ButtonsContainer); this.container.appendChild(this.htmlElement); this.handlerOkClick=SEvent.attachDOM(this.OkButton, "click", this.onOkClick, this); this.handlerCancelClick=SEvent.attachDOM(this.CancelButton, "click", this.onCancelClick, this); }; SConfirmWindow.prototype.applyStyles=function() { with(this.OkButton) { style.padding="3px"; style.margin="3px"; } with(this.CancelButton) { style.padding="3px"; style.margin="3px"; } with(this.textContainer) { style.padding="5px"; style.overflow="auto"; } with(this.ButtonsContainer) { style.textAlign="right";   } with(this.htmlElement) { style.border="1px solid gray"; style.zIndex="99"; style.overflow="hidden"; } }; SConfirmWindow.prototype.onOkClick=function() { this.retVal=0;  this.Close(); }; SConfirmWindow.prototype.onCancelClick=function() { this.retVal=1;  this.Close(); }; SConfirmWindow.prototype.setSize=function(width, height) { width=Math.floor(width); height=Math.floor(height); if (width<150) { width=150; }  if (height<80) { height=150; }  if (this.width!=width&&this.height!=height) { this.htmlElement.style.display="none"; this.width=width; this.height=height;    this.htmlElement.style.width=toPixel(this.width); this.htmlElement.style.height=toPixel(this.height); this.htmlElement.style.display=""; } }; SConfirmWindow.prototype.moveTo=function(left, top) { left=Math.floor(left); top=Math.floor(top); if (this.left!=left&&this.top!=top) { this.htmlElement.style.display="none"; this.left=left; this.top=top;    this.htmlElement.style.left=toPixel(this.left); this.htmlElement.style.top=toPixel(this.top); this.htmlElement.style.display=""; } }; SConfirmWindow.prototype.center=function() { var x=(this.container.clientWidth/2)-(this.width/2); var y=(this.container.clientHeight/2)-(this.height/2);   this.moveTo(x, y); }; SConfirmWindow.prototype.setBackColor=function(color) { if (this.backColor!=color) { this.backColor=color; this.htmlElement.style.backgroundColor=this.backColor; } }; SConfirmWindow.prototype.setFontColor=function(color) { if (this.fontColor!=color) { this.fontColor=color; this.htmlElement.style.color=this.fontColor; } }; SConfirmWindow.prototype.setBorderStyle=function(cssStyle) { this.htmlElement.style.border=cssStyle; }; SConfirmWindow.prototype.setOpacity=function(value) { ChangeOpacity(this.htmlElement, value); }; SConfirmWindow.prototype.setButtonsStyle=function(backcolor, color, fontFamily, fontSize) { with(this.OkButton) { if (fontFamily) style.fontFamily=fontFamily; if (fontSize)  style.fontSize=toPixel(fontSize); if (color) style.color=color; if (backcolor) style.backgroundColor=backcolor; } with(this.CancelButton) { if (fontFamily) style.fontFamily=fontFamily; if (fontSize)  style.fontSize=toPixel(fontSize); if (color) style.color=color; if (backcolor) style.backgroundColor=backcolor; } }; SConfirmWindow.prototype.setFont=function(fontFamily, fontSize) { fontSize=Math.floor(fontSize); if (this.fontFamily!=fontFamily&&this.fontSize!=fontSize) { this.fontFamily=fontFamily; this.fontSize=fontSize; this.htmlElement.style.fontFamily=this.fontFamily; this.htmlElement.style.fontSize=toPixel(this.fontSize); } }; SConfirmWindow.prototype.setMessage=function(text) { if (this.text!=text) { this.text=text; this.textContainer.innerHTML=""; this.textContainer.innerHTML=text; } }; SConfirmWindow.prototype.setOkButtonStatus=function(status) { this.OkButton.disabled=!status; }; SConfirmWindow.prototype.setCancelButtonStatus=function(status) { this.CancelButton.disabled=!status; }; SConfirmWindow.prototype.createDIV=function (size, sizeUnit,  top, left, bottom, right, posUnit) { var oDiv=document.createElement('div'); oDiv.style.position='absolute'; switch(sizeUnit) { case "pixel": oDiv.style.width=toPixel(size.width); oDiv.style.height=toPixel(size.height); break; default: oDiv.style.width=toPercent(size.width); oDiv.style.height=toPercent(size.height); } switch(posUnit) { case "pixel": if (top) { oDiv.style.bottom=""; oDiv.style.top=toPixel(top); } if (left) { oDiv.style.right=""; oDiv.style.left=toPixel(left); } if (bottom) { oDiv.style.top=""; oDiv.style.bottom=toPixel(bottom); } if (right) { oDiv.style.left=""; oDiv.style.right=toPixel(right); } break; default: if (top) { oDiv.style.bottom=""; oDiv.style.top=toPercent(top); } if (left) { oDiv.style.right=""; oDiv.style.left=toPercent(left); } if (bottom) { oDiv.style.top=""; oDiv.style.bottom=toPercent(bottom); } if (right) { oDiv.style.left=""; oDiv.style.right=toPercent(right); }   }  return oDiv; }; SConfirmWindow.prototype.Close=function () { SEvent.deattachDOM(this.OkButton, "click", this.handlerOkClick); SEvent.deattachDOM(this.CancelButton, "click", this.handlerCancelClick); this.textContainer=null; this.ButtonsContainer=null; this.OkButton=null; this.CancelButton=null; this.handlerOkClick=null; this.handlerCancelClick=null;  this.container.removeChild(this.htmlElement); this.htmlElement=null; SEvent.Trigger(this, "OnClose", this.retVal); }; SConfirmWindow.prototype.createButton=function (value) { var oBut=document.createElement('INPUT'); oBut.type="button"; oBut.value=value; return oBut; }; 
function SMap(layer, mapEspecifications) { if(!layer||typeof(layer.id)=="undefined") { return null; }; this.mapLayerObj=layer;  this.mapLayerObj.style.display="block"; SetSelectableStatus(this.mapLayerObj, "off"); this.layerHideMapObj=null;  this.mapPixelWidth=0; this.mapPixelHeight=0;  this.level=1;  this.pointCoorCenter=new SGeoPoint(0,0);  this.dynLayerCont=null;  this.layerScaleBar=null;   this.scaleBar=null;  this.dLayerHandler=null; this.aLayers=new Array(); this.timerOverLays=new STimer(2000); this.timerResize=new STimer(1000); this.mapControls=new Array(); this.iconLayers=null; this.genlayer="genericiconlayer"; this.windowInfo=null; this.callOut=null; this.calloutListenerClose=null; this.currentMapType=null; this.lastMapType=null; this.SDigitizer=null; this.isDigitizing=false; this.digiListener2=null; this.digiListener3=null; this.digiListener4=null; this.isZoomAbled=true; this.zoomRange=null; this.types=new Array(); if (!mapEspecifications||mapEspecifications.key) { this.mapSpecs=new SMapSpecifications(); } else if(!mapEspecifications&&mapEspecifications.key) { this.mapSpecs=mapEspecifications; } else { return; } this.isLoaded=false; this.createSpecifications(); this.Grid=null;  this.detectResize=false; this.Init(); this.wresize=SEvent.attachDOM(window, 'resize', this.resize, this); this.wunload=SEvent.attachDOM(window, 'unload', this.destroy, this); };  SMap.prototype.destroy=function()  { try { for(var i=0;i<this.mapControls.length;i++) { this.removeControl(this.mapControls[i]); } this.Grid.destroy(); this.removeAllIcons(); this.mapLayerObj.removeChild(this.layerHideMapObj); this.layerHideMapObj=null; this.mapLayerObj=null; this.dynLayerCont=null; SEvent.RemoveInternalListener(this.ehStartDrag); SEvent.RemoveInternalListener(this.ehDragging); SEvent.RemoveInternalListener(this.ehEndDrag); SEvent.RemoveInternalListener(this.ehclick); SEvent.RemoveInternalListener(this.ehdblclick); SEvent.RemoveInternalListener(this.ehresize); SEvent.RemoveInternalListener(this.ehzrectc); SEvent.RemoveInternalListener(this.ehzrect); SEvent.RemoveInternalListener(this.ekzoomin); SEvent.RemoveInternalListener(this.ekzoomout); SEvent.RemoveInternalListener(this.ekzoomout); SEvent.RemoveInternalListener(this.ekmousedown); } catch(e) { }  }; SMap.prototype.Init=function() { this.isLoaded=true; var hidemapsource=new SGeoPoint(0,0); this.layerHideMapObj=this.CreateLayer(this.mapLayerObj, "", 0, 0, 1, hidemapsource, null, null, "visible"); this.layerScaleBar=this.CreateLayer(this.mapLayerObj, "scalebar", 0,0, 1, new SGeoPoint(0,0), null, null, "visible"); this.Grid=new SGrid(this.layerHideMapObj, this.currentMapType , null, null); this.dynLayerCont=this.CreateLayer(this.layerHideMapObj, null,this.Grid.width,this.Grid.height,1, new SGeoPoint(0,0), "","","visible"); this.mapPixelWidth=this.Grid.viewSize.width; this.mapPixelHeight=this.Grid.viewSize.height; if (this.mapPixelWidth < 256 || this.mapPixelHeight <256) { this.layerScaleBar.style.display="none"; } var objHead=document.getElementsByTagName('head'); if (objHead[0])   { var objCSS=objHead[0].appendChild(document.createElement('link')); objCSS.title='scalebar-thin'; objCSS.rel='stylesheet'; objCSS.href=SMAP_CSS_PATH+'scalebar-thin.css'; objCSS.type='text/css';   }  this.scaleBar=new ScaleBar(445644800); this.scaleBar.place('scalebar'); this.scaleBar.divisions=1;  this.scaleBar.subdivisions=2; this.scaleBar.minWidth=100; this.scaleBar.maxWidth=150;  this.scaleBar.update(); this.ehStartDrag=SEvent.InternalBind(this.Grid, "onstartdrag", this, this.startdrag); this.ehDragging=SEvent.InternalBind(this.Grid, "ondraggin", this, this.draggin); this.ehEndDrag=SEvent.InternalBind(this.Grid, "onenddrag", this, this.enddrag); this.ehclick=SEvent.InternalBind(this.Grid, "onclick", this, this.click); this.ehdblclick=SEvent.InternalBind(this.Grid, "ondblclick", this, this.dblclick); this.ehresize=SEvent.InternalBind(this.Grid, "onresize", this, this.resize); this.ehzrect=SEvent.InternalBind(this.Grid, "onzoomrectangle", this, this.zoomwindow); this.ehzrectc=SEvent.InternalBind(this.Grid, "onzoomrectangleclick", this, this.zoomwindowclick); this.ekzoomin=SEvent.InternalBind(this.Grid, "onzoominkey", this, this.ZoomIn); this.ekzoomout=SEvent.InternalBind(this.Grid, "onzoomoutkey", this, this.ZoomOut); this.ekmousedown=SEvent.InternalBind(this.Grid, "onmousedown", this, this.mousedown); this.ekmouseup=SEvent.InternalBind(this.Grid, "onmouseup", this, this.mouseup); this.ekmouseover=SEvent.InternalBind(this.Grid, "onmouseover", this, this.mouseover); this.onmouserightclick=SEvent.InternalBind(this.Grid, "onmouserightclick", this, this.onmouserightclick); }; SMap.prototype.onmouserightclick=function(pixelPoint) { SEvent.Trigger(this, "OnMapMouseRigthClick", this.getLatLongFromPixel(pixelPoint), pixelPoint); }; SMap.prototype.mouseover=function(pixelPoint) { SEvent.Trigger(this, "OnMapMouseOver", this.getLatLongFromPixel(pixelPoint)); }; SMap.prototype.mousedown=function(pixelPoint) { SEvent.Trigger(this, "OnMapMouseDown", this.getLatLongFromPixel(pixelPoint)); }; SMap.prototype.mouseup=function(pixelPoint) { SEvent.Trigger(this, "OnMapMouseUp", this.getLatLongFromPixel(pixelPoint)); }; SMap.prototype.updateOverLays=function() { this.refreshDynamicLayers(); this.reposOverLays();  }; SMap.prototype.refreshDynamicLayers=function() { for (layer in this.aLayers) {  try { this.aLayers[layer].image.style.display="none"; this.aLayers[layer].image.src=""; this.aLayers[layer].size.width=this.Grid.width; this.aLayers[layer].size.height=this.Grid.height; this.aLayers[layer].image.style.width=toPixel(this.aLayers[layer].size.width);  this.aLayers[layer].image.style.height=toPixel(this.aLayers[layer].size.height); this.aLayers[layer].update(); } catch(e) { } }  }; SMap.prototype.reposOverLays=function() { this.dynLayerCont.style.left=toPixel(this.Grid.topLeftTile.left); this.dynLayerCont.style.top=toPixel(this.Grid.topLeftTile.top); }; SMap.prototype.LoadMap=function() { this.level=1; this.ZoomAndGoTo(new SGeoPoint(0,0),this.level); }; SMap.prototype.CreateGrid=function(tileId,pixelId) { var offset=this.GridOffset(pixelId,tileId); tileId.X=Math.round(tileId.X - Math.floor(this.Grid.cols/2)); tileId.Y=Math.round(tileId.Y + Math.floor(this.Grid.rows/2)); if (this.Grid.aTiles&&this.Grid.aTiles.length>0) { this.Grid.rebuild(tileId.X, tileId.Y, this.level, this.currentMapType, offset.X,offset.Y); } else { this.Grid.CreateGrid(tileId.X, tileId.Y, this.level, this.currentMapType, offset.X,offset.Y); this.Grid.setCenterPixelId(); this.Grid.setCenterCoor(); } }; SMap.prototype.ZoomAndGoTo=function(point, level) { var oldLevel=this.level; level=parseInt(level); if (isNaN(level)||level<1||level>19||!this.isZoomAbled) { return } if (this.GetGridExtend().Contains(point)&&level==oldLevel) { var pp1=this.getPixelFromLatLong(point); var pp2=new SGeoPoint(this.mapPixelWidth/2, this.mapPixelHeight/2); this.FlyMapCenter(pp1, pp2); } else { this.scaleBar.update(445644800/Math.pow(2,level-1)); alignBottom(this.layerScaleBar, 60); alignLeft(this.layerScaleBar, 20); this.pointCoorCenter=point; this.level=parseInt(level); var tileId=this.GetID(point); var pixelId=this.GetID(point, this.currentMapType.getTileSize()); this.CreateGrid(tileId,pixelId); this.Grid.CalculateExtend(); this.Grid.getImage(); this.updateOverLays(); } if (level!=oldLevel) { SEvent.Trigger(this, "OnMapChangeLevel", this.level); } else { SEvent.Trigger(this, "OnMapTryZoom"); } }; SMap.prototype.ZoomIn=function() { this.Grid.cancelSlide(); this.ZoomAndGoTo(this.pointCoorCenter,(this.level+1)); }; SMap.prototype.ZoomOut=function() { this.Grid.cancelSlide(); this.ZoomAndGoTo(this.pointCoorCenter,(this.level-1)); }; SMap.prototype.ZoomToLevel=function(nivel) { if (typeof(parseInt(nivel))!="number") { return false; }  this.ZoomAndGoTo(this.GetCenter(),nivel); }; SMap.prototype.GetCenter=function() { return this.pointCoorCenter; }; SMap.prototype.GetLevel=function() { return this.level; }; SMap.prototype.FlyMapCenter=function(startPoint,endPoint) { this.Grid.slide(startPoint,endPoint); }; SMap.prototype.GetGridExtend=function() {  return this.Grid.getCoorGridExtend(); }; SMap.prototype.GetMapExtend=function() {  return (this.Grid.getCoorViewExtend());  }; SMap.prototype.CreateLayer=function (baselayer,id,width,height,prioridad,source,color,bordercolor,visibility) { var oDiv=document.createElement('div'); oDiv.id=id; oDiv.style.backgroundColor=color; oDiv.style.position='absolute'; oDiv.style.left=toPixel(source.X); oDiv.style.top=toPixel(source.Y); oDiv.style.width=toPixel(width); oDiv.style.height=toPixel(height); oDiv.style.zIndex=prioridad; oDiv.style.overflow=visibility; baselayer.appendChild(oDiv); return oDiv; }; SMap.prototype.GridOffset=function(pixelId,tileId) {  var offset=new SGeoPoint(0,0); var compX=0; var compY=0; if(!this.IsDecimal((this.Grid.cols)/2)) { compX=this.currentMapType.getTileSize()/2; } if(!this.IsDecimal((this.Grid.rows)/2)) { compY=this.currentMapType.getTileSize()/2; }  offset.X=( ( (tileId.X * this.currentMapType.getTileSize()))- pixelId.X) - (this.currentMapType.getTileSize()/2); offset.Y=( pixelId.Y - ( (tileId.Y*this.currentMapType.getTileSize()) ) ) - (this.currentMapType.getTileSize()/2) *-1; offset.X=offset.X-compX; offset.Y=offset.Y-compY; return offset; }; SMap.prototype.GetID=function(coor,limite) { if(!limite) { var limite=1; } var sim=new SImagesLevel(this.level); sim.numXFiles=sim.numXFiles *limite; sim.numYFiles=sim.numYFiles *limite; var scon=new SConvers(sim); var id=new SGeoPoint(scon.GetMinYId(coor.X),scon.GetMinYId(coor.Y)); return id; }; SMap.prototype.GetCoor=function(id,limite) { if(!limite) { var limite=1; } var sim=new SImagesLevel(this.level); sim.numXFiles=sim.numXFiles *limite; sim.numYFiles=sim.numYFiles *limite; var scon=new SConvers(sim); var coor=new SGeoPoint(scon.GetMinXCoor(id.X),scon.GetMinYCoor(id.Y)); return coor; }; SMap.prototype.IsDecimal=function (num) { var valor_entero=Math.floor(Math.abs(num)); var valor_decimal=Math.abs(num) - valor_entero; if (valor_decimal > 0) { return true; } else { return false; } }; SMap.prototype.AddDynamicLayer=function(name) { if (!this.isLoaded) { return; }  var layer=null; if (!this.aLayers[name]) { this.aLayers[name]=new SLayer(this.dynLayerCont, name, this.Grid.width, this.Grid.height, this); layer=this.aLayers[name]; SEvent.Trigger(this, "OnDynamicLayerAdded", name); } else { layer=this.aLayers[name]; } return layer; }; SMap.prototype.GetDynamicLayer=function(name) { if (!this.isLoaded) { return; }  return (this.aLayers[name]); }; SMap.prototype.RemoveDynamicLayer=function(name) { if (!this.isLoaded) { return; }  if (this.aLayers[name]) { this.aLayers[name].destroy(); delete this.aLayers[name]; SEvent.Trigger(this, "OnDynamicLayerDeleted", name); } }; SMap.prototype.UpdateDynamicLayer=function(name) { if (!this.isLoaded) { return; }   if (this.aLayers[name]) { this.aLayers[name].update(); } }; SMap.prototype.DynamicLayerExist=function(name) { if (!this.isLoaded) { return false; }   if (!this.aLayers[name]) { return false; } else { return true; } }; SMap.prototype.addControl=function(oControl) { if(!oControl||!oControl.LoadControl||!oControl.setDefaultPosition||oControl.htmlElement) { return; } for(var i=0;i<this.mapControls.length;i++) { var currentControl=this.mapControls[i]; if(currentControl==oControl) { return; } } oControl.LoadControl(this, this.mapLayerObj); oControl.setDefaultPosition(); this.mapControls.push(oControl); return oControl; }; SMap.prototype.removeControl=function(oControl) { for(var i=0;i<this.mapControls.length;i++) { var currentControl=this.mapControls[i]; if(currentControl==oControl) { try { this.mapLayerObj.removeChild(oControl.htmlElement); this.mapControls.splice(i,1); } catch(e) { } return; } } }; SMap.prototype.openWindow=function(point, size, content) { if (!point||!point.X||!point.Y) { return null; } if (!size||!size.width||!size.height) { return null; } if (this.callOut) { this.callOut.close(); } this.callOut=new SCallOut(this.layerHideMapObj, this); this.callOut.createWindow(0, 0, size.width, size.height); this.callOut.setHtmlContent(!content?"":content); this.callOut.setCoordPosition(point); this.callOut.autoPositionCallOut(); this.calloutListenerClose=SEvent.Bind(this.callOut, "close", this, this.closeCallOut); return (this.callOut); }; SMap.prototype.closeCallOut=function() { this.callOut=null; SEvent.RemoveListener(this.calloutListenerClose); this.calloutListenerClose=null; }; SMap.prototype.addIcon=function(sicon, belongTo) { if (!this.isLoaded) { return; }   if (!sicon||!sicon.setMapReference) { return null; } sicon.setMapReference(this, this.layerHideMapObj); var layer=this.genlayer; if (!this.iconLayers) { this.iconLayers=new Array(); } if (belongTo) { if (!this.iconLayers[belongTo]) { this.iconLayers[belongTo]=new Array(); } layer=belongTo; } else  { if (!this.iconLayers[layer]) { this.iconLayers[layer]=new Array(); } } this.iconLayers[layer].push(sicon); }; SMap.prototype.removeAllIcons=function() { if (!this.isLoaded) { return; }   for(layer in this.iconLayers) { this.removeIconsOnLayer(layer); } this.iconLayers=null; }; SMap.prototype.GetIconsOnLayer=function(layer) { if (this.isLoaded) { if (this.iconLayers&&this.iconLayers[layer]) { return this.iconLayers[layer]; } } return null; }; SMap.prototype.removeIconsOnLayer=function(layer) { if (!this.isLoaded) { return; }   if (this.iconLayers&&this.iconLayers[layer]) { for (var i=0; i < this.iconLayers[layer].length; i++) { try{ this.iconLayers[layer][i].remove(); delete this.iconLayers[layer][i]; this.iconLayers[layer][i]=null; }catch(e){ } } this.iconLayers[layer]=null; }  }; SMap.prototype.startdrag=function() { for (layer in this.aLayers) { this.aLayers[layer].stopTimer(); } this.timerOverLays.stop(); SEvent.Trigger(this, "OnMapStartMove"); }; SMap.prototype.draggin=function() { this.Grid.CalculateExtend(); this.Grid.setCenterPixelId(); this.Grid.setCenterCoor(); SEvent.Trigger(this, "OnMapMoving"); }; SMap.prototype.enddrag=function(forced) { this.Grid.CalculateExtend(); this.pointCoorCenter=this.Grid.pointCoorCenter; this.timerOverLays.stop(); this.timerOverLays.startTimeout(this, this.updateOverLays); SEvent.Trigger(this, "OnMapEndMove"); }; SMap.prototype.getLatLongFromPixel=function(point) { point.X -=this.Grid.aTiles[0][0].left ;    point.Y -=this.Grid.aTiles[0][0].top ; var pixelPoint=new SGeoTool().PixelToCoor(point, this.GetGridExtend(), this.Grid.width, this.Grid.height); return (pixelPoint); }; SMap.prototype.getLatLongFromPixelFromView=function(point) { var pixelPoint=new SGeoTool().PixelToCoor(point, this.GetMapExtend(), this.mapPixelWidth, this.mapPixelHeight); return (pixelPoint); }; SMap.prototype.getPixelFromLatLong=function(LatLongPoint) { var resPoint=new SGeoTool().CoorToPixel(LatLongPoint, this.GetMapExtend(), this.mapPixelWidth, this.mapPixelHeight); return (resPoint); }; SMap.prototype.getPixelOnGrid=function(point) { var pixelPoint=new SGeoTool().CoorToPixel(point, this.GetGridExtend(), this.Grid.width, this.Grid.height); pixelPoint.X=pixelPoint.X+this.Grid.aTiles[0][0].left;    pixelPoint.Y=pixelPoint.Y+this.Grid.aTiles[0][0].top; return pixelPoint; }; SMap.prototype.click=function(gridPixelPoint) { SEvent.Trigger(this, "OnMapClick", this.getLatLongFromPixel(gridPixelPoint)); }; SMap.prototype.dblclick=function(pixelPoint) { SEvent.Trigger(this, "OnMapDoubleClick", this.getLatLongFromPixel(pixelPoint)); }; SMap.prototype.resize=function() { if (!this.isLoaded) { return; }  if (this.detectResize) { this.timerResize.stop(); this.timerResize.startTimeout(this, this.resized); } }; SMap.prototype.recalculate=function() { if (!this.isLoaded) { return; }  var Level=this.level; var center=this.GetCenter(); this.Grid.recalculateTileMeasurements(); this.mapPixelHeight=this.Grid.viewSize.height; this.mapPixelWidth=this.Grid.viewSize.width;  this.ZoomAndGoTo(center,Level); SEvent.Trigger(this, "OnMapResize"); if (this.mapPixelWidth < 256 || this.mapPixelHeight <256) { this.layerScaleBar.style.display="none"; }  else { this.layerScaleBar.style.display=""; } }; SMap.prototype.resized=function() { if (!this.isLoaded) { return; }  var Level=this.level; var center=this.GetCenter(); this.Grid.recalculateTileMeasurements(); this.mapPixelHeight=this.Grid.viewSize.height; this.mapPixelWidth=this.Grid.viewSize.width;  this.ZoomAndGoTo(center,Level); SEvent.Trigger(this, "OnMapResize"); if (this.mapPixelWidth < 256 || this.mapPixelHeight <256) { this.layerScaleBar.style.display="none"; }  else { this.layerScaleBar.style.display=""; }  }; SMap.prototype.detectWindowResize=function(flag) { this.detectResize=!flag?false:true; }; SMap.prototype.ZoomToBox=function(box, minLevel, maxLevel) { if (!this.isLoaded) { return; }  var bw=box.GetWidth()<=0?0.00000001:box.GetWidth(); var bh=box.GetHeight()<=0?0.00000001:box.GetHeight(); var zoomDone=false; if (box.Xmin&&box.Xmax&&box.Ymin&&box.Ymax&&bw>0&&bh>0) { try { var maxLevel=!maxLevel?19:maxLevel; var minLevel=!minLevel?1:minLevel; var mapExt=this.GetMapExtend(); var minMapSize=(this.mapPixelWidth > this.mapPixelHeight)?this.mapPixelHeight:this.mapPixelWidth; var maxBoxSize=(bw < bh)?bh:bw; var boxArea=Math.pow(maxBoxSize,2); var boxCenter=box.GetCenter(); for (i=maxLevel;i>minLevel-1; i--) { var imgS=(360/Math.pow(2, i-1))/minMapSize; var areaPixel=Math.pow(imgS,2); var areaMapa=Math.pow(minMapSize,2); var calc=( areaPixel * areaMapa); if (calc-boxArea >0) { var level=((i+1)>maxLevel)?i:(i+1); this.ZoomAndGoTo(boxCenter, level); zoomDone=true; break; } } if (!zoomDone&&minLevel) { this.ZoomAndGoTo(boxCenter, this.level+1); } } catch(e) { alert(e.description); }; } }; SMap.prototype.zoomwindow=function(box) { if (!this.isLoaded) { return; }  var min=this.getLatLongFromPixelFromView(new SGeoPoint(box.Xmin, box.Ymin)); var max=this.getLatLongFromPixelFromView(new SGeoPoint(box.Xmax, box.Ymax)); this.ZoomToBox(new SGeoBox(min.X, min.Y, max.X, max.Y), this.level); }; SMap.prototype.zoomwindowclick=function(point) { if (!this.isLoaded) { return; } var latlong=this.getLatLongFromPixelFromView(point); var nl=this.level+1>19?19:this.level+1; this.ZoomAndGoTo(latlong, nl); }; SMap.prototype.addMapType=function(mapType) { if (typeof(mapType.name)!="undefined" && mapType.name) { this.types[mapType.name]=mapType; SEvent.Trigger(this, "OnMapTypeAdded"); } }; SMap.prototype.removeMapType=function(mapType) { if (typeof(mapType.name)!="undefined" && mapType.name) { if (this.types[mapType.name]) { delete this.types[mapType.name]; SEvent.Trigger(this, "OnMapTypeRemoved", mapType.name); } } }; SMap.prototype.getMapTypes=function() { var r_types=new Array(); for (type in this.types) { r_types.push(this.types[type]); } return (r_types); }; SMap.prototype.setMapType=function(mapTypeName) { var change=false; if (mapTypeName&&this.types[mapTypeName]) { if (this.currentMapType) { if (this.currentMapType.getName() !=mapTypeName) { change=true; this.lastMapType=this.currentMapType; } } else { this.lastMapType=this.types[mapTypeName]; change=true;  } if (change) { this.currentMapType=this.types[mapTypeName]; if (this.isLoaded) { this.Grid.setMapType(this.currentMapType); this.Grid.getImage(); this.Grid.reconfigureImages(); SEvent.Trigger(this, "OnMapTypeChanged", this.currentMapType); } } } }; SMap.prototype.getCurrentMapType=function() { return (this.currentMapType); }; SMap.prototype.createSpecifications=function() { for (var i=0;i<this.mapSpecs.mapTypes.length; i++) { var mt=this.mapSpecs.mapTypes[i]; this.types[mt.name]=mt; } this.setMapType(S_VECTOR_MAP); this.zoomRange=this.mapSpecs.zoomRange; }; SMap.prototype.getState=function() { if (this.isLoaded) { var mapState=new Object(); map=this; mapState.toString=function() { var stringState=""; stringState +="basic="; stringState +="xmin|"+ this.extend.Xmin + "~1~"; stringState +="ymin|"+ this.extend.Ymin + "~1~"; stringState +="xmax|"+ this.extend.Xmax + "~1~"; stringState +="ymax|"+ this.extend.Ymax + "~1~"; stringState +="x|"+ this.center.X + "~1~"; stringState +="y|"+ this.center.Y + "~1~"; stringState +="w|"+ this.size.width + "~1~"; stringState +="h|"+ this.size.height + "~1~"; stringState +="z|"+ this.zoom + "~1~"; stringState +="map|"+ this.mapFile; if (mapState.icons.length>0) { stringState +="&overlays="; for (var i=0; i< mapState.icons.length; i++) { var icon=mapState.icons[i]; var pixelPoint=map.getPixelFromLatLong(icon.latLong); stringState +="x|"+ Math.floor(pixelPoint.X) + "~1~"; stringState +="y|"+ Math.floor(pixelPoint.Y) + "~1~"; stringState +="path|"+ icon.path + "~1~"; stringState +="w|"+ icon.size.width + "~1~"; stringState +="h|"+ icon.size.height + "~1~"; stringState +="align|"+ icon.align ; stringState +="~2~"; } } return stringState; }; var icon=new Object(); mapState.icons=new Array(); mapState.center=this.GetCenter(); mapState.extend=this.GetMapExtend(); mapState.size=new SSize(this.mapPixelWidth, this.mapPixelHeight); mapState.zoom=this.level; mapState.mapFile=this.currentMapType.getMapFile(); for(layer in this.iconLayers) { try{ { for (var i=0; i < this.iconLayers[layer].length; i++) { if (mapState.extend.Contains(this.iconLayers[layer][i].posLatLong)&&!this.iconLayers[layer][i].isOff) { var icon=new Object(); icon.path=this.iconLayers[layer][i].path; icon.latLong=this.iconLayers[layer][i].posLatLong; icon.size=this.iconLayers[layer][i].size; icon.align=this.iconLayers[layer][i].getAlign(); mapState.icons.push(icon); } } } } catch(e) { }    } return mapState; } return null; }; SMap.prototype.sendMail=function(from, to, subject, message, imageCopyright, imageName, imageType) { if (!this.isLoaded) { return }  var mapStatus=this.getState(); var params=mapStatus.toString(); params +="&";  params +="action=mail&"; params +="from="+from+"&"; params +="to="+to+"&"; params +="subject="+subject+"&"; params +="message="+message+"&"; if (imageName) { params +="imgname="+imageName+"&"; } if (imageType) { params +="imgtype="+imageType+"&"; } if (imageCopyright) { params +="imgcopyr="+imageCopyright+"&"; } var map=this; if (mapStatus) { var http=new SHttpRequest(); http.Open(SMAP_MAP_IMAGE_GENERATOR); http.Send(params, function(){ if (http.request.readyState==4) { SEvent.Trigger(map, "OnMapMailSended", "mail"); } });   return false; } }; SMap.prototype.getZip=function(frame, imageCopyright, imageName) { if (!this.isLoaded) { return }  var mapStatus=this.getState(); var params=mapStatus.toString(); var optionals=""; params +="&";  params +="action=compress"+ "&"; if (imageName) { optionals +="&imgname="+imageName+"&"; } if (imageCopyright) { params +="imgcopyr="+imageCopyright+"&"; } var map=this; if (mapStatus) { var http=new SHttpRequest(); http.Open(SMAP_MAP_IMAGE_GENERATOR); http.Send(params, function(){ if (http.request.readyState==4) { if (http.request.responseText!="") { frame.src=DOWNLOAD_ZIP_PATH+"?file="+http.request.responseText+"&"+new Date().getTime( ) + optionals; SEvent.Trigger(map, "OnMapZipDownloaded", "zip"); } } });   return false; } }; SMap.prototype.getInformationImage=function(imgObject, infoElement) { if (!this.isLoaded||!infoElement||typeof(infoElement)!="string") { return false; }  var mapState=new Object(); mapState.center=this.GetCenter(); mapState.extend=this.GetMapExtend(); mapState.size=new SSize(this.mapPixelWidth, this.mapPixelHeight); mapState.zoom=this.level; mapState.mapFile=this.currentMapType.getMapFile(); var params=""; params +="basic="; params +="xmin|"+ mapState.extend.Xmin + "~1~"; params +="ymin|"+ mapState.extend.Ymin + "~1~"; params +="xmax|"+ mapState.extend.Xmax + "~1~"; params +="ymax|"+ mapState.extend.Ymax + "~1~"; params +="x|"+ mapState.center.X + "~1~"; params +="y|"+ mapState.center.Y + "~1~"; params +="w|"+ mapState.size.width + "~1~"; params +="h|"+ mapState.size.height + "~1~"; params +="z|"+ mapState.zoom + "~1~"; params +="map|"+ mapState.mapFile; switch (infoElement.toUpperCase()) { case "LEGEND": params +="&action=legend"; break; case "SCALEBAR": params +="&action=scalebar"; break; default: return false;  } try { imgObject.src=SMAP_MAP_IMAGE_GENERATOR + "?" + params; } catch(e) { return false } return true; }; SMap.prototype.activateZoomRectangle=function() { if (!this.isLoaded) { return; }  this.Grid.activateZoomRectangle(); SEvent.Trigger(this, "OnZoomWindowActivated")  }; SMap.prototype.cancelZoomRectangle=function() { if (!this.isLoaded) { return; }   this.Grid.deactivateZoomRectangle();  SEvent.Trigger(this, "OnZoomWindowDeactivated")  }; SMap.prototype.StartDigitizer=function(withCloseButton) { if (!this.isLoaded) { return; }   if (typeof(this.SDigitizer)=="undefined"||!this.SDigitizer) { this.SDigitizer=new SDigitizer(this.mapLayerObj, this, withCloseButton); this.isDigitizing=true; SEvent.Trigger(this, "OnStartDigitizer"); this.DisableDrag(); this.DisableZoom(); this.DisableKeyboard(); this.DisableClick();   } if (this.SDigitizer) { this.digiListener2=SEvent.InternalBind(this.SDigitizer, "onClose", this, this.onCloseDigitizer); this.digiListener3=SEvent.InternalBind(this.SDigitizer, "onToolSelected", this, this.onToolSelected); this.digiListener4=SEvent.InternalBind(this.SDigitizer, "onGeometryComplete", this, this.onGeometryCompleted); } return this.SDigitizer;  }; SMap.prototype.ClearDigitizer=function() { if (!this.isLoaded||typeof(this.SDigitizer)=="undefined"||!this.SDigitizer) { return; }  this.SDigitizer.Clear(); }; SMap.prototype.EndDigitizer=function() { if (!this.isLoaded||typeof(this.SDigitizer)=="undefined"||!this.SDigitizer) { return; }  this.SDigitizer.Destroy(); this.SDigitizer=null; }; SMap.prototype.onCloseDigitizer=function() { this.isDigitizing=false; this.EnableDrag(); this.EnableZoom(); this.EnableKeyboard(); this.EnableClick();   SEvent.RemoveInternalListener(this.digiListener2); SEvent.RemoveInternalListener(this.digiListener3); SEvent.RemoveInternalListener(this.digiListener4); this.digiListener2=null; this.digiListener3=null; this.digiListener4=null; this.SDigitizer=null; SEvent.Trigger(this, "OnCloseDigitizer"); }; SMap.prototype.onToolSelected=function(tool) { SEvent.Trigger(this, "OnToolSelected", tool); }; SMap.prototype.onGeometryCompleted=function(geom) { geom.parse2Coordinates(this.GetMapExtend(), this.mapPixelWidth, this.mapPixelHeight); SEvent.Trigger(this, "OnGeometryEnded", geom); }; SMap.prototype.DisableDrag=function() { if (this.isLoaded) { this.Grid.dragDisabled=true; } }; SMap.prototype.DisableZoom=function() { if (this.isLoaded) { this.isZoomAbled=false; }  }; SMap.prototype.DisableKeyboard=function() { if (this.isLoaded) { this.Grid.keyboardDisabled=true; }  }; SMap.prototype.DisableClick=function() { if (this.isLoaded) { this.Grid.clickDisabled=true; }   }; SMap.prototype.EnableDrag=function() { if (this.isLoaded) { this.Grid.dragDisabled=false; }  }; SMap.prototype.EnableZoom=function() { if (this.isLoaded) { this.isZoomAbled=true; }  }; SMap.prototype.EnableKeyboard=function() { if (this.isLoaded) { this.Grid.keyboardDisabled=false; }   }; SMap.prototype.EnableClick=function() { if (this.isLoaded) { this.Grid.clickDisabled=false; }   }; SMap.prototype.GetDimension=function() { if (this.isLoaded) { return new SSize(this.mapPixelWidth, this.mapPixelHeight); }   }; 
SGeoPoint.prototype.borderColor="#FF0000"; SGeoPoint.prototype.fillColor="#FF5A00"; SGeoPoint.prototype.IdType=new SGeometryType().Point; SGeoPoint.prototype.Size=6; SGeoPoint.prototype.borderWidth=2; SGeoPoint.prototype.type="Punto"; SGeoPoint.prototype.ToWKT=function() { return "POINT("+this.X + " " + this.Y+")"; }; SGeoPoint.prototype.parse2Coordinates=function(extend, width, height) { var tool=new SGeoTool(); var p=tool.PixelToCoor(this, extend, width, height); this.X=p.X; this.Y=p.Y; }; SGeoPoint.prototype.MakeBuffer=function(radious) { return new SCircle(this, radious); }; SGeoPoint.prototype.Draw=function(wzLibrary) { this.Paint(wzLibrary); }; SGeoPoint.prototype.Paint=function(wzLibrary) { if (wzLibrary) { wzLibrary.setStroke(this.borderWidth); if (this.fillColor&&this.fillColor!="") { wzLibrary.setColor(this.fillColor); wzLibrary.fillRect(this.X-Math.floor(this.Size/2), this.Y-Math.floor(this.Size/2), this.Size, this.Size); wzLibrary.setColor(this.borderColor); wzLibrary.drawRect(this.X-Math.floor(this.Size/2), this.Y-Math.floor(this.Size/2), this.Size, this.Size); } else { wzLibrary.setColor(this.borderColor); wzLibrary.drawRect(this.X-(this.Size/2), this.Y-(this.Size/2), this.Size, this.Size); } wzLibrary.paint(); } }; function SGeometryType() { this.Polygon=1; this.Rectangle=2; this.Point=3; this.Line=4; this.Circle=5; this.PolyLine=6; }; function SRectangle(x, y, height, width) { this.x=typeof(x)!="number"?0:x; this.y=typeof(y)!="number"?0:y; this.height=typeof(height)!="number"?0:height; this.width=typeof(width)!="number"?0:width; this.type="Rectángulo"; this.IdType=new SGeometryType().Rectangle; return this; }; SRectangle.prototype.x=null; SRectangle.prototype.y=null; SRectangle.prototype.height=null; SRectangle.prototype.width=null; SRectangle.prototype.type=null; SRectangle.prototype.IdType=null; SRectangle.prototype.fillColor="#FFE900"; SRectangle.prototype.borderColor="#FF0000"; SRectangle.prototype.borderWidth=1; SRectangle.prototype.ToWKT=function() { var p1=new SGeoPoint(this.x, this.y); var p2=new SGeoPoint(this.x+this.width, this.y); var p3=new SGeoPoint(this.x+this.width, this.y-this.height); var p4=new SGeoPoint(this.x, this.y-this.height); var p5=new SGeoPoint(this.x, this.y); return "POLYGON(("+ p1.X + " " + p1.Y + ", "+ p2.X + " " + p2.Y + ", " + p3.X + " " + p3.Y + ", " + p4.X + " " + p4.Y + ", " + p5.X + " " + p5.Y +  "))"; }; SRectangle.prototype.parse2Coordinates=function(extend, width, height) { var tool=new SGeoTool(); var top_left_vertice=tool.PixelToCoor(new SGeoPoint(this.x, this.y), extend, width, height); var top_right_vertice=tool.PixelToCoor(new SGeoPoint(this.x+this.width, this.y), extend, width, height); var down_right_vertice=tool.PixelToCoor(new SGeoPoint(this.x+this.width, this.y+this.height), extend, width, height); var down_left_vertice=tool.PixelToCoor(new SGeoPoint(this.x, this.y+this.height), extend, width, height); this.x=top_left_vertice.X; this.y=top_left_vertice.Y; this.height=Math.abs(top_left_vertice.Y - down_left_vertice.Y); this.width=Math.abs(top_left_vertice.X - top_right_vertice.X); }; SRectangle.prototype.HandDraw=function(point1, point2, wzLibrary) { if (wzLibrary&&point1&&point2) { var w=0; var h=0; var x=0; var y=0; this.height=point2.Y-point1.Y; this.width=point2.X-point1.X; if (this.width>0 && this.height<0) { w=Math.abs(this.width); h=Math.abs(this.height); x=point1.X; y=point1.Y - h; } else if(this.width<0 && this.height<0) { w=Math.abs(this.width); h=Math.abs(this.height); x=point2.X; y=point2.Y; } else if(this.width<0 && this.height>0) { w=Math.abs(this.width); h=Math.abs(this.height); x=point2.X; y=point2.Y-h; } else if(this.width>0 && this.height>0) { w=Math.abs(this.width); h=Math.abs(this.height); x=point1.X; y=point1.Y; } this.height=typeof(h)!="number"?0:h; this.width=typeof(w)!="number"?0:w; this.x=typeof(x)!="number"?0:x; this.y=typeof(y)!="number"?0:y; this.Paint(wzLibrary); } }; SRectangle.prototype.Draw=function(wzLibrary) { if(wzLibrary) { this.Paint(wzLibrary); } }; SRectangle.prototype.EndDraw=function(wzLibrary) { if(wzLibrary) { this.Paint(wzLibrary); } }; SRectangle.prototype.ToString=function() { return this.GetBox().ToString(); }; SRectangle.prototype.Paint=function(wzLibrary) { if (wzLibrary) { wzLibrary.clear(); wzLibrary.setStroke(this.borderWidth); wzLibrary.setColor(this.borderColor); if (this.fillColor&&this.fillColor!="") { wzLibrary.setColor(this.fillColor); wzLibrary.fillRect(this.x, this.y, this.width, this.height); wzLibrary.setColor(this.borderColor); wzLibrary.drawRect(this.x, this.y, this.width, this.height); } else { wzLibrary.drawRect(this.x, this.y, this.width, this.height); } wzLibrary.paint(); } }; SRectangle.prototype.GetArea=function() { return (this.width*this.height); }; SRectangle.prototype.GetBox=function() { var xmin=this.x; var xmax=this.x + this.width; var ymin=this.y - this.height; var ymax=this.y; return (new SGeoBox(xmin,ymin,xmax,ymax)); }; SRectangle.prototype.RebuildFromBox=function(box) { this.x=box.Xmin; this.y=box.Ymin; this.width=box.Xmax - box.Xmin; this.height=box.Ymax - box.Ymin; }; function SLine(point1, point2) { if(point1&&point2) { this.X1=point1.X; this.Y1=point1.Y; this.X2=point2.X; this.Y2=point2.Y; } return this; }; SLine.prototype.X1=null; SLine.prototype.Y1=null; SLine.prototype.X2=null; SLine.prototype.Y2=null; SLine.prototype.fillColor=""; SLine.prototype.borderColor="#80FB13"; SLine.prototype.borderWidth=2; SLine.prototype.type="Línea"; SLine.prototype.IdType=new SGeometryType().Line; SLine.prototype.Slope=function() { if (this.X1==this.X2) { return Math.pow(10, 100); } else { return (this.Y2 - this.Y1) / (this.X2 - this.X1); } }; SLine.prototype.ToString=function() { var p1=new SGeoPoint(this.X1, this.Y1); var p2=new SGeoPoint(this.X2, this.Y2); return this.X1 + " " + this.Y1 + ", " + this.X2 + " " + this.Y2; }; SLine.prototype.ToWKT=function() { return "LINESTRING("+this.ToString()+")"; }; SLine.prototype.parse2Coordinates=function(extend, width, height) { var tool=new SGeoTool(); var p1=tool.PixelToCoor(new SGeoPoint(this.X1, this.Y1), extend, width, height); var p2=tool.PixelToCoor(new SGeoPoint(this.X2, this.Y2), extend, width, height); this.X1=p1.X; this.Y1=p1.Y; this.X2=p2.X; this.Y2=p2.Y; }; SLine.prototype.IntersectsWith=function(line) {   var m1=this.Slope();   var m2=line.Slope();   if ( m1==m2)   { return false;   } var b1=this.Intercept(); var b2=line.Intercept();   var nCommonX=( b2 - b1 ) / ( m1 - m2 );   var nCommonY=m2*nCommonX + b2;   if ( this.X1 !=this.X2 )   {     nCommonY=m1*nCommonX + b1;   }   return ( isBetween( nCommonX, this.X1, this.X2 ) &&            isBetween( nCommonX, line.X1, line.X2 ) &&            isBetween( nCommonY, this.Y1, this.Y2 ) &&            isBetween( nCommonY, line.Y1, line.Y2 )            ); }; SLine.prototype.Intercept=function() { var x=this.X1; var y=this.Y1; var m=this.Slope(); return (y-m*x); }; function isBetween(nValue, nPoint1, nPoint2) {   if ( nPoint1 < nPoint2 )   {     return ( nValue > nPoint1 && nValue < nPoint2 );   }   else   {     return ( nValue > nPoint2 && nValue < nPoint1 );   } }; SLine.prototype.GetLength=function() {   var measure=0;   var dist_x=this.X1 - this.X2;   var dist_y=this.Y1 - this.Y2;   var measure=Math.sqrt(dist_x * dist_x + dist_y * dist_y);   return measure; }; SLine.prototype.HandDraw=function(point1, point2 , wzLibrary) { if (wzLibrary&&point1&&point2) { this.X1=point1.X; this.Y1=point1.Y; this.X2=point2.X; this.Y2=point2.Y; this.Paint(wzLibrary); } }; SLine.prototype.Draw=function(point1, point2, wzLibrary) { if (point1&&point2&&wzLibrary) { this.HandDraw(point1, point2 , wzLibrary); } }; SLine.prototype.EndDraw=function(wzLibrary) { if (wzLibrary) { this.Paint(); } }; SLine.prototype.Paint=function(wzLibrary) { if (wzLibrary) { wzLibrary.setStroke(this.borderWidth); wzLibrary.setColor(this.borderColor); wzLibrary.clear(); wzLibrary.drawLine(this.X1, this.Y1, this.X2, this.Y2); wzLibrary.paint(); } }; SLine.prototype.GetBox=function() { var xmin=(this.X1 < this.X2) ? this.X1 : this.X2; var xmax=(this.X1 > this.X2) ? this.X1 : this.X2; var ymin=(this.Y1 > this.Y2) ? this.Y1 : this.Y2; var ymax=(this.Y1 < this.Y2) ? this.Y1 : this.Y2; return new SGeoBox(xmin, ymin, xmax, ymax); }; function SCircle(center, radio) { try { this.center=center; this.radious=radio; this.type="Círculo"; this.EndRadious=null; this.IdType=new SGeometryType().Circle; this.fillColor="#FFA200"; this.borderColor="#FFFFFF"; this.borderWidth=1; this.radiousMeters=null; return this; } catch(e) { return null; } }; SCircle.prototype.center=null; SCircle.prototype.radious=null; SCircle.prototype.type=null; SCircle.prototype.IdType=null; SCircle.prototype.fillColor=null; SCircle.prototype.borderColor=null; SCircle.prototype.borderWidth=null; SCircle.prototype.parsed=null; SCircle.prototype.parse2Coordinates=function(extend, width, height) { if (!this.parsed) { var tool=new SGeoTool(); this.center=tool.PixelToCoor(this.center, extend, width, height); if (!this.radiousMeters) { var pEndRadious=tool.PixelToCoor(this.EndRadious, extend, width, height); } else { var pEndRadious=new SGeoPoint(this.center.X+this.radiousMeters, this.center.Y+this.radiousMeters); } this.radious=this.center.GetPointsDistance(pEndRadious); } }; SCircle.prototype.DrawFromRadiousInMeters=function(center, value, extend, width, height, wzLibrary) { if (!value) { return false; } var myRegExp=new RegExp(/^\d*$|^\d*\.\d{1,}$/); if (!myRegExp.test(value)) { return "El valor del radio debe ser num&eacute;rico"; } var value=parseFloat(value); if (value==0) { return "El valor de radio no puede ser 0 (cero)"; } if (isNaN(value)) { return "El valor del radio debe ser num&eacute;rico"; } var tool=new SGeoTool(); this.center=center; var centerInCoordinates=tool.PixelToCoor(center, extend, width, height); var radiousInGrades=(value/111000); var p2InCoordinates=new SGeoPoint(centerInCoordinates.X+radiousInGrades, centerInCoordinates.Y); var p2InPixel=tool.CoorToPixel(p2InCoordinates,extend,width,height); var radiousInPixel=this.center.GetPointsDistance(p2InPixel); this.radious=radiousInPixel; if (this.radious>400) { this.radious=0; return "No puede dibujar un círculo tan grande a este nivel. Si es posible, aléjese un poco más en el mapa para dibujar este circulo"; } this.Draw(wzLibrary); this.center=centerInCoordinates; this.radious=radiousInGrades; this.parsed=true; return null; }; SCircle.prototype.HandDraw=function(point1, point2, wzLibrary) { if (wzLibrary&&point1&&point2) { wzLibrary.clear(); wzLibrary.setStroke(2); wzLibrary.setColor("#FFFFFF"); this.center=point1; this.radious=parseInt(this.center.GetPointsDistance(point2)); var cbox=this.GetBox(); cbox.Xmin=parseInt(cbox.Xmin); cbox.Xmax=parseInt(cbox.Xmax); cbox.Ymin=parseInt(cbox.Ymin); cbox.Ymax=parseInt(cbox.Ymax); wzLibrary.drawLine(this.center.X-10, this.center.Y, this.center.X+10, this.center.Y); wzLibrary.drawLine(this.center.X, this.center.Y-10, this.center.X, this.center.Y+10); var guideLineSize=50; wzLibrary.drawLine(this.center.X-(guideLineSize/2), cbox.Ymin, this.center.X+(guideLineSize/2), cbox.Ymin); wzLibrary.drawLine(this.center.X-(guideLineSize/2), cbox.Ymax, this.center.X+(guideLineSize/2), cbox.Ymax); wzLibrary.drawLine(cbox.Xmin, this.center.Y-(guideLineSize/2), cbox.Xmin, this.center.Y+(guideLineSize/2)); wzLibrary.drawLine(cbox.Xmax, this.center.Y-(guideLineSize/2), cbox.Xmax, this.center.Y+(guideLineSize/2)); this.center.Paint(wzLibrary); wzLibrary.paint(); } }; SCircle.prototype.Draw=function(wzLibrary) { this.Paint(wzLibrary); }; SCircle.prototype.EndDraw=function(wzLibrary) { this.Paint(wzLibrary); }; SCircle.prototype.Paint=function(wzLibrary) { if (wzLibrary) { wzLibrary.clear(); wzLibrary.setStroke(this.borderWidth); var cBox=this.GetBox(); cBox.Xmin=parseInt(cBox.Xmin); cBox.Ymin=parseInt(cBox.Ymin); cBox.Xmax=parseInt(cBox.Xmax); cBox.Ymax=parseInt(cBox.Ymax); if (this.fillColor&&this.fillColor!="") { wzLibrary.setColor(this.fillColor); wzLibrary.fillEllipse(cBox.Xmin, cBox.Ymax, (this.radious*2), (this.radious*2)); wzLibrary.setColor(this.borderColor); wzLibrary.drawEllipse(cBox.Xmin, cBox.Ymax, (this.radious*2), (this.radious*2)); } else { wzLibrary.setColor(this.borderColor); wzLibrary.drawEllipse(cBox.Xmin, cBox.Ymax, (this.radious*2), (this.radious*2)); } wzLibrary.paint(); } }; SCircle.prototype.GetBox=function() { var xmin=this.center.X - Math.abs(this.radious); var xmax=this.center.X + Math.abs(this.radious); var ymin=this.center.Y + Math.abs(this.radious); var ymax=this.center.Y - Math.abs(this.radious); return (new SGeoBox(xmin,ymin,xmax,ymax)); }; SCircle.prototype.GetArea=function() { var area=Math.PI * (this.radious*this.radious); return area; }; function SPolyLine() { this.Points=new Array(); this.type="Multilinea"; this.IdType=new SGeometryType().PolyLine; this.borderColor="#FF1200"; this.borderWidth=2; return this; }; SPolyLine.prototype.Points=null; SPolyLine.prototype.type=null; SPolyLine.prototype.IdType=null; SPolyLine.prototype.borderColor=null; SPolyLine.prototype.borderWidth=null; SPolyLine.prototype.ToString=function() { var retVal=""; for (i=0;i<this.Points.length;i++) { retVal+=this.Points[i].X + " " + this.Points[i].Y + ", "; } retVal=retVal.substr(0, retVal.length -2); return retVal; }; SPolyLine.prototype.ToWKT=function() { return "LINESTRING("+this.ToString()+")"; }; SPolyLine.prototype.parse2Coordinates=function(extend, width, height) { var tool=new SGeoTool(); for (i=0; i<this.Points.length;i++) { var xp=tool.PixelToCoor(this.Points[i], extend, width, height); this.Points[i].X=xp.X; this.Points[i].Y=xp.Y; } }; SPolyLine.prototype.GetLength=function() {   var measure=0;   for (var i=0; i<this.Points.length - 1; i++)   {     var dist_x=this.Points[i].X - this.Points[i+1].X;      var dist_y=this.Points[i].Y - this.Points[i+1].Y;      measure +=Math.sqrt(dist_x * dist_x + dist_y * dist_y);   }   return measure; }; SPolyLine.prototype.GetBox=function() {   var xmin=this.Points[0].X;   var xmax=this.Points[0].X;   var ymin=this.Points[0].Y;   var ymax=this.Points[0].Y;   for (var i=1; i < this.Points.length; i++)   {     xmin=(this.Points[i].X < xmin) ? this.Points[i].X : xmin;     xmax=(this.Points[i].X > xmax) ? this.Points[i].X : xmax;     ymin=(this.Points[i].Y < ymin) ? this.Points[i].Y : ymin;     ymax=(this.Points[i].Y > ymax) ? this.Points[i].Y : ymax;   }   return (new SGeoBox(xmin, ymin, xmax, ymax)); }; SPolyLine.prototype.HandDraw=function(point, wzLibrary) { if (wzLibrary&&point) { this.AddPoint(point); var lastLine=this.getLastSegment(); if (lastLine) { wzLibrary.setStroke(this.borderWidth); wzLibrary.setColor(this.borderColor); wzLibrary.drawLine(lastLine.X1, lastLine.Y1, lastLine.X2, lastLine.Y2); wzLibrary.paint(); } } }; SPolyLine.prototype.Draw=function(xPoints, yPoints, wzLibrary) { var xp=new Array(); var yp=new Array(); if (!xPoints||!yPoints) { for (i=0;i<this.Points.length;i++) { xp.push(this.Points[i].X); yp.push(this.Points[i].Y); } } else { xPoints=xp; yPoints=yp; } this.Paint(xPoints, yPoints, wzLibrary); }; SPolyLine.prototype.EndDraw=function() { }; SPolyLine.prototype.Paint=function(xPoints, yPoints, wzLibrary) { if (wzLibrary&&xPoints.length>0&&yPoints.length>0) { wzLibrary.clear(); wzLibrary.setStroke(this.borderWidth); wzLibrary.setColor(this.borderColor); wzLibrary.drawPolyline(xPoints, yPoints); wzLibrary.paint(); } }; SPolyLine.prototype.length=function() { return (this.Points.length); }; SPolyLine.prototype.AddPoint=function(point) { if (this.Points.length>0&&point.Equal(this.Points[this.Points.length-1])) { return null; } else { this.Points.push(point); return point; } }; SPolyLine.prototype.RemoveLastPoint=function() { if (this.Points.length>0) { this.Points.pop(); } }; SPolyLine.prototype.getLastSegment=function() { if (this.Points.length > 1) { var point1=new SGeoPoint(this.Points[this.Points.length-2].X, this.Points[this.Points.length-2].Y); var point2=new SGeoPoint(this.Points[this.Points.length-1].X, this.Points[this.Points.length-1].Y); return (new SLine(point1, point2)); } else { return null; } }; function SPolygon() { this.Points=new Array(); this.xPoints=new Array(); this.yPoints=new Array(); this.type="Polígono"; this.IdType=new SGeometryType().Polygon; this.ShowVertices=true; return this; }; SPolygon.prototype.borderWidth=1; SPolygon.prototype.borderColor="#FF0000"; SPolygon.prototype.fillColor="#FFE900"; SPolygon.prototype.AddPoint=function(point) { if (this.Points.length>0&&point.Equal(this.Points[this.Points.length-1])) { return null; } else { if (this.CheckIntersections(point)) { this.Points.push(point); this.xPoints.push(point.X); this.yPoints.push(point.Y); return point; } else { return null; } } }; SPolygon.prototype.parse2Coordinates=function(extend, width, height) { var tool=new SGeoTool(); for (i=0; i<this.Points.length-1;i++) { var xp=tool.PixelToCoor(this.Points[i], extend, width, height); this.Points[i].X=xp.X; this.Points[i].Y=xp.Y; } }; SPolygon.prototype.CheckIntersections=function(newPoint) { if (this.Points.length>1) { var newLine=new SLine(this.Points[this.Points.length-1], newPoint); var isok=true; for (i=this.Points.length; i>=0;i--) { var line=this.GetLineNumber(i-1); if (line&&newLine.IntersectsWith(line)) { isok=false; break; } } return isok; } else { return true; } }; SPolygon.prototype.GetLineNumber=function(index) { if (this.Points.length>=2&&index>=0&&index<=this.Points.length-2) { var p1=this.Points[index]; var p2=this.Points[index+1]; return (new SLine(p1, p2)); } else { return null; } }; SPolygon.prototype.ToString=function() { var retVal=""; for (i=0;i<this.Points.length;i++) { retVal+=this.Points[i].X + " " + this.Points[i].Y + ", "; } retVal=retVal.substr(0, retVal.length-2); return retVal; }; SPolygon.prototype.ToWKT=function() { return "POLYGON(("+this.ToString()+"))"; }; SPolygon.prototype.RemoveLastPoint=function() { if (this.Points.length>0) { this.Points.pop(); } }; SPolygon.prototype.getLastSegment=function() { if (this.Points.length > 1) { var point1=new SGeoPoint(this.Points[this.Points.length-2].X, this.Points[this.Points.length-2].Y); var point2=new SGeoPoint(this.Points[this.Points.length-1].X, this.Points[this.Points.length-1].Y); return (new SLine(point1, point2)); } else { return null; } }; SPolygon.prototype.Close=function(flag, wzLibrary) { if (this.Points.length<3) { return null; } else { if (this.CheckIntersections(this.Points[0])) { var point2=new SGeoPoint(this.Points[this.Points.length-1].X, this.Points[this.Points.length-1].Y); var point1=this.AddPoint(this.Points[0]); var lastLine=new SLine(point1, point2); if (flag&&wzLibrary&&lastLine) { this.DrawLine(lastLine, wzLibrary); wzLibrary.setStroke(this.borderWidth); if (this.fillColor&&this.fillColor!="") { wzLibrary.clear(); wzLibrary.setColor(this.fillColor); wzLibrary.fillPolygon(this.xPoints, this.yPoints); wzLibrary.setColor(this.borderColor); wzLibrary.drawPolyline(this.xPoints, this.yPoints); wzLibrary.paint(); } } return this.Points[0]; } else { return null; } } }; SPolygon.prototype.IsClosed=function () { return (this.Points.length>2 && this.Points[0].X==this.Points[this.Points.length-1].X && this.Points[0].Y==this.Points[this.Points.length-1].Y ); }; SPolygon.prototype.GetArea=function() {   if (this.Points.length > 2)   {     var measure=0;      for (var i=0; i<this.Points.length - 1;i++)      {        measure +=this.Points[i].X * this.Points[i+1].Y - this.Points[i+1].X * this.Points[i].Y;      }      measure +=this.Points[this.Points.length -1].X * this.Points[0].Y - this.Points[0].X * this.Points[this.Points.length -1].Y;      return Math.abs(measure) / 2;   }   else   {     return 0;   } }; SPolygon.prototype.GetBox=function() { var xmin=this.Points[0].X; var xmax=this.Points[0].X; var ymin=this.Points[0].Y; var ymax=this.Points[0].Y; for (var i=1; i < this.Points.length; i++) {     xmin=(this.Points[i].X < xmin) ? this.Points[i].X : xmin;      xmax=(this.Points[i].X > xmax) ? this.Points[i].X : xmax;      ymin=(this.Points[i].Y < ymin) ? this.Points[i].Y : ymin;      ymax=(this.Points[i].Y > ymax) ? this.Points[i].Y : ymax;    }    return new SGeoBox(xmin, ymin, xmax, ymax); }; SPolygon.prototype.HandDraw=function(point, wzLibrary) { var retVal=true; if (wzLibrary&&point) { var vertice=this.AddPoint(point); if (!vertice) { retVal=false; } if (vertice&&this.ShowVertices) { vertice.Draw(wzLibrary); } var lastLine=this.getLastSegment(); if (lastLine) { wzLibrary.setStroke(this.borderWidth); wzLibrary.setColor(this.borderColor); this.DrawLine(lastLine, wzLibrary); } } return retVal; }; SPolygon.prototype.DrawLine=function(line, wzLibrary) { wzLibrary.drawLine(line.X1, line.Y1, line.X2, line.Y2); wzLibrary.paint(); }; SPolygon.prototype.Draw=function(xPoints, yPoints, wzLibrary) { var xp=new Array(); var yp=new Array(); if (!xPoints||!yPoints) { for (i=0;i<this.Points.length;i++) { xp.push(this.Points[i].X); yp.push(this.Points[i].Y); } } else { xPoints=xp; yPoints=yp; } this.Paint(xPoints, yPoints, wzLibrary); }; SPolygon.prototype.Paint=function(xPoints, yPoints, wzLibrary) { if (wzLibrary&&xPoints.length>0&&yPoints.length>0) { wzLibrary.clear(); wzLibrary.setStroke(this.borderWidth); wzLibrary.setColor(this.borderColor); wzLibrary.drawPolygon(xPoints, yPoints); wzLibrary.paint(); } }; function SDigitizer(container, map, withCloseButton) { this.isDrawing=false; this.mouseDown=false; this.posOnMouseDown=null; this.posOnMouseUp=null; this.messagesLayer=null; this.withClosebutton=!withCloseButton?false:true; if (map) { this.map=map; } if (container.id) { this.container=container.id; this.oLayer=container; } else { this.container=container; this.oLayer=document.getElementById(container); } this.Polygon=null; this.Circle=null; this.Line=null; this.Point=null; this.CaptureEntry=new SCaptureEntry(this.oLayer); if (this.container) { var BackLayer=this.CreateLayer(container,this.container+"digi",this.oLayer.offsetWidth, this.oLayer.offsetHeight,39,new SGeoPoint(0,0),"","","visible"); var MediumLayer=this.CreateLayer(container,this.container+"digiMediumLayer",this.oLayer.offsetWidth, this.oLayer.offsetHeight,40,new SGeoPoint(0,0),"","","visible"); var TopLayer=this.CreateLayer(container,this.container+"Internal",this.oLayer.offsetWidth, this.oLayer.offsetHeight,41,new SGeoPoint(0,0),"","","visible"); var ml=this.CreateLayer(container,TopLayer.id+"messages",this.oLayer.offsetWidth, 35,38,new SGeoPoint(0,this.oLayer.offsetHeight-35),"#FFFFFF","","visible"); if (this.withClosebutton) { var btnClose=this.CreateButton(container,this.container+"btnCerrar", 130, 25,new SGeoPoint(20,this.oLayer.offsetHeight-70), "Cerrar Digitalizador", "#FFFFFF"); this.closeBtnCon=SEvent.attachDOM(btnClose, "click", this.confirmOut,  this); } if (BackLayer.filters) { BackLayer.style.filter="progid:DXImageTransform.Microsoft.Slide(duration=1, bands='1'); alpha(opacity=20)"; BackLayer.filters[0].Apply(); BackLayer.style.backgroundColor="#A4A7AF"; BackLayer.filters[0].Play(duration=1); } else if(ns6) { BackLayer.style.backgroundColor="#A4A7AF"; BackLayer.style.MozOpacity="0.2"; } else { } this.oLayer=TopLayer; this.backLayer=BackLayer; this.MediumLayer=MediumLayer; this.MessagesLayer=ml; if (this.withClosebutton) { this.CloseButton=btnClose; ChangeOpacity(this.CloseButton, 80); }  ChangeOpacity(ml, 60); ml.style.fontFamily="verdana"; ml.style.fontSize="11px"; ml.style.color="#FFFFFF"; ml.style.backgroundColor="#001E6F"; ml.style.fontWeight="normal"; ml.style.padding="4px;"; this.messagesLayer=ml; this.ShowMessage("Iniciado"); BackLayer=null; MediumLayer=null; TopLayer=null; ml=null; btnClose=null; } this.oLayer.unselectable=true; this.mousedownBinded=SEvent.InternalBind(this.CaptureEntry, "onmousedown", this, this.viewport_MouseDown); this.mupBinded=SEvent.InternalBind(this.CaptureEntry, "onmouseup", this, this.viewport_MouseUp); this.mmoveBinded=SEvent.InternalBind(this.CaptureEntry, "onmousemove", this, this.viewport_Mousemove); this.mdblclickBinded=SEvent.InternalBind(this.CaptureEntry, "onmousedblclick", this, this.viewport_MouseDblclick); this.draw=new jsGraphics(this.MediumLayer.id); this.draw.setStroke(0); SEvent.InternalTrigger(this, "onStart"); return this; }; SDigitizer.prototype.confirmOut=function(e) { if (confirm("¿Est&aacute; seguro que desea cerrar el digitalizador?")) { this.Destroy(); } }; SDigitizer.prototype.geometryType=null; SDigitizer.prototype.isDrawing=false; SDigitizer.prototype.mouseDown=false; SDigitizer.prototype.posOnMouseDown=null; SDigitizer.prototype.posOnMouseUp=null; SDigitizer.prototype.container=null; SDigitizer.prototype.oLayer=null; SDigitizer.prototype.Polygon=null; SDigitizer.prototype.Circle=null; SDigitizer.prototype.Line=null; SDigitizer.prototype.Point=null; SDigitizer.prototype.LastGeometry=null; SDigitizer.prototype.Destroy=function() { try { var node=document.getElementById(this.container); if (this.withClosebutton) { node.removeChild(this.CloseButton); } node.removeChild(this.backLayer); SEvent.RemoveInternalListener(this.mousedownBinded); SEvent.RemoveInternalListener(this.mupBinded); SEvent.RemoveInternalListener(this.mmoveBinded); SEvent.RemoveInternalListener(this.mdblclickBinded); node.removeChild(this.oLayer); node.removeChild(this.MediumLayer); node.removeChild(this.MessagesLayer); this.CloseButton=null; this.backLayer=null; this.oLayer=null; this.MediumLayer=null; this.MessagesLayer=null; SEvent.InternalTrigger(this, "onClose"); } catch(e) { }   }; SDigitizer.prototype.ShowMessage=function(str) { this.messagesLayer.innerHTML=str; }; SDigitizer.prototype.CreateButton=function(container, id, width, height, origen, text, backcolor) { var btn=document.createElement('INPUT'); btn.id=id; btn.value=text; btn.type="button"; btn.style.backgroundColor="#FFFFFF"; btn.style.fontFamily="verdana"; btn.style.fontSize="10px"; btn.style.backgroundColor=backcolor; btn.style.fontWeight="normal"; btn.style.border="1px solid gray"; btn.style.position='absolute'; btn.style.left=(origen.X+"px"); btn.style.top=(origen.Y+"px"); btn.style.width=(width+"px"); btn.style.height=(height+"px"); btn.style.zIndex="100"; btn.style.visibility="visible"; btn.objParent=this; container.appendChild(btn); return btn; }; SDigitizer.prototype.CreateLayer=function (baselayer,id,width,height,prioridad,origen,color,bordercolor,visibility) { var oDiv=document.createElement('div'); oDiv.id=id; oDiv.style.backgroundColor=color; oDiv.style.position='absolute'; oDiv.style.left=(origen.X+"px"); oDiv.style.top=(origen.Y+"px"); oDiv.style.width=(width+"px"); oDiv.style.height=(height+"px"); oDiv.style.zIndex=prioridad; oDiv.unselectable="on"; oDiv.style.MozUserFocus="none"; oDiv.style.MozUserSelect="none"; oDiv.style.visibility=visibility; baselayer.appendChild(oDiv); return oDiv; }; SDigitizer.prototype.SetTool=function(geometryType, id) { if (geometryType&&typeof(geometryType)!="undefined") { this.geometryType=geometryType; this.isDrawing=true; this.oLayer.objParent=this; this.draw.clear(); SwitchCursor(this.oLayer, "crosshair"); SEvent.InternalTrigger(this, "OnToolSelected", geometryType); var xG=new SGeometryType(); switch(this.geometryType) { case xG.Polygon: this.ShowMessage("Herramienta de pol&iacute;gono: <b>Haga click</b> con el bot&oacute;n izquierdo del rat&oacute;n para crear los v&eacute;rtices y <b>doble click</b> para cerrar y finalizar el pol&iacute;gono"); this.Polygon=null; break; case xG.Circle: this.ShowMessage("Herramienta de c&iacute;rculo: <b>Presione el bot&oacute;n izquierdo del rat&oacute;n y arrastre</b> hasta cubrir el &aacute;rea deseada con las l&iacute;neas gu&iacute;as. Para finalizar suelte el bot&oacute;n del rat&oacute;n."); this.Circle=null; break; case xG.Rectangle: this.ShowMessage("Herramienta de rect&aacute;ngulo:  <b>Presione el bot&oacute;n izquierdo del rat&oacute;n y arrastre</b> hasta cubrir el &aacute;rea deseada, entonces suelte el bot&oacute;n del rat&oacute;n."); this.Rectangle=null; break; case xG.Line: this.ShowMessage("Herramienta de l&iacute;nea: <b>Presione el bot&oacute;n izquierdo del rat&oacute;n y arrastre</b> hata el punto deseado, entonces suelte el bot&oacute;n del rat&oacute;n."); this.Line=null; break; case xG.Point: this.ShowMessage("Herramienta de puntos:  Haga <b>click</b> con el bot&oacute;n izquierdo del rat&oacute;n en el &aacute;rea donde desea colocar el punto."); this.Point=null; break; case xG.PolyLine: this.ShowMessage("Herramienta de l&iacute;nea continua:  <b>Haga click</b> con el bot&oacute;n izquierdo del rat&oacute;n para crear los v&eacute;rtices y <b>doble click</b> para finalizar la l&iacute;nea"); this.PolyLine=null; break; default: this.ShowMessage("Herramienta no conocida."); } this.Attribute=id; ChangeOpacity(this.MediumLayer, 100); SEvent.InternalTrigger(this, "onToolSelected", this.geometryType); } }; SDigitizer.prototype.Clear=function() { ChangeOpacity(this.MediumLayer, 100); this.draw.clear(); var lastSelected=this.geometryType; SwitchCursor(this.oLayer, "crosshair"); this.Reset(); this.ShowMessage("El Digitalizador ha sido reiniciado."); this.SetTool(lastSelected); }; SDigitizer.prototype.Reset=function() { SwitchCursor(this.oLayer, "default"); this.Polygon=null; this.Circle=null; this.Rectangle=null; this.Line=null; this.Point=null; this.PolyLine=null; this.posOnMouseUp=null; this.posOnMouseDown=null; this.isDrawing=false; this.geometryType=null; this.oLayer.objParent=null; }; SDigitizer.prototype.viewport_MouseDown=function(e) { if (this.isDrawing) { this.mouseDown=true; this.posOnMouseDown=this.getMousePosition(e); } }; SDigitizer.prototype.viewport_MouseUp=function(e) { if (this.isDrawing) { this.posOnMouseUp=this.getMousePosition(e); if (this.posOnMouseDown.GetPointsDistance(this.posOnMouseUp)<2) { this.viewport_MouseClick(e); return } this.mouseDown=false; var xG=new SGeometryType(); switch(this.geometryType) { case xG.Polygon: break; case xG.Circle: if (this.Circle&&this.Circle.radious&&this.Circle.radious!=0) { this.Circle.EndRadious=this.posOnMouseUp; this.Circle.EndDraw(this.draw); this.GeometryEnded(this.Circle); } break; case xG.Rectangle: if (this.Rectangle) { this.Rectangle.EndDraw(this.draw); this.GeometryEnded(this.Rectangle); } break; case xG.Line: if(this.Line) { this.Line.EndDraw(this.draw); this.GeometryEnded(this.Line); } break; } } }; SDigitizer.prototype.viewport_MouseClick=function(e) { if (this.isDrawing) { var xG=new SGeometryType(); switch(this.geometryType) { case xG.Polygon: if(!this.Polygon) { this.Polygon=new SPolygon(); } var isOk=this.Polygon.HandDraw(this.posOnMouseUp, this.draw); if(!isOk) { this.ShowMessage("Con el v&eacute;rtice que intenta colocar creaar&iacute;a un pol&iacute;gono inv&aacute;lido"); } else { this.ShowMessage("Dibujando pol&iacute;gono"); } break; case xG.Circle: if (this.posOnMouseDown&&this.posOnMouseDown.Equal(this.posOnMouseUp)&&this.map) { var currPos=this.getMousePosition(e); this.Circle=new SCircle(new SGeoPoint(0,0), 0); this.Circle.HandDraw(currPos, currPos, this.draw); currPos.Paint(this.draw); var radio=prompt("Introduzca el radio del círculo en metros:", 20); this.Circle.center=currPos; this.Circle.radious=radio; var retVal=this.Circle.DrawFromRadiousInMeters(this.getMousePosition(e), radio, this.map.GetMapExtend(), this.map.mapPixelWidth, this.map.mapPixelHeight, this.draw); if (retVal==null) { this.GeometryEnded(this.Circle); } else { if(retVal) { alert(retVal);  this.draw.clear(); this.SetTool(this.geometryType); } else { this.Circle.radious=0; this.draw.clear(); } } } break; case xG.Point: this.draw.clear(); this.Point=this.posOnMouseUp; this.Point.Draw(this.draw); this.GeometryEnded(this.Point); break; case xG.PolyLine: if(!this.PolyLine) { this.PolyLine=new SPolyLine(); } this.PolyLine.HandDraw(this.posOnMouseUp, this.draw); break; case xG.Rectangle: break; case xG.Line: break; } } }; SDigitizer.prototype.GeometryEnded=function(geom) { if (geom) { geom.Attribute=this.Attribute; this.LastGeometry=geom; ChangeOpacity(this.MediumLayer, 60); this.Polygon=null; this.Circle=null; this.Rectangle=null; this.Line=null; this.Point=null; this.PolyLine=null; SEvent.InternalTrigger(this, "onGeometryComplete", geom); } }; SDigitizer.prototype.viewport_MouseDblclick=function(e) { var xG=new SGeometryType(); if (this.isDrawing) { this.ShowMessage("Intentando finalizar la geometr&iacute;"); switch(this.geometryType) { case xG.Polygon: if (this.Polygon.Close(true, this.draw)) { this.GeometryEnded(this.Polygon); } else { this.ShowMessage("Con el v&eacute;rtice que intenta colocar creaar&iacute;a un pol&iacute;gono inv&aacute;lido"); } break; case xG.PolyLine: if (this.PolyLine) { this.GeometryEnded(this.PolyLine); } break; } } }; SDigitizer.prototype.viewport_Mousemove=function(e) { if (this.isDrawing&&this.mouseDown) { var xG=new SGeometryType(); switch(this.geometryType) { case xG.Circle: if (!this.Circle) { this.Circle=new SCircle(null, 0); } this.Circle.HandDraw(this.posOnMouseDown, this.getMousePosition(e), this.draw); break; case xG.Rectangle: if (!this.Rectangle) { this.Rectangle=new SRectangle(0,0,0,0); } this.Rectangle.HandDraw(this.posOnMouseDown, this.getMousePosition(e), this.draw); ChangeOpacity(this.MediumLayer, 40); break; case xG.Line: if(!this.Line) { this.Line=new SLine(); } this.Line.HandDraw(this.posOnMouseDown, this.getMousePosition(e), this.draw); break; case xG.Point: break; } } }; SDigitizer.prototype.getMousePosition=function(e) { if (e.target&&e.target.objParent) { var x=e.layerX; var y=e.layerY; } else if(e.target&&!e.target.objParent) { var x=e.target.offsetLeft + (e.target.clientWidth - (e.target.clientWidth - e.layerX)+1); var y=e.target.offsetTop + (e.target.clientHeight - (e.target.clientHeight - e.layerY)+1); } else if(e.srcElement&&e.srcElement.objParent) { var x=e.offsetX; var y=e.offsetY; } else if(e.srcElement&&!e.srcElement.objParent) { var x=e.srcElement.offsetLeft + e.offsetX; var y=e.srcElement.offsetTop + e.offsetY; } return (new SGeoPoint(x, y)); }; 
function SLabel(text, size, opacity) { this.width=0; this.height=0; this.left=0; this.top=0; this.width=0; this.height=0; this.left=0; this.top=0; this.retVal=0; this.fontColor=""; this.backColor=""; this.fontFamily=""; this.fontSize=""; this.handlerOkClick=null; this.handlerCancelClick=null; this.createInterface(); this.applyStyles(); this.setBackColor("#FFFFFF"); this.setFontColor("#000000"); this.setFont("Verdana, Arial, Helvetica, sans-serif", 9); this.opacity=opacity; this.align="left"; if (size) { this.setSize(size.width, size.height); } else { this.setSize(0, 0); } if (text) { this.setText(text); } }; SLabel.prototype.createInterface=function() { this.htmlElement=this.createDIV(new SSize(330, 300), "pixel", 0, 0, null, null, "pixel"); this.setOpacity(this.opacity); this.textContainer=this.createDIV(new SSize(95, 80), "percent", 3, 2, null, null, "percent"); this.htmlElement.appendChild(this.textContainer); }; SLabel.prototype.appendTo=function(container) { if (typeof(container)!="object") { return } this.container=container; if (this.htmlElement) { this.container.appendChild(this.htmlElement); } }; SLabel.prototype.applyStyles=function() { with(this.textContainer) { style.padding="1px"; style.overflow="hidden"; } with(this.htmlElement) { style.border="1px solid gray"; style.zIndex="99"; style.overflow="hidden"; } }; SLabel.prototype.setSize=function(width, height) { width=Math.floor(width); height=Math.floor(height); if (this.width!=width&&this.height!=height) { this.htmlElement.style.display="none"; this.width=width; this.height=height;    this.htmlElement.style.width=toPixel(this.width); this.htmlElement.style.height=toPixel(this.height); this.htmlElement.style.display=""; } }; SLabel.prototype.moveTo=function(left, top) { left=Math.floor(left); top=Math.floor(top); this.left=left; this.top=top;    this.htmlElement.style.left=toPixel(this.left); this.htmlElement.style.top=toPixel(this.top); }; SLabel.prototype.center=function() { var x=(this.container.clientWidth/2)-(this.width/2); var y=(this.container.clientHeight/2)-(this.height/2);   this.moveTo(x, y); }; SLabel.prototype.setBackColor=function(color) { if (this.backColor!=color) { this.backColor=color; this.htmlElement.style.backgroundColor=this.backColor; } }; SLabel.prototype.setFontColor=function(color) { if (this.fontColor!=color) { this.fontColor=color; this.htmlElement.style.color=this.fontColor; } }; SLabel.prototype.setFont=function(fontFamily, fontSize, fontWeight) { fontSize=Math.floor(fontSize); this.fontFamily=fontFamily; this.fontSize=fontSize; this.htmlElement.style.fontFamily=this.fontFamily; this.htmlElement.style.fontSize=toPixel(this.fontSize); if (fontWeight) { this.htmlElement.style.fontWeight=fontWeight; } }; SLabel.prototype.setText=function(text) { if (this.text!=text) { this.text=text; this.textContainer.innerHTML=""; this.textContainer.innerHTML=text; } }; SLabel.prototype.createDIV=function (size, sizeUnit,  top, left, bottom, right, posUnit) { var oDiv=document.createElement('div'); oDiv.style.position='absolute'; switch(sizeUnit) { case "pixel": oDiv.style.width=toPixel(size.width); oDiv.style.height=toPixel(size.height); break; default: oDiv.style.width=toPercent(size.width); oDiv.style.height=toPercent(size.height); } switch(posUnit) { case "pixel": if (top) { oDiv.style.bottom=""; oDiv.style.top=toPixel(top); } if (left) { oDiv.style.right=""; oDiv.style.left=toPixel(left); } if (bottom) { oDiv.style.top=""; oDiv.style.bottom=toPixel(bottom); } if (right) { oDiv.style.left=""; oDiv.style.right=toPixel(right); } break; default: if (top) { oDiv.style.bottom=""; oDiv.style.top=toPercent(top); } if (left) { oDiv.style.right=""; oDiv.style.left=toPercent(left); } if (bottom) { oDiv.style.top=""; oDiv.style.bottom=toPercent(bottom); } if (right) { oDiv.style.left=""; oDiv.style.right=toPercent(right); }   }  return oDiv; }; SLabel.prototype.setOpacity=function(value) { ChangeOpacity(this.htmlElement, value);  }; SLabel.prototype.remove=function () { this.textContainer=null; this.container.removeChild(this.htmlElement); this.htmlElement=null; SEvent.Trigger(this, "OnLabelRemoved", this.retVal); }; SLabel.prototype.setTextAlign=function(align) { if (align!=this.align) { this.align=align; this.textContainer.style.textAlign=this.align; } }; SLabel.prototype.setVisibility=function(visibility) { this.htmlElement.style.display=visibility; }; 
var jg_ihtm, jg_ie, jg_fast, jg_dom, jg_moz, jg_n4=(document.layers && typeof document.classes !="undefined"); function chkDHTM(x, i) { x=document.body || null; jg_ie=x && typeof x.insertAdjacentHTML !="undefined"; jg_dom=(x && !jg_ie && typeof x.appendChild !="undefined" && typeof document.createRange !="undefined" && typeof (i=document.createRange()).setStartBefore !="undefined" && typeof i.createContextualFragment !="undefined"); jg_ihtm=!jg_ie && !jg_dom && x && typeof x.innerHTML !="undefined"; jg_fast=jg_ie && document.all && !window.opera; jg_moz=jg_dom && typeof x.style.MozOpacity !="undefined"; } function pntDoc() { this.wnd.document.write(jg_fast? this.htmRpc() : this.htm); this.htm=''; } function pntCnvDom() { var x=document.createRange(); x.setStartBefore(this.cnv); x=x.createContextualFragment(jg_fast? this.htmRpc() : this.htm); this.cnv.appendChild(x); this.htm=''; } function pntCnvIe() { this.cnv.insertAdjacentHTML("BeforeEnd", jg_fast? this.htmRpc() : this.htm); this.htm=''; } function pntCnvIhtm() { this.cnv.innerHTML +=this.htm; this.htm=''; } function pntCnv() { this.htm=''; } function mkDiv(x, y, w, h) { this.htm +='<div style="position:absolute;'+ 'left:' + x + 'px;'+ 'top:' + y + 'px;'+ 'width:' + w + 'px;'+ 'height:' + h + 'px;'+ 'clip:rect(0,'+w+'px,'+h+'px,0);'+ 'background-color:' + this.color + (!jg_moz? ';overflow:hidden' : '')+ ';"><\/div>'; } function mkDivIe(x, y, w, h) { this.htm +='%%'+this.color+';'+x+';'+y+';'+w+';'+h+';'; } function mkDivPrt(x, y, w, h) { x=parseInt(x); y=parseInt(y); w=parseInt(w); h=parseInt(h); this.htm +='<div style="position:absolute;'+ 'border-left:' + w + 'px solid ' + this.color + ';'+ 'left:' + x + 'px;'+ 'top:' + y + 'px;'+ 'width:0px;'+ 'height:' + h + 'px;'+ 'clip:rect(0,'+w+'px,'+h+'px,0);'+ 'background-color:' + this.color + (!jg_moz? ';overflow:hidden' : '')+ ';"><\/div>'; } function mkLyr(x, y, w, h) { x=parseInt(x); y=parseInt(y); w=parseInt(w); h=parseInt(h); this.htm +='<layer '+ 'left="' + x + '" '+ 'top="' + y + '" '+ 'width="' + w + '" '+ 'height="' + h + '" '+ 'bgcolor="' + this.color + '"><\/layer>\n'; } var regex=/%%([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);/g; function htmRpc() { return this.htm.replace( regex, '<div style="overflow:hidden;position:absolute;background-color:'+ '$1;left:$2;top:$3;width:$4;height:$5"></div>\n'); } function htmPrtRpc() { return this.htm.replace( regex, '<div style="overflow:hidden;position:absolute;background-color:'+ '$1;left:$2;top:$3;width:$4;height:$5;border-left:$4px solid $1"></div>\n'); } function mkLin(x1, y1, x2, y2) { if (x1 > x2) { var _x2=x2; var _y2=y2; x2=x1; y2=y1; x1=_x2; y1=_y2; } var dx=x2-x1, dy=Math.abs(y2-y1), x=x1, y=y1, yIncr=(y1 > y2)? -1 : 1; if (dx >=dy) { var pr=dy<<1, pru=pr - (dx<<1), p=pr-dx, ox=x; while ((dx--) > 0) { ++x; if (p > 0) { this.mkDiv(ox, y, x-ox, 1); y +=yIncr; p +=pru; ox=x; } else p +=pr; } this.mkDiv(ox, y, x2-ox+1, 1); } else { var pr=dx<<1, pru=pr - (dy<<1), p=pr-dy, oy=y; if (y2 <=y1) { while ((dy--) > 0) { if (p > 0) { this.mkDiv(x++, y, 1, oy-y+1); y +=yIncr; p +=pru; oy=y; } else { y +=yIncr; p +=pr; } } this.mkDiv(x2, y2, 1, oy-y2+1); } else { while ((dy--) > 0) { y +=yIncr; if (p > 0) { this.mkDiv(x++, oy, 1, y-oy); p +=pru; oy=y; } else p +=pr; } this.mkDiv(x2, oy, 1, y2-oy+1); } } } function mkLin2D(x1, y1, x2, y2) { if (x1 > x2) { var _x2=x2; var _y2=y2; x2=x1; y2=y1; x1=_x2; y1=_y2; } var dx=x2-x1, dy=Math.abs(y2-y1), x=x1, y=y1, yIncr=(y1 > y2)? -1 : 1; var s=this.stroke; if (dx >=dy) { if (dx > 0 && s-3 > 0) { var _s=(s*dx*Math.sqrt(1+dy*dy/(dx*dx))-dx-(s>>1)*dy) / dx; _s=(!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1; } else var _s=s; var ad=Math.ceil(s/2); var pr=dy<<1, pru=pr - (dx<<1), p=pr-dx, ox=x; while ((dx--) > 0) { ++x; if (p > 0) { this.mkDiv(ox, y, x-ox+ad, _s); y +=yIncr; p +=pru; ox=x; } else p +=pr; } this.mkDiv(ox, y, x2-ox+ad+1, _s); } else { if (s-3 > 0) { var _s=(s*dy*Math.sqrt(1+dx*dx/(dy*dy))-(s>>1)*dx-dy) / dy; _s=(!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1; } else var _s=s; var ad=Math.round(s/2); var pr=dx<<1, pru=pr - (dy<<1), p=pr-dy, oy=y; if (y2 <=y1) { ++ad; while ((dy--) > 0) { if (p > 0) { this.mkDiv(x++, y, _s, oy-y+ad); y +=yIncr; p +=pru; oy=y; } else { y +=yIncr; p +=pr; } } this.mkDiv(x2, y2, _s, oy-y2+ad); } else { while ((dy--) > 0) { y +=yIncr; if (p > 0) { this.mkDiv(x++, oy, _s, y-oy+ad); p +=pru; oy=y; } else p +=pr; } this.mkDiv(x2, oy, _s, y2-oy+ad+1); } } } function mkLinDott(x1, y1, x2, y2) { if (x1 > x2) { var _x2=x2; var _y2=y2; x2=x1; y2=y1; x1=_x2; y1=_y2; } var dx=x2-x1, dy=Math.abs(y2-y1), x=x1, y=y1, yIncr=(y1 > y2)? -1 : 1, drw=true; if (dx >=dy) { var pr=dy<<1, pru=pr - (dx<<1), p=pr-dx; while ((dx--) > 0) { if (drw) this.mkDiv(x, y, 1, 1); drw=!drw; if (p > 0) { y +=yIncr; p +=pru; } else p +=pr; ++x; } if (drw) this.mkDiv(x, y, 1, 1); } else { var pr=dx<<1, pru=pr - (dy<<1), p=pr-dy; while ((dy--) > 0) { if (drw) this.mkDiv(x, y, 1, 1); drw=!drw; y +=yIncr; if (p > 0) { ++x; p +=pru; } else p +=pr; } if (drw) this.mkDiv(x, y, 1, 1); } } function mkOv(left, top, width, height) { var a=width>>1, b=height>>1, wod=width&1, hod=(height&1)+1, cx=left+a, cy=top+b, x=0, y=b, ox=0, oy=b, aa=(a*a)<<1, bb=(b*b)<<1, st=(aa>>1)*(1-(b<<1)) + bb, tt=(bb>>1) - aa*((b<<1)-1), w, h; while (y > 0) { if (st < 0) { st +=bb*((x<<1)+3); tt +=(bb<<1)*(++x); } else if (tt < 0) { st +=bb*((x<<1)+3) - (aa<<1)*(y-1); tt +=(bb<<1)*(++x) - aa*(((y--)<<1)-3); w=x-ox; h=oy-y; if (w&2 && h&2) { this.mkOvQds(cx, cy, -x+2, ox+wod, -oy, oy-1+hod, 1, 1); this.mkOvQds(cx, cy, -x+1, x-1+wod, -y-1, y+hod, 1, 1); } else this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, oy-h+hod, w, h); ox=x; oy=y; } else { tt -=aa*((y<<1)-3); st -=(aa<<1)*(--y); } } this.mkDiv(cx-a, cy-oy, a-ox+1, (oy<<1)+hod); this.mkDiv(cx+ox+wod, cy-oy, a-ox+1, (oy<<1)+hod); } function mkOv2D(left, top, width, height) { left=parseInt(left); top=parseInt(top); width=parseInt(width); height=parseInt(height); var s=this.stroke; width +=s-1; height +=s-1; var a=width>>1, b=height>>1, wod=width&1, hod=(height&1)+1, cx=left+a, cy=top+b, x=0, y=b, aa=(a*a)<<1, bb=(b*b)<<1, st=(aa>>1)*(1-(b<<1)) + bb, tt=(bb>>1) - aa*((b<<1)-1); if (s-4 < 0 && (!(s-2) || width-51 > 0 && height-51 > 0)) { var ox=0, oy=b, w, h, pxl, pxr, pxt, pxb, pxw; while (y > 0) { if (st < 0) { st +=bb*((x<<1)+3); tt +=(bb<<1)*(++x); } else if (tt < 0) { st +=bb*((x<<1)+3) - (aa<<1)*(y-1); tt +=(bb<<1)*(++x) - aa*(((y--)<<1)-3); w=x-ox; h=oy-y; if (w-1) { pxw=w+1+(s&1); h=s; } else if (h-1) { pxw=s; h +=1+(s&1); } else pxw=h=s; this.mkOvQds(cx, cy, -x+1, ox-pxw+w+wod, -oy, -h+oy+hod, pxw, h); ox=x; oy=y; } else { tt -=aa*((y<<1)-3); st -=(aa<<1)*(--y); } } this.mkDiv(cx-a, cy-oy, s, (oy<<1)+hod); this.mkDiv(cx+a+wod-s+1, cy-oy, s, (oy<<1)+hod); } else { var _a=(width-((s-1)<<1))>>1, _b=(height-((s-1)<<1))>>1, _x=0, _y=_b, _aa=(_a*_a)<<1, _bb=(_b*_b)<<1, _st=(_aa>>1)*(1-(_b<<1)) + _bb, _tt=(_bb>>1) - _aa*((_b<<1)-1), pxl=new Array(), pxt=new Array(), _pxb=new Array(); pxl[0]=0; pxt[0]=b; _pxb[0]=_b-1; while (y > 0) { if (st < 0) { st +=bb*((x<<1)+3); tt +=(bb<<1)*(++x); pxl[pxl.length]=x; pxt[pxt.length]=y; } else if (tt < 0) { st +=bb*((x<<1)+3) - (aa<<1)*(y-1); tt +=(bb<<1)*(++x) - aa*(((y--)<<1)-3); pxl[pxl.length]=x; pxt[pxt.length]=y; } else { tt -=aa*((y<<1)-3); st -=(aa<<1)*(--y); } if (_y > 0) { if (_st < 0) { _st +=_bb*((_x<<1)+3); _tt +=(_bb<<1)*(++_x); _pxb[_pxb.length]=_y-1; } else if (_tt < 0) { _st +=_bb*((_x<<1)+3) - (_aa<<1)*(_y-1); _tt +=(_bb<<1)*(++_x) - _aa*(((_y--)<<1)-3); _pxb[_pxb.length]=_y-1; } else { _tt -=_aa*((_y<<1)-3); _st -=(_aa<<1)*(--_y); _pxb[_pxb.length-1]--; } } } var ox=0, oy=b, _oy=_pxb[0], l=pxl.length, w, h; for (var i=0; i < l; i++) { if (typeof _pxb[i] !="undefined") { if (_pxb[i] < _oy || pxt[i] < oy) { x=pxl[i]; this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, _oy+hod, x-ox, oy-_oy); ox=x; oy=pxt[i]; _oy=_pxb[i]; } } else { x=pxl[i]; this.mkDiv(cx-x+1, cy-oy, 1, (oy<<1)+hod); this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod); ox=x; oy=pxt[i]; } } this.mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod); this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod); } } function mkOvDott(left, top, width, height) { var a=width>>1, b=height>>1, wod=width&1, hod=height&1, cx=left+a, cy=top+b, x=0, y=b, aa2=(a*a)<<1, aa4=aa2<<1, bb=(b*b)<<1, st=(aa2>>1)*(1-(b<<1)) + bb, tt=(bb>>1) - aa2*((b<<1)-1), drw=true; while (y > 0) { if (st < 0) { st +=bb*((x<<1)+3); tt +=(bb<<1)*(++x); } else if (tt < 0) { st +=bb*((x<<1)+3) - aa4*(y-1); tt +=(bb<<1)*(++x) - aa2*(((y--)<<1)-3); } else { tt -=aa2*((y<<1)-3); st -=aa4*(--y); } if (drw) this.mkOvQds(cx, cy, -x, x+wod, -y, y+hod, 1, 1); drw=!drw; } } function mkRect(x, y, w, h) { var s=this.stroke; this.mkDiv(x, y, w, s); this.mkDiv(x+w, y, s, h); this.mkDiv(x, y+h, w+s, s); this.mkDiv(x, y+s, s, h-s); } function mkRectDott(x, y, w, h) { this.drawLine(x, y, x+w, y); this.drawLine(x+w, y, x+w, y+h); this.drawLine(x, y+h, x+w, y+h); this.drawLine(x, y, x, y+h); } function jsgFont() { this.PLAIN='font-weight:normal;'; this.BOLD='font-weight:bold;'; this.ITALIC='font-style:italic;'; this.ITALIC_BOLD=this.ITALIC + this.BOLD; this.BOLD_ITALIC=this.ITALIC_BOLD; } var Font=new jsgFont(); function jsgStroke() { this.DOTTED=-1; } var Stroke=new jsgStroke(); function jsGraphics(id, wnd) { this.setColor=new Function('arg', 'this.color=arg.toLowerCase();'); this.setStroke=function(x) { this.stroke=x; if (!(x+1)) { this.drawLine=mkLinDott; this.mkOv=mkOvDott; this.drawRect=mkRectDott; } else if (x-1 > 0) { this.drawLine=mkLin2D; this.mkOv=mkOv2D; this.drawRect=mkRect; } else { this.drawLine=mkLin; this.mkOv=mkOv; this.drawRect=mkRect; } }; this.setPrintable=function(arg) { this.printable=arg; if (jg_fast) { this.mkDiv=mkDivIe; this.htmRpc=arg? htmPrtRpc : htmRpc; } else this.mkDiv=jg_n4? mkLyr : arg? mkDivPrt : mkDiv; }; this.setFont=function(fam, sz, sty) { this.ftFam=fam; this.ftSz=sz; this.ftSty=sty || Font.PLAIN; }; this.drawPolyLine=null; this.drawPolyline=this.drawPolyLine=function(x, y, s) { for (var i=0 ; i<x.length-1 ; i++ ) this.drawLine(x[i], y[i], x[i+1], y[i+1]); }; this.fillRect=function(x, y, w, h) { this.mkDiv(x, y, w, h); }; this.drawPolygon=function(x, y) { this.drawPolyline(x, y); this.drawLine(x[x.length-1], y[x.length-1], x[0], y[0]); }; this.drawOval=null; this.drawEllipse=this.drawOval=function(x, y, w, h) { this.mkOv(x, y, w, h); }; this.fillOval=null; this.fillEllipse=this.fillOval=function(left, top, w, h) { var a=(w -=1)>>1, b=(h -=1)>>1, wod=(w&1)+1, hod=(h&1)+1, cx=left+a, cy=top+b, x=0, y=b, ox=0, oy=b, aa2=(a*a)<<1, aa4=aa2<<1, bb=(b*b)<<1, st=(aa2>>1)*(1-(b<<1)) + bb, tt=(bb>>1) - aa2*((b<<1)-1), pxl, dw, dh; if (w+1) while (y > 0) { if (st < 0) { st +=bb*((x<<1)+3); tt +=(bb<<1)*(++x); } else if (tt < 0) { st +=bb*((x<<1)+3) - aa4*(y-1); pxl=cx-x; dw=(x<<1)+wod; tt +=(bb<<1)*(++x) - aa2*(((y--)<<1)-3); dh=oy-y; this.mkDiv(pxl, cy-oy, dw, dh); this.mkDiv(pxl, cy+y+hod, dw, dh); ox=x; oy=y; } else { tt -=aa2*((y<<1)-3); st -=aa4*(--y); } } this.mkDiv(cx-a, cy-oy, w+1, (oy<<1)+hod); }; this.fillPolygon=function(array_x, array_y) { var i; var y; var miny, maxy; var x1, y1; var x2, y2; var ind1, ind2; var ints; var n=array_x.length; if (!n) return; miny=array_y[0]; maxy=array_y[0]; for (i=1; i < n; i++) { if (array_y[i] < miny) miny=array_y[i]; if (array_y[i] > maxy) maxy=array_y[i]; } for (y=miny; y <=maxy; y++) { var polyInts=new Array(); ints=0; for (i=0; i < n; i++) { if (!i) { ind1=n-1; ind2=0; } else { ind1=i-1; ind2=i; } y1=array_y[ind1]; y2=array_y[ind2]; if (y1 < y2) { x1=array_x[ind1]; x2=array_x[ind2]; } else if (y1 > y2) { y2=array_y[ind1]; y1=array_y[ind2]; x2=array_x[ind1]; x1=array_x[ind2]; } else continue; if ((y >=y1) && (y < y2)) polyInts[ints++]=Math.round((y-y1) * (x2-x1) / (y2-y1) + x1); else if ((y==maxy) && (y > y1) && (y <=y2)) polyInts[ints++]=Math.round((y-y1) * (x2-x1) / (y2-y1) + x1); } polyInts.sort(integer_compare); for (i=0; i < ints; i+=2) this.mkDiv(polyInts[i], y, polyInts[i+1]-polyInts[i]+1, 1); } }; this.drawString=function(txt, x, y) { this.htm +='<div style="position:absolute;white-space:nowrap;'+ 'left:' + x + 'px;'+ 'top:' + y + 'px;'+ 'font-family:' +  this.ftFam + ';'+ 'font-size:' + this.ftSz + ';'+ 'color:' + this.color + ';' + this.ftSty + '">'+ txt + '<\/div>'; }; this.drawStringRect=function(txt, x, y, width, halign) { this.htm +='<div style="position:absolute;overflow:hidden;'+ 'left:' + x + 'px;'+ 'top:' + y + 'px;'+ 'width:'+width +'px;'+ 'text-align:'+halign+';'+ 'font-family:' +  this.ftFam + ';'+ 'font-size:' + this.ftSz + ';'+ 'color:' + this.color + ';' + this.ftSty + '">'+ txt + '<\/div>'; }; this.drawImage=function(imgSrc, x, y, w, h, a) { this.htm +='<div style="position:absolute;'+ 'left:' + x + 'px;'+ 'top:' + y + 'px;'+ 'width:' +  w + ';'+ 'height:' + h + ';">'+ '<img src="' + imgSrc + '" width="' + w + '" height="' + h + '"' + (a? (' '+a) : '') + '>'+ '<\/div>'; }; this.clear=function() { this.htm=""; if (this.cnv) this.cnv.innerHTML=this.defhtm; }; this.mkOvQds=function(cx, cy, xl, xr, yt, yb, w, h) { this.mkDiv(xr+cx, yt+cy, w, h); this.mkDiv(xr+cx, yb+cy, w, h); this.mkDiv(xl+cx, yb+cy, w, h); this.mkDiv(xl+cx, yt+cy, w, h); }; this.setStroke(1); this.setFont('verdana,geneva,helvetica,sans-serif', String.fromCharCode(0x31, 0x32, 0x70, 0x78), Font.PLAIN); this.color='#000000'; this.htm=''; this.wnd=wnd || window; if (!(jg_ie || jg_dom || jg_ihtm)) chkDHTM(); if (typeof id !='string' || !id) this.paint=pntDoc; else { this.cnv=document.all? (this.wnd.document.all[id] || null) : document.getElementById? (this.wnd.document.getElementById(id) || null) : null; this.defhtm=(this.cnv && this.cnv.innerHTML)? this.cnv.innerHTML : ''; this.paint=jg_dom? pntCnvDom : jg_ie? pntCnvIe : jg_ihtm? pntCnvIhtm : pntCnv; } this.setPrintable(false); } function integer_compare(x,y) { return (x < y) ? -1 : ((x > y)*1); } 
function SNavigator() { }; SNavigator.prototype.container=null; SNavigator.prototype.htmlElement=null; SNavigator.prototype.isLoaded=false; SNavigator.prototype.upButton=null; SNavigator.prototype.upLeftButton=null; SNavigator.prototype.upRightButton=null; SNavigator.prototype.leftButton=null; SNavigator.prototype.downLeftButton=null; SNavigator.prototype.downButton=null; SNavigator.prototype.downRightButton=null; SNavigator.prototype.rightButton=null; SNavigator.prototype.wunload=null; SNavigator.prototype.size=null; SNavigator.prototype.handUp=null; SNavigator.prototype.handLeft=null; SNavigator.prototype.handDown=null; SNavigator.prototype.handRight=null; SNavigator.prototype.handUpLeft=null; SNavigator.prototype.handUpRight=null; SNavigator.prototype.handDownLeft=null; SNavigator.prototype.handDownRight=null; SNavigator.prototype.imgUp=null; SNavigator.prototype.imgUpLeft=null; SNavigator.prototype.imgLeft=null; SNavigator.prototype.imgDownLeft=null; SNavigator.prototype.imgDown=null; SNavigator.prototype.imgDownRight=null; SNavigator.prototype.imgRight=null; SNavigator.prototype.imgUpRight=null; SNavigator=function() { this.isLoaded=false; this.imgUp="center_top.png"; this.imgUpLeft="left_top.png"; this.imgLeft="left_center.png"; this.imgDownLeft="left_botton.png"; this.imgDown="center_botton.png"; this.imgDownRight="right_botton.png"; this.imgRight="right_center.png"; this.imgUpRight="right_top.png"; this.wunload=SEvent.attachDOM(window, 'unload', this.destroy, this); return this; }; SNavigator.prototype.LoadControl=function(mapRef, container) { if (!mapRef||!container) { return; } this.isLoaded=true; this.map=mapRef; this.container=container; this.CreateInterface(); }; SNavigator.prototype.setDefaultPosition=function() { if (this.isLoaded) { } }; SNavigator.prototype.CreateInterface=function() { this.htmlElement=this.createDIV(this.container, new SSize(100, 100), "percent",  0, 0, null, null, "pixel"); this.htmlElement.style.zIndex=5; this.htmlElement.style.visibility="hidden"; this.upButton=this.createImage(this.htmlElement, new SSize(25, 25), "pixel", "0px", "49.5%", null, null); this.upButton.src=SMAP_CONTROLS_PATH + "navigator/" + this.imgUp; this.upLeftButton=this.createImage(this.htmlElement, new SSize(25, 25), "pixel", "0px", "0px", null, null); this.upLeftButton.src=SMAP_CONTROLS_PATH + "navigator/" + this.imgUpLeft; this.leftButton=this.createImage(this.htmlElement, new SSize(25, 25), "pixel", "49.5%", "0px", null, null); this.leftButton.src=SMAP_CONTROLS_PATH + "navigator/" + this.imgLeft; this.upRightButton=this.createImage(this.htmlElement, new SSize(25, 25), "pixel", "0px", null, null, "-1px"); this.upRightButton.src=SMAP_CONTROLS_PATH + "navigator/" + this.imgUpRight; this.downButton=this.createImage(this.htmlElement, new SSize(25, 25), "pixel", null, "49.5%", "0px", null); this.downButton.src=SMAP_CONTROLS_PATH + "navigator/" + this.imgDown; this.downLeftButton=this.createImage(this.htmlElement, new SSize(25, 25), "pixel", null, "0px", "0px", null); this.downLeftButton.src=SMAP_CONTROLS_PATH + "navigator/" + this.imgDownLeft; this.downRightButton=this.createImage(this.htmlElement, new SSize(25, 25), "pixel", null, null, "0px", "-1px"); this.downRightButton.src=SMAP_CONTROLS_PATH + "navigator/" + this.imgDownRight; this.rightButton=this.createImage(this.htmlElement, new SSize(25, 25), "pixel", "49.5%", null, null, "-1px"); this.rightButton.src=SMAP_CONTROLS_PATH + "navigator/" + this.imgRight; this.size=new SSize(parseInt(this.htmlElement.clientWidth), parseInt(this.htmlElement.clientHeight)); this.handUp=SEvent.attachDOM(this.upButton, 'click', this.DoSlide, this, "up"); this.handLeft=SEvent.attachDOM(this.leftButton, 'click', this.DoSlide, this, "left"); this.handDown=SEvent.attachDOM(this.downButton, 'click', this.DoSlide, this, "down"); this.handRight=SEvent.attachDOM(this.rightButton, 'click', this.DoSlide, this, "right"); this.handUpLeft=SEvent.attachDOM(this.upLeftButton, 'click', this.DoSlide, this, "up-left"); this.handUpRight=SEvent.attachDOM(this.upRightButton, 'click', this.DoSlide, this, "up-right"); this.handDownLeft=SEvent.attachDOM(this.downLeftButton, 'click', this.DoSlide, this, "down-left"); this.handDownRight=SEvent.attachDOM(this.downRightButton, 'click', this.DoSlide, this, "down-right"); this.applyButtonStyle(this.upButton); this.applyButtonStyle(this.upLeftButton); this.applyButtonStyle(this.leftButton); this.applyButtonStyle(this.upRightButton); this.applyButtonStyle(this.downButton); this.applyButtonStyle(this.downLeftButton); this.applyButtonStyle(this.downRightButton); this.applyButtonStyle(this.rightButton); }; SNavigator.prototype.DoSlide=function(e, direction) { var from=null; this.size.width=this.map.mapPixelWidth; this.size.height=this.map.mapPixelHeight; switch(direction) { case "up": from=new SGeoPoint(this.size.width/2, 0); break; case "left": from=new SGeoPoint(0, this.size.height/2); break; case "down": from=new SGeoPoint(this.size.width/2, this.size.height); break; case "right": from=new SGeoPoint(this.size.width, this.size.height/2); break; case "up-left":  from=new SGeoPoint(0, 0); break; case "up-right":  from=new SGeoPoint(this.size.width, 0); break; case "down-left": from=new SGeoPoint(0, this.size.height); break; case "down-right": from=new SGeoPoint(this.size.width, this.size.height); break; } if (from) { var to=new SGeoPoint(this.size.width/2, this.size.height/2); this.map.FlyMapCenter(from, to); } }; SNavigator.prototype.destroy=function() { if (this.isLoaded) { SEvent.deattachDOM(this.upButton, 'click', this.handUp); SEvent.deattachDOM(this.upLeftButton, 'click', this.handUpLeft); SEvent.deattachDOM(this.leftButton, 'click', this.handLeft); SEvent.deattachDOM(this.upRightButton, 'click', this.handUpRight); SEvent.deattachDOM(this.downButton, 'click', this.handDown); SEvent.deattachDOM(this.downLeftButton, 'click', this.handDownLeft); SEvent.deattachDOM(this.downRightButton, 'click', this.handDownRight); SEvent.deattachDOM(this.rightButton, 'click', this.handRight); this.upButton=null; this.upLeftButton=null; this.leftButton=null; this.upRightButton=null; this.downButton=null; this.downLeftButton=null; this.downRightButton=null; this.rightButton=null; this.container.removeChild(this.htmlElement); this.htmlElement=null; } SEvent.deattachDOM(window, 'unload', this.wunload); }; SNavigator.prototype.applyButtonStyle=function(obj) { SetSelectableStatus(obj, "off"); SwitchCursor(obj, "pointer"); }; SNavigator.prototype.createDIV=function (container, size, sizeUnit,  top, left, bottom, right, posUnit) { var oDiv=document.createElement('div'); oDiv.style.position='absolute'; switch(sizeUnit) { case "pixel": oDiv.style.width=toPixel(size.width); oDiv.style.height=toPixel(size.height); break; default: oDiv.style.width=toPercent(size.width); oDiv.style.height=toPercent(size.height); } switch(posUnit) { case "pixel": if (top) { oDiv.style.top=toPixel(top); } if (left) { oDiv.style.left=toPixel(left); } if (bottom) { oDiv.style.bottom=toPixel(bottom); } if (right) { oDiv.style.right=toPixel(right); } break; default: if (top) { oDiv.style.top=toPercent(top); } if (left) { oDiv.style.left=toPercent(left); } if (bottom) { oDiv.style.bottom=toPercent(bottom); } if (right) { oDiv.style.right=toPercent(right); }   }  container.appendChild(oDiv); return oDiv; }; SNavigator.prototype.createImage=function(container, size, sizeUnit,  top, left, bottom, right) { var image=document.createElement('IMG');   image.style.position="absolute"; image.style.border="0px solid gray"; image.style.width=size.width; image.style.height=size.height; if (top) { image.style.top=top; } if (left) { image.style.left=left; } if (bottom) { image.style.bottom=bottom; } if (right) { image.style.right=right; } image.style.zIndex=0; image.style.visibility="visible"; image.onload=function() { if (this.runtimeStyle&&/\.png$/.test(this.src.toLowerCase())) { if (this.runtimeStyle.filter=="") { this.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "',sizingMethod='scale')"; this.src=SMAP_IMAGES_PATH + "blank.gif"; } } };  container.appendChild(image); return image; }; 
function SMapTypeSwitcher(){}; SMapTypeSwitcher.prototype.map=null; SMapTypeSwitcher.prototype.htmlElement=null; SMapTypeSwitcher.prototype.container=null; SMapTypeSwitcher=function() { this.createInterface(); }; SMapTypeSwitcher.prototype.LoadControl=function(mapRef, container) { if (!mapRef||!container) { return; } this.map=mapRef; this.container=container; this.createInterface(); }; SMapTypeSwitcher.prototype.setDefaultPosition=function() { }; SMapTypeSwitcher.prototype.createInterface=function() { }; SMapTypeSwitcher.prototype.createDIV=function (container, size, sizeUnit,  top, left, bottom, right, posUnit) { var oDiv=document.createElement('div'); oDiv.style.position='absolute'; switch(sizeUnit) { case "pixel": oDiv.style.width=toPixel(size.width); oDiv.style.height=toPixel(size.height); break; default: oDiv.style.width=toPercent(size.width); oDiv.style.height=toPercent(size.height); } switch(posUnit) { case "pixel": if (top) { oDiv.style.top=toPixel(top); } if (left) { oDiv.style.left=toPixel(left); } if (bottom) { oDiv.style.bottom=toPixel(bottom); } if (right) { oDiv.style.right=toPixel(right); } break; default: if (top) { oDiv.style.top=toPercent(top); } if (left) { oDiv.style.left=toPercent(left); } if (bottom) { oDiv.style.bottom=toPercent(bottom); } if (right) { oDiv.style.right=toPercent(right); }   }  container.appendChild(oDiv); return oDiv; }; 
Slider=function Slider(mode)  { this.mode=!mode?"full":mode; this.offsetX=10; this.offsetY=10; return this; }; Slider.isSupported=typeof document.createElement !="undefined" && typeof document.documentElement !="undefined" && typeof document.documentElement.offsetWidth=="number"; Slider.prototype.setPosition=function(vertical, horizontal) { switch(vertical) { case "middle": this.Frame.style.top=(parseInt(this.map.mapLayerObj.style.height)/2) - (parseInt(this.Frame.style.height)/2); this.Frame.style.bottom=""; break; case "bottom": this.Frame.style.top=""; this.Frame.style.bottom=this.offsetY+"px"; break; case "top": default: this.Frame.style.top=this.offsetY+"px"; this.Frame.style.bottom=""; } switch(horizontal) { case "left": this.Frame.style.left=this.offsetX+"px"; this.Frame.style.right=""; break; case "middle": this.Frame.style.left=(parseInt(this.map.mapLayerObj.style.width)/2) - (parseInt(this.Frame.style.width)/2); this.Frame.style.right=""; break; case "rigth": default: this.Frame.style.right=this.offsetX+"px"; this.Frame.style.left=""; } this.xlogpos=horizontal; this.ylogpos=vertical; }; Slider.prototype.setOffSet=function(x, y) { if (!x||typeof(x)!="number") x=10; if (!y||typeof(y)!="number") y=10; this.offsetX=x; this.offsetY=y; this.setPosition(this.xlogpos, this.ylogpos); }; Slider.prototype.LoadControl=function(mapReference, oElement, Left, Top, Mode) { if (!oElement)  { return; } Left=!Left?-100:Left; Top=!Top?0:Top; this.Frame=this.createLayer(oElement, "frameSlider", 20, 200, 5, "visible", "top", Left, Top, "", ""); this.Container=this.createLayer(this.Frame, "sliderBody", 20, 156, 0, "visible", "center", 0, 20, "", SMAP_CONTROLS_PATH+"slider/sliderbar.gif"); if (Mode) { if (Mode=="compact"||Mode=="full") { this.mode=Mode; } else { this.mode="full"; } } this._orientation="vertical"; this._range=new SRange(); this._range.setExtent(0); this._blockIncrement=10; this._unitIncrement=1; this._timer=new STimer(100); this.StartValue=1; this.htmlElement=this.Frame; if (Slider.isSupported && this.Container)  { if (mapReference) { this.map=mapReference; SEvent.Bind(mapReference, "OnMapChangeLevel", this, this.ExternalChangeLevel); } else { this.map=null; } this.document=this.Container.ownerDocument || this.Container.document; this.element=this.Container; this.element.slider=this; this.element.unselectable="on"; this.element.style.MozUserFocus="normal"; this.element.style.MozUserSelect="none"; this.element.style.cursor="default"; this.line=this.document.createElement("DIV"); this.line.unselectable="on"; this.line.appendChild(this.document.createElement("DIV")); this.up=this.createLayer(this.Frame, "upButton", 20, 20, 0, "visible", "top", 0, 0, "", SMAP_CONTROLS_PATH+"slider/plus.gif"); this.up.title="Zoom In"; this.up.style.cursor="pointer"; this.down=this.createLayer(this.Frame, "DownButton", 20, 20, 0, "visible", "top", 0, 174, "", SMAP_CONTROLS_PATH+"slider/less.gif"); this.down.title="Zoom Out"; this.down.style.cursor="pointer"; this.handle=this.createLayer(this.element, "handle", 20, 13, 0, "visible", "center", 0, 0, "", SMAP_CONTROLS_PATH+"slider/slider.gif"); SwitchCursor(this.handle, "move"); if (this.mode=="compact") { this.element.style.height=0+"px"; this.handle.style.visibility="hidden"; this.down.style.top=22+"px"; this.Frame.style.height=44+"px"; this.Frame.style.overflow="hidden"; } } this.input=document.createElement("INPUT"); this.input.id="slider-input-1"; this.input.name="slider-input-1"; this.input.style.visibility="hidden"; this.input.style.display="none"; this.element.appendChild(this.input); this.wunload=SEvent.attachDOM(window, 'unload', this.destroy, this); var oThis=this; this._range.onchange=function ()  { oThis.recalculate(); if (typeof oThis.onchange=="function") { oThis.onchange(); } }; this.more=function()  { var s=oThis; s.setValue(s.getValue() + 1); if (s.StartValue!=s.getValue()) { s.StartValue=s.getValue(); oThis.ondrop(); } }; this.less=function ()  { var s=oThis; s.setValue(s.getValue() + -1); if (s.StartValue!=s.getValue()) { s.StartValue=s.getValue(); oThis.ondrop(); } }; if (Slider.isSupported && this.Container)  { this.element.onfocus=Slider.eventHandlers.onfocus; this.element.onblur=Slider.eventHandlers.onblur; this.element.onmousedown=Slider.eventHandlers.onmousedown; this.element.onmouseover=Slider.eventHandlers.onmouseover; this.element.onmouseout=Slider.eventHandlers.onmouseout; this.up.onmouseup=this.more; this.down.onmouseup=this.less; this.element.onselectstart=function ()  {  return false;  }; this._timer.ontimer=function ()  { oThis.ontimer(); }; window.setTimeout(function() { oThis.recalculate();}, 1); } else  { this.input.onchange=function (e)  { oThis.setValue(oThis.input.value); }; } this.setMaximum(19); this.setMinimum(1); this.setBlockIncrement(4); this.setUnitIncrement(1); if (this.map.level) { this.setValue(this.map.level); } }; Slider.prototype.setDefaultPosition=function() { this.setPosition("top", "right"); }; Slider.prototype.ExternalChangeLevel=function(c) { this.setValue(c); }; Slider.prototype.ondrop=function() { if (this.map) { this.map.ZoomAndGoTo(this.map.GetCenter(),this.getValue()); } }; Slider.prototype.onchange=function() { }; Slider.eventHandlers={ getEvent: function (e, el)  { if (!e)  { if (el) { e=el.document.parentWindow.event; } else { e=window.event; } } if (!e.srcElement)  { var el=e.target; while (el !=null && el.nodeType !=1) { el=el.parentNode; } e.srcElement=el; } if (typeof e.offsetX=="undefined")  { e.offsetX=e.layerX; e.offsetY=e.layerY; } return e; }, getDocument: function (e)  { if (e.target) { return e.target.ownerDocument; } return e.srcElement.document; }, getSlider: function (e)  { var el=e.target || e.srcElement; while (el !=null && el.slider==null)  { el=el.parentNode; } if (el) { return el.slider; } return null; }, getLine: function (e)  { var el=e.target || e.srcElement; while (el !=null && el.className !="line")  { el=el.parentNode; } return el; }, getHandle: function (e)  { var el=e.target || e.srcElement; var re=/handle/; while (el !=null && !re.test(el.className))  { el=el.parentNode; } return el; }, onfocus: function (e)  { var s=this.slider; s._focused=true; s.handle.className="handle hover"; }, onblur: function (e)  { var s=this.slider; s._focused=false; s.handle.className="handle"; }, onmouseover: function (e)  { try { e=Slider.eventHandlers.getEvent(e, this); var s=this.slider; if (s) { if (e.srcElement==s.handle) { s.handle.className="handle hover"; } } } catch(err) { } }, onmouseout: function (e)  { try { e=Slider.eventHandlers.getEvent(e, this); var s=this.slider; if (e.srcElement==s.handle && !s._focused) { s.handle.className="handle"; } } catch(err) { } }, onmousedown: function (e)  { e=Slider.eventHandlers.getEvent(e, this); var s=this.slider; s.StartValue=s.getValue(); if (s.element.focus) { s.element.focus(); } Slider._currentInstance=s; var doc=s.document; if (doc.addEventListener)  { doc.addEventListener("mousemove", Slider.eventHandlers.onmousemove, true); doc.addEventListener("mouseup", Slider.eventHandlers.onmouseup, true); } else if (doc.attachEvent)  { doc.attachEvent("onmousemove", Slider.eventHandlers.onmousemove); doc.attachEvent("onmouseup", Slider.eventHandlers.onmouseup); doc.attachEvent("onlosecapture", Slider.eventHandlers.onmouseup); s.element.setCapture(); } if (Slider.eventHandlers.getHandle(e))  { Slider._sliderDragData={ screenX: e.screenX, screenY: e.screenY, dx:   e.screenX - s.handle.offsetLeft, dy:   e.screenY - s.handle.offsetTop, startValue: s.getValue(), slider:  s }; } else  { var lineEl=Slider.eventHandlers.getLine(e); s._mouseX=e.offsetX + (lineEl ? s.line.offsetLeft : 0); s._mouseY=e.offsetY + (lineEl ? s.line.offsetTop : 0); s._increasing=null; s.ontimer(); } }, onmousemove: function (e)  { e=Slider.eventHandlers.getEvent(e, this); if (Slider._sliderDragData)  {  var s=Slider._sliderDragData.slider; var boundSize=s.getMaximum() - s.getMinimum(); var size, pos, reset; if (s._orientation=="horizontal")  { size=s.element.offsetWidth - s.handle.offsetWidth; pos=e.screenX - Slider._sliderDragData.dx; reset=Math.abs(e.screenY - Slider._sliderDragData.screenY) > 100; } else  { size=parseInt(s.element.style.height) - parseInt(s.handle.style.height); pos=parseInt(s.element.style.height) - parseInt(s.handle.style.height) - (e.screenY - Slider._sliderDragData.dy); reset=Math.abs(e.screenX - Slider._sliderDragData.screenX) > 100; } s.setValue(reset ? Slider._sliderDragData.startValue : s.getMinimum() + boundSize * pos / size); return false; } else  { var s=Slider._currentInstance; if (s !=null)  { var lineEl=Slider.eventHandlers.getLine(e); s._mouseX=e.offsetX + (lineEl ? s.line.offsetLeft : 0); s._mouseY=e.offsetY + (lineEl ? s.line.offsetTop : 0); } } }, onmouseup: function (e)  { e=Slider.eventHandlers.getEvent(e, this); var s=Slider._currentInstance; var doc=s.document; if (doc.removeEventListener)  { doc.removeEventListener("mousemove", Slider.eventHandlers.onmousemove, true); doc.removeEventListener("mouseup", Slider.eventHandlers.onmouseup, true); } else if (doc.detachEvent)  { doc.detachEvent("onmousemove", Slider.eventHandlers.onmousemove); doc.detachEvent("onmouseup", Slider.eventHandlers.onmouseup); doc.detachEvent("onlosecapture", Slider.eventHandlers.onmouseup); s.element.releaseCapture(); } if (Slider._sliderDragData)  {  Slider._sliderDragData=null; } else  { s._timer.stop(); s._increasing=null; } if (s.StartValue!=s.getValue()) { s.StartValue=s.getValue(); s.ondrop(); } Slider._currentInstance=null; }, onkeydown: function (e)  { e=Slider.eventHandlers.getEvent(e, this); var s=this.slider; var kc=e.keyCode; switch (kc)  { case 33:  s.setValue(s.getValue() + s.getBlockIncrement()); break; case 34:  s.setValue(s.getValue() - s.getBlockIncrement()); break; case 35:  s.setValue(s.getOrientation()=="horizontal" ? s.getMaximum() : s.getMinimum()); break; case 36: s.setValue(s.getOrientation()=="horizontal" ? s.getMinimum() : s.getMaximum()); break; case 38: case 39: s.setValue(s.getValue() + s.getUnitIncrement()); break; case 37: case 40:  s.setValue(s.getValue() - s.getUnitIncrement()); break; } if (kc >=33 && kc <=40)  { return false; } }, onkeypress: function (e)  { e=Slider.eventHandlers.getEvent(e, this); var kc=e.keyCode; if (kc >=33 && kc <=40)  { return false; } }, onmousewheel: function (e)  { e=Slider.eventHandlers.getEvent(e, this); var s=this.slider; if (s._focused)  { s.setValue(s.getValue() + e.wheelDelta / 120 * s.getUnitIncrement()); return false; } } }; Slider.prototype.createLayer=function (Container, Id, Width, Height, zIndex, Overflow, Align, Left, Top, BackColor, BackgroundImage) { try { oDiv=document.createElement("DIV"); oDiv.id=Id; oDiv.style.position="absolute"; oDiv.style.left=Left+"px"; } catch(e) { } oDiv.style.top=Top+"px"; oDiv.style.width=Width+"px"; oDiv.style.border="none red 0px"; oDiv.style.height=Height+"px"; oDiv.style.zIndex=zIndex; oDiv.style.visibility="visible"; oDiv.style.backgroundRepeat="no-repeat"; oDiv.style.backgroundPosition=Align; oDiv.style.backgroundColor=BackColor; oDiv.style.backgroundImage="url("+BackgroundImage+")"; oDiv.style.overflow=Overflow; Container.appendChild(oDiv); return oDiv; }; Slider.prototype.setValue=function (v)  { this._range.setValue(v); this.input.value=this.getValue(); }; Slider.prototype.getValue=function ()  { return this._range.getValue(); }; Slider.prototype.setMinimum=function (v)  { this._range.setMinimum(v); this.input.value=this.getValue(); }; Slider.prototype.getMinimum=function ()  { return this._range.getMinimum(); }; Slider.prototype.setMaximum=function (v)  { this._range.setMaximum(v); this.input.value=this.getValue(); }; Slider.prototype.getMaximum=function ()  { return this._range.getMaximum(); }; Slider.prototype.setUnitIncrement=function (v)  { this._unitIncrement=v; }; Slider.prototype.getUnitIncrement=function ()  { return this._unitIncrement; }; Slider.prototype.setBlockIncrement=function (v)  { this._blockIncrement=v; }; Slider.prototype.getBlockIncrement=function ()  { return this._blockIncrement; }; Slider.prototype.getOrientation=function ()  { return this._orientation; }; Slider.prototype.setOrientation=function (sOrientation)  { if (sOrientation !=this._orientation)  { if (Slider.isSupported && this.element)  { } this._orientation=sOrientation; this.recalculate(); } }; Slider.prototype.recalculate=function()  { if (!Slider.isSupported || !this.element) { return; } try{ var w=this.element.offsetWidth; var h=this.element.offsetHeight; var hw=this.handle.offsetWidth; var hh=this.handle.offsetHeight; var lw=this.line.offsetWidth; var lh=this.line.offsetHeight; if (this._orientation=="horizontal")  { this.handle.style.left=(w - hw) * (this.getValue() - this.getMinimum())/(this.getMaximum() - this.getMinimum()) + "px"; this.handle.style.top=(h - hh) / 2 + "px"; this.line.style.top=(h - lh) / 2 + "px"; this.line.style.left=hw / 2 + "px"; this.line.style.width=Math.max(0, w - hw - 2)+ "px"; this.line.firstChild.style.width=Math.max(0, w - hw - 4)+ "px"; } else  { this.handle.style.left=(w - hw) / 2 + "px"; this.handle.style.top=h - hh - (h - hh) * (this.getValue() - this.getMinimum())/(this.getMaximum() - this.getMinimum()) + "px"; this.line.style.left=(w - lw) / 2 + "px"; this.line.style.top=hh / 2 + "px"; this.line.style.height=Math.max(0, h - hh - 2) + "px";  this.line.firstChild.style.height=Math.max(0, h - hh - 4) + "px"; } }catch(e){} }; Slider.prototype.ontimer=function ()  { var hw=this.handle.offsetWidth; var hh=this.handle.offsetHeight; var hl=this.handle.offsetLeft; var ht=this.handle.offsetTop; if (this._orientation=="horizontal")  { if (this._mouseX > hl + hw && (this._increasing==null || this._increasing))  { this.setValue(this.getValue() + this.getBlockIncrement()); this._increasing=true; } else if (this._mouseX < hl && (this._increasing==null || !this._increasing))  { this.setValue(this.getValue() - this.getBlockIncrement()); this._increasing=false; } } else  { if (this._mouseY > ht + hh && (this._increasing==null || !this._increasing))  { this.setValue(this.getValue() - this.getBlockIncrement()); this._increasing=false; } else if (this._mouseY < ht && (this._increasing==null || this._increasing))  { this.setValue(this.getValue() + this.getBlockIncrement()); this._increasing=true; } } }; Slider.prototype.destroy=function ()  { this.Frame=null; this.Container=null; this.up=null; this.down=null; this.handle=null; this.input=null; }; 
var ie=document.all; var ns6=document.getElementById&&!document.all; STab=function() { }; STab.prototype.Index=null; STab.prototype.Label=null; STab.prototype.Url=null; STab.prototype.closeButton=null; STab.prototype.TabLashElement=null; STab.prototype.TabElement=null; STab.prototype.hMouseOver=null; STab.prototype.hMouseOut=null; STab.prototype.hMouseClick=null; STab.prototype.hMouseDblClick=null; function SWindowInfo() { }; SWindowInfo.prototype.containerOnMousedown=null; SWindowInfo.prototype.containerdblclick=null; SWindowInfo.prototype.cbOnclick=null; SWindowInfo.prototype.minbtnclk=null; SWindowInfo.prototype.domEventsCapture=null; SWindowInfo.prototype.mousedownBinded=null; SWindowInfo.prototype.mupBinded=null; SWindowInfo.prototype.mmoveBinded=null; SWindowInfo.prototype.dragging=false; SWindowInfo.prototype.dragPoint=null; SWindowInfo=function(container, map, variable) { this.mapObject=null; if(map) { this.mapObject=map; this.listenerLevel=SEvent.Bind(map, "OnMapChangeLevel",this, this.mapchangelevel); this.listenerClick=SEvent.Bind(map, "OnMapClick",this, this.mapclick); } else { this.wunload=SEvent.attachDOM(window, 'unload', this.Close, this); } if (container) { this.Container=container; } else { return null; } this.Tabs=new Array(); return this; }; SWindowInfo.prototype.Tabs=null; SWindowInfo.prototype.Container=null; SWindowInfo.prototype.Label=""; SWindowInfo.prototype.htmlElement=null; SWindowInfo.prototype.Position=null; SWindowInfo.prototype.Height=null; SWindowInfo.prototype.Width=null; SWindowInfo.prototype.Left=null; SWindowInfo.prototype.Top=null; SWindowInfo.prototype.ShowPointer=false; SWindowInfo.prototype.AbsoluteHeight=null; SWindowInfo.prototype.AbsoluteWidth=null; SWindowInfo.prototype.posOnStart=null; SWindowInfo.prototype.hide=false; SWindowInfo.prototype.Shadow=null; SWindowInfo.prototype.CloseOnLostfocus=null; SWindowInfo.prototype.ShowTransitionAnimation=null; SWindowInfo.prototype.TabTopBorderColor="#6893CB"; SWindowInfo.prototype.TitleBackColor="#FFFFFF"; SWindowInfo.prototype.TitleFontColor="#000000"; SWindowInfo.prototype.TitleFont="Verdana"; SWindowInfo.prototype.ActiveTabBackColor="#FFFFFF"; SWindowInfo.prototype.ActiveTabFontColor="#000000"; SWindowInfo.prototype.ActiveTabFont="tahoma"; SWindowInfo.prototype.InactiveTabBackColor=""; SWindowInfo.prototype.InactiveTabFontColor="#333333"; SWindowInfo.prototype.InactiveTabFont="tahoma"; SWindowInfo.prototype.defaultHeight=300; SWindowInfo.prototype.defaultWidth=250; SWindowInfo.prototype.defaultTitleHeight=15; SWindowInfo.prototype.defaultTopBarHeight=20; SWindowInfo.prototype.defaultTabLashHeight=15; SWindowInfo.prototype.TitleBarElement=null; SWindowInfo.prototype.LabelTitleBarElement=null; SWindowInfo.prototype.TopBarElement=null; SWindowInfo.prototype.CloseButtonLayer=null; SWindowInfo.prototype.PivotImage=null; SWindowInfo.prototype.PivotX=null; SWindowInfo.prototype.PivotY=null; SWindowInfo.prototype.activeTab=-1; SWindowInfo.prototype.DragTool=null; SWindowInfo.prototype.LoadControl=function(map, container){}; SWindowInfo.prototype.setDefaultPosition=function(){}; SWindowInfo.prototype.LatLongPosition=null; SWindowInfo.prototype.wunload=null; SWindowInfo.prototype.destroy=function() { try { SEvent.deattachDOM(this, 'click', this.containerOnMousedown); SEvent.deattachDOM(this, 'doubleclick', this.labelhdblclk); SEvent.deattachDOM(this, 'click', this.cbOnclick); SEvent.deattachDOM(this, 'click', this.minbtnclk); SEvent.deattachDOM(window, "unload", this.wunload); if (this.mapObject) { SEvent.RemoveListener(this.listenerLevel); SEvent.RemoveListener(this.listenerClick); } else { SEvent.RemoveListener(this.mousedownBinded); SEvent.RemoveListener(this.mupBinded); SEvent.RemoveListener(this.mmoveBinded); } this.dragging=null; this.dragPoint=null; this.domEventsCapture=null; this.removeAllTabs(); this.Container.removeChild(this.htmlElement); this.TitleBarElement=null; this.LabelTitleBarElement=null; this.TopBarElement=null; this.CloseButtonLayer=null; this.PivotImage=null; this.htmlElement=null; this.Tabs=null; this.containerOnMousedown=null; this.containerdblclick=null; this.labelhdblclk=null; this.cbOnclick=null; this.minbtnclk=null; this.mapObject=null; this.Container=null; } catch(e) { } }; SWindowInfo.prototype.CreateWindow=function(width, height, Left, Top, pointer) { var pointer=!pointer?false:true; this.Top=!Top?0:Top; this.Left=!Left?0:Left; this.Width=!width?this.defaultWidth:width; this.Height=!height?this.defaultHeight:height; this.htmlElement=this.CreateLayer(this.Container, "STabWindowFrame", this.Width, this.Height, 99, "visible", "top", this.Left, this.Top, "", "", "solid gray 1px"); this.htmlElement.style.display="none"; if (this.mapObject) { this.containerOnMousedown=SEvent.attachDOM(this.htmlElement, 'mousedown', function(e) { var e=!e?event:e; return (this.cancelBehaviour(e)); }, this); this.containerdblclick=SEvent.attachDOM(this.htmlElement, 'dblclick', function(e) { var e=!e?event:e; return (this.cancelBehaviour(e)); }, this); } this.htmlElement.style.display=""; this.TitleBarElement=this.CreateLayer(this.htmlElement, "STabWindowBarTitle", "100%", this.defaultTitleHeight, 0, "visible", "top", 0, 0, this.TitleBackColor, ""); this.LabelTitleBarElement=this.CreateLayer(this.TitleBarElement, "STabWindowLabelTitle", "100%", "100%", 100, "visible", "top", 0, 0, "", ""); this.setLabelTitleStyle(); this.TopBarElement=this.CreateLayer(this.htmlElement, "STabTopBar", "100%", this.defaultTopBarHeight, 100, "visible", "top", 0, this.defaultTitleHeight, this.TabTopBorderColor, ""); this.TopBarElement.style.borderBottom='1px solid black'; if (!pointer) { this.domEventsCapture=new SCaptureEntry(this.htmlElement); this.mousedownBinded=SEvent.InternalBind(this.domEventsCapture, "onmousedown", this, this.mouseDown); this.mupBinded=SEvent.InternalBind(this.domEventsCapture, "onmouseup", this, this.mouseUp); this.mmoveBinded=SEvent.InternalBind(this.domEventsCapture, "onmousemove", this, this.mouseMove); this.mouseDoubleClickHand=SEvent.attachDOM(this.TitleBarElement, 'dblclick', this.Minimize, this);   } this.WithPointer(pointer); this.CreateCloseButton();  }; SWindowInfo.prototype.mouseDown=function(e) { var button=e.button?e.button:e.which; var e=!e?event:e; var source=""; if (e.srcElement) { source=e.srcElement.id; } else { source=e.target.id; } if (source!="STabWindowLabelTitle") { return false; } if (e.preventDefault) { e.preventDefault(); } if (button==2) { this.dragging=false; return false; } if (!this.dragPoint) { this.dragPoint=new SGeoPoint(0, 0); } this.dragPoint.X=e.clientX; this.dragPoint.Y=e.clientY; this.dragging=true; if (this.htmlElement.setCapture) { this.htmlElement.setCapture(); } SwitchCursor(this.htmlElement,"move"); }; SWindowInfo.prototype.mouseUp=function(e) { this.dragging=false; SwitchCursor(this.htmlElement, "default"); this.TopBarElement.style.display=""; if(document.releaseCapture) { document.releaseCapture(); } }; SWindowInfo.prototype.mouseMove=function(e) { var mousePosition=new SGeoPoint(e.clientX, e.clientY); if (this.dragging) { this.TopBarElement.style.display="none"; var xp=this.Left + (mousePosition.X - this.dragPoint.X); var yp=this.Top + (mousePosition.Y - this.dragPoint.Y); this.moveTo(xp, yp); this.dragPoint.X=mousePosition.X; this.dragPoint.Y=mousePosition.Y; } }; SWindowInfo.prototype.moveTo=function(x,y) { x=Math.floor(x); y=Math.floor(y); if(this.Left!=x||this.Top!=y) {  this.Left=x; this.Top=y; this.htmlElement.style.left=toPixel(this.Left); this.htmlElement.style.top=toPixel(this.Top); } }; SWindowInfo.prototype.SetWindowLabel=function(LabelString) { if (LabelString&&typeof(LabelString)=="string") { this.Label=LabelString; } else { return; } var oTextNode=document.createTextNode(this.Label); this.LabelTitleBarElement.appendChild(oTextNode); oTextNode=null; }; SWindowInfo.prototype.removeAllTabs=function() { while(this.Tabs.length > 0) { this.RemoveTab(this.Tabs.length-1); } delete this.Tabs; }; SWindowInfo.prototype.WithPointer=function(flag) { if (flag&&flag==true) { if(this.MinimizeButtonLayer) { this.htmlElement.removeChild(this.MinimizeButtonLayer); this.MinimizeButtonLayer=false; } this.PivotImage=this.CreateImage("imgSPivotImage", SMAP_CONTROLS_PATH+"SWindowInfo/images/pointer.gif", 65, 55, 0, this.Height-(ie?2:0), "absolute"); SetSelectableStatus(this.PivotImage, "off"); this.htmlElement.appendChild(this.PivotImage); this.PivotImage.style.top=this.Height-(!ie?0:0)+"px"; this.AbsoluteHeight=parseInt(this.htmlElement.style.height) + parseInt(this.PivotImage.style.height); this.AbsoluteWidth=parseInt(this.htmlElement.style.height) + parseInt(this.PivotImage.style.height); this.PivotY=this.AbsoluteHeight; this.PivotX=0; } else { this.CreateMinimizeButton(); if (this.PivotImage) { this.htmlElement.removeChild(this.PivotImage); this.AbsoluteHeight=parseInt(this.htmlElement.style.height); this.AbsoluteWidth=parseInt(this.htmlElement.style.height); this.PivotY=0; this.PivotX=0; } this.PivotImage=null; } }; SWindowInfo.prototype.SetPixelPosition=function(left, top, xOffSet, yOffSet) { var left=!left?0:left; var top=!top?0:top; var xOffSet=!xOffSet?0:xOffSet; var yOffSet=!yOffSet?0:yOffSet; left=parseInt(left); top=parseInt(top); xOffSet=parseInt(xOffSet); yOffSet=parseInt(yOffSet); if(this.PivotX==0&&this.PivotY==0) { this.htmlElement.style.left=toPixel(left); this.htmlElement.style.top=toPixel(top); } else { this.htmlElement.style.left=toPixel(left+this.PivotX+xOffSet); this.htmlElement.style.top=toPixel(top-this.PivotY-yOffSet); } }; SWindowInfo.prototype.SetDegreePosition=function(longitude, latitude, xOffSet, yOffSet) { if (this.mapObject) { var latitude=parseFloat(latitude); var longitude=parseFloat(longitude); var xOffSet=parseInt(xOffSet); var yOffSet=parseInt(yOffSet); var point=new SGeoPoint(longitude, latitude); this.LatLongPosition=point; var pixelPoint=this.mapObject.getPixelOnGrid(point); this.SetPixelPosition(pixelPoint.X, pixelPoint.Y, xOffSet, yOffSet); } }; SWindowInfo.prototype.AddTab=function(label, url, closeButton) { var oTab=new STab(); try { var oTab=new STab(); oTab.Index=this.Tabs.length; oTab.Label=label; oTab.Url=url; oTab.closeButton=closeButton; this.Tabs.push(oTab); } catch(e) { oTab=null; } return this.CreateWindowTab(oTab); }; SWindowInfo.prototype.RemoveTab=function(index) { if (this.Tabs[index])  { SEvent.deattachDOM(this.Tabs[index], "mouseover", this.Tabs[index].hMouseOver); SEvent.deattachDOM(this.Tabs[index], "mouseout", this.Tabs[index].hMouseOut); SEvent.deattachDOM(this.Tabs[index], "click", this.Tabs[index].hMouseClick); SEvent.deattachDOM(this.Tabs[index].lashClose, "dblclick", this.Tabs[index].hMouseDblClick); this.Tabs[index].hMouseOver=null; this.Tabs[index].hMouseOut=null; this.Tabs[index].hMouseClick=null; this.Tabs[index].TabLashElement.oncontextmenu=""; this.Tabs[index].TabLashElement.oncontextmenu=null; this.TopBarElement.removeChild(this.Tabs[index].TabLashElement); this.TopBarElement.removeChild(this.Tabs[index].TabElement); this.Tabs[index].TabLashElement=null; this.Tabs[index].TabElement=null; this.Tabs[index]=null; this.Tabs.splice(index,1); for (i=0;i<this.Tabs.length;i++) { this.Tabs[i].Index=i; this.Tabs[i].TabLashElement.index=i; } this.SortTabs(); if (this.activeTab > 0) { this.SetActiveTab(this.activeTab-1); } else if(this.Tabs.length>0&&this.activeTab==0&&index==0) { this.activeTab=-1; this.SetActiveTab(0); } else { this.activeTab=-1; } } }; SWindowInfo.prototype.Show=function() { this.htmlElement.style.display="block"; if (!this.hide) { if (this.activeTab==-1) { this.SetActiveTab(0); } } }; SWindowInfo.prototype.Hide=function() { this.htmlElement.style.display="none"; this.hide=true; }; SWindowInfo.prototype.Close=function() { this.destroy(); try {   this.onWindowClose(); } catch(e) { } }; SWindowInfo.prototype.Minimize=function() { var currHeight=parseInt(this.htmlElement.style.height); var tb=parseInt(this.TitleBarElement.style.height)+2; if (currHeight==tb) { var newHeight=this.Height; this.htmlElement.style.overflow="visible"; this.TopBarElement.style.display=""; } else { var newHeight=tb; this.htmlElement.style.overflow="hidden"; this.TopBarElement.style.display="none"; } this.htmlElement.style.height=newHeight + "px"; }; SWindowInfo.prototype.GetTabDocument=function(index) { index=!index?0:parseInt(index); if (index > (this.Tabs.length-1) || index < 0) { return null; } var iframe=this.Tabs[index].TabElement.getElementsByTagName("iframe"); var doc=null; if (iframe) { var iframe=iframe[0]; if (ie) { doc=iframe.Document; } else if(ns6) { doc=iframe.contentDocument; } } return doc; }; SWindowInfo.prototype.CreateCloseButton=function() { this.CloseButtonLayer=this.CreateLayer(this.htmlElement, "STabWindowCloseButton", 10, 10, 10, "visible", "", (this.Width-15), 3, "", "", ""); SwitchCursor(this.CloseButtonLayer, "pointer"); this.CloseButtonLayer.title="Cerrar"; this.cbOnclick=SEvent.attachDOM(this.CloseButtonLayer, 'click', this.ButtonClosePressed, this); var buttonImage=this.CreateImage("imgSCloseWindowIMage", SMAP_CONTROLS_PATH+"SWindowInfo/images/close_button.gif", 10, 10, 0, 0, "relative"); SetSelectableStatus(buttonImage, "off"); this.CloseButtonLayer.appendChild(buttonImage); buttonImage=null; }; SWindowInfo.prototype.Resize=function(_width, _height) { this.htmlElement.style.display="none"; this.Height=_height; this.Width=_width; this.htmlElement.style.width=_width + "px"; this.htmlElement.style.height=_height + "px"; this.CloseButtonLayer.style.left=(this.Width-15)+"px"; var frameHeight=this.Height - (this.defaultTitleHeight + this.defaultTopBarHeight + (ie?3:1)); var frameWidth=this.Width - (ie?2:0); if (this.MinimizeButtonLayer) { this.MinimizeButtonLayer.style.left=(this.Width-30)+"px"; } this.htmlElement.style.overflow="visible"; this.TopBarElement.style.display=""; for (i=0;i<this.Tabs.length;i++) { var lastState=this.Tabs[i].TabElement.style.display; this.Tabs[i].TabElement.style.display="none"; this.Tabs[i].TabElement.style.height=(this.Height - (this.defaultTitleHeight+this.defaultTopBarHeight)-5) + "px"; var iframe=this.Tabs[i].TabElement.getElementsByTagName("iframe"); if (iframe.length>0) { iframe=iframe[0]; iframe.style.width=toPixel(frameWidth); iframe.style.height=toPixel(frameHeight); } iframe=null; this.Tabs[i].TabElement.style.display=lastState; } if (this.PivotImage) { this.PivotImage.style.top=this.Height-(!ie?2:0)+"px"; } this.htmlElement.style.display=""; }; SWindowInfo.prototype.cancelBehaviour=function(e) { if(e.srcElement ) { e.cancelBubble=true; e.returnValue=false; } else if(e.preventDefault) { e.stopPropagation(); e.preventDefault(); } return false; }; SWindowInfo.prototype.CreateMinimizeButton=function() { this.MinimizeButtonLayer=this.CreateLayer(this.htmlElement, "STabWindowCloseButton", 10, 10, 10, "visible", "", (this.Width-30), 3, "", "", ""); SwitchCursor(this.MinimizeButtonLayer, "pointer"); this.minbtnclk=SEvent.attachDOM(this.MinimizeButtonLayer, 'click', this.ButtonMinimizePressed, this); var buttonImage=this.CreateImage("imgSMinimizeWindowIMage", SMAP_CONTROLS_PATH+"SWindowInfo/images/minimize_button.gif", 10, 10, 0, 0, "relative"); SetSelectableStatus(buttonImage, "off"); this.MinimizeButtonLayer.appendChild(buttonImage); buttonImage=null; }; SWindowInfo.prototype.ButtonClosePressed=function(e) { this.Close(); return false; }; SWindowInfo.prototype.ButtonMinimizePressed=function(e) { if (!this.PivotImage) { this.Minimize(); } }; SWindowInfo.prototype.setLabelTitleStyle=function() { this.LabelTitleBarElement.style.marginLeft="5px"; this.LabelTitleBarElement.style.marginTop="2px"; this.LabelTitleBarElement.style.fontFamily=this.TitleFont; this.LabelTitleBarElement.style.fontSize="10px"; this.LabelTitleBarElement.style.color=this.TitleFontColor; this.LabelTitleBarElement.style.fontWeight="normal"; SetSelectableStatus(this.LabelTitleBarElement, "off"); this.SetWindowLabel(); }; SWindowInfo.prototype.setLashStyle=function(lash, style) { switch(style) { case "active": lash.style.marginLeft="3px"; lash.style.fontFamily=this.ActiveTabFont; lash.style.color=this.ActiveTabFontColor; lash.style.backgroundColor=this.ActiveTabBackColor; lash.style.fontSize="11px"; lash.style.fontWeight="bold"; lash.style.borderTop='1px solid black'; lash.style.borderLeft='1px solid black'; lash.style.borderRight='1px solid black'; break; case "inactive": default: lash.style.marginLeft="3px"; lash.style.fontFamily=this.InactiveTabFont; lash.style.fontWeight="normal"; lash.style.color=this.InactiveTabFontColor; lash.style.backgroundColor=this.InactiveTabBackColor; lash.style.fontSize="11px"; lash.style.borderTop='0px solid black'; lash.style.borderLeft='0px solid black'; lash.style.borderRight='0px solid black'; } }; SWindowInfo.prototype.SetActiveTab=function(index) { var tmpActiveTab=this.activeTab; if (this.activeTab!=index) { index=parseInt(index); if (index>this.Tabs.length||index<0) { return; } for (i=0;i<this.Tabs.length;i++) { if (i==index) { this.Tabs[i].TabLashElement.style.zIndex=1; this.Tabs[i].TabElement.style.zIndex=1; this.Tabs[i].TabElement.style.display=""; this.Tabs[i].lashClose.style.display=""; this.setLashStyle(this.Tabs[i].TabLashElement, "active"); } else { this.Tabs[i].TabLashElement.style.zIndex=0; this.Tabs[i].TabElement.style.zIndex=0; this.Tabs[i].TabElement.style.display="none"; this.setLashStyle(this.Tabs[i].TabLashElement, "inactive"); this.Tabs[i].lashClose.style.display="none"; } if (!this.Tabs[i].closeButton) this.Tabs[i].lashClose.style.display="none"; } this.activeTab=index; } }; SWindowInfo.prototype.SortTabs=function() { for (i=0;i<this.Tabs.length;i++) { if (i==0) { position=3; var anchoAcumulado=30; } else { position=(parseInt(this.Tabs[i-1].TabLashElement.style.left) + parseInt(this.Tabs[i-1].TabLashElement.style.width)) + 1; } var anchoAcumulado=anchoAcumulado + parseInt(this.Tabs[i].TabLashElement.style.width); this.Tabs[i].TabLashElement.style.left=position + "px"; } if ((this.Width - anchoAcumulado)<0) { this.Resize(anchoAcumulado, this.Height); } }; SWindowInfo.prototype.CreateWindowTab=function(objectTab) { if (objectTab) { var frameHeight=this.Height - (this.defaultTitleHeight + this.defaultTopBarHeight + (ie?3:1)); var frameWidth=this.Width - (ie?2:0); if (this.PivotImage) { var page="<iframe scrolling='no' frameborder='0' width='"+frameWidth+"px' height='"+ frameHeight +"px' src='about:blank' style='z-index:0; width:"+frameWidth+"px; height:"+frameHeight+"px;'></iframe>"; } else { var page="<iframe scrolling='auto' frameborder='0' width='"+frameWidth+"px' height='"+frameHeight+"px' src='about:blank' style='z-index:0; width:"+frameWidth+"px; height:"+frameHeight+"px;'></iframe>"; } if (document.all) { var topforLash=parseInt(this.TopBarElement.style.height) - 15; } else { var topforLash=parseInt(this.TopBarElement.style.height) - 15; } objectTab.TabLashElement=this.CreateLayer(this.TopBarElement, "STabLash"+objectTab.Index, (objectTab.Label.length*9), 15, 1, "visible", "", 0, topforLash, this.ActiveTabBackColor, "", ""); this.setLashStyle(objectTab.TabLashElement); objectTab.lashClose=this.CreateImage("imgSCloseTabIMage", SMAP_CONTROLS_PATH+"SWindowInfo/images/close_button.gif", 10, 10, 0, 0, "absolute"); SetSelectableStatus(objectTab.lashClose, "off"); objectTab.lashClose.style.left=""; objectTab.lashClose.style.right="2px"; objectTab.lashClose.style.top="2px"; objectTab.lashClose.style.display="none"; objectTab.hMouseDblClick=SEvent.attachDOM(objectTab.lashClose, 'click', this.onTabDblClick, this, objectTab); objectTab.TabLashElement.appendChild(objectTab.lashClose); objectTab.TabLashElement.style.textAlign="center"; SwitchCursor(objectTab.TabLashElement, "pointer"); objectTab.TabLashElement.index=objectTab.Index; objectTab.hMouseOver=SEvent.attachDOM(objectTab.TabLashElement, 'mouseover', function(){this.style.fontWeight="bold";}, objectTab.TabLashElement); objectTab.hMouseOut=SEvent.attachDOM(objectTab.TabLashElement, 'mouseout', function(){this.style.fontWeight="normal";}, objectTab.TabLashElement); objectTab.hMouseClick=SEvent.attachDOM(objectTab.TabLashElement, 'click', this.onTabClick, this, objectTab); objectTab.TabLashElement.oncontextmenu=function(){return false;}; var oTextNode=document.createTextNode(objectTab.Label); objectTab.TabLashElement.appendChild(oTextNode); oTextNode=null; SetSelectableStatus(objectTab.TabLashElement, "off"); objectTab.TabElement=this.CreateLayer(this.TopBarElement, "STabP", "100%", this.Height - (this.defaultTitleHeight+this.defaultTopBarHeight)-5 , -1, "visible", "", 0, 21, this.ActiveTabBackColor, "", ""); objectTab.TabElement.style.display="none"; objectTab.TabElement.style.visibility=""; objectTab.TabElement.innerHTML=page; var iframe=objectTab.TabElement.getElementsByTagName("iframe"); iframe[0].src=objectTab.Url; objectTab.TabElement.style.margin=toPixel(0); objectTab.TabElement.style.marginTop=(ie?toPixel(-1):toPixel(0)); if(objectTab.Index==0) { this.SetActiveTab(0); } this.SortTabs(); iframe=null; topforLash=null; } return objectTab; }; SWindowInfo.prototype.onTabDblClick=function(e, obj) { if (this.Tabs.length>1) {  this.RemoveTab(obj.Index);  this.SortTabs(); } }; SWindowInfo.prototype.onTabClick=function(e, obj) { this.SetActiveTab(obj.Index); try { this.OnTabSelected(obj.Index); } catch(e){} }; SWindowInfo.prototype.CreateImage=function (id, src, height, width, left, top, position) { oimg=document.createElement("IMG"); oimg.id=id; oimg.style.position=position; oimg.style.left=toPixel(parseInt(left)); oimg.style.top=toPixel(parseInt(top)); oimg.style.width=toPixel(parseInt(width)); oimg.style.height=toPixel(parseInt(height)); oimg.style.border=0; oimg.src=src; oimg.style.visibility="inherit"; return oimg; }; SWindowInfo.prototype.CreateLayer=function (Container, Id, Width, Height, zIndex, Overflow, BackgroundAlign, Left, Top, BackColor, BackgroundImage, Border) { Height=Height.toString().indexOf("%")!=-1?Height:Height+"px"; Width=Width.toString().indexOf("%")!=-1?Width:Width+"px"; Border=!Border?"none black 0px":Border; oDiv=document.createElement("DIV"); oDiv.id=Id; oDiv.style.position="absolute"; oDiv.style.left=toPixel(Left); oDiv.style.top=toPixel(Top); oDiv.style.width=Width; oDiv.style.border=Border; oDiv.style.height=Height; oDiv.style.zIndex=zIndex; oDiv.style.visibility="inherit"; oDiv.style.backgroundColor=BackColor; if (BackgroundImage||BackgroundImage!="") { oDiv.style.backgroundRepeat="no-repeat"; oDiv.style.backgroundPosition=BackgroundAlign; oDiv.style.backgroundImage="url("+BackgroundImage+")"; } oDiv.style.overflow=Overflow; Container.appendChild(oDiv); return oDiv; }; SWindowInfo.prototype.mapchangelevel=function(level) { if (this.mapObject) { this.SetDegreePosition(this.LatLongPosition.X, this.LatLongPosition.Y, 0,0); } }; SWindowInfo.prototype.mapclick=function() { if (this.mapObject) { this.Close(); } }; SWindowInfo.prototype.closeButtonVisibility=function(value) { if (!value) { this.CloseButtonLayer.style.display="none"; } else { this.CloseButtonLayer.style.display=""; } };  SWindowInfo.prototype.minimizeButtonVisibility=function(value) { if (!value) { this.MinimizeButtonLayer.style.display="none"; } else { this.MinimizeButtonLayer.style.display=""; } };   
function ScaleBar(scaleDenominator)  { this.scaleDenominator=(scaleDenominator==null) ? 1 : scaleDenominator;     this.displaySystem='metric';      this.minWidth=100;      this.maxWidth=200;      this.divisions=2;     this.subdivisions=2;     this.showMinorMeasures=false;     this.abbreviateLabel=false;     this.singleLine=false;     this.resolution=72;      this.align='left';      this.container=document.createElement('div');     this.container.className='sbWrapper';     this.labelContainer=document.createElement('div');     this.labelContainer.className='sbUnitsContainer';     this.labelContainer.style.position='absolute';     this.graphicsContainer=document.createElement('div');     this.graphicsContainer.style.position='absolute';     this.graphicsContainer.className='sbGraphicsContainer';     this.numbersContainer=document.createElement('div');     this.numbersContainer.style.position='absolute';     this.numbersContainer.className='sbNumbersContainer';     var markerMajor=document.createElement('div');     markerMajor.className='sbMarkerMajor';     this.graphicsContainer.appendChild(markerMajor);     var markerMinor=document.createElement('div');     markerMinor.className='sbMarkerMinor';     this.graphicsContainer.appendChild(markerMinor);     var barPiece=document.createElement('div');     barPiece.className='sbBar';     this.graphicsContainer.appendChild(barPiece);     var barPieceAlt=document.createElement('div');     barPieceAlt.className='sbBarAlt';     this.graphicsContainer.appendChild(barPieceAlt); }; ScaleBar.prototype.update=function(scaleDenominator)  {     if(scaleDenominator !=null)      {         this.scaleDenominator=scaleDenominator;     }     function HandsomeNumber(smallUglyNumber, bigUglyNumber, sigFigs)      {         var sigFigs=(sigFigs==null) ? 10 : sigFigs;         var bestScore=Number.POSITIVE_INFINITY;         var bestTieBreaker=Number.POSITIVE_INFINITY;         var handsomeValue=smallUglyNumber;         var handsomeNumDec=3;         for(var halvingExp=0; halvingExp < 3; ++halvingExp)          {             var comelyMultiplicand=Math.pow(2, (-1 * halvingExp));             var maxTensExp=Math.floor(Math.log(bigUglyNumber / comelyMultiplicand) / Math.LN10);             for(var tensExp=maxTensExp; tensExp > (maxTensExp - sigFigs + 1); --tensExp)              {                 var numDec=Math.max(halvingExp - tensExp, 0);                 var testMultiplicand=comelyMultiplicand * Math.pow(10, tensExp);                 if((testMultiplicand * Math.floor(bigUglyNumber / testMultiplicand)) >=smallUglyNumber)                  {                     if(smallUglyNumber % testMultiplicand==0)    {                         var testMultiplier=smallUglyNumber / testMultiplicand;                     }                     else                      {                         var testMultiplier=Math.floor(smallUglyNumber / testMultiplicand) + 1;                     }                     var testScore=testMultiplier + (2 * halvingExp);                     var testTieBreaker=(tensExp < 0) ? (Math.abs(tensExp) + 1) : tensExp;                     if((testScore < bestScore) || ((testScore==bestScore) && (testTieBreaker < bestTieBreaker)))                      {                         bestScore=testScore;                         bestTieBreaker=testTieBreaker;                         handsomeValue=(testMultiplicand * testMultiplier).toFixed(numDec);                         handsomeNumDec=numDec;                     }                 }             }         }         this.value=handsomeValue;         this.score=bestScore;         this.tieBreaker=bestTieBreaker;         this.numDec=handsomeNumDec;     }     HandsomeNumber.prototype.toString=function()   {         return this.value.toString();     };     HandsomeNumber.prototype.valueOf=function()   {         return this.value;     };     function styleValue(aSelector, styleKey)   {         var aValue=0;         if(document.styleSheets)    {             for(var sheetIndex=document.styleSheets.length - 1; sheetIndex >=0; --sheetIndex)  {                 var aSheet=document.styleSheets[sheetIndex];             }         }         return aValue ? aValue : 0;     };     function formatNumber(aNumber, numDecimals)   {         numDecimals=(numDecimals) ? numDecimals : 0;         var formattedInteger='' + Math.round(aNumber);         var thousandsPattern=/(-?[0-9]+)([0-9]{3})/;         while(thousandsPattern.test(formattedInteger))    {             formattedInteger=formattedInteger.replace(thousandsPattern, '$1,$2');         }         if(numDecimals > 0)    {             var formattedDecimal=Math.floor(Math.pow(10, numDecimals) * (aNumber - Math.round(aNumber)));             if(formattedDecimal==0)  {                 return formattedInteger;             }             else  {                 return formattedInteger + '.' + formattedDecimal;             }         }         else    {             return formattedInteger;         }     };     this.container.title='scale 1:' + formatNumber(this.scaleDenominator);     var measurementProperties=new Object();     measurementProperties.english= {         units: ['miles', 'feet', 'inches'],         abbr: ['mi', 'ft', 'in'],         inches: [63360, 12, 1]     };     measurementProperties.metric= {        units: ['kilometros', 'metros', 'centimetros'],         abbr: ['km', 'm', 'cm'],         inches: [39370.07874, 39.370079, 0.393701]     };     var comparisonArray=new Array();     for(var unitIndex=0; unitIndex < measurementProperties[this.displaySystem].units.length; ++unitIndex)      {         comparisonArray[unitIndex]=new Object();         var pixelsPerDisplayUnit=this.resolution * measurementProperties[this.displaySystem].inches[unitIndex] / this.scaleDenominator;         var minSDDisplayLength=(this.minWidth / pixelsPerDisplayUnit) / (this.divisions * this.subdivisions);         var maxSDDisplayLength=(this.maxWidth / pixelsPerDisplayUnit) / (this.divisions * this.subdivisions);         for(var valueIndex=0; valueIndex < (this.divisions * this.subdivisions); ++valueIndex)          {             var minNumber=minSDDisplayLength * (valueIndex + 1);             var maxNumber=maxSDDisplayLength * (valueIndex + 1);             var niceNumber=new HandsomeNumber(minNumber, maxNumber);             comparisonArray[unitIndex][valueIndex]={value: (niceNumber.value / (valueIndex + 1)), score: 0, tieBreaker: 0, numDec: 0, displayed: 0};             for(var valueIndex2=0; valueIndex2 < (this.divisions * this.subdivisions); ++valueIndex2)              {                 displayedValuePosition=niceNumber.value * (valueIndex2 + 1) / (valueIndex + 1);                 niceNumber2=new HandsomeNumber(displayedValuePosition, displayedValuePosition);                 var isMajorMeasurement=((valueIndex2 + 1) % this.subdivisions==0);                 var isLastMeasurement=((valueIndex2 + 1)==(this.divisions * this.subdivisions)); if((this.singleLine && isLastMeasurement) || (!this.singleLine && (isMajorMeasurement || this.showMinorMeasures)))                  {                     comparisonArray[unitIndex][valueIndex].score +=niceNumber2.score;                     comparisonArray[unitIndex][valueIndex].tieBreaker +=niceNumber2.tieBreaker;                     comparisonArray[unitIndex][valueIndex].numDec=Math.max(comparisonArray[unitIndex][valueIndex].numDec, niceNumber2.numDec);                     comparisonArray[unitIndex][valueIndex].displayed +=1;                 }                 else                  {                     comparisonArray[unitIndex][valueIndex].score +=niceNumber2.score / this.subdivisions;                     comparisonArray[unitIndex][valueIndex].tieBreaker +=niceNumber2.tieBreaker / this.subdivisions;                 }             }             var scoreAdjustment=(unitIndex + 1) * comparisonArray[unitIndex][valueIndex].tieBreaker / comparisonArray[unitIndex][valueIndex].displayed;             comparisonArray[unitIndex][valueIndex].score *=scoreAdjustment;         }     }     var subdivisionDisplayLength=null;     var displayUnits=null;     var displayUnitsAbbr=null;     var subdivisionPixelLength=null;     var bestScore=Number.POSITIVE_INFINITY;     var bestTieBreaker=Number.POSITIVE_INFINITY;     var numDec=0;     for(var unitIndex=0; unitIndex < comparisonArray.length; ++unitIndex)      {         for(valueIndex in comparisonArray[unitIndex])          {             if((comparisonArray[unitIndex][valueIndex].score < bestScore) || ((comparisonArray[unitIndex][valueIndex].score==bestScore) && (comparisonArray[unitIndex][valueIndex].tieBreaker < bestTieBreaker)))              {                 bestScore=comparisonArray[unitIndex][valueIndex].score;                 bestTieBreaker=comparisonArray[unitIndex][valueIndex].tieBreaker;                 subdivisionDisplayLength=comparisonArray[unitIndex][valueIndex].value;                 numDec=comparisonArray[unitIndex][valueIndex].numDec;                 displayUnits=measurementProperties[this.displaySystem].units[unitIndex];                 displayUnitsAbbr=measurementProperties[this.displaySystem].abbr[unitIndex];                 pixelsPerDisplayUnit=this.resolution * measurementProperties[this.displaySystem].inches[unitIndex] / this.scaleDenominator;                 subdivisionPixelLength=pixelsPerDisplayUnit * subdivisionDisplayLength;              }         }     }     var xOffsetMarkerMajor=(styleValue('.sbMarkerMajor', 'borderLeftWidth') + styleValue('.sbMarkerMajor', 'width') + styleValue('.sbMarkerMajor', 'borderRightWidth')) / 2;     var xOffsetMarkerMinor=(styleValue('.sbMarkerMinor', 'borderLeftWidth') + styleValue('.sbMarkerMinor', 'width') + styleValue('.sbMarkerMinor', 'borderRightWidth')) / 2;     var xOffsetBar=(styleValue('.sbBar', 'borderLeftWidth') + styleValue('.sbBar', 'borderRightWidth')) / 2;     var xOffsetBarAlt=(styleValue('.sbBarAlt', 'borderLeftWidth') + styleValue('.sbBarAlt', 'borderRightWidth')) / 2;  if(!document.styleSheets)      {         xOffsetMarkerMajor=0.5;         xOffsetMarkerMinor=0.5;     }     while(this.labelContainer.hasChildNodes())      {         this.labelContainer.removeChild(this.labelContainer.firstChild);     }     while(this.graphicsContainer.hasChildNodes())      {         this.graphicsContainer.removeChild(this.graphicsContainer.firstChild);     }     while(this.numbersContainer.hasChildNodes())      {         this.numbersContainer.removeChild(this.numbersContainer.firstChild);     }     var aMarker, aBarPiece, numbersBox, xOffset;     var alignmentOffset= {         left: 0,         center: (-1 * this.divisions * this.subdivisions * subdivisionPixelLength / 2),         right: (-1 * this.divisions * this.subdivisions * subdivisionPixelLength)     };     var xPosition=0 + alignmentOffset[this.align];     var markerMeasure=0;     for(var divisionIndex=0; divisionIndex < this.divisions; ++divisionIndex)      {         xPosition=divisionIndex * this.subdivisions * subdivisionPixelLength;         xPosition +=alignmentOffset[this.align];         markerMeasure=(divisionIndex==0) ? 0 : ((divisionIndex * this.subdivisions) * subdivisionDisplayLength).toFixed(numDec);         aMarker=document.createElement('div');         aMarker.className='sbMarkerMajor';         aMarker.style.position='absolute';         aMarker.style.overflow='hidden';         aMarker.style.left=Math.round(xPosition - xOffsetMarkerMajor) + 'px';         aMarker.appendChild(document.createTextNode(' '));         this.graphicsContainer.appendChild(aMarker);         if(!this.singleLine)    {             numbersBox=document.createElement('div');             numbersBox.className='sbNumbersBox';             numbersBox.style.position='absolute';             numbersBox.style.overflow='hidden';             numbersBox.style.textAlign='center';             if(this.showMinorMeasures)  {                 numbersBox.style.width=Math.round(subdivisionPixelLength * 2) + 'px';                 numbersBox.style.left=Math.round(xPosition - subdivisionPixelLength) + 'px';             }             else  {                 numbersBox.style.width=Math.round(this.subdivisions * subdivisionPixelLength * 2) + 'px';                 numbersBox.style.left=Math.round(xPosition - (this.subdivisions * subdivisionPixelLength)) + 'px';             }             numbersBox.appendChild(document.createTextNode(markerMeasure));             this.numbersContainer.appendChild(numbersBox);         }         for(var subdivisionIndex=0; subdivisionIndex < this.subdivisions; ++subdivisionIndex)    {             aBarPiece=document.createElement('div');             aBarPiece.style.position='absolute';             aBarPiece.style.overflow='hidden';             aBarPiece.style.width=Math.round(subdivisionPixelLength) + 'px';             if((subdivisionIndex % 2)==0)  {                 aBarPiece.className='sbBar';                 aBarPiece.style.left=Math.round(xPosition - xOffsetBar) + 'px';             }             else  {                 aBarPiece.className='sbBarAlt';                 aBarPiece.style.left=Math.round(xPosition - xOffsetBarAlt) + 'px';             }             aBarPiece.appendChild(document.createTextNode(' '));             this.graphicsContainer.appendChild(aBarPiece);             if(subdivisionIndex < (this.subdivisions - 1))  {                 xPosition=((divisionIndex * this.subdivisions) + (subdivisionIndex + 1)) * subdivisionPixelLength;                 xPosition +=alignmentOffset[this.align];                 markerMeasure=(divisionIndex * this.subdivisions + subdivisionIndex + 1) * subdivisionDisplayLength;                 aMarker=document.createElement('div');                 aMarker.className='sbMarkerMinor';                 aMarker.style.position='absolute';                 aMarker.style.overflow='hidden';                 aMarker.style.left=Math.round(xPosition - xOffsetMarkerMinor) + 'px';                 aMarker.appendChild(document.createTextNode(' '));                 this.graphicsContainer.appendChild(aMarker);                 if(this.showMinorMeasures && !this.singleLine)   {                     numbersBox=document.createElement('div');                     numbersBox.className='sbNumbersBox';                     numbersBox.style.position='absolute';                     numbersBox.style.overflow='hidden';                     numbersBox.style.textAlign='center';                     numbersBox.style.width=Math.round(subdivisionPixelLength * 2) + 'px';                     numbersBox.style.left=Math.round(xPosition - subdivisionPixelLength) + 'px';                     numbersBox.appendChild(document.createTextNode(markerMeasure));                     this.numbersContainer.appendChild(numbersBox);                 }             }         }     }     xPosition=(this.divisions * this.subdivisions) * subdivisionPixelLength;     xPosition +=alignmentOffset[this.align];     markerMeasure=((this.divisions * this.subdivisions) * subdivisionDisplayLength).toFixed(numDec);     aMarker=document.createElement('div');     aMarker.className='sbMarkerMajor';     aMarker.style.position='absolute';     aMarker.style.overflow='hidden';     aMarker.style.left=Math.round(xPosition - xOffsetMarkerMajor) + 'px';     aMarker.appendChild(document.createTextNode(' '));     this.graphicsContainer.appendChild(aMarker);     if(!this.singleLine)      {         numbersBox=document.createElement('div');         numbersBox.className='sbNumbersBox';         numbersBox.style.position='absolute';         numbersBox.style.overflow='hidden';         numbersBox.style.textAlign='center';         if(this.showMinorMeasures)          {             numbersBox.style.width=Math.round(subdivisionPixelLength * 2) + 'px';             numbersBox.style.left=Math.round(xPosition - subdivisionPixelLength) + 'px';         }         else          {             numbersBox.style.width=Math.round(this.subdivisions * subdivisionPixelLength * 2) + 'px';             numbersBox.style.left=Math.round(xPosition - (this.subdivisions * subdivisionPixelLength)) + 'px';         }         numbersBox.appendChild(document.createTextNode(markerMeasure));         this.numbersContainer.appendChild(numbersBox);     }     var labelBox=document.createElement('div');     labelBox.style.position='absolute';     var labelText;     if(this.singleLine)      {         labelText=markerMeasure;         labelBox.className='sbLabelBoxSingleLine';         labelBox.style.top='-0.6em';         labelBox.style.left=(xPosition + 10) + 'px';     }     else      {         labelText='';         labelBox.className='sbLabelBox';         labelBox.style.textAlign='center';         labelBox.style.width=Math.round(this.divisions * this.subdivisions * subdivisionPixelLength) + 'px';         labelBox.style.left=Math.round(alignmentOffset[this.align]) + 'px';         labelBox.style.overflow='hidden';     }     if(this.abbreviateLabel)      {         labelText +=' ' + displayUnitsAbbr;     }     else      {         labelText +=' ' + displayUnits;     }     labelBox.appendChild(document.createTextNode(labelText));     this.labelContainer.appendChild(labelBox);     if(!document.styleSheets)      {         var defaultStyle=document.createElement('style');         defaultStyle.type='text/css';         var styleText='.sbBar {top: 0px; background: #666666; height: 1px; border: 0;}';         styleText +='.sbBarAlt {top: 0px; background: #666666; height: 1px; border: 0;}';         styleText +='.sbMarkerMajor {height: 7px; width: 1px; background: #666666; border: 0;}';         styleText +='.sbMarkerMinor {height: 5px; width: 1px; background: #666666; border: 0;}';         styleText +='.sbLabelBox {top: -16px;}';         styleText +='.sbNumbersBox {top: 7px;}';         defaultStyle.appendChild(document.createTextNode(styleText));         document.getElementsByTagName('head').item(0).appendChild(defaultStyle);     }     this.container.appendChild(this.graphicsContainer);     this.container.appendChild(this.labelContainer);     this.container.appendChild(this.numbersContainer); }; ScaleBar.prototype.place=function(elementId)  {     if(elementId==null)      { document.body.appendChild(this.container);     }     else      { var anElement=document.getElementById(elementId); if(anElement !=null)  { anElement.appendChild(this.container); }     }     this.update(); }; 
