﻿
     // If the browser is Firefox get the version number

var ffv = 0;

var ffn = "Firefox/"

var ffp = navigator.userAgent.indexOf(ffn);

if (ffp != -1) ffv = parseFloat(navigator.userAgent.substring(ffp + ffn.length));

// If we're using Firefox 1.5 or above override the Virtual Earth drawing functions to use SVG

if (ffv >= 1.5) {

Msn.Drawing.Graphic.CreateGraphic=function(f,b) { return new Msn.Drawing.SVGGraphic(f,b) }

}
     Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
     Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);
     var postbackElement=null;
     var searchWord = null;
     var isSubTerm = false;
     var selectedTerm = null;
     var siteid = null;
     var windowContent = null;
     var keyword;
     var lat1;
     var lon1;
     var lat2;
     var lon2;
     var isHuActive = false;
     var isCoordActive = true;
     var searchType = 'coordinates';
     var wshed;
     var isNewSearch = false;
     var seconds = 0;
     //var pcount = 250;
//Constants
//var mWidth = pageWidth();
var mWidth;
//var mHeight = pageHeight()-66;
var mHeight;
var PopupPrefix = "VPOP";
     var bdate;
     var edate;
     var map = null;  
     
function positionPageElements(){
    mWidth = pageWidth();
    mHeight = pageHeight();
     
     //document.getElementById("myMap").style.width=mWidth*1+'px';
     document.getElementById("myMap").style.height=mHeight-60+'px';
     
     document.getElementById("searchboxcontainer").style.left=mWidth*0.5-265+'px';   
     document.getElementById("searchboxcontainer").style.visibility="visible";  
     document.getElementById("exampleKeywords").style.left=mWidth*0.5-265+'px';   
     document.getElementById("exampleKeywords").style.visibility="visible"; 
     document.getElementById("keywordsTitle").style.left=mWidth*0.5-265+'px';
     document.getElementById("keywordsTitle").style.visibility="visible"; 
     document.getElementById("topzoommenu").style.left=mWidth*0.5-45+'px'; 
     document.getElementById("topzoommenu").style.visibility="visible";
     document.getElementById("cartContainer").style.left=mWidth-250+'px'; 
     document.getElementById("mask").style.width=mWidth+20+'px'; 
     document.getElementById("mask").style.height=mHeight+100+'px';
     document.getElementById("maskLoading").style.width=mWidth+20+'px'; 
     document.getElementById("maskLoading").style.height=mHeight+100+'px';
     document.getElementById("indicator").style.left=mWidth*0.5-125+'px';
     document.getElementById("indicator").style.top=mHeight*0.5-100+'px';
     document.getElementById("ProgressLoading").style.left=mWidth*0.5-125+'px';
     document.getElementById("ProgressLoading").style.top=mHeight*0.5-100+'px';
     
     document.getElementById("DownloadFileDialog").style.left=mWidth*0.6-125+'px';
     document.getElementById("DownloadFileDialog").style.top=mHeight*0.6-100+'px';

}           
function GetMap() { 

   //if (!(document.compatMode && document.all)){
   positionPageElements();
   //alert('Your browser may have compatibility issues. IE 6 or higher is recommended.');
//}
//
//CloseSearchWindow();
//
//window.moveTo(0,0);
//window.resizeTo(screen.width,screen.height);
//window.resizeTo(screen.availWidth,screen.availHeight);


     
     
     map = new VEMap('myMap');
     //map.SetDashboardSize(VEDashboardSize.Tiny); 

     map.LoadMap(new VELatLong(30, -95), 4,VEMapStyle.Hybrid, false, VEMapMode.Mode2D, true, 0); 

     map.HideDashboard(); 

 
     //this is new
//changed     map.AttachEvent("onchangeview", GetPinData);
  map.AttachEvent("onchangeview", RefreshPins);
  map.AttachEvent("onmousedown", CreateBoundingBox);
  map.AttachEvent("onmousemove", moveHandler);

CountSeconds();
    // map.AttachEvent("onmouseup", resizeZoomBox);
     
    //map.AttachEvent("onmousedown", "return false;");
    //   map.AttachEvent("onmouseup", released);
   //  map.AttachEvent("onmousemove", myEventTester);
    //map.vemapcontrol.EnableGeoCommunity(true);

     } 
      


//public varibles  
var pins = new Array();
var CurrentPopupID = 0;

//class for clustered pin
function clusteredPin(loc, bounds) {
	this.loc = loc;
	this.bounds = bounds;
} 

function menuZoomIn(){
    var zoom = map.GetZoomLevel();
    if (zoom<18){
      map.SetZoomLevel(zoom+2);
    }
}
function menuZoomOut(){
  var zoom = map.GetZoomLevel();
  if (zoom>2){
    map.SetZoomLevel(zoom-2);
  }
}
      
      
function RefreshPins(){
  isNewSearch=false;
  GetPinData();
}
//var alertcount = 0;
function GetPinData(){  
    //encode the current map bounds
    //alert("getpindata:"+hasDataToDraw)
    var points = new Array();
    var pixel1 = new VEPixel(0,0);
    points.push(map.PixelToLatLong(pixel1));

    var pixel2 = new VEPixel(mWidth,mHeight);
    points.push(map.PixelToLatLong(pixel2));
    var bounds = createEncodings(points);
    //get zoomlevel

    var zoom = map.GetZoomLevel();
    //call webservice
    //alert(alertcount++);
    //if (keyword!=null && keyword!=""){
    // removing keyword requirement
    if (true){
        if(searchType == 'coordinates'){
            // ClusterPin.MapService.NumberOfPins(bounds, lat1, lon1, lat2, lon2, keyword, edate, bdate, onPinCountComplete,OnFailed);
            
            if (isSubTerm==true){
                if (zoom>10){
                    ClusterPin.MapService.GetNoClusterSubStationMap(bounds, lat1, lon1, lat2, lon2, keyword, edate, bdate, selectedTerm, onStationsComplete,OnFailed);
                }else{
                    ClusterPin.MapService.GetClusteredSubMapData(bounds, zoom, lat1, lon1, lat2, lon2, keyword, edate, bdate, selectedTerm, OnMapDataSucceeded,OnFailed);
                }
            }else{
                if (zoom>10){
                    ClusterPin.MapService.GetNoClusterStationMap(bounds, lat1, lon1, lat2, lon2, keyword, edate, bdate, isNewSearch, onStationsComplete,OnFailed);
                }else{
                    ClusterPin.MapService.GetClusteredMapData(bounds, zoom, lat1, lon1, lat2, lon2, keyword, edate, bdate, isNewSearch, OnMapDataSucceeded,OnFailed);
                }
            }
        }else{
            if (isSubTerm==true){
                if (zoom>10){
                    ClusterPin.MapService.GetNoClusterSubStationMapbyHU(bounds, wshed, keyword, edate, bdate, selectedTerm, onStationsComplete,OnFailed);
                }else{
                    ClusterPin.MapService.GetClusteredSubMapDatabyHU(bounds, zoom, wshed, keyword, edate, bdate, selectedTerm, OnMapDataSucceeded,OnFailed);
                }
            }else{
                if (zoom>10){
                    ClusterPin.MapService.GetNoClusterStationMapbyHU(bounds, wshed, keyword, edate, bdate, isNewSearch, onStationsComplete,OnFailed);
                }else{
                    ClusterPin.MapService.GetClusteredMapDatabyHU(bounds, zoom, wshed, keyword, edate, bdate, isNewSearch, OnMapDataSucceeded,OnFailed);
                }
            }
        }
    }
  //newly removed 
//isNewSearch = false;

}
function CountSeconds(){
seconds+=1;
setTimeout("CountSeconds()",1000);

}
function OnFailed(error)
{
//    var stackTrace = error.get_stackTrace();
//    var message = error.get_message();
//    var statusCode = error.get_statusCode();
//    var exceptionType = error.get_exceptionType();
//   var timedout = error.get_timedOut();
//   
//    // Display the error.    
//   var RsltElem = 
//        "Stack Trace: " +  stackTrace + "<br/>" +
//       "Service Error: " + message + "<br/>" +
//        "Status Code: " + statusCode + "<br/>" +
//        "Exception Type: " + exceptionType + "<br/>" +
//        "Timedout: " + timedout;
//        alert(RsltElem);
if (seconds>301){
alert('Session timed out due to prolonged user inactivity.Please resubmit your query by simply clicking \'Go!\'or refresh the page to start over.');
map.DeleteAllShapes();
}else{
//alert('An unforseen error occurred. Sorry for the inconvenience.');
}
document.getElementById("indicator").style.visibility="hidden";
}

//callback when data returns from web service
var hasDataToDraw = false;
function OnMapDataSucceeded(results, eventArgs)
{


    //decode pins
    var result=results.split(",")
    var locs = decodeLine(result[0]);
    seconds = 0;
    //clear existing pins
    pins = new Array();
    map.DeleteAllShapes();
    pinID = 0;
    hasDataToDraw = (locs.length > 0);
    
    //put data into memory
    for(x = 0; x < locs.length; x++) {
         pins.push(new clusteredPin(locs[x],result[x+1]));
         AddPinAlt(x, locs[x])
    }
       document.getElementById("indicator").style.visibility="hidden";
       searchWord=document.getElementById("KeywordBox").value;
     // alert("mapdatasuccess"+locs.length);
           
}

//helper to add a VE pin.
function AddPinAlt(pinID, latlon){
    var pin = new VEShape(VEShapeType.Pushpin, latlon);
    //var pin = new VE(pinID, latlon, 'images/cluster2.gif', "Station(s)", "Zoom in further to see individual stations and/or details" + "", "DefaultPinOffset");
    pin.SetCustomIcon("<img src='images/cluster2.gif'/>");
    //pin.
    map.AddShape(pin);
}
         
function PanMap(x,y,latlong){ 
    if (x!=null & y!=null) { 
        map.Pan(x,y);
    }else if (latlong!=null) {
        map.PanToLatLong(latlong);
    }
}  
   
function beginRequest(sender, args) {
     postbackElement = args.get_postBackElement();
}

   
   function pageLoaded(sender, args) {
            if(postbackElement!=null){
            if (postbackElement.id.toLowerCase().indexOf('button1') > -1 || postbackElement.id.toLowerCase().indexOf('button2') > -1) {
                document.getElementById("divScroll").style.left=mWidth-250+'px'; 
                ShowNavigationTree();
                menu2[2]='<a href="javascript:ToggleTreeWindow()">Results Tree</a>'
            }
        }
        }
function getTodaysDate() {
       var now = new Date();
       var m = now.getMonth()+1 ;
       if (m < 10 )
        { m = "0"+m;
        }
        else {
        m = m +"";
        }
        var d = now.getDate();
        if (d < 10 ) {
        d = "0"+d;
        } else {
        d = d+"";
        }
   var  adate = m + "/" + d +"/" + now.getFullYear();
  
    return adate
}



   function ShowStations()
   {
   HideNavigationTree();
   map.DeleteAllShapes();
   document.getElementById("indicator").style.visibility="visible";
   keyword = document.getElementById("KeywordBox").value;
   lat1 = document.getElementById("SouthLat").value;
   lon1 = document.getElementById("WestLong").value;
   lat2 = document.getElementById("NorthLat").value;
   lon2 = document.getElementById("EastLong").value;
   bdate = document.getElementById("beginDate").value;
   edate = document.getElementById("endDate").value;
   if (bdate==null || bdate=="" || bdate== " "){
   bdate = "01/01/1800";
   }
   if (edate==null|| edate=="" || edate== " "){
   edate = getTodaysDate();  
   } 
   isNewSearch = true;
   isSubTerm=false;
   if (isHuActive){
   searchType = 'watershed';
   wshed = document.getElementById("WatershedBox").value;
   
   bdate = document.getElementById("beginDateHU").value;
   edate = document.getElementById("endDateHU").value;
   if (bdate==null || bdate=="" || bdate== " "){
   bdate = "01/01/1998";
   }
   if (edate==null|| edate=="" || edate== " "){
   edate = getTodaysDate();  
   } 
   
   
   if (wshed==null || wshed==""){
   
   wshed='Schuylkill River, Pennsylvania';
   }
   }else{
   
   searchType = 'coordinates';
   }
if(lat1==null || lat2=="" || lon1==" " || lon2==null || lat2==null){
lat1="36";
lat2="39";
lon1="-79";
lon2="-76";

}
   //if (keyword!=null && keyword!=""){  
   // allow blank keywords to pass...
   if (true){

      GetPinData();//newly added August 7
   
      searchWord=keyword; 
      if (searchType == 'coordinates'){
  __doPostBack('Button1','');
   }
         if (searchType == 'watershed'){
   __doPostBack('Button2','');
//newly added August 7
         Stations.StationsService.GetBoundingBoxFromHU(wshed, keyword, edate, bdate,onBoundingBoxComplete); 

  }
   searchWord=keyword;
   }else{
            alert('Keyword box is blank. Please enter a keyword');
            document.getElementById("indicator").style.visibility="hidden";
   
   }
   //newly removed
  // isNewSearch = false;
 
   }
   
   //newly added August 7
   function onBoundingBoxComplete(bbox){
   if (bbox.NWLat!=0 ){

           map.SetMapView([new VELatLong(bbox.NWLat,bbox.NWLon), 
                new VELatLong(bbox.SELat,bbox.SELon)]);
}
   
   }
function onCountComplete(count){
alert(count);
if (count<750){
searchWord = document.getElementById("KeywordBox").value;

ShowStationsOnMap();
__doPostBack('Button1','');


}else{
alert('Your query returned too many results. Please try again with a smaller bounding box.');
document.getElementById("indicator").style.visibility="hidden";
}

}

function ShowNavigationTree(){

var isvcc = document.getElementById("cartContainer").style.visibility;
if (isvcc=='visible'){
document.getElementById("cartContainer").style.visibility="hidden";
}

document.getElementById("divScroll").style.visibility="visible";

}

function HideNavigationTree(){

document.getElementById("divScroll").style.visibility="hidden";

}


function ShowStationsOnMap()
   {
   map.DeleteAllShapes();
   document.getElementById("indicator").style.visibility="visible";
     isSubTerm = false;
     //newly added
     isNewSearch=false;
     selectedTerm = null;
   GetPinData();
   }
   
   
  function Subset(branch,keyword)
   {
   map.DeleteAllShapes();
   document.getElementById("indicator").style.visibility="visible";
        isSubTerm = true;
        //newly added
       // isNewSearch =false;
        selectedTerm = branch;
        GetPinData();
        
   //Stations.StationsService.GetStationSubset(lat1,lon1,lat2,lon2, keyword, bdate, edate, branch, onStationsComplete);  
   }

   function HideSearchWindow(){
   
   document.getElementById("DIV5").style.visibility="hidden";
   
   }
   
   function ShowSearchWindow(){
   
   document.getElementById("DIV5").style.visibility="visible";
   
   }
   
   function onStationsComplete(stations){
   //new
   seconds = 0;
   map.DeleteAllShapes();
   //new ends
   for(var i=0; i < stations.length; i++){	
     //AddAJAXPin(stations[i].StationID,new VELatLong(stations[i].Lat, stations[i].Lon),'images/'+stations[i].Organization+'.gif', stations[i].StationCode);
     AddAJAXPin(stations[i].StationID,new VELatLong(stations[i].Lat, stations[i].Lon),'icon.aspx?name='+stations[i].Organization, stations[i].StationCode);
   }
   document.getElementById("indicator").style.visibility="hidden";
    searchWord=document.getElementById("KeywordBox").value;

   } 
    
    
    function AddAJAXPin(pinID,latlon, icon_url, siteCode)
{
   
    //var pin = new VEPushpin(pinID, latlon, icon_url, 
    //   siteCode , '<a href="javascript:GetDetails(\''+pinID+'\')">See Details</a>&nbsp;<a href="javascript:AddSiteToCart(\''+siteCode+'\',\''+pinID+'\')">Add to Cart</a>');  
    var pin = new VEShape(VEShapeType.Pushpin, latlon);
   
//var pin = new VEPushpin(pinID, latlon, icon_url, 
  //     siteCode , '<a href="javascript:GetDetails(\''+pinID+'\')">See Details</a>&nbsp;<a href="javascript:AddSiteToCart(\''+pinID+'\')">Add to Cart</a>');  
     pin.SetTitle(siteCode);
   pin.SetCustomIcon(icon_url);
   //pin.SetDescription('<a href="javascript:GetDetails(\''+pinID+'\')">See Details</a>&nbsp;<a href="javascript:AddSiteToCart(\''+pinID+'\')">Add to Cart</a>');
   
   //pin.SetTitle(pinID);

pin.SetDescription('<a href="javascript:GetDetails(\''+pinID+'\',\''+pin.GetID()+'\')">See Details</a>&nbsp;<a href="javascript:AddSiteToCart(\''+siteCode+'\',\''+pinID+'\')">Add to Cart</a>');
    map.AddShape(pin);
    //pin.SetDescription('<a href="javascript:GetDetails(\''+pinID+'\',\''+pin.GetID()+'\')">See Details</a>&nbsp;<a href="javascript:AddSiteToCart(\''+siteCode+'\',\''+pinID+'\')">Add to Cart</a>');
} 

function GetDetails(siteID,DivID){
    

   Stations.StationsService.GetStationDetail(siteID, onDetailsComplete);  
   //document.getElementById(siteID + "_" + map.GUID).onmouseout();
   //document.getElementById(DivID).onmouseout();
   //VEHideVEShapeERO(false);

}

function onDetailsComplete(details){
//alert ("detailscomplete"+details);
   windowContent =  '<table style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px; padding-top: 5px; background-color: white;width:445px;height:275px;">';
   //windowContent += '<tr><td><tr><td style="width:139px;height:133px"><img src="images/'+details.Organization+'logo.jpg"/></td><td style="text-align:left;width:306px;height:12px">';
   windowContent += '<tr><td><tr><td style="width:139px;height:133px"><img src="logo.aspx?name='+details.Organization+'"/></td><td style="text-align:left;width:306px;height:12px">';
   windowContent += '<b>Site ID: </b>'+details.StationCode+'<br/><b>Site Name: </b>'+details.StationName+'<br/>';
   windowContent += '<b>Latitude: </b>'+details.Lat+'<br/><b>Longitude: </b>'+details.Lon+'<br/><b>Elevation: </b>'+details.Elevation+'<br/><b>County: </b>'+details.County+'<br/>';
   windowContent += '<b>State: </b>'+details.State+'<br/><input type="Hidden" id="siteId" name="siteId" value="'+details.StationCode+'"></td></tr>';
   windowContent += '<tr> <td colspan="2" style="text-align:left;width:445px;padding-left:5px"><b>All variables measured at this station</b><br>';
   windowContent += '<select id="allVar" name="allVar" style="font-size:small;width: 380px;z-index:601;">';
   siteid=details.SiteID;
   Stations.StationsService.GetStationCatalog(siteid, bdate, edate, onCatalogComplete); 
}

function onCatalogComplete (catalog){
var catContent;
//alert(catalog);
for(var i=0; i < catalog.length; i++)
   {
   if (catalog[i].SourceID==3){
   catalog[i].VariableName= catalog[i].VariableName+ ' - Real-Time';
   }	
   if (catalog[i].SourceID==1){
    catalog[i].VariableName=catalog[i].VariableName + ' - Daily' ;
   }	
   if (catalog[i].SourceID==2){
    catalog[i].VariableName=catalog[i].VariableName + ' - Irregular Timeseries';
   }
   
   if (catalog[i].VariableName.length>59){
   catalog[i].VariableName=catalog[i].VariableName.substring(0,56)+'...';
   }
  catContent = catContent +'<option value="'+catalog[i].SourceID+'$'+catalog[i].VariableCode+'">'+catalog[i].VariableName+'</option>';
   }
   if (isSubTerm==true) {
   Stations.StationsService.GetStationCatalogConceptIDFiltered(siteid, searchWord, selectedTerm, bdate, edate, onCatalogFilteredComplete); 
   }else{   
   Stations.StationsService.GetStationCatalogFiltered(siteid, searchWord, bdate, edate, onCatalogFilteredComplete); 
   }
windowContent= windowContent+catContent+'</select><a href="javascript:GetUnfilteredOption()"><img src="images/download.jpg" alt="Download" border="0"/></a><a href="javascript:AddToCartNoFilter()"><img src="images/addToCart.jpg"/></a></td></tr><tr> <td colspan="2" style="text-align:left;width:445px;padding-left:5px"><b>Relevant variables measured at this station</b><br><select id="filteredVar" name="filteredVar" style="font-size:small;width: 380px;z-index:601;">';

}


function onCatalogFilteredComplete (catalog){
var catContent;
for(var i=0; i < catalog.length; i++)
   {
   if (catalog[i].SourceID==3){
   catalog[i].VariableName= catalog[i].VariableName+ ' - Real-Time';
   }	
   if (catalog[i].SourceID==1){
    catalog[i].VariableName=catalog[i].VariableName + ' - Daily' ;
   }	
   if (catalog[i].SourceID==2){
    catalog[i].VariableName=catalog[i].VariableName + ' - Irregular Timeseries';
   }
   
   if (catalog[i].VariableName.length>59){
   catalog[i].VariableName=catalog[i].VariableName.substring(0,56)+'...';
   }
  catContent = catContent +'<option value="'+catalog[i].SourceID+'$'+catalog[i].VariableCode+'">'+catalog[i].VariableName+'</option>';
   }
document.getElementById("stationDetailsContent").innerHTML= windowContent+catContent+'</select><a href="javascript:GetFilteredOption()"><img src="images/download.jpg" alt="Download" border="0"/></a><a href="javascript:AddToCartFiltered()"><img src="images/addToCart.jpg"/></a></td></tr></table>';
document.getElementById("mask").style.visibility="visible";
document.getElementById("stationDetailsContainer").style.left=mWidth*0.5-243+'px';   
document.getElementById("stationDetailsContainer").style.visibility="visible"; 
}

function CloseStationDetails(){

document.getElementById("stationDetailsContainer").style.visibility="hidden";
document.getElementById("mask").style.visibility="hidden";

}


function GetFilteredOption(){

var s = document.getElementById("filteredVar");
var v = s.options[s.selectedIndex].value;
var st = document.getElementById("siteId");
document.getElementById("ProgressLoading").style.visibility="visible";
document.getElementById("maskLoading").style.visibility="visible";
ExcelDataRetrievalService.GetExcelLink(v + '$'+ st.value, bdate, edate, onGetExcelComplete, onExcelError);
}

function onGetExcelComplete(dlink){

if (dlink!=null && dlink!="" && dlink!=" "){
 window.location=dlink;
//alert("Download from :" + dlink );
//showDownloadFile(dlink);
document.getElementById("ProgressLoading").style.visibility="hidden";
document.getElementById("maskLoading").style.visibility="hidden";
}else{
alert('Data source\'s web service is not responding. Sorry for the inconvenience');
document.getElementById("ProgressLoading").style.visibility="hidden";
document.getElementById("maskLoading").style.visibility="hidden";
}
}

function showDownloadFile(dlink) {
document.getElementById("DownloadFileDialog").style.visibility="visible";
document.getElementById("downloadFile").href=dlink;
document.getElementById("downloadFileSpan").innerHTML=dlink;
}

function GetUnfilteredOption(){

var s = document.getElementById("allVar");
var v = s.options[s.selectedIndex].value;
var st = document.getElementById("siteId");
document.getElementById("ProgressLoading").style.visibility="visible";
document.getElementById("maskLoading").style.visibility="visible";
ExcelDataRetrievalService.GetExcelLink(v + '$'+ st.value, bdate, edate, onGetExcelComplete, onExcelError);
}

function onExcelError(error){
alert('Data source\'s web service is not responding. Sorry for the inconvenience');
document.getElementById("ProgressLoading").style.visibility="hidden";
document.getElementById("maskLoading").style.visibility="hidden";
}
   
function MapSwitch(type){

if (type=='m') {
map.SetMapStyle(VEMapStyle.Road);
}
if(type=='h'){
map.SetMapStyle(VEMapStyle.Hybrid);
}
if(type=='a'){
map.SetMapStyle(VEMapStyle.Aerial);
}
}

function pageWidth() {return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;}


function CloseSearchWindow(){
HideSearchWindow();
//document.getElementById('downImage').style.visibility='hidden';
//document.getElementById('upImage').style.visibility='hidden';
//document.getElementById('maxImage').style.visibility='hidden';
document.getElementById('closeImage').style.visibility='hidden';

}

function MinimizeSearchWindow(){
HideSearchWindow();
document.getElementById('upImage').style.visibility='visible';
document.getElementById('maxImage').style.visibility='visible';

}

function MaximizeSearchWindow(){
ShowSearchWindow();
//document.getElementById('downImage').style.visibility='visible';
//document.getElementById('upImage').style.visibility='hidden';
//document.getElementById('maxImage').style.visibility='hidden';
document.getElementById('closeImage').style.visibility='visible';
}

function ToggleSearchWindow(){
var vis = document.getElementById('DIV5').style.visibility;
if (vis=='hidden' && isCoordActive){
MaximizeSearchWindow();
}else if (vis=='visible'){
CloseSearchWindow();
}
var vis = document.getElementById('filterBoxHU').style.visibility;
if (vis=='hidden' && isHuActive){
document.getElementById("filterBoxHU").style.visibility = 'visible' ;
document.getElementById('closeImage2').style.visibility='visible';
}else if (vis=='visible'){
document.getElementById("filterBoxHU").style.visibility = 'hidden' ;
document.getElementById('closeImage2').style.visibility='hidden';
}

}

function ToggleTreeWindow(){
var vis = document.getElementById("divScroll").style.visibility;
if (vis=='hidden'){
ShowNavigationTree();
}else{
HideNavigationTree();
}
}



function SwitchtoLatLonSearch(){
document.getElementById("filterBoxHU").style.visibility = 'hidden' ;
document.getElementById('closeImage2').style.visibility='hidden';
document.getElementById("DIV5").style.visibility = 'visible' ;
document.getElementById('closeImage').style.visibility='visible';
isHuActive = false;
isCoordActive = true;
}

function SwitchtoHUSearch(){
document.getElementById("DIV5").style.visibility = 'hidden' ;
document.getElementById('closeImage').style.visibility='hidden';
document.getElementById("filterBoxHU").style.visibility = 'visible' ;
document.getElementById('closeImage2').style.visibility='visible';
isHuActive = true;
isCoordActive = false;
}

function HideHUC(){
document.getElementById("filterBoxHU").style.visibility = 'hidden' ;
document.getElementById('closeImage2').style.visibility='hidden';
}


