
var currentTabId = "ReportTab1";

function conductRestrictionSearch(address)
{
    map.HideInfoBox();
    document.getElementById('Iframe_RestrictionSearch').src = 'Loading.aspx?address=' + address;   
    showRestrictionSearch();
}

function conductRestrictionSearchText(address)
{
    document.getElementById('Iframe_RestrictionSearch').src = 'Loading.aspx?address=' + address + '&textonly=1';   
    showRestrictionSearch();
}

function showRestrictionSearch()
{
    var RestrictionSearchDiv = document.getElementById('RestrictionSearch');
    RestrictionSearchDiv.style.display='block';
}

function hideRestrictionSearch()
{
    document.getElementById('RestrictionSearch').style.display='none';
}

function restrictionSearchTextOnly(lat, lon, address)
{
    document.getElementById('divRainfall').style.display='none';
    document.getElementById('Iframe_AddressTextOnly').src = 'WaterRestrictionTextOnly.aspx?lat=' + lat + '&lon=' + lon + '&address=' + address;    
    document.getElementById('divAddressTextOnly').style.display='block';
}

function emergencySupplySearch()
{
    var lga = document.getElementById('ddLGA').value;
    if (lga != "Select a Local Government Area") loadGeoRSSLayerZoom('VEPlusGeoRSS.ashx?FeedId=2&lga=' + lga);
}

function showRainfall()
{
    document.getElementById('divAddressTextOnly').style.display='none';
    document.getElementById('divRainfall').style.display='block';
}

function hideLayersAndRainfall()
{
    hideAllLayers();
    document.getElementById('divRainfall').style.display='none';
}

function alernativeRef(layerId)
{
    switch(layerId)
    {
        case "1": // Catchment Management Authorities
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/governance/catchment_management_authorities/your_local_cma";
            break;
        
        case "2": // Urban Water Corporations
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/governance/water_corporations/your_local_water_corporation";
            break;
    
        case "3": // Rural Water Corporations
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/governance/water_corporations/your_local_water_corporation";
            break;
    
        case "4": // Water Storages
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/inyourregion/water-storages";
            break;
    
        case "5": // Government Projects
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/inyourregion/government-projects";
            break;
    
        case "6": // Weekly Rainfall
            // Nothing.
            break;
    
        case "7": // Emergency Supply Points
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/saving/farms/emergency-supply/map/table";
            break;
    
        case "8": // Groundwater Site Reports
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/?a=10209";
            break;
    
        case "9": // Irrigation Allocations
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/inyourregion/irrigation-allocations";
            break;
            
        case "10": // Streamflow
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/inyourregion/streamflow";
            break;
        
        case "11": // Groundwater Levels
            window.parent.window.location.href = "http://www.ourwater.vic.gov.au/?a=10304";
            break;
    }
}

function getAlternateRef(layerId, controlId)
{
    var newRef;
    var hyperLink = document.getElementById(controlId)

    hyperLink.onclick = null;

    switch(layerId)
    {
        case "1": // Catchment Management Authorities
            newRef = "http://www.ourwater.vic.gov.au/governance/catchment_management_authorities/your_local_cma";
            break;
        
        case "2": // Urban Water Corporations
            newRef = "http://www.ourwater.vic.gov.au/governance/water_corporations/your_local_water_corporation";
            break;
    
        case "3": // Rural Water Corporations
            newRef = "http://www.ourwater.vic.gov.au/governance/water_corporations/your_local_water_corporation";
            break;
    
        case "4": // Water Storages
            newRef = "http://www.ourwater.vic.gov.au/inyourregion/water-storages";
            break;
    
        case "5": // Government Projects
            newRef = "http://www.ourwater.vic.gov.au/inyourregion/government-projects";
            break;

        case "7": // Emergency Supply Points
            newRef = "http://www.ourwater.vic.gov.au/saving/farms/emergency-supply/map/table";
            break;
    
        case "8": // Groundwater Site Reports
            newRef = "http://www.ourwater.vic.gov.au/?a=10209";
            break;
    
        case "9": // Irrigation Allocations
            newRef = "http://www.ourwater.vic.gov.au/inyourregion/irrigation-allocations";
            break;
            
        case "10": // Streamflow
            newRef = "http://www.ourwater.vic.gov.au/inyourregion/streamflow";
            break;
        
        case "11": // Groundwater Levels
            newRef = "http://www.ourwater.vic.gov.au/?a=10304";
            break;
            
        //case "12": // Catchment Basins. * TO BE IMPLEMENTED *
            //break;
            
        default:
            hyperLink.onclick = function(){return false;};
            newRef = "#";
            break;
            
    }
    
    hyperLink.href = newRef;
}

function TabClick(tabId)
{
    try
    {
        switch (tabId)
        {
            case "ReportTab1":
                document.getElementById("ReportTab1").className="selectedTab";
                document.getElementById("ReportTab2").className="unselectedTab";
                document.getElementById("ReportDiv2").style.display="none";
                document.getElementById("ReportDiv1").style.display="block";
                break;
            case "ReportTab2":
                document.getElementById("ReportTab2").className="selectedTab";
                document.getElementById("ReportTab1").className="unselectedTab";
                document.getElementById("ReportDiv1").style.display="none";
                document.getElementById("ReportDiv2").style.display="block";
                break;
        }
        currentTabId = tabId;
    }
    catch(err)
    {
        alert(err.message);
    }
}

function checkEnter(e)
{
    if(e.keyCode == 13) 
    {
        conductRestrictionSearch(document.getElementById('txtAddress').value);
    }
}

function showLGAHider()
{
    document.getElementById("lgahider").style.display="block";
}

function hideLGAHider()
{
    document.getElementById("lgahider").style.display="none";
}

function showMaintenance()
{
    document.getElementById("divMaintenance").style.display="block";
}