dojo.provide("tests.webmap.widget._Pointer");

dojo.require("doh.runner");
dojo.require("webmap.widget._Pointer");
dojo.require("tests.Util");
dojo.require("gov.nyc.doitt.gis.service.map.domain");

var pointFromNode = null;
var pointToNode = null;
var pointer = null;

function doPointerSetup(){
	tests.Util.resetDom();
	pointFromNode = document.createElement("div");
	document.body.appendChild(pointFromNode);
	pointFromNode.id = "pointFromNode";
	dojo.style(pointFromNode, "position", "absolute");
	dojo.style(pointFromNode, "left", "20px");
	dojo.style(pointFromNode, "top", "10px");
	dojo.style(pointFromNode, "width", "200px");
	dojo.style(pointFromNode, "height", "100px");

	pointToNode = document.createElement("div");
	pointToNode.id = "pointToNode";
	dojo.style(pointToNode, "position", "absolute");
	document.body.appendChild(pointToNode);
	pointToNode.id = "pointToNode";
	dojo.style(pointToNode, "left", "100px");
	dojo.style(pointToNode, "top", "300px");
	dojo.style(pointToNode, "width", "20px");
	dojo.style(pointToNode, "height", "20px");

	pointer = document.createElement("div");
	pointer.id = "pointer";
	dojo.style(pointer, "position", "absolute");
	document.body.appendChild(pointer);
	pointer.id = "pointer";
	dojo.style(pointer, "left", "200px");
	dojo.style(pointer, "top", "400px");
	dojo.style(pointer, "width", "40px");
	dojo.style(pointer, "height", "20px");
}

doh.register("tests.webmap.widget._Pointer", 
	[
		{
			name: "startup",
			setUp: doPointerSetup,
			runTest: function() {
				var _cacheXmlCalled = false;
				var _setPointCalled = false;
				var _setBoxCalled = false;
				var _drawPointerCalled = false;
				var p = new webmap.widget._Pointer({pointFromNode:"pointFromNode", pointToNode:"pointToNode"}, null);
				p._cacheXml = function(){
					_cacheXmlCalled = true;
				};
				p._setPoint = function(){
					_setPointCalled = true;
				};
				p._setBox = function(){
					_setBoxCalled = true;
				};
				p._drawPointer = function(){
					_drawPointerCalled = true;
				};
				p.startup();
				tests.assertEqual(dojo.moduleUrl("webmap.widget", "templates/pointer"), p.xmlPath);
				tests.assertTrue(_cacheXmlCalled);	
				tests.assertTrue(_setPointCalled);	
				tests.assertTrue(_setBoxCalled);	
				tests.assertTrue(_drawPointerCalled);
				tests.assertEqual(pointToNode, p.pointToNode);
				tests.assertEqual(pointFromNode, p.pointFromNode);
				
				_cacheXmlCalled = false;
				_setPointCalled = false;
				_setBoxCalled = false;
				_drawPointerCalled = false;
				var p2 = new webmap.widget._Pointer({pointFromNode:pointFromNode, pointToNode:pointToNode}, null);
				p2._cacheXml = function(){
					_cacheXmlCalled = true;
				};
				p2._setPoint = function(){
					_setPointCalled = true;
				};
				p2._setBox = function(){
					_setBoxCalled = true;
				};
				p2._drawPointer = function(){
					_drawPointerCalled = true;
				};
				p2.startup();
				tests.assertTrue(_setPointCalled);	
				tests.assertTrue(_setBoxCalled);	
				tests.assertTrue(_drawPointerCalled);
				tests.assertEqual(pointToNode, p2.pointToNode);
				tests.assertEqual(pointFromNode, p2.pointFromNode);
				p.destroy();
				p2.destroy();
			}
		},
		{
			name: "destroy",
			setUp: doPointerSetup,
			runTest: function() {
				var ptr = document.createElement("div");
				ptr.id = "ptr";
				document.body.appendChild(ptr);
				pointer.id = "pointer";
				var p = new webmap.widget._Pointer({_pointer:ptr}, pointer);
				//TODO: see that other widget's destroy tests do this
				tests.assertFalse(null == dojo.byId("ptr"));
				tests.assertFalse(null == dojo.byId("pointer"));
				p.destroy();
				tests.assertEqual(null, dojo.byId("ptr"));
				tests.assertEqual(null, dojo.byId("pointer"));
			}			
		},
		{
			name: "_hide_no_pointer",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new webmap.widget._Pointer({_pointer:null}, null);
				var called = false;
				var c = dojo.connect(dojo, "style", function(){called = true;});
				p.hide();
				p.destroy();
				tests.assertFalse(called);
				dojo.disconnect(c);
			}			
		},
		{
			name: "_hide_has_pointer",
			setUp: doPointerSetup,
			runTest: function() {
				var ptr = document.createElement("div");
				document.body.appendChild(ptr);
				var p = new webmap.widget._Pointer({_pointer:ptr}, pointer);
				var called = false;
				var c = dojo.connect(dojo, "style", function(){called = true;});
				p.hide();
				p.destroy();
				tests.assertTrue(called);
				dojo.disconnect(c);
			}			
		},
		{
			name: "show_pointerIsInBox",
			setUp: doPointerSetup,
			runTest: function() {
				var _isPointInBoxCalled = false;
				var _setBoxCalled = false;
				var p = new webmap.widget._Pointer({}, null);
				p._isPointInBox = function (){_isPointInBoxCalled = true;return true;};
				p._setBox = function (){_setBoxCalled = true;};
				p._pointer = pointer;
				p.domNode = document.body;
				p.show();
				tests.assertTrue(_setBoxCalled);
				tests.assertTrue(_isPointInBoxCalled);
				tests.assertEqual(null, p._pointer);
				tests.assertEqual("none", dojo.style(p._pointer, "display"));
			}
		},
		{
			name: "show_pointerNotInBox",
			widget: null,
			boxCount: 0,
			drawCount: 0,
			setUp: function(){
				doPointerSetup();
				this.widget = new webmap.widget._Pointer({}, pointer);
				var _p = document.createElement("div");
				document.body.appendChild(_p);
				this.widget._pointer = _p;
				this.widget._isPointInBox = function(){return false;};
				var _this = this;
				this.widget._setBox = function(){_this.boxCount++;};
				this.widget._drawPointer = function(){_this.drawCount++;};
				this.widget.parent = {
					minimized:false,
					domNode:pointToNode
				};
				dojo.style(pointToNode, "display", "block");
			},
			runTest: function() {
				this.widget.show();
				tests.assertEqual("block", dojo.style(this.widget._pointer, "display"));
				tests.assertEqual(1, this.boxCount);
				tests.assertEqual(1, this.drawCount);
				this.widget.parent.minimized = true;
				this.widget.show();
				tests.assertEqual("block", dojo.style(this.widget._pointer, "display"));
				tests.assertEqual(2, this.boxCount);
				tests.assertEqual(1, this.drawCount);
				dojo.style(this.widget.parent.domNode, "display", "none");
				dojo.style(this.widget._pointer, "display", "none");
				this.widget.show();
				tests.assertEqual("none", dojo.style(this.widget._pointer, "display"));
				tests.assertEqual(3, this.boxCount);
				tests.assertEqual(1, this.drawCount);
			},
			tearDown: function(){
				this.widget.destroy();
			}
		},
		{
			name: "setPointerBackgroundColor",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new webmap.widget._Pointer({}, null);
				var show = 0;
				p.show = function(){show++;};
				p.setPointerBackgroundColor("myColor");
				tests.assertEqual("myColor", p._fill);
				tests.assertEqual(1, show);
			}
		},
		{
			name: "setPointerBorderColor",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new webmap.widget._Pointer({}, null);
				var show = 0;
				p.show = function(){show++;};
				p.setPointerBorderColor("myColor");
				tests.assertEqual("myColor", p._stroke);
				tests.assertEqual(1, show);
			}
		},
		{
			name: "setPointerBorderWidth",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new webmap.widget._Pointer({}, null);
				var show = 0;
				p.show = function(){show++;};
				p.setPointerBorderWidth("myWidth");
				tests.assertEqual("myWidth", p._strokeWidth);
				tests.assertEqual(1, show);
			}
		},
		{
			name: "_cacheXml",
			setUp: doPointerSetup,
			runTest: function() {
				webmap.widget._xmlPointerCache = null;
				var p = new webmap.widget._Pointer({}, null);
				p.xmlPath =  dojo.moduleUrl("webmap.widget", "templates/pointer");
				p._cacheXml();
				if (dojo.isIE) {
					tests.assertEqual(webmap.util.XmlDocumentUtil.docToString(
						webmap.util.XmlDocumentUtil.loadFile(p.xmlPath + ".vml")),
						webmap.widget._xmlPointerCache);
				} else {
					tests.assertEqual(webmap.util.XmlDocumentUtil.docToString(
						webmap.util.XmlDocumentUtil.loadFile(p.xmlPath + ".svg")),
						webmap.widget._xmlPointerCache);
				}
				webmap.widget._xmlPointerCache = "fred";
				p._cacheXml();
				tests.assertEqual("fred", webmap.widget._xmlPointerCache);
				webmap.widget._xmlPointerCache = null;
			}
		},
		{
			name: "_setPoint",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new webmap.widget._Pointer({}, null);
				p.pointToNode = pointToNode;
				p._setPoint();
				tests.assertEqual("110,310", p.point.toString());
				p.x = 300;
				p.y = 333;
				p._setPoint();
				tests.assertEqual("300,333", p.point.toString());
			}
		},
		{
			name: "_setBox",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new webmap.widget._Pointer({}, null);
				p.pointFromNode = pointFromNode;
				p._setBox();
				tests.assertEqual(20, p._box.minX);
				tests.assertEqual(10, p._box.minY);
				tests.assertEqual(220, p._box.maxX);
				tests.assertEqual(110, p._box.maxY);
			}
		},
		{
			name: "_drawPointer_ff",
			widget: null,
			box: null,
			setUp: function(){
				if (dojo.isIE) return;
				doPointerSetup();
				this.widget = new webmap.widget._Pointer({x:10,y:20}, pointer);
				this.widget.startup();
				this.box = new gov.nyc.doitt.gis.service.map.domain.ImageEnvelope();
				this.box.minX = 100;
				this.box.minY = 200; 
				this.box.maxX = 300;
				this.box.maxY = 400;
				var _this = this;
				this.widget._getPointerAttachLocation = function(){
					var a = new webmap.widget._Attachment();
					a.points = "1 2,2 3,3 4";
					a.box = _this.box;
					return a;
				};
			},
			runTest: function() {
				//TODO: add tests for fill, stroke, etc
				if (dojo.isIE) return;
				this.widget._drawPointer();
				tests.assertEqual('<svg svg="http://www.w3.org/2000/svg" version="1.1"><polyline points="1,2 2,3 3,4" stroke-width="1" stroke="black" fill="cornsilk"></polyline></svg>',
					this.widget._pointer.innerHTML);
				tests.assertEqual(this.box.minX, dojo.style(this.widget._pointer, "left"));
				tests.assertEqual(this.box.minY, dojo.style(this.widget._pointer, "top"));
				tests.assertEqual(this.box.getWidth(), dojo.style(this.widget._pointer, "width"));
				tests.assertEqual(this.box.getHeight(), dojo.style(this.widget._pointer, "height"));
			},
			tearDown: function(){
				if (dojo.isIE) return;
				this.widget.destroy();
			}
		},
		{
			name: "_drawPointer_ie",
			widget: null,
			box: null,
			setUp: function(){
				if (!dojo.isIE) return;
				doPointerSetup();
				this.widget = new webmap.widget._Pointer({x:10,y:20}, pointer);
				this.widget.startup();
				this.box = new gov.nyc.doitt.gis.service.map.domain.ImageEnvelope();
				this.box.minX = 100;
				this.box.minY = 200; 
				this.box.maxX = 300;
				this.box.maxY = 400;
				var _this = this;
				this.widget._getPointerAttachLocation = function(){
					var a = new webmap.widget._Attachment();
					a.points = "1 2,2 3,3 4";
					a.box = _this.box;
					return a;
				};
			},
			runTest: function() {
				//TODO: add tests for fill, stroke, etc
				if (!dojo.isIE) return;
				this.widget._drawPointer();
				tests.assertEqual('put vml here',
					this.widget._pointer.innerHTML);
				tests.assertEqual(this.box.minX, dojo.style(this.widget._pointer, "left"));
				tests.assertEqual(this.box.minY, dojo.style(this.widget._pointer, "top"));
				tests.assertEqual(this.box.getWidth(), dojo.style(this.widget._pointer, "width"));
				tests.assertEqual(this.box.getHeight(), dojo.style(this.widget._pointer, "height"));
			},
			tearDown: function(){
				if (!dojo.isIE) return;
				this.widget.destroy();
			}
		},
		{
			name: "_getPointerAttachLocationSuccessfulIntersect",
			setUp: doPointerSetup,
			runTest: function() {
				var _isPointInBoxCalled = false;
				var p = new webmap.widget._Pointer({}, null);
				p._isPointInBox = function() {
					_isPointInBoxCalled = true;
					return false;
				}
				p._getAttachXSet = function(a) {
					tests.assertEqual(new webmap.widget._Attachment(),a);
					a.methodCalls = ["_getAttachXSet"];
					return "xs";
				}
				p._getAttachYSet = function(a) {
					a.methodCalls.push("_getAttachYSet");
					return "ys";
				}
				p._intersect = function(xs,ys) {
					tests.assertEqual("xs",xs);
					tests.assertEqual("ys",ys);
					return "success";
				}
				p._getAttachPoints = function(a) {
					a.methodCalls.push("_getAttach");
				}
				var result = p._getPointerAttachLocation();
				tests.assertEqual(["_getAttachXSet","_getAttachYSet","_getAttach"],
					result.methodCalls);
				tests.assertEqual("success", result.location);
			}
		},
		{
			name: "_getPointerAttachLocationNoIntersect",
			setUp: doPointerSetup,
			runTest: function() {
				var _isPointInBoxCalled = false;
				var p = new webmap.widget._Pointer({x:0,y:0}, null);
				p._isPointInBox = function() {
					_isPointInBoxCalled = true;
					return false;
				}
				p._getAttachXSet = function(a) {
					tests.assertEqual(new webmap.widget._Attachment(),a);
					a.methodCalls = ["_getAttachXSet"];
					return "xs";
				}
				p._getAttachYSet = function(a) {
					a.methodCalls.push("_getAttachYSet");
					a.location = "should be reset to null by call to _intersect";
					return "ys";
				}
				p._intersect = function(xs,ys) {
					tests.assertEqual("xs",xs);
					tests.assertEqual("ys",ys);
					return null;
				}
				p._resolveCorner = function(xs,ys) {
					tests.assertEqual("xs",xs);
					tests.assertEqual("ys",ys);
					return "woohoo";
				}
				p._getAttachPoints = function(a) {
					a.methodCalls.push("_getAttach");
				}
				var result = p._getPointerAttachLocation();
				tests.assertEqual(["_getAttachXSet","_getAttachYSet","_getAttach"],
					result.methodCalls);
				tests.assertEqual("woohoo", result.location);
			}
		},
		{
			name: "_getPointerAttachLocation",
			setUp: doPointerSetup,
			runTest: function() {
				tests.assertEqual("left-top", attachLocationTest(50,125));
				tests.assertEqual("left-bottom", attachLocationTest(50,175));
				tests.assertEqual("bottom-left", attachLocationTest(125,250));
				tests.assertEqual("bottom-right", attachLocationTest(175,250));
				tests.assertEqual("right-bottom", attachLocationTest(225,175));
				tests.assertEqual("right-top", attachLocationTest(225,125));
				tests.assertEqual("top-right", attachLocationTest(175,50));
				tests.assertEqual("top-left", attachLocationTest(125,50));
			}
		},
		{
			name: "_intersect",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new webmap.widget._Pointer({x:0,y:0}, null);
				tests.assertEqual("ricky", p._intersect(["fred","ricky"],["ricky","lucy"]));
				tests.assertEqual("fred", p._intersect(["fred","ricky"],["ethel","fred"]));
				tests.assertEqual(null, p._intersect(["fred","ethel"],["ricky","lucy"]));
			}
		},
		{
			name: "_resolveCorner",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new webmap.widget._Pointer({}, null);
				tests.assertEqual("bottom-left",
					p._resolveCorner(["left-bottom", "top-right"],["bottom-left","right-bottom"]));
				tests.assertEqual("bottom-right",
					p._resolveCorner(["top-right","right-bottom"],["bottom-left","bottom-right"]));
				tests.assertEqual("right-top",
					p._resolveCorner(["left-top", "top-right"],["right-top","bottom-left"]));
				tests.assertEqual("top-left",
					p._resolveCorner(["left-top", "top-right"],["right-bottom","top-left"]));
			}
		},
		{
			name: "_getAttachPointsBottomLeft",
			setUp: doPointerSetup,
			runTest: function() {
				var expected = "100,0 0,102 120,0";
				tests.assertEqual(expected, attachPointTest({
					location:"bottom-left",
					pointX:0,
					pointY:300
				}));
				expected = "0,0 10,102 20,0";
				tests.assertEqual(expected, attachPointTest({
					location:"bottom-left",
					pointX:110,
					pointY:300
				}));
				expected = "0,0 25,102 20,0";
				tests.assertEqual(expected, attachPointTest({
					location:"bottom-left",
					pointX:125,
					pointY:300
				}));
			}
		},
		{
			name: "_getAttachPointsBottomRight",
			setUp: doPointerSetup,
			runTest: function() {
				var expected = "200,0 0,102 180,0";
				tests.assertEqual(expected, attachPointTest({
					location:"bottom-right",
					pointX:0,
					pointY:300
				}));
				expected = "200,0 0,12 180,0";
				tests.assertEqual(expected, attachPointTest({
					location:"bottom-right",
					pointX:0,
					pointY:210
				}));
				expected = "200,0 0,27 180,0";
				tests.assertEqual(expected, attachPointTest({
					location:"bottom-right",
					pointX:0,
					pointY:225
				}));
			}
		},
		{
			name: "_getAttachPointsLeftBottom",
			setUp: doPointerSetup,
			runTest: function() {
				tests.assertEqual("101,20 0,120 101,0", attachPointTest({
					location:"left-bottom",
					pointX:0,
					pointY:300
				}));
				tests.assertEqual("1,20 0,120 1,0", attachPointTest({
					location:"left-bottom",
					pointX:110,
					pointY:300
				}));
				tests.assertEqual("1,20 0,120 1,0", attachPointTest({
					location:"left-bottom",
					pointX:125,
					pointY:300
				}));
			}
		},
		{
			name: "_getAttachPointsLeftTop",
			setUp: doPointerSetup,
			runTest: function() {
				tests.assertEqual("101,100 0,0 101,120", attachPointTest({
					location:"left-top",
					pointX:0,
					pointY:0
				}));
				tests.assertEqual("101,0 0,10 101,20", attachPointTest({
					location:"left-top",
					pointX:0,
					pointY:110
				}));
				tests.assertEqual("101,0 0,25 101,20", attachPointTest({
					location:"left-top",
					pointX:0,
					pointY:125
				}));
			}
		},
		{
			name: "_getAttachPointsRightBottom",
			setUp: doPointerSetup,
			runTest: function() {
				return;
				var expected = "0,50 51,0 0,30";
				if (dojo.isIE) expected = "0,49 52,-1 0,29";
				tests.assertEqual(expected, attachPointTest({
					location:"right-bottom",
					pointX:250,
					pointY:250
				}));
				expected = "0,20 51,10 0,0";
				if (dojo.isIE) expected = "0,19 52,9 0,-1";
				tests.assertEqual(expected, attachPointTest({
					location:"right-bottom",
					pointX:250,
					pointY:190
				}));
			}
		},
		{
			name: "_getAttachPointsRightTop",
			setUp: doPointerSetup,
			runTest: function() {
				return;
				var expected = "0,100 51,0 0,120";
				if (dojo.isIE) expected = "0,100 52,0 0,120";
				tests.assertEqual(expected, attachPointTest({
					location:"right-top",
					boxMinX:0,
					boxMinY:100,
					boxMaxX:100,
					boxMaxY:200,
					pointX:150,
					pointY:0
				}));
				expected = "0,0 51,20 0,20";
				if (dojo.isIE) expected = "0,0 52,20 0,20";
				tests.assertEqual(expected, attachPointTest({
					location:"right-top",
					boxMinX:0,
					boxMinY:100,
					boxMaxX:100,
					boxMaxY:200,
					pointX:150,
					pointY:120
				}));
			}
		},
		{
			name: "_getAttachPointsTopLeft",
			setUp: doPointerSetup,
			runTest: function() {
				return;
				tests.assertEqual("50,51 0,0 70,51", attachPointTest({
					location:"top-left",
					boxMinX:50,
					boxMinY:50,
					boxMaxX:150,
					boxMaxY:100,
					pointX:0,
					pointY:0
				}));
				tests.assertEqual("0,51 5,0 20,51", attachPointTest({
					location:"top-left",
					boxMinX:50,
					boxMinY:50,
					boxMaxX:150,
					boxMaxY:100,
					pointX:55,
					pointY:0
				}));
			}
		},
		{
			name: "_getAttachPointsTopRight",
			setUp: doPointerSetup,
			runTest: function() {
				return;
				tests.assertEqual("1,200 0,0 1,180", attachPointTest({
					location:"left-bottom",
					boxMinX:0,
					boxMinY:100,
					boxMaxX:100,
					boxMaxY:200,
					pointX:220,
					pointY:0
				}));
				tests.assertEqual("1,200 0,0 1,180", attachPointTest({
					location:"left-bottom",
					boxMinX:0,
					boxMinY:100,
					boxMaxX:100,
					boxMaxY:200,
					pointX:188,
					pointY:0
				}));
			}
		},
		{
			name: "_isPointInBox",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new webmap.widget._Pointer({}, null);
				p._box = new gov.nyc.doitt.gis.service.map.domain.ImageEnvelope();
				p._box.minX = 0;
				p._box.minY = 100;
				p._box.maxX = 100;
				p._box.maxY = 200;
				p.point = new gov.nyc.doitt.gis.service.map.domain.ImagePoint({x:220,y:0});
				tests.assertFalse(p._isPointInBox());
				p.point = new gov.nyc.doitt.gis.service.map.domain.ImagePoint({x:10,y:110});
				tests.assertTrue(p._isPointInBox());
				p.point = new gov.nyc.doitt.gis.service.map.domain.ImagePoint({x:0,y:100});
				tests.assertTrue(p._isPointInBox());
				p.point = new gov.nyc.doitt.gis.service.map.domain.ImagePoint({x:10,y:100});
				tests.assertTrue(p._isPointInBox());
				p.point = new gov.nyc.doitt.gis.service.map.domain.ImagePoint({x:0,y:110});
				tests.assertTrue(p._isPointInBox());
			}
		},
		{
			name: "_PointToString",
			setUp: doPointerSetup,
			runTest: function() {
				var p = new gov.nyc.doitt.gis.service.map.domain.ImagePoint({x:220,y:0});
				tests.assertEqual("220,0", p.toString());
			}
		},
		{
			name: "_BoxGetDimensions",
			setUp: doPointerSetup,
			runTest: function() {
				var box = new gov.nyc.doitt.gis.service.map.domain.ImageEnvelope();
				box.minX = 0;
				box.minY = 10;
				box.maxX = 100;
				box.maxY = 200;
				tests.assertEqual(100, box.getWidth());
				tests.assertEqual(190, box.getHeight());
			}
		}
	]
);
function attachLocationTest(x,y){
	var p = new webmap.widget._Pointer({}, null);
	p.pointerWidth = 20;
	p._box = new gov.nyc.doitt.gis.service.map.domain.ImageEnvelope();
	p._box.minX = 100;
	p._box.minY = 100;
	p._box.maxX = 200;
	p._box.maxY = 200;
	p.point = new gov.nyc.doitt.gis.service.map.domain.ImagePoint({x:x,y:y});
	return p._getPointerAttachLocation().location;
}

function attachPointTest(args){
	var attach = new webmap.widget._Attachment();
	attach.location = args.location;
	var p = new webmap.widget._Pointer({}, null);
	p.pointerWidth = 20;
	p._box = new gov.nyc.doitt.gis.service.map.domain.ImageEnvelope();
	p._box.minX = 100;
	p._box.minY = 100;
	p._box.maxX = 200;
	p._box.maxY = 200;
	p.point = new gov.nyc.doitt.gis.service.map.domain.ImagePoint({x:args.pointX,y:args.pointY});
	p._getAttachPoints(attach);
	return attach.points;
}