function startSelectTDDSBox(e) {
	if (checkIfActiveLayerAvailable()) {
		moveLayer("theMap",hspc,vspc);
		getImageXY(e);
		// keep it within the MapImage
		if ((mouseX<iWidth) && (mouseY<iHeight)) {
			if (selectBox) {
				stopSelectBox(e);
			} else {
				x1=mouseX;
				y1=mouseY
				x2=x1+1;
				y2=y1+1;
				zleft=x1;
				ztop=y1;
				zbottom=y1;
				zright=x1
				boxIt(x1,y1,x2,y2);
				/*
				clipLayer("zoomBoxTop",x1,y1,x2,y2);
				clipLayer("zoomBoxLeft",x1,y1,x2,y2);
				clipLayer("zoomBoxRight",x1,y1,x2,y2);
				clipLayer("zoomBoxBottom",x1,y1,x2,y2);
				*/
				selectBox=true;
				
				//if (isNav4) {
					showLayer("zoomBoxTop");
					showLayer("zoomBoxLeft");
					showLayer("zoomBoxRight");
					showLayer("zoomBoxBottom");
				//} else {
				//	showLayer("zoomBox");
				//}
			}
			highlightedOne="";
		}
		return false;
	}

}

function stopSelectBoxFTP(e) {
    // alert("in stopSelect box");
	selectBox=false;
	
    hideLayer("zoomBoxTop");
    hideLayer("zoomBoxLeft");
    hideLayer("zoomBoxRight");
    hideLayer("zoomBoxBottom");
	
    
	if ((zright <zleft+2) && (zbottom < ztop+2)) {
		
		getMapXY(mouseX,mouseY);

		searchTolerance = (xDistance/iWidth) * pixelTolerance;
		tempLeft = mapX-searchTolerance;
		tempTop = mapY-searchTolerance;
		tempRight = mapX+searchTolerance;
		tempBottom = mapY+searchTolerance;
	
		//select(e);
	} else {
	// */	
		pixelX = xDistance / iWidth;
		var theY = iHeight - ztop;
		//alert(theY);
		pixelY = yDistance / iHeight;
		tempTop = pixelY * theY + eBottom;
		tempRight = pixelX * zright + eLeft;
		tempLeft = pixelX * zleft + eLeft;
		theY = iHeight - zbottom;
		pixelY = yDistance / iHeight;
		tempBottom = pixelY * theY + eBottom;
		//alert(tempBottom);
	}
		window.scrollTo(0,0);
	
	queryStartRecord=1;
// alert("tempLeft" +  tempLeft  + "TempTop"  + tempTop  +  "tempRight" +  tempRight  + "tempbottom" +  tempBottom);
    
	var selectEnvelope='maxy="' + forceComma(tempTop) + '" maxx="' + forceComma(tempRight) + '" miny="' + forceComma(tempBottom) + '" minx="' + forceComma(tempLeft) + '"';
	drawSelectBoundary=true;
	showBuffer=false;
	selectionMode=2;


	// Call our new tiled url as a new window.
	var vy2=Math.abs(tempTop-tempBottom);
	var vx2=Math.abs(tempRight-tempLeft);
	var va2=vx2*vy2;
        var randNum = Math.round( Math.random() * 2000 );
        var windowName = "winName" + randNum;

        var TDDSURL= parent.MapFrame.tddsMachineURL + "tddsRequest/tddsFrameset.jsp?PL=ED05,ED04,ED06,ED02,ED01,ED03,ED11,ED10,ED12,ED08,ED09,ED07,ED21,ED19,ED17,ED18,ED16,ED14,ED15,ED13,ED22,ED20&AL=" + tempTop + "," + tempBottom + "," + tempRight + "," + tempLeft;
	window.open(TDDSURL, windowName, "height=600,width=800,scrollbars,resizable,location, menubar,status,toolbar");

	return true;

}








