function toggleDisplay(divid){var element=document.getElementById(divid);if(element.style.display==''){element.style.display='none';}else{element.style.display='';}}
function setDisplay(divid,display){document.getElementById(divid).style.display=display;}
var latLongs={};function addLatLong(id,latitude,longitude){latLongs[id]={};latLongs[id].latitude=latitude;latLongs[id].longitude=longitude;}
function MapSystem(mapImageOverlay,mapImageWidth,mapImageHeight,latitudeTop,latitudeBottom,longitudeTopLeft,longitudeTopRight,longitudeBottomLeft,longitudeBottomRight,pointerWidthCenter,pointerHeightCenter){this.mapImageOverlay=mapImageOverlay;this.mapImageWidth=mapImageWidth;this.mapImageHeight=mapImageHeight;this.pointerWidthCenter=pointerWidthCenter;this.pointerHeightCenter=pointerHeightCenter;this.latitude={};this.latitude.top=latitudeTop;this.latitude.bottom=latitudeBottom;this.totalLatitude=latitudeBottom-latitudeTop;this.longitude={};this.longitude.top={};this.longitude.bottom={};this.longitude.top.left=longitudeTopLeft;this.longitude.top.right=longitudeTopRight;this.longitude.bottom.left=longitudeBottomLeft;this.longitude.bottom.right=longitudeBottomRight;this.topLongitude=longitudeTopRight-longitudeTopLeft;this.bottomLongitude=longitudeBottomRight-longitudeBottomLeft;}
MapSystem.prototype.calculateCoordinates=function(latitude,longitude){var temp={};var topLongitudeRatio=this.mapImageWidth/this.topLongitude;var verticalPercentage=(latitude-this.latitude.top)/this.totalLatitude;temp.top=Math.round(verticalPercentage*this.mapImageHeight);y1=this.latitude.top-latitude;y2=this.latitude.top-this.latitude.bottom;x1=((longitude-this.longitude.top.left)/this.topLongitude);x2=((longitude-this.longitude.bottom.left)/this.bottomLongitude);x3=x2-x1;d1=Math.atan(x3/y2);x5=y1*Math.tan(d1)
temp.left=Math.round((x5*this.longitude.top.left+longitude-this.longitude.top.left)*topLongitudeRatio);var horizontalModifier=(x1*(1-verticalPercentage))+(x2*(verticalPercentage));temp.left=Math.round(horizontalModifier*this.mapImageWidth);return temp;}
MapSystem.prototype.setLocation=function(latitude,longitude){if(latitude!=0){var temp=this.calculateCoordinates(latitude,longitude);this.mapImageOverlay.style.top=(temp.top-this.pointerHeightCenter)-this.mapImageHeight+'px';this.mapImageOverlay.style.left=(temp.left-this.pointerWidthCenter)+'px';this.mapImageOverlay.style.visibility='visible';}else{this.mapImageOverlay.style.visibility='hidden';}}
MapSystem.prototype.doLocation=function(id){this.setLocation(latLongs[id].latitude,latLongs[id].longitude);}
