 
var theSelection = ""; 

function identify(e) {
	getImageXY(e);
}

function makeQueryURL()
{	 
    if (insideMap)
    { 
	getMapXY(mouseX,mouseY);
	queryX = mapX.toString();
	queryY = mapY.toString();
	URLString = new String;
	 
	URLString = "/cgi-bin/mapserv.exe?map="+escape(parent.MapFrame.document.mapserv.map.value);

	parseImgExt();
	URLString += "&imgext="
	for (i=0; i<newext.length; i++) 
	{
	   URLString += newext[i];	   
	   if (i<newext.length-1) 
	      { URLString += "+";  }
	}
	
	URLString += "&imgxy="+mouseX+"+"+mouseY;	
	URLString += "&mode=query"; 
        
	showQuery(URLString);	
   }
}



function showQuery(URL) 
{       //alert(URL);
	parent.QueryFrame.location.href = URL;	
	 
}

function zoomToQuery(bridge)
{

   // alert(bridge);
    
    var Selection =  "%2F" + bridge + "%2F";    
    
    URLString = new String;
    
    URLString = "/cgi-bin/mapserv.exe?map="+escape(parent.MapFrame.document.mapserv.map.value);
    
    parseImgExt();
    
    URLString += "&imgext="
    for (i=0; i<newext.length; i++) 
    {   URLString += newext[i];
        if (i<newext.length-1) URLString += "+";
    }
    
    URLString += "&zoomdir = 0" ;
    URLString += "&imgxy="+mouseX+"+"+mouseY;
    URLString += "&mapext="+parent.MapFrame.document.mapserv.imgext.value;
        
    URLString += "&mode=itemnquery";
    URLString += "&qlayer=bridge&map_querymap_size=" + imgxy  + "&map_bridge_header=demo.html&map_bridge_template=zoomto.html&map_web_error=../zoomaway.html&map_bridge_filter=" + Selection;
   
   //  alert(URLString);
    
    parent.MapFrame.location.href = URLString;   

}


function zoomToSelected()
{  
   var i =0;  
     
   //alert(parent.QueryFrame.document.Qform.Bnum.length);  
   
   if (parent.QueryFrame.document.Qform.Bnum.length == 2)
   {     //alert("No Bridges Found"); 
	//imgWin = window.open( "", "imgwin", "width=250,height=150,resizable,screenX=0,screenY=0,left=200,top=300");

	//imgWin.document.write('<html><head><title>'+ "Stone Arch Bridge" +'  </title>');
	//imgWin.document.write('</head>');
	//imgWin.document.write('<BODY BGCOLOR=#f0e4be TEXT=#191970 >');

	//imgWin.document.write('<center>');

	//imgWin.document.write(' <br><br> <b>No Bridges Found</b> <br><br><br> ');
	
	//imgWin.document.write(' <input type="button" value="Ok" onClick="window.close();">');
	
	//imgWin.document.write('</center>');
	//imgWin.document.write('</body></html>');
        //imgWin.document.close();
        
        return ;
         
         //urlOptions = "&mapext=" + parent.MapFrame.document.mapserv.mapext.value;   
   }  
    
   else 
      if (parent.QueryFrame.document.Qform.Bnum.length == 3)  
         {    theSelection =  "%2F" + parent.QueryFrame.document.Qform.Bnum[i].value + "%2F";               
              urlOptions = "&mapext=" + parent.QueryFrame.document.Qform.Ext_val[i].value;
              parent.MapFrame.document.mapserv.mapext.value = parent.QueryFrame.document.Qform.Ext_val[i].value;
         }
      else 
        {    
	    theSelection = "%2F";       
	    while (i < parent.QueryFrame.document.Qform.Bnum.length - 3)
	    { 	       
	      theSelection = theSelection + parent.QueryFrame.document.Qform.Bnum[i].value +"%7C";
	      i = i + 1;
	    } 
	    theSelection = theSelection + parent.QueryFrame.document.Qform.Bnum[i].value + "%2F";	    
	    urlOptions = "&mapext=shapes";
	    parent.MapFrame.document.mapserv.mapext.value=mapext;
	}  
 
  
  URLString = new String;

  URLString = "/cgi-bin/mapserv.exe?map="+escape(parent.MapFrame.document.mapserv.map.value);

  parseImgExt();
  
   
  URLString += "&imgext="
  for (i=0; i<newext.length; i++) 
  {   URLString += newext[i];
      if (i<newext.length-1) URLString += "+";
  }
 
  URLString += "&imgxy="+mouseX+"+"+mouseY; 
  mode = "itemnquery";    
  URLString += "&mode=itemnquery";
  URLString += urlOptions;  
  URLString += "&qlayer=bridge&map_querymap_size=" + imgxy + "&map_bridge_header=demo.html&map_bridge_template=zoomto.html&map_web_error=../zoomaway.html&map_bridge_filter=" + theSelection;
  
  //alert(URLString);
  parent.MapFrame.location.href = URLString;     
 
 
 } // zoomToSelected()
 
 
 
 function zoomToSelected1(i)
 {   
   bridgenum = parent.QueryFrame.document.Qform.Bnum[i].value;
    
    theSelection =  "%2F" + bridgenum + "%2F";
    urlOptions = "&mapext=" + parent.QueryFrame.document.Qform.Ext_val[i].value;
    parent.MapFrame.document.mapserv.mapext.value = parent.QueryFrame.document.Qform.Ext_val[i].value;
     
   URLString = new String;
 
   URLString = "/cgi-bin/mapserv.exe?map="+escape(parent.MapFrame.document.mapserv.map.value);
 
   parseImgExt();
   
    
   URLString += "&imgext="
   for (i=0; i<newext.length; i++) 
   {   URLString += newext[i];
       if (i<newext.length-1) URLString += "+";
   }
 
   URLString += "&imgxy="+mouseX+"+"+mouseY;
  
   mode = "itemnquery";
   
   URLString += urlOptions;
   URLString += "&mode=itemnquery";
   URLString += "&qlayer=bridge&map_querymap_size=" + imgxy + "&map_bridge_header=demo.html&map_bridge_template=zoomto.html&map_web_error=../zoomaway.html&map_bridge_filter=" + theSelection;
  
  // alert(URLString); 
   
   parent.MapFrame.location.href = URLString;     
    
  } // zoomToSelected()
  
  function zoomToTownship()
  { 
    if (isNav6)
    {             
      i = parent.ScriptFrame.document.searchform.Township.selectedIndex;        	    
      Township = parent.ScriptFrame.document.searchform.Township.options[i].value; 
      parent.ScriptFrame.document.searchform.County.options[0].selected = "None";
    } 
    else 
    {
      parent.ScriptFrame.document.searchform.County.options.value = "None";	    
      Township = parent.ScriptFrame.document.searchform.Township.options.value; 
    }
       
	index1 = parent.ScriptFrame.document.searchform.Township.selectedIndex;   
	TownshipName = parent.ScriptFrame.document.searchform.Township.options[index1].text;

	parent.ScriptFrame.document.searchform.Keyword.value = "";

	parent.QueryFrame.location.href = "/Township.php?Township="+Township+"&TownshipName="+TownshipName;
     
   
 }
 
 
  
 function zoomToSelectedTownship()
 {  
    var i =0;  
      
    // alert(parent.QueryFrame.document.Qform.Extval.value);  
    
    if (parent.QueryFrame.document.Qform.Bnum.length == 2)
    {     //alert("No Bridges Found"); 
 	//imgWin = window.open( "", "imgwin", "width=250,height=150,resizable,screenX=0,screenY=0,left=200,top=300");
 
 	//imgWin.document.write('<html><head><title>'+ "Stone Arch Bridge" +'  </title>');
 	//imgWin.document.write('</head>');
 	//imgWin.document.write('<BODY BGCOLOR=#f0e4be TEXT=#191970 >');
 
 	//imgWin.document.write('<center>');
 
 	//imgWin.document.write(' <br><br> <b>No Bridges Found</b> <br><br><br> ');
 	
 	//imgWin.document.write(' <input type="button" value="Ok" onClick="window.close();">');
 	
 	//imgWin.document.write('</center>');
 	//imgWin.document.write('</body></html>');
        //imgWin.document.close();
        
        theSelection = " ";	    
	urlOptions = "&mapext=" + parent.QueryFrame.document.Qform.Extval.value;
	parent.MapFrame.document.mapserv.mapext.value=parent.QueryFrame.document.Qform.Extval.value;
       //  return ;
          
          //urlOptions = "&mapext=" + parent.MapFrame.document.mapserv.mapext.value;   
    }  
     
    else 
       if (parent.QueryFrame.document.Qform.Bnum.length == 3)  
          {    theSelection =  "%2F" + parent.QueryFrame.document.Qform.Bnum[i].value + "%2F";               
               urlOptions = "&mapext=" + parent.QueryFrame.document.Qform.Extval.value;
               parent.MapFrame.document.mapserv.mapext.value = parent.QueryFrame.document.Qform.Extval.value;
          }
       else 
         {    
 	    theSelection = "%2F";       
 	    while (i < parent.QueryFrame.document.Qform.Bnum.length - 3)
 	    { 	       
 	      theSelection = theSelection + parent.QueryFrame.document.Qform.Bnum[i].value +"%7C";
 	      i = i + 1;
 	    } 
 	    theSelection = theSelection + parent.QueryFrame.document.Qform.Bnum[i].value + "%2F";	    
 	    urlOptions = "&mapext=" + parent.QueryFrame.document.Qform.Extval.value;
 	    parent.MapFrame.document.mapserv.mapext.value=parent.QueryFrame.document.Qform.Extval.value;
 	}  
  
   
   URLString = new String;
 
   URLString = "/cgi-bin/mapserv.exe?map="+escape(parent.MapFrame.document.mapserv.map.value);
 
   parseImgExt();
   
    
   URLString += "&imgext="
   for (i=0; i<newext.length; i++) 
   {   URLString += newext[i];
       if (i<newext.length-1) URLString += "+";
   }
  
   URLString += "&imgxy="+mouseX+"+"+mouseY; 
   mode = "itemnquery";    
   URLString += "&mode=itemnquery";
   URLString += urlOptions;  
   URLString += "&qlayer=bridge&map_querymap_size=" + imgxy + "&map_bridge_header=demo.html&map_bridge_template=zoomto.html&map_web_error=../zoomaway.html&map_bridge_filter=" + theSelection;
   
   //alert(URLString);
   parent.MapFrame.location.href = URLString;     
  
  
  } // zoomToSelected()
 
 
 function zoomToCounty()
 { 
    if (isNav6)
       {    
           i = parent.ScriptFrame.document.searchform.County.selectedIndex;
	   county = parent.ScriptFrame.document.searchform.County.options[i].value; 
	   parent.ScriptFrame.document.searchform.Township.options[0].selected = "None";	       
       } 
    else 
       {
 	   parent.ScriptFrame.document.searchform.Township.options.value = "None";	   
           county = parent.ScriptFrame.document.searchform.County.options.value;  
       }
   
   parent.ScriptFrame.document.searchform.Keyword.value = " ";	   
   key = "";
   
   parent.QueryFrame.location.href = "/sab_report1.php?county="+county+"&key="+key;    
  
 }