var prodID=new Array();
var prodName=new Array();
var prodViewerURL=new Array();
var prodViewerParams=new Array();
var prodServiceID=new Array();
var prodLayerID=new Array();
var prodNameField=new Array();
var prodIDField=new Array();
var urlIDParameter=new Array();
var multiURLList=new Array();
var multiURLIDs=new Array();
var viewProductMode=1001;
var currentProdID='';
var previousService='';
var previousLayer='';
var path=document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/')+1);
var viewMultiURL='http://'+hostName+path+'prod/viewMultiProds.jsp';
var url;
var counter=0;
var winHandle;
prodID[counter]='topo_map';
prodName[prodID[counter]]='Topographic Maps';
prodViewerURL[prodID[counter]]='http://'+hostName+path+'prod/viewTopoMap.jsp';
prodViewerParams[prodID[counter]]='';prodServiceID[prodID[counter]]=prodTopoServiceID;
prodLayerID[prodID[counter]]=Topographic_Map_Index_Label_1;
prodNameField[prodID[counter]]='MNEMONIC';
prodIDField[prodID[counter]]='MNEMONIC';
urlIDParameter[prodID[counter]]='MAP_ID';
counter++;
prodID[counter]='aerial_photo';
prodName[prodID[counter]]='Aerial Photos';
prodViewerURL[prodID[counter]]='http://'+hostName+path+'prod/viewAerialPhoto.jsp';
prodViewerParams[prodID[counter]]='scrollbars=false,resizable=false,width=900,height=600,menubar=false,status=yes,location=false,screenX=220,screenY=15,hotkeys=no,dependent=true';
prodServiceID[prodID[counter]]=prodAirviewServiceID;
prodLayerID[prodID[counter]]=Airview_Index_Label_1;
prodNameField[prodID[counter]]='NAME';
prodIDField[prodID[counter]]='NUMBER';
urlIDParameter[prodID[counter]]='MAP_NUM';
counter++;
function writeProductList()
{
var buf='';
var flag=true;
var str='selected';
var t=parent.MapFrame;
var k=t.activeMapServiceIndex;
for(var i=0;i<prodID.length;i++)
{
var id=prodID[i];
if(prodName[id]==t.mapServiceName[k])
{
buf+='<option value ="'+prodID[i]+'"'+str+' selected>'+prodName[id]+'</option>';
}
else
{
buf+='<option value ="'+prodID[i]+'"'+str+'>'+prodName[id]+'</option>';
}
if(flag)
{
str='';
flag=false;
}
}
return buf;
}
function useViewProductTool(funcType)
{
top.TextFrame.document.location='view.html';
toolMode=viewProductMode;
}
function viewProducts(mouseEvent)
{
for(var i=0;i<counter;i++)
{
multiURLList[prodID[i]]=new Array();
multiURLIDs[prodID[i]]='';
}
getImageXY(mouseEvent)
var theX=mouseX;
var theY=mouseY;
getMapXY(theX,theY);
searchTolerance=(xDistance/iWidth)*pixelTolerance;
idWest=mapX-searchTolerance;
idNorth=mapY+searchTolerance;
idEast=mapX+searchTolerance;
idSouth=mapY-searchTolerance;
clickPointX[0]=mouseX;
clickPointY[0]=mouseY;
if(top.TextFrame.document.viewProducts!=null)
{
var prods=top.TextFrame.document.viewProducts.productList.options;
var selProds=new Array();
var counter=0;
for(var i=0;i<prods.length;i++)
{
if(prods[i].selected)
{
selProds[counter]=prods[i];
counter++;
}
}
if(selProds.length==0)
{
alert('You need to select a product \nto view from the list.');
return;
}
else if(selProds.length==1)
{
switch(selProds[0].value)
{
case prodID[0]:
currentProdID=prodID[0];
break;
case prodID[1]:
currentProdID=prodID[1];
break;
}
if(activeMapServiceIndex!=prodServiceID[currentProdID])
{
previousService=activeMapServiceIndex;
switchActiveMapService(prodServiceID[currentProdID],false,viewProductMode);
}
else
getProductFeatureIDs();
}
else
{
alert(selProds);
}
}
}
function processViewProducts(theReply)
{
theIndex=parseInt(activeMapServiceIndex);
if(aimsLayersPresent)
{
getLayers(theReply);
LayerVisible.length=0;
if(mapServiceLayersVisible[theIndex].indexOf(",")!=-1)
{
LayerVisible=mapServiceLayersVisible[theIndex].split(",");
}
else
{
LayerVisible[0]=mapServiceLayersVisible[theIndex]
}
mapServiceLayers[theIndex]=getLayerIDs(theReply);
}
hideRetrieveData();
getProductFeatureIDs();
}
function getProductFeatureIDs()
{
previousLayer=ActiveLayerIndex;
setActiveLayer(prodLayerID[currentProdID]);
var right=clickPointX[0];
var left=clickPointX[0];
var top=clickPointY[0];
var bottom=clickPointY[0];
if(right==left)
{
right+=.01;
left-=.01;
}
if(bottom==top)
{
bottom+=.01;
top-=.01;
}
var id=LayerID[prodLayerID[currentProdID]];
var axl='';
axl+='<ARCXML version="1.1">\n';
axl+='<REQUEST>\n';
axl+='<GET_FEATURES featurelimit="'+maxFeaturesReturned+'" beginrecord="0" outputmode="xml" geometry="true" envelope="true" globalenvelope="true" attributes="true">\n';
axl+='<LAYER id="'+id+'"/>\n';
axl+='<SPATIALQUERY subfields="#ALL#">\n';
axl+='<SPATIALFILTER relation="area_intersection">\n';
axl+='<ENVELOPE minx = "'+idEast+'" miny="'+idNorth+'" maxx="'+idWest+'" maxy="'+idSouth+'"/>\n';
axl+='</SPATIALFILTER>\n';
axl+='</SPATIALQUERY>\n';
axl+='</GET_FEATURES>\n';
axl+='</REQUEST>\n';
axl+='</ARCXML>';
sendToServer(imsQueryURL,axl,viewProductMode);
}
function processGetProductFeatureIDs(theReply)
{
var reply=new String(theReply);
var featureCount=justGetFeatureCount(reply);
multiURLList[currentProdID]=new Array();
if(featureCount==0)
{
alert('There are no '+prodName[currentProdID]+' covering that feature.');
return;
}
var names=getValues(reply,prodNameField[currentProdID]);
var vals=getValues(reply,prodIDField[currentProdID]);
var buf;
var urls=new Array();
for(var i=0;i<vals.length;i++)
{
var url=prodViewerURL[currentProdID];
switch(currentProdID)
{
case prodID[0]:
url+='?'+urlIDParameter[currentProdID]+'='+vals[i].replace(' ','%20');
break;
case prodID[1]:
url+='?'+urlIDParameter[currentProdID]+'='+vals[i].replace(' ','%20')+'&X='+mapX+'&Y='+mapY;
break;
}
multiURLList[currentProdID][i]=url;
}
if(vals.length>1)
{
multiURLIDs[currentProdID]='?'+urlIDParameter[currentProdID]+'S='+vals;
if(currentProdID==prodID[1])
multiURLIDs[currentProdID]+='&X='+mapX+'&Y='+mapY;
openViewMultiProductsWindow();
}
else
{
openViewProductWindow(url);
}
}
function viewScrollPhoto(X,Y)
{
mapX=X;
mapY=Y;
previousLayer=ActiveLayerIndex;
var currentProdID='aerial_photo';
setActiveLayer(prodLayerID[currentProdID]);
previousService=activeMapServiceIndex;
searchTolerance=(xDistance/iWidth)*pixelTolerance;
idWest=mapX-searchTolerance;
idNorth=mapY+searchTolerance;
idEast=mapX+searchTolerance;
idSouth=mapY-searchTolerance;
var id=LayerID[prodLayerID[currentProdID]];
var axl='';
axl+='<ARCXML version="1.1">\n';
axl+='<REQUEST>\n';
axl+='<GET_FEATURES featurelimit="'+maxFeaturesReturned+'" beginrecord="0" outputmode="xml" geometry="true" envelope="true" globalenvelope="true" attributes="true">\n';
axl+='<LAYER id="'+id+'"/>\n';
axl+='<SPATIALQUERY subfields="#ALL#">\n';
axl+='<SPATIALFILTER relation="area_intersection">\n';
axl+='<ENVELOPE minx = "'+idEast+'" miny="'+idNorth+'" maxx="'+idWest+'" maxy="'+idSouth+'"/>\n';
axl+='</SPATIALFILTER>\n';
axl+='</SPATIALQUERY>\n';
axl+='</GET_FEATURES>\n';
axl+='</REQUEST>\n';
axl+='</ARCXML>';
sendToServer(imsQueryURL,axl,1030);
}
function processScrollPhoto(theReply)
{
var names=getValues(theReply,prodNameField[currentProdID]);
var vals=getValues(theReply,prodIDField[currentProdID]);
var mapNum="";
for(var i=0;i<vals.length;i++)
{
switch(currentProdID)
{
case prodID[1]:
mapNum=vals[i].replace(' ','%20');
break;
}
}
winHandle.displayNewPhoto(mapNum,mapX,mapY);
}
function refreshOrderFrame()
{
parent.OrderFrame.document.location.reload();
}
function openViewProductWindow(url)
{
var winName='';
var winParams=prodViewerParams[currentProdID];winHandle=window.open(url,winName,winParams);
}
function openViewMultiProductsWindow()
{
var winUrl=viewMultiURL+multiURLIDs[currentProdID];
var winName='viewMultiProdsWin';
var winParams='scrollbars=true,resizable=false,width=200,height=600,menubar=false,status=false,location=false,screenX=220,screenY=15,hotkeys=no,dependent=true';
winHandle=window.open(winUrl,winName,winParams);
}
function getValues(reply,theField)
{
var featureCount=justGetFeatureCount(reply);
var fieldValues=new Array(featureCount);
var firstValueIndex=reply.indexOf(theField);
var lastValueIndex=reply.lastIndexOf(theField);
if(firstValueIndex!=lastValueIndex)
{
var curValueIndex=0;
for(var i=0;i<featureCount;i++)
{
curValueIndex=reply.indexOf(theField,curValueIndex);if(curValueIndex==-1)break;
fieldValues[i]=justGetFieldValue(reply,theField,curValueIndex);curValueIndex=reply.indexOf("</FEATURE",curValueIndex);}
}
else
fieldValues[0]=justGetFieldValue(reply,theField,0);
return fieldValues;
}
function startViewProductBox(e)
{
if(checkIfActiveLayerAvailable())
{
moveLayer("theMap",hspc,vspc);
getImageXY(e);
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);
selectBox=true;
showLayer("zoomBoxTop");
showLayer("zoomBoxLeft");
showLayer("zoomBoxRight");
showLayer("zoomBoxBottom");
}
highlightedOne="";
}
return false;
}
}
function stopViewProductBox(e)
{
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;
}
else
{
pixelX=xDistance/iWidth;
var theY=iHeight-ztop;
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;
}
window.scrollTo(0,0);
queryStartRecord=1;
viewProducts(e);
}
