var austinmap = null;
var mapdiv = null;
var newimgdiv = null; // HTML Element to receive new images
var topOff = 10;
var leftOff = 10;
var clipTop = 0;
var time,xamount,yamount,theTime,theHeight,DHTML;
var counter1 = 0;
//number of ms to wait until event clear calls
eventClearTime = 1000;
var dummyimg = null;
var text = null;
// browser warning vars
var warningHeight = 40;
var showWarning = false;
var warning = null;
// event handler vars
var ie55up = false;
var ie55down = false;
var ie = false;
var isSafari = false;
//document.write('
');
//document.write('
Click on a + to load a picture, or click elsewhere on the map to zoom in. This version of the map is still under development. If you like, you can still use the old Java applet version.
');
document.write('You are using a nonstandard browser. An administrator has been alerted and we will try to add support for your browser as soon as possible. In the meantime, please consider upgrading to a more friendly browser such as Mozilla\'s Firefox. You can also try using the old Java version of the map applet. Check back soon.
');
return;
}
var agt = navigator.userAgent.toLowerCase();
var IE = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
ie = IE;
var IE3 = (IE && (parseInt(navigator.appVersion) < 4));
var IE4 = (IE && (parseInt(navigator.appVersion) == 4) && (agt.indexOf("msie4")!=-1));
var IE5 = (IE && (parseInt(navigator.appVersion) == 4) && (agt.indexOf("msie 5.0")!=-1) );
ie55up = (IE && !(IE3) && !(IE4) && !(IE5));
ie55down = (IE && !ie55up);
isSafari = navigator.userAgent.toLowerCase().indexOf('safari') != -1;
return true;
}
/* function void init_displayBrowserWarnings()
Displays warnings about the browser being outdated, if necessary.
*/
function init_displayBrowserWarnings()
{
warning = new getObj('browserwarning');
warning.style.position = 'absolute';
warning.style.overflow = 'hidden';
if (ie55down)
{
showWarning = true;
parent.left.location = "browsers.php";
}
else
{
warning.style.height = 0;
if (warning.style.display)
warning.style.display = "none";
}
return true;
}
/* function void init_setEventHandler()
Registers the event handler function.
*/
function init_setEventHandler()
{
mapdiv = new getObj('map');
if (document.getElementById || document.all) // mozilla & IE start here
{
if (window.captureEvents) window.captureEvents(Event.Click | Event.DblClick | Event.MouseDown | Event.MouseMove | Event.MouseOut | Event.MouseUp | Event.Resize);
mapdiv.obj.onclick = eventHandler;
mapdiv.obj.ondblclick = eventHandler;
mapdiv.obj.onmousedown = eventHandler;
mapdiv.obj.onmousemove = eventHandler;
mapdiv.obj.onmouseout = eventHandler;
mapdiv.obj.onmouseup = eventHandler;
window.onresize = eventHandler;
}
return true;
}
/* function void init_setMapDivStyle()
Sets the style values for the map div.
*/
function init_setMapDivStyle()
{
mapdiv.style.visibility = 'visible';
mapdiv.style.position = 'absolute';
mapdiv.style.top = showWarning ? (topOff + warningHeight) : topOff;
mapdiv.style.width = 486;
mapdiv.style.height = showWarning ? (486 - warningHeight) : 486;
mapdiv.style.overflow = 'hidden';
return true;
}
/* function void addImage()
Adds an image to the mapdiv.
*/
function addImage()
{
newimgdiv.appendChild(document.createElement('img'));
//mapdiv.obj.appendChild(document.createElement('img'));
}
/* function void addObjectToMap(String elem)
Adds a new HTML element to the mapdiv object.
*/
function addObjectToMap(elem)
{
mapdiv.obj.appendChild(document.createElement(elem));
}
/* function number cap(number val, number maxval)
Caps the value of val at maxval;
i.e. returns the lesser of val and maxval.
*/
function cap(val, maxval)
{
if (val > maxval) return maxval;
return val;
}
function centerOn(val)
{
aMap().centerOn(val);
}
function contributeMode()
{
aMap().contributeMode();
}
/* function number cup(number val, number minval)
Cups the value of val at minval;
i.e. returns the greater of val and minval;
*/
function cup(val, minval)
{
if (val < minval) return minval;
return val;
}
//! DEPRECATED: object-orient into AustinMap
/* function void eventHandler(Event e)
Handles events.
*/
function eventHandler(e)
{
aMap().eventHandler(e);
}
/* public Object getObj(String name)
Returns an HTML element, with the object stored in this.obj and its style element stored in this.style.
*/
function getObj(name)
{
if (document.getElementById)
{
/* mozilla uses this one */
//if (!document.getElementById(name)) alert('Object not found: ' + name);
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all)
{
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers)
{
this.obj = document.layers[name];
this.style = document.layers[name];
}
}
/* function void hideWarning()
Hides the outdated browser warning message.
*/
function hideWarning()
{
showWarning = false;
warning.style.height = 0;
if (warning.style.display)
warning.style.display = "none";
map.style.top = topOff;
austinmap.paint();
}
/* public HotImage HotImage([int left, int top, int width, int height, String src, [boolean hot]])
Initializes a HotImage.
*/
var docimgsidx = 0;
function HotImage()
{
addImage();
this.imag = document.images[docimgsidx];
++docimgsidx;
this.imag.style.position = 'absolute';
if (!ie55down) this.imag.style.cursor = 'pointer';
this.imag.style.overflow = 'hidden';
this.arean = new Square(0, 0, 0, 0);
this.contains = HotImage_contains;
this.height = HotImage_height;
this.hot = HotImage_hot;
this.i2 = null
this.idx = null;
this.j2 = null
this.left = HotImage_left;
// toggle hotimage active
this.on = true;
this.ispng = false;
// stores whether this hotImage is a png
this.pngSrc = HotImage_pngSrc;
this.shift = HotImage_shift;
this.src = HotImage_src;
this.top = HotImage_top;
this.width = HotImage_width;
this.zoom = null;
if (arguments.length > 0)
{
this.left(arguments[0]);
this.top(arguments[1]);
this.width(arguments[2]);
this.height(arguments[3]);
this.src(arguments[4]);
if (arguments.length == 6) this.hot(arguments[5]);
}
}
/* public boolean HotImage.contains(Point pt)
Returns true if pt is in this HotImage.
*/
function HotImage_contains(pt)
{
return this.arean.contains(pt);
}
/* public void HotImage.height(int val)
Moves this HotImage's height to val.
*/
function HotImage_height(val)
{
this.imag.height = val;
if (this.ispng && ie55up) this.imag.style.height = val;
this.arean.bottom = this.arean.top + val;
}
/* public void HotImage.val(boolean val)
Toggles this HotImage on or off.
Does nothing if new setting matches current setting.
*/
function HotImage_hot(val)
{
if (this.on == val) return;
if (val == false)
{
this.imag.src_old = this.imag.src;
this.imag.src = 'images/clear.gif';
if (!ie55down) this.imag.style.cursor = 'default';
this.imag.style.visibility = 'hidden';
this.on = false;
}
else if (val == true)
{
this.imag.src = this.imag.src_old;
if (!ie55down) this.imag.style.cursor = 'pointer';
this.imag.style.visibility = 'visible';
this.on = true;
}
}
/* public void HotImage.left(int val)
Moves this HotImage's left edge to val.
*/
function HotImage_left(val)
{
this.imag.style.left = val;
this.arean.left = val;
this.arean.right = this.arean.left + parseInt(this.imag.width);
}
/* public void HotImage.shift(int x, int y)
Moves this HotImage right by x, down by y.
*/
function HotImage_shift(x, y)
{
this.left(this.arean.left + x);
this.top(this.arean.top + y);
}
/* public void HotImage.pngSrc(String val)
Changes this HotImage's source to the png file val.
*/
function HotImage_pngSrc(val)
{
this.src('images/clear.gif');
this.ispng = true;
if (ie55up)
{
this.imag.src = 'images/blank.png';
this.imag.style.width = this.arean.right - this.arean.left;
this.imag.style.height = this.arean.bottom - this.arean.top;
var filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader";
filter += "(src=\'" + val + "\', sizingMethod='scale')";
this.imag.style.filter = filter;
}
else this.imag.src = val;
}
/* public void HotImage.src(String val)
Changes this HotImage's source to the non-png file val.
*/
function HotImage_src(val)
{
if (this.ispng)
{
if (ie55up)
{
// in this case, be sure to call src after resizing image...
this.imag.style.width = this.arean.right - this.arean.left;
this.imag.style.height = this.arean.bottom - this.arean.top;
this.imag.style.filter = '';
}
this.ispng = false;
}
this.imag.src = 'images/clear.gif';
this.imag.src = val;
}
/* public void HotImage.top(String val)
Changes this HotImage's top edge to val.
*/
function HotImage_top(val)
{
this.imag.style.top = val;
this.arean.top = val;
this.arean.bottom = this.arean.top + parseInt(this.imag.height);
}
/* public void HotImage.width(int val)
Changes this HotImage's width to val.
*/
function HotImage_width(val)
{
this.imag.width = val;
if (this.ispng && ie55up) this.imag.style.width = val;
this.arean.right = this.arean.left + val;
}
/* function double latToY(float lat)
Changes latitude to Mercator Projection Y.
*/
function latToY(lat)
{
lat = toRadians(lat);
return toDegrees ( Math.log ( Math.tan (lat) + (1 / Math.cos (lat)) ) );
}
/* function number limit (number val, number minval, number maxval)
Returns val, restricting it to the range minval <= val <= maxval.
*/
function limit(val, minval, maxval)
{
if (val < minval) return minval;
if (val > maxval) return maxval;
return val;
}
function makeMapMode()
{
austinmap.makeMapMode();
}
function makeMapModeCancel()
{
austinmap.makeMapModeCancel();
}
function aMap()
{
return austinmap;
}
/*
Employee.prototype = new Person();
Employee.prototype.constructor = Employee;
Employee.superclass = Person.prototype;
*/
function GoogleMap()
{
this.id = -2;
this.title = 'Google';
this.maxzl = 17;
this.getTile = GoogleMap_getTile;
this.inSquare = GoogleMap_inSquare;
}
function GoogleMap_getTile(zl, x, y)
{
return 'http://mt0.google.com/mt?v=w2.88&hl=en&x=' + (x - 1) + '&y=' + (y - 1) + '&z=' + zl;
}
function GoogleMap_inSquare()
{
return true;
}
function GoogleSatelliteMap()
{
this.id = -1;
this.title = 'Google Satellite';
this.maxzl = 17;
this.getTile = GoogleSatelliteMap_getTile;
this.getTileFromLatLong = GoogleSatelliteMap_getTileFromLatLong;
this.inSquare = GoogleSatelliteMap_inSquare;
}
function GoogleSatelliteMap_getTile(zl, x, y)
{
var ext = 't';
var numtil = Math.pow(2, zl);
--x;
--y;
while (zl > 0)
{
numtil /= 2;
var xmod = Math.floor(x / numtil);
var ymod = Math.floor(y / numtil);
x %= numtil;
y %= numtil;
if (xmod == 0 && ymod == 0) ext += 'q';
else if (xmod == 1 && ymod == 0) ext += 'r';
else if (xmod == 1 && ymod == 1) ext += 's';
else if (xmod == 0 && ymod == 1) ext += 't';
--zl;
}
return 'http://kh.google.com/kh?v=3&t=' + ext;
}
// zoom is my zoom, with world = 0
function GoogleSatelliteMap_getTileFromLatLong(zoom, lat, lng)
{
var ext = 't';
while (zoom > 0)
{
if (lat > 0 && lng < 0) ext += 'q';
else if (lat > 0 && lng > 0) ext += 'r';
else if (lat < 0 && lng > 0) ext += 's';
else if (lat < 0 && lng < 0) ext += 't';
if (lat > 0) lat = 2 * lat - 180;
else lat = 2 * lat + 180;
if (lng > 0) lng = 2 * lng - 180;
else lng = 2 * lng + 180;
--zoom;
}
return 'http://kh.google.com/kh?v=3&t=' + ext;
}
function GoogleSatelliteMap_inSquare()
{
return true;
}
function PlusMap()
{
this.id = -3;
this.title = 'Pluses';
this.maxzl = 17;
this.xLeft = -180.0;
this.xRight = 180.0;
this.yTop = 180.0;
this.yBottom = -180.0;
this.getTile = PlusMap_getTile;
this.inSquare = PlusMap_inSquare;
this.setBounds = PlusMap_setBounds;
var numzls = this.maxzl + 1;
this.bottomTile = new Array(numzls);
this.leftTile = new Array(numzls);
this.rightTile = new Array(numzls);
this.topTile = new Array(numzls);
}
function PlusMap_getTile(zl, x, y)
{
if (x < this.leftTile[zl] || x > this.rightTile[zl] || y < this.topTile[zl] || y > this.bottomTile[zl])
return 'images/blank.png';
return 'tiles/tiles_plus/plus_' + zl + '_' + (y - 1) + '_' + (x - 1) + '.png';
}
function PlusMap_inSquare(s)
{
var box = new Square(
austinmap.yToPixels(this.yTop),
austinmap.xToPixels(this.xRight),
austinmap.yToPixels(this.yBottom),
austinmap.xToPixels(this.xLeft)
);
return box.inSquare(s);
}
function PlusMap_setBounds()
{
for (var zl = 0; zl <= this.maxzl; ++zl)
{
var latOffset = austinmap.Y_TOP - this.yBottom;
var zeroTilePosition = latOffset / austinmap.TILE_SIDE_LL;
this.bottomTile[zl] = Math.ceil (zeroTilePosition * Math.pow (austinmap.ZF, zl));
var longOffset = this.xLeft - austinmap.X_LEFT;
zeroTilePosition = longOffset / austinmap.TILE_SIDE_LL;
this.leftTile[zl] = Math.floor (zeroTilePosition * Math.pow (austinmap.ZF, zl)) + 1;
longOffset = this.xRight - austinmap.X_LEFT;
zeroTilePosition = longOffset / austinmap.TILE_SIDE_LL;
this.rightTile[zl] = Math.ceil (zeroTilePosition * Math.pow (austinmap.ZF, zl));
latOffset = austinmap.Y_TOP - this.yTop;
zeroTilePosition = latOffset / austinmap.TILE_SIDE_LL;
this.topTile[zl] = Math.floor (zeroTilePosition * Math.pow (austinmap.ZF, zl)) + 1;
}
}
/* public Map Map(int id, String title, String ext, int maxzl, double xleft, double xright, double ytop, double ybottom)
Initializes a new Map.
*/
function Map(id, title, ext, maxzl, xleft, xright, ytop, ybottom)
{
this.id = id;
this.title = title;
this.tileext = ext;
this.base = 'tiles/tiles_' + this.tileext + '/' + this.tileext + '_';
this.maxzl = maxzl;
this.xLeft = xleft;
this.xRight = xright;
this.yTop = ytop;
this.yBottom = ybottom;
this.xSpan = this.xRight - this.xLeft;
this.ySpan = this.yTop - this.yBottom;
this.getTile = Map_getTile;
this.inSquare = Map_inSquare;
var numzls = this.maxzl + 1;
this.bottomTile = new Array(numzls);
this.leftTile = new Array(numzls);
this.rightTile = new Array(numzls);
this.topTile = new Array(numzls);
for (var zl = 0; zl <= this.maxzl; ++zl)
{
var latOffset = austinmap.Y_TOP - this.yBottom;
var zeroTilePosition = latOffset / austinmap.TILE_SIDE_LL;
this.bottomTile[zl] = Math.ceil (zeroTilePosition * Math.pow (austinmap.ZF, zl));
var longOffset = this.xLeft - austinmap.X_LEFT;
zeroTilePosition = longOffset / austinmap.TILE_SIDE_LL;
this.leftTile[zl] = Math.floor (zeroTilePosition * Math.pow (austinmap.ZF, zl)) + 1;
longOffset = this.xRight - austinmap.X_LEFT;
zeroTilePosition = longOffset / austinmap.TILE_SIDE_LL;
this.rightTile[zl] = Math.ceil (zeroTilePosition * Math.pow (austinmap.ZF, zl));
latOffset = austinmap.Y_TOP - this.yTop;
zeroTilePosition = latOffset / austinmap.TILE_SIDE_LL;
this.topTile[zl] = Math.floor (zeroTilePosition * Math.pow (austinmap.ZF, zl)) + 1;
}
}
/* public String Map.getTile(int zl, int x, int y)
Gets the filename for the tile of this Map at the specified zoom level, and x and y coordinate.
*/
function Map_getTile(zl, x, y)
{
if (zl > this.maxzl) return 'images/nomap.gif';
if (x < this.leftTile[zl] || x > this.rightTile[zl] || y < this.topTile[zl] || y > this.bottomTile[zl])
return 'images/dragons_dark.jpg';
return this.base + zl + '_' + y + '_' + x + '.jpg';
}
/* public boolean Map.inSquare(Square s)
Returns true if any portion of this Map is in the Square s.
The Square s is already in AustinMap coordinates for the zoom level zl.
*/
function Map_inSquare(s)
{
var box = new Square(
austinmap.yToPixels(this.yTop),
austinmap.xToPixels(this.xRight),
austinmap.yToPixels(this.yBottom),
austinmap.xToPixels(this.xLeft)
);
return box.inSquare(s);
}
/* function number max (number[] val)
Returns the maximum value in the passed array.
*/
function max()
{
if (arguments.length == 0) return null;
var result = arguments[0];
for (var i = 1; i < arguments.length; ++i)
{
if (arguments[i] > result) result = arguments[i];
}
return result;
}
/* function number min (number[] val)
Returns the minimum value in the passed array.
*/
function min()
{
if (arguments.length == 0) return null;
var result = arguments[0];
for (var i = 1; i < arguments.length; ++i)
{
if (arguments[i] < result) result = arguments[i];
}
return result;
}
function movePic(picid)
{
austinmap.movePic(picid);
}
/* public Node Node(Object val)
Initializes a Node object with val as its value.
*/
function Node(val)
{
this.value = val;
this.next = null;
}
/* public Picture Picture([int id, double xco, double yco, int degrees, int range, String filename, int thumbwidth, int thumbheight])
Initializes a Picture object.
*/
function Picture()
{
this.center = new Point(0, 0);
this.degrees = 0;
this.id = 0;
this.filename = null;
this.twidth = 0;
this.theight = 0;
this.distanceFrom = Picture_distanceFrom;
this.getPoint = Picture_getPoint;
this.inArrow = Picture_inArrow;
this.setPoint = Picture_setPoint;
if (arguments.length > 0)
{
this.id = arguments[0];
this.setPoint(new Point(arguments[1], arguments[2]));
this.degrees = arguments[3];
this.range = arguments[4];
if (this.range == null)
this.range = 0;
this.filename = arguments[5];
this.twidth = arguments[6];
this.theight = arguments[7];
}
}
/* public double Picture.distanceFrom(amap, xpixel, ypixel)
Returns the distance from the click at (xpixel, ypixel) (which already has corner.x and corner.y added) to this Picture's center.
Returns the actual distance squared for points, and the distance to the projected line for arrows.
*/
function Picture_distanceFrom(amap, xpixel, ypixel)
{
if (this.range < amap.minArrow[amap.zl]) /* pluses */
{
var click = new Point(xpixel, ypixel);
return click.distanceSq(
new Point(
amap.xToPixels(this.center.x),
amap.yToPixels(this.center.y)
));
}
else /* arrows */
{
var x1 = amap.xToPixels(this.center.x);
var y1 = amap.yToPixels(this.center.y);
var radix = amap.arrowRadius[amap.zl][this.range][0];
var rad = toRadians(this.degrees);
var x2 = x1 + Math.round(radix * Math.cos(rad));
var y2 = y1 - Math.round(radix * Math.sin(rad));
return ptSegDist(x1, y1, x2, y2, xpixel, ypixel);
}
}
/* public Point Picture.getPoint(int level)
Returns the point at which a picture resides in the zoomlevel level.
*/
function Picture_getPoint(level)
{
return new Point(austinmap.xToPixels(this.center.x, level), austinmap.yToPixels(this.center.y, level));
}
/* public boolean Picture.inArrow(AustinMap amap, int xpixel, int ypixel)
Returns whether the click at (xpixel, ypixel) (which already has corner.x and corner.y added)
is located in this picture's region.
*/
function Picture_inArrow(amap, xpixel, ypixel)
{
if (this.range < amap.minArrow[amap.zl]) /* pluses */
{
var xpos = amap.xToPixels(this.center.x);
var ypos = amap.yToPixels(this.center.y);
var rad = amap.plusRadius[amap.zl];
var abox = new Square(
ypos - rad, xpos + rad,
ypos + rad, xpos - rad);
return abox.contains(new Point(xpixel, ypixel));
}
else /* arrows */
{
var xpos = amap.xToPixels(this.center.x);
var ypos = amap.yToPixels(this.center.y);
var rad = amap.arrowRadius[amap.zl][this.range][0];
var tip = amap.arrowRadius[amap.zl][this.range][1];
var radians = toRadians(this.degrees);
var cosT = Math.cos(radians);
var sinT = Math.sin(radians);
var acosT = tip * cosT;
var asinT = tip * sinT;
var bcosT = rad * cosT;
var bsinT = rad * sinT;
var arrow = new Triangle(
new Point(xpos, ypos),
new Point(xpos + bcosT + asinT,
ypos - bsinT + acosT),
new Point(xpos + bcosT - asinT,
ypos - bsinT - acosT)
);
return arrow.boundingContains(new Point(xpixel, ypixel));
}
}
/* public void Picture.setPoint(Point pt)
Sets this Picture's point at pt, and sets the values for other zoom levels.
*/
function Picture_setPoint(pt)
{
this.center = new Point(pt.x, pt.y);
}
/* public Point Point(int xcoord, int ycoord)
Initializes a Point object with center (xcoord, ycoord).
*/
function Point(xcoord, ycoord)
{
this.x = new Number(xcoord);
this.y = new Number(ycoord);
this.distance = Point_distance;
this.distanceSq = Point_distanceSq;
}
/* public double Point_distance(Point pt2)
Returns the distance from this point to pt2.
*/
function Point_distance(pt2)
{
return Math.sqrt(this.distanceSq(pt2));
}
/* public double Point_distanceSq(Point pt2)
Returns the distance squared from this point to pt2.
*/
function Point_distanceSq(pt2)
{
return Math.pow(pt2.x - this.x, 2) + Math.pow(pt2.y - this.y, 2);
}
/* function double ptSegDist(int x1, int y1, int x2, int y2, int px, int py)
Returns the shortest distance from the point (px, py) to the line segment with ends
(x1, y1) and (x2, y2).
*/
function ptSegDist(x1, y1, x2, y2, px, py)
{
/* algorithm taken from Java's Line2D.ptSegDist method
code from: http://developer.classpath.org/doc/java/awt/geom/Line2D-source.html
*/
var pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
var x;
var y;
if (pd2 == 0)
{
x = x1;
y = y2;
}
else
{
var u = ((px - x1) * (x2 - x1) + (py - y1) * (y2 - y1)) / pd2;
if (u < 0)
{
// "Off the end"
x = x1;
y = y1;
}
else if (u > 1.0)
{
x = x2;
y = y2;
}
else
{
x = x1 + u * (x2 - x1);
y = y1 + u * (y2 - y1);
}
}
return Math.sqrt( (x - px) * (x - px) + (y - py) * (y - py) );
}
/* public Queue Queue()
Initializes a new Queue.
*/
function Queue()
{
this.head = null;
this.length = 0;
this.clear = Queue_clear;
this.dequeue = Queue_dequeue;
this.enqueue = Queue_enqueue;
this.hasNext = Queue_hasNext;
}
/* public void Queue.clear()
Clears this Queue.
*/
function Queue_clear()
{
this.head = null;
this.length = 0;
}
/* public Object Queue.dequeue()
Pops the next object on the Queue and returns it.
*/
function Queue_dequeue()
{
if (this.length == 0) return;
var result = this.head.value;
this.head = this.head.next;
--this.length;
return result;
}
/* public void Queue.enqueue(Object val)
Adds the object val to the end of this Queue.
*/
function Queue_enqueue(val)
{
++this.length;
if (this.head == null)
this.head = new Node(val);
else
{
var current = this.head;
while (current.next != null) current = current.next;
current.next = new Node(val);
}
}
/* public boolean Queue.hasNext()
Returns true if this Queue has another Object left.
*/
function Queue_hasNext()
{
return (this.length != 0);
}
/* public RegImage RegImage([int left, int top, int width, int height, String src, [boolean vis]])
Initializes a new RegImage.
*/
function RegImage()
{
addImage();
this.imag = document.images[docimgsidx];
++docimgsidx;
this.imag.style.position = 'absolute';
this.imag.style.overflow = 'hidden';
this.arean = new Square(0, 0, 0, 0);
this.curs = 'default';
this.i2 = null;
this.idx = null;
this.j2 = null;
// toggle regimage visible
this.on = true;
this.ispng = false;
this.srcpng = null;
this.zoom = null;
this.cursor = RegImage_cursor;
this.height = RegImage_height;
this.left = RegImage_left;
this.pngSrc = RegImage_pngSrc;
this.src = RegImage_src;
this.top = RegImage_top;
this.toString = RegImage_toString;
this.vis = RegImage_vis;
this.width = RegImage_width;
if (arguments.length > 0)
{
this.left(arguments[0]);
this.top(arguments[1]);
this.width(arguments[2]);
this.height(arguments[3]);
this.src(arguments[4]);
if (arguments.length == 6)
this.vis(arguments[5]);
else
this.vis(true);
}
else
{
this.left(0);
this.top(0);
this.width(1);
this.height(1);
this.src('images/clear.gif');
this.vis(true);
}
}
/* public void RegImage.cursor(String val)
Changes this RegImage's cursor to val.
*/
function RegImage_cursor(val)
{
this.curs = val;
if (this.on || arguments.length > 1) //! what is the second argument for?
this.imag.style.cursor = val;
}
/* public void RegImage.height(int val)
Changes this RegImage's height to val.
*/
function RegImage_height(val)
{
this.imag.height = val;
this.imag.style.height = val;
this.arean.bottom = this.arean.top + val;
}
/* public void RegImage.left(int val)
Changes the position of this RegImage's left side to val.
*/
function RegImage_left(val)
{
this.imag.style.left = val;
var theWidth = this.arean.right - this.arean.left;
this.arean.left = val;
this.arean.right = this.arean.left + theWidth;
}
/* public void RegImage.pngSrc(String val)
Changes this RegImage's source to the png file val.
*/
function RegImage_pngSrc(val)
{
if (!val) return;
this.src('images/clear.gif');
this.ispng = true;
this.srcpng = val;
if (ie55up)
{
this.imag.style.width = this.arean.right - this.arean.left;
this.imag.style.height = this.arean.bottom - this.arean.top;
var filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader";
filter += "(src='" + val + "', sizingMethod='scale');";
this.imag.style.filter = filter;
}
else this.src(val);
}
/* public void RegImage.src(String val)
Changes this RegImage's source to the non-png file val.
*/
function RegImage_src(val)
{
if (this.ispng)
{
if (ie55up)
{
// in this case, be sure to call src after resizing image...
this.imag.style.filter = '';
}
this.ispng = false;
}
this.imag.src = 'images/clear.gif';
this.imag.src = val;
}
/* public void RegImage.top(String val)
Changes the position of this RegImage's top edge to val.
*/
function RegImage_top(val)
{
this.imag.style.top = val;
var theHeight = this.arean.bottom - this.arean.top;
this.arean.top = val;
this.arean.bottom = this.arean.top + theHeight;
}
/* public string RegImage.toString()
Returns a string describing this RegImage.
*/
function RegImage_toString()
{
var result = '';
// result += 'RegImage;';
// result += ' position: ' + this.imag.style.position + ';';
// result += ' overflow: ' + this.imag.style.overflow + ';';
result += ' vis: ' + this.imag.style.visibility + ';';
result += ' (t,r,b,l): ('
+ this.arean.top + ', '
+ this.arean.right + ', '
+ this.arean.bottom + ', '
+ this.arean.left
+ ');';
// result += ' cursor: ' + this.curs + ';';
result += ' i2: ' + this.i2 + ';';
result += ' j2: ' + this.j2 + ';';
// result += ' idx: ' + this.idx + ';';
result += ' on: ' + this.on + ';';
result += ' ispng: ' + this.ispng + ';';
result += ' src: ' + this.imag.src + ';';
result += ' srcpng: ' + this.srcpng + ';';
result += ' zoom: ' + this.zoom + ';';
return result;
}
/* public void RegImage.vis(boolean val)
Toggles this RegImage on or off (visible/invisible).
*/
function RegImage_vis(val)
{
if (this.on == val) return;
if (val == false)
{
if (!ie55down) this.imag.style.cursor = 'default';
if (this.ispng)
{
if (ie55up) this.imag.style.filter = '';
}
else this.imag.style.visibility = 'hidden';
}
else if (val == true)
{
if (!ie55down) this.imag.style.cursor = this.curs;
if (this.ispng) this.pngSrc(this.srcpng);
this.imag.style.visibility = 'visible';
}
this.on = val;
}
/* public void RegImage.width(int val)
Sets this RegImage's width to val.
*/
function RegImage_width(val)
{
this.imag.width = val;
this.imag.style.width = val;
this.arean.right = this.arean.left + val;
}
/* function int roundBig(double val)
Rounds val up absolutely (away from zero).
*/
function roundBig(val)
{
if (Math.round(val) == val) return val;
if (val > 0) return Math.ceil(val);
return -1 * Math.ceil(-1 * val);
}
/* function void setContent(HTMLObject element, Object newcontent)
Sets the content of element to newcontent.
Tested only with cells; may work with other elements.
*/
function setContent(element, newcontent)
{
if (element == null) return;
if (element.innerHTML || element.innerHTML == '')
element.innerHTML = newcontent;
else if (document.createRange())
{
range = document.createRange();
// remove old content
//while (element.hasChildNodes())
// element.removeChild(element.lastChild);
range.setStartAfter(element);
docFrag = range.createContextualFragment(newcontent);
element.appendChild(docFrag);
}
}
/* public Square Square(int top, int right, int bottom, int left)
Initializes a Square object.
(Image coordinates, with left->x->right, top->y->bottom)
*/
function Square(top, right, bottom, left)
{
this.top = top;
this.right = right;
this.bottom = bottom;
this.left = left;
this.contains = Square_contains;
this.inSquare = Square_inSquare;
}
/* public boolean Square.contains(Point pt)
Returns true if the Point pt is in this Square.
*/
function Square_contains(pt)
{
return (
(pt.x >= this.left) &&
(pt.x <= this.right) &&
(pt.y >= this.top) &&
(pt.y <= this.bottom) );
}
/* public boolean Square.inSquare(Square s)
Returns true if any portion of the Square s is in this Square.
*/
function Square_inSquare(s)
{
return (
s.right > this.left &&
s.bottom > this.top &&
s.left < this.right &&
s.top < this.bottom
);
}
/* function double toDegrees(double rad)
Returns the conversion of rad from radians to degrees.
*/
function toDegrees(rad)
{
return (180 * rad / Math.PI);
}
/* function double toRadians(double deg)
Returns the conversion of deg from degrees to radians.
*/
function toRadians(deg)
{
return (Math.PI * deg / 180);
}
/* public Triangle Triangle(Point p1, Point p2, Point p3)
Initializes a new Triangle with corners p1, p2, p3.
(Image coordinates, with left->x->right, top->y->bottom)
*/
function Triangle(p1, p2, p3)
{
this.p1 = p1;
this.p2 = p2;
this.p3 = p3;
this.boundingContains = Triangle_boundingContains;
}
/* public boolean Triangle.boundingContains(Point p)
Returns true if the bounding box for this triangle contains the Point p.
*/
function Triangle_boundingContains(p)
{
var box = new Square(
min(this.p1.y, this.p2.y, this.p3.y),
max(this.p1.x, this.p2.x, this.p3.x),
max(this.p1.y, this.p2.y, this.p3.y),
min(this.p1.x, this.p2.x, this.p3.x)
);
return box.contains(p);
}