 //var host = "http://darthmaul/"

//which tools are to be present
var identify = true;
var zoomin = true;
var zoomout = true;
var pan = true;
var pan1 = true;
 
//inital tool setup
var initialTool = new String;
var tool = new String;
var initialTool = "identify";
var tool = initialTool;

//toolpic setting
function resetToolPic() { 
	//set ToolPics to non-set
	if (identify) parent.ButtonFrame.document.identify.src="images/info_high.gif";
	if (zoomin) parent.ButtonFrame.document.zoomin.src= "images/zoomin_high.gif";
	if (zoomout) parent.ButtonFrame.document.zoomout.src= "images/zoomout_high.gif";
	//if (pan) parent.ButtonFrame.document.pan.src= "/images/pan_high.gif";
	if (pan1)  parent.ButtonFrame.document.pan1.src= "images/pan_high.gif"; 
	 
}
		
function setToolPic(selTool) {   
	resetToolPic();
	if (selTool == "identify") parent.ButtonFrame.document.identify.src= "images/info_low.gif";
	if (selTool == "zoomin") parent.ButtonFrame.document.zoomin.src= "images/zoomin_low.gif";
	if (selTool == "zoomout") parent.ButtonFrame.document.zoomout.src= "images/zoomout_low.gif";
	//if (selTool == "pan") parent.ButtonFrame.document.pan.src= "/images/pan_low.gif";
	if (selTool == "pan1")   parent.ButtonFrame.document.pan1.src= "images/pan_low.gif";  
	 
}

function setTool(selectedTool) {
	switch (selectedTool) {
		
		case "zoomin":
		//	parent.MapFrame.document.mapserv.mode.value = "browse";
			parent.MapFrame.document.mapserv.zoomdir.value = 1;
			zoomdir = 1;
			tool = "zoomin";		
		break;
		
		case "zoomout":
		//	parent.MapFrame.document.mapserv.mode.value = "browse";
			parent.MapFrame.document.mapserv.zoomdir.value = -1;
			zoomdir = -1;
			tool = "zoomout";
		
		break;
		
		case "fullextent":
		
		        //alert( parent.MapFrame.document.mapserv.mode.value);
		         fullview();
		         		        
		break;
			
	        case "refresh" :
		//	parent.MapFrame.document.mapserv.mode.value = "browse";
			parent.MapFrame.document.mapserv.zoomdir.value = "0";
			zoomdir = 0;
		//	parent.MapFrame.document.mapserv.submit();
			return(false)
		break;
		
		case "pan":
		        
		        //alert( parent.MapFrame.document.mapserv.mode.value);
		//	mode = "browse";
		        if (theSelection != "")
			{  
			  parent.MapFrame.document.mapserv.mode.value = "itemnquery";			   
	                }
	                else
	                { 
	                  parent.MapFrame.document.mapserv.mode.value="browse";
	                }  
			parent.MapFrame.document.mapserv.zoomdir.value = 0;
			zoomdir = 0;
			tool = "panning";			
									
		break;
		
		case "identify":
		 //	parent.MapFrame.document.mapserv.mode.value="query";
			tool = "identify";
		
		break;	
		
		case "pan1":
			 
			parent.MapFrame.document.mapserv.zoomdir.value = 0;
			zoomdir = 0;
			tool = "panningn";			
				
		break;
	}
}



function fullview()
{  
   if (parent.MapFrame.document.mapserv.mode.value == "itemnquery")
	{     
	       parent.MapFrame.document.mapserv.mapext.value= fullExtent;
	       URLString = new String;
	       imageext = new String;

	       URLString = "/cgi-bin/mapserv.exe?map="+escape(parent.MapFrame.document.mapserv.map.value);

	       parseImgExt();

	       for (i=0; i<newext.length; i++) 
		  {   imageext += newext[i];
		      if (i<newext.length-1) imageext += "+";
		  }
 
               for (i=0; i<parent.LayerFrame.document.layerForm.layer.length;i++) 
                   {   if (parent.LayerFrame.document.layerForm.layer[i].checked)
	                { URLString += "&layer="+parent.LayerFrame.document.layerForm.layer[i].value; }
                   }
        
	       URLString += "&imgext=" + imageext;		  
	       URLString += "&mapext=" + parent.MapFrame.document.mapserv.mapext.value;
	       URLString += "&imgxy="+mouseX+"+"+mouseY;		       

	       if (theSelection != "")
	       {
		     URLString += "&mode=itemnquery";
		     if (projectquery == 1)
			{  URLString += "&map_web_error=../zoomaway.html&map_querymap_style=hilite&map_querymap_size="+imgxy;     }
		     else
			{  URLString += "&map_web_error=../zoomaway.html&map_querymap_size="+imgxy;   }
		     
		     qlayer = qlayerCheck();
		     URLString += "&qlayer="+qlayer; 
		     URLString += "&map_"+qlayer+"_header=demo.html";
		     URLString += "&map_"+qlayer+"_template=zoomto.html";
		     URLString += "&map_"+qlayer+"_filter=" + theSelection;  		  
		     
		     //URLString += "&qlayer=program&map_querymap_size=" + imgxy + "&map_program_header=demo.html&map_program_template=zoomto.html&map_web_error=../keystone/zoomaway.html&map_program_filter=" + theSelection;		   
		}

		parent.MapFrame.location.href = URLString;
	}

	else
	{	
		parent.MapFrame.document.mapserv.mapext.value= fullExtent;
		URLString = new String;
		imageext = new String;

		URLString = "/cgi-bin/mapserv.exe?map="+escape(parent.MapFrame.document.mapserv.map.value);

		parseImgExt();

		for (i=0; i<newext.length; i++) 
		  {   imageext += newext[i];
		      if (i<newext.length-1) imageext += "+";
		  }

		URLString += "&imgext=" + imageext;			       

		for (i=0; i<parent.LayerFrame.document.layerForm.layer.length;i++) 
		{   if (parent.LayerFrame.document.layerForm.layer[i].checked)
		      {  URLString += "&layer="+parent.LayerFrame.document.layerForm.layer[i].value; }
		}

		URLString += "&mapext=" + parent.MapFrame.document.mapserv.mapext.value;
		URLString += "&imgxy="+mouseX+"+"+mouseY;		       

		parent.MapFrame.location.href = URLString;        
	}	

}	
