﻿//** by coomsie **/

//var for search
var searchControl = null;
var drawOptions = null;

//var for grades
var searchControl = null;
var drawOptions = null;
var siteGradeDefn = new Array();
siteGradeDefn['Very good'] = "<img src='images/Very goodB.png' alt='Very Good' align='left' style='padding-right:5px;' /> <h3>Very Good</h3>" +
"<h4>Considered satisfactory for swimming at all times.Therefore these sites may not require monitoring on a regular basis.</h4>" +
"<p class='siteGradeI'>Water quality tests and assessment of potential contamination sources indicate sites in this category are considered to have very good water quality. There may be some run-off from low-intensity agricultural/urban/rural catchments, but there are likely to be no significant sources of faecal contamination. </p>";

siteGradeDefn['Good'] = "<img src='images/GoodB.png' alt='Good' align='left' style='padding-right:5px;' /><h3>Good</h3>" +
"<h4>Satisfactory for swimming most of the time. Exceptions may include following rainfall.</h4><p class='siteGradeI'>These sites are monitored regularly throughout the summer season and warning signs will be erected by the local district or city council if water quality deteriorates." +
"Water-quality tests and assessment of potential contamination sources indicate sites within this category are considered to have generally good water quality. On occasions (such as after high rainfall) there may be an increased risk of contamination from run-off. Such sites receive run-off from one or more of the following sources and may contain animal or human faecal material:</p>" +
"<ul class='siteGradeI'><li>river discharges impacted by tertiary treated wastewater, combined sewer overflows, intensive agricultural/rural catchments, feral bird/animal populations </li>" +
"<li>river discharges impacted by run-off from low-intensity agricultural/urban/rural catchment </li>" +
"<li>stormwater not contaminated by sewage.</li></ul>";

siteGradeDefn['Fair'] = "<img src='images/FairB.png' alt='Fair' align='left' style='padding-right:5px;' /><h3>Fair</h3>" +
"<h4>Generally satisfactory for swimming, though there are many potential sources of faecal material.</h4><p class='siteGradeI'>Caution should be taken during periods of high rainfall, and swimming avoided if water is discoloured. These sites are monitored weekly and warning signs are erected by the local district or city council if water quality deteriorates." +
"Water-quality tests and assessment of potential contamination sources indicate sites in this category are considered to have generally fair water quality. Events such as high rainfall increase the risk of contamination levels from run-off. Such sites receive run-off from one or more of the following sources and may contain animal or human faecal material:  </p>" +
"<ul class='siteGradeI'><li>river discharges impacted by tertiary treated wastewater, combined sewer overflows, intensive agricultural/rural catchments, feral bird/animal populations   </li>" +
"<li>river discharges impacted by run-off from low-intensity agricultural/urban/rural catchment</li>" +
"<li>stormwater not contaminated by sewage. </li></ul> ";

siteGradeDefn['Poor'] = "<img src='images/PoorB.png' alt='Poor' align='left' style='padding-right:5px;' /><h3>Poor</h3><br/>" +
"<h4>Generally not suitable for swimming, as indicated by historical results. </h4><p class='siteGradeI'>Swimming should be avoided, particularly by the very young, the very old and those with compromised immunity. Permanent warning signs may be erected by the local district or city council at these sites to indicate these sites are not generally suitable for swimming.  <br/>" +

"<p class='siteGradeI'>Water-quality tests and assessment of potential contamination sources indicate sites in this category are considered to have generally poor water quality. These sites receive run-off from one or more of the following sources and may contain animal or human faecal material: </p> " +
"<ul class='siteGradeI'><li>tertiary treated wastewater  </li>" +
"<li>urban stormwater, marinas or moorings, intensive agriculture </li>" +
"<li>river discharges containing untreated / primary / secondary treated wastewater or on-site waste treatment systems  </li>" +
"<li>river discharges impacted by tertiary treated wastewater, combined sewer overflows, intensive agricultural/rural catchments, feral bird/animal populations.  </li></ul><";

siteGradeDefn['Very poor'] = "<img src='images/Very poorB.png' alt='Very poor' align='left' style='padding-right:5px;' /><h3>Very Poor</h3>" +
"<h4>Avoid swimming, as there are direct discharges of faecal material.</h4> " +

"<p class='siteGradeI'>Permanent signage is erected by the local district or city council at the site stating that swimming is not recommended. " +

"Water-quality tests and assessment of potential contamination sources indicate sites within this category are considered to have very poor water quality. These sites receive run-off from one or more of the following sources and may contain animal or human faecal material: </p> " +
"<ul class='siteGradeI'><li>untreated/primary/secondary treated wastewater   </li>" +
"<li>on-site waste treatment systems</li>" +
"<li>tertiary treated wastewater  </li>" +
"<li>urban stormwater, marinas or moorings, intensive agriculture   </li>" +
"<li>river discharges containing untreated/ primary/secondary treated wastewater or on-site waste treatment systems.  </li></ul>";

siteGradeDefn['Insufficient data'] = "<img src='images/Insufficient dataB.png' alt='Insufficient data' align='left' style='padding-right:5px;' /><h3>Insufficient Data</h3><p>This swimming site is currently under testing and has not had a swimming grade applied to it.</p> ";

siteGradeDefn['Fair, but affected by rain'] = "<img src='images/FairB.png' alt='Fair' align='left' style='padding-right:5px;' /><h3>Fair</h3>" +
"<h4>Generally satisfactory for swimming, though there are many potential sources of faecal material.</h4><p class='siteGradeI'>Caution should be taken during periods of high rainfall, and swimming avoided if water is discoloured. These sites are monitored weekly and warning signs are erected by the local district or city council if water quality deteriorates." +
"Water-quality tests and assessment of potential contamination sources indicate sites in this category are considered to have generally fair water quality. Events such as high rainfall increase the risk of contamination levels from run-off. Such sites receive run-off from one or more of the following sources and may contain animal or human faecal material:  </p>" +
"<ul class='siteGradeI'><li>river discharges impacted by tertiary treated wastewater, combined sewer overflows, intensive agricultural/rural catchments, feral bird/animal populations   </li>" +
"<li>river discharges impacted by run-off from low-intensity agricultural/urban/rural catchment</li>" +
"<li>stormwater not contaminated by sewage. </li></ul> "+
"<h3>Rainfall Issues</h3><p class='siteGradeI'>This site generally has low to moderate concentrations of faecal indicator bacteria. However, bacteria concentrations can increase dramatically at this site during rainfall. Swimming in these waters should be avoided for up to 48 hours after significant rainfall.</p>";

siteGradeDefn['Good, but affected by rain'] = "<img src='images/GoodB.png' alt='Good' align='left' style='padding-right:5px;' /><h3>Good</h3>" +
"<p class='siteGradeI'>Satisfactory for swimming most of the time. Exceptions may include following rainfall. These sites are monitored regularly throughout the summer season and warning signs will be erected by the local district or city council if water quality deteriorates." +
"Water-quality tests and assessment of potential contamination sources indicate sites within this category are considered to have generally good water quality. On occasions (such as after high rainfall) there may be an increased risk of contamination from run-off. Such sites receive run-off from one or more of the following sources and may contain animal or human faecal material:</p>" +
"<ul class='siteGradeI'><li>river discharges impacted by tertiary treated wastewater, combined sewer overflows, intensive agricultural/rural catchments, feral bird/animal populations </li>" +
"<li>river discharges impacted by run-off from low-intensity agricultural/urban/rural catchment </li>" +
"<li>stormwater not contaminated by sewage.</li></ul>"+
"<h3>Rainfall Issues</h3><p class='siteGradeI'>This site generally has low to moderate concentrations of faecal indicator bacteria. However, bacteria concentrations can increase dramatically at this site during rainfall. Swimming in these waters should be avoided for up to 48 hours after significant rainfall.</p>";

siteGradeDefn['Historic Site'] = "<h4>Historic Site</h4><p class='siteGradeI'>This site is no longer being monitored. </p>";
siteGradeDefn['rainfall'] = "<h3>May be unsuitable for swimming for up to 48 hours after rainfall.</h3>";
siteGradeDefn['disclaimer'] = "<h3>Disclaimer</h3><p>The maps used in this application are sourced from Google.   Environment Canterbury takes no responsibility for any loss or damage of any kind arising from inaccurate or incomplete information that may be displayed on any map used in this application.    This disclaimer does not apply to swimming water quality markers or marker information inserted by Environment Canterbury onto the maps used in this application.</p>";

var params = null;
var siteGradeDefnShort = new Array();
siteGradeDefnShort['Very good'] = "Considered satisfactory for swimming at all times.";

siteGradeDefnShort['Good'] = "Satisfactory for swimming most of the time."

siteGradeDefnShort['Fair'] = "Generally satisfactory for swimming.";

siteGradeDefnShort['Poor'] = "Generally not suitable for swimming."
siteGradeDefnShort['Very poor'] = "Avoid swimming."

siteGradeDefnShort['Insufficient data'] = "Insufficient data to grade.";
siteGradeDefnShort['Fair, but affected by rain'] = "Generally satisfactory for swimming. May be unsuitable for swimming for up to 48 hours after rainfall.";
siteGradeDefnShort['Good, but affected by rain'] = "Satisfactory for swimming. May be unsuitable for swimming for up to 48 hours after rainfall.";
siteGradeDefnShort['rainfall'] = "May be unsuitable for swimming for up to 48 hours after rainfall.";
siteGradeDefnShort['Historic Site'] = "This site is no longer monitored.";

//vars for areas
var areas = new Array();
areas['Kaikoura'] = '-42.399122159860006 , 173.69384765625';
areas['Northern Canterbury'] = "-42.8910580558156 , 172.91519165039062"; 
areas['North Christchurch'] = "-43.250704366070266 , 172.4352264404297";
areas['Banks Peninsula'] = "-43.70660077729877 , 172.86643981933594";
areas['South Christchurch'] = "-43.50224662373913 , 172.66319274902344";
areas['Central Canterbury Plains'] = "-43.555515149559724 , 172.43728637695312"; 
areas['Central South Canterbury'] = "-43.977004674964064 , 171.02210998535156";
areas['Waitaki'] = "-44.09942068528651 , 170.8154296875";
areas['Timaru'] = "-44.03626980953461 , 171.28921508789062"; 

var params = null;


var watergraph = "/Beta/waterQuality/WaterQualityGraph.aspx?site_id=";
//var watergraph = "Graphathome.htm?site_id=";

var mapurl = "http://arcgis.ecan.govt.nz/ArcGIS/rest/services/Beta/Swimming_Water_Quality/MapServer";

var gmap = null;
var dynMapOv = null;

var minzoomlevel = 8;
var maxzoomlevel = 13;

var identifyOvs = [];

function initialize() {
    checkwindow();
    //Load Google Maps
    gmap = new GMap2(document.getElementById("gmap"));
    var centerat = new GLatLng(-43.66086959838867, 172.716579437256);

    // ====== Restricting the range of Zoom Levels =====
    // Get the list of map types
    var mt = gmap.getMapTypes();
    // Overwrite the getMinimumResolution() and getMaximumResolution() methods
    for (var i = 0; i < mt.length; i++) {
        mt[i].getMinimumResolution = function() {
            return minzoomlevel;
        }
        mt[i].getMaximumResolution = function() {
            return maxzoomlevel;
        }
    }

    gmap.addControl(new GLargeMapControl());
    gmap.addControl(new GMapTypeControl());
    gmap.setCenter(centerat, 11);
    gmap.enableScrollWheelZoom();

    //create mapextension to add identify results to map
    mapext = new esri.arcgis.gmaps.MapExtension(gmap);

    idtask = new esri.arcgis.gmaps.IdentifyTask(mapurl);

    // Find Task
    findTask = new esri.arcgis.gmaps.FindTask(mapurl);

    // You can execute a task and listen for the complete event or use the callback to get the results
    GEvent.addListener(findTask, "complete", function() {
    });

    // Find Parameters
    params = new esri.arcgis.gmaps.FindParameters();
    params.layerIds = [0];
    params.searchFields = ["AreaName"];

    executeFind();

    //create custom dynamic layer
    //esri.arcgis.gmaps.DynamicMapServiceLayer(url,esri.arcgis.gmaps.ImageParameters?,opacity?,callback?);
    var dynamicMap = new esri.arcgis.gmaps.DynamicMapServiceLayer(mapurl, null, 1, dynmapcallback);

    ///// ARCGIS CLICK STUFF
    GEvent.addListener(gmap, "click", function(overlay, point) {
        if (point != undefined)
            //document.getElementById('controls').innerHTML = point.x + '<br />' + point.y;
        doIdentify(overlay, point);
    });
}


function initSearch() {
    // create a search control
    searchControl = new google.search.SearchControl(null);

    searchControl.setResultSetSize(google.search.Search.SMALL_RESULTSET);

    // add in a full set of searchers
    searchControl.addSearcher(new google.search.ImageSearch());
    //searchControl.addSearcher(new google.search.VideoSearch());
   // searchControl.addSearcher(new google.search.NewsSearch());
    //searchControl.addSearcher(new google.search.WebSearch());
    //searchControl.addSearcher(new google.search.BlogSearch());

    // create a drawOptions object
    drawOptions = new google.search.DrawOptions();
    // tell the searcher to draw itself in tabbed mode
    drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
}

function dynmapcallback(groundov) {
    //Add groundoverlay to map using gmap.addOverlay()
    gmap.addOverlay(groundov);
    dynMapOv = groundov;
    //finsihed loading?
    endLoading();
}


function executeFind() {

    if (document.getElementById('regionname') == 'undefined') {
        searchText = "South Christchurch";
        // set find parameters
        params.searchText = searchText;
    } else {

    var searchText = document.getElementById('regionname');
    // set find parameters
    params.searchText = searchText.innerHTML;
    }

    // execute find task
    findTask.execute(params, findCompleteCallback);

}

var gOverlays;

function findCompleteCallback(response) {
    //if response is nothing
    if (response == null) return;

    // add the findresutls to google map without any style
    //gOverlays = mapext.addToMap(findResults);

    var findResults = response.findResults, findResult, geometry, attributes, geom, i, j, name, foundField;
    var table = "<table>";
    //<th><h3>Quality</h3></th></tr>";
    var uniqueId = 0;
    listOfOverlays = [];
    

    for (i = 0; i < findResults.length; i++) { // process each result in the response
        findResult = findResults[i];
        geometry = findResult.feature.geometry;
        attributes = findResult.feature.attributes;
        name = findResult.layerName;
        foundField = findResult.foundFieldName;

        // add a row to the table of results
         table = table + "<tr><td class='sitesReg'><a href='#' onclick='showInfoWindow(" + uniqueId + ")'><img src='images/" + attributes["Site Grade"] + "Sm.gif' alt='"+ attributes["Site Grade"] +"'/> &nbsp; " + attributes["Site Name"] + "</a></td></tr>";

        for (j = 0; j < geometry.length; j++) { // Feature.geometry is an array of GPolygon/GPolyline/GMarker
            geom = geometry[j];

            // setup the click event listener for the overlay
            GEvent.addListener(geom, "click");


            // maintain a list of overlays and their associated click listener function
            // later used when the hyperlink for a result is clicked
            //listOfOverlays[uniqueId++] = { "overlay": geom, "func": functn };
            listOfOverlays[uniqueId++] = { "overlay": geom, "attributes": attributes };
        }
    }
    // note that we are NOT using the MapExtension class here to add the FindResults

    // show the table of results
    table = table
    // + "</table>";
    document.getElementById('RegionSites').innerHTML = table;
    endLoading();
    resizeMap();
}

function showInfoWindow(uniqueId) { // function to be called when the user clicks on the link
    var point = listOfOverlays[uniqueId].overlay;
    //var func = listOfOverlays[uniqueId].func
    var attributes = listOfOverlays[uniqueId].attributes;

    var centerat = point.getLatLng();
    gmap.setCenter(centerat, maxzoomlevel);

    // show the infowindow
    createInfoWindow(point, attributes);
}

function createInfoWindow(point, attributes) {
  var content1 = "<div id='graphdiv'><h2 class='siteName'>" + attributes["Site Name"] + " Weekly Results </h2>";
    // var content2 = "<p>The swimming water quality at <br /> <b>" + attributes["Site Name"] + "</b> is <font color='red'><b>" + attributes["Site Grade"] + "</b></font><p><img src='/images/graph.jpg' /></p><p> <a href='" + attributes["Link"] + "'>click for full details<a></p>";
    var content3 = "<h3>Images of " + attributes["Site Name"] + "</h3><p class='smallText'>These images have been taken from google and may not always be accurate</p><div id='" + attributes["SiteID"] + "' align='center' class='gsearch'></div>";
    var linkdetails = "<p> <a href='" + attributes["Link"] + "'>View data from previous years <a></p></div>";
    var content4 = "<h3>What does this grading mean?</h3>";
    var moreInfo = "<div style='width:350px;'><h3>Further Information About Swimming Water Quality</h3><p>Find out about how we monitor, the health risks and where the contamintion comes from:</p><ul><li>Monitoring and testing information</li><li>Contamination sources</li><li>Health risks</li></ul></div>";
    var siteGradeDef = attributes["Site Grade"];
    var warning = "<h3 style='color:#d60f0b'>WARNING</h3>It is advised that when the tide is out the water in this estuary does not meet the MoH/MfE guidelines for contact recreation."
    var content8 = "<div id='graphdiv'><h2 class='siteName'>" + attributes["Site Name"] + " swimming conditions are</h2><p class='swimConditions'><img src='images/" + attributes["Site Grade"] + "Gr.gif' alt='" + attributes["Site Grade"] + "' /></p>"
    var contentOverview = content8 + "<h2 class='siteName'>" + siteGradeDefnShort[siteGradeDef] + "</h2>";

    var brassels = "<h3 style='color:#d60f0b'>Further notes!</h3>December 2008 – this site is currently dry";
    var ashbury = "<h3 style='color:#d60f0b'>Further notes!</h3>As a consequence of earthworks there was no access to this site in November and December 2008.";
    var warningLake = "<h3 style='color:#d60f0b'>Warning</h3>Toxic algal bloom present";
  
if (attributes["NotSampled"] == "Yes") {
            var contentOverview = content8 + "<h2 class='siteName'>" + siteGradeDefnShort[siteGradeDef] + "</h2>" + "<h3 style='color:#d60f0b'>Please note!</h3>This site is not being monitored this year.";
        }
      if (attributes["Site Name"]=="Pareora River at Brassells Bridge") {
             var contentOverview = content8 + "<h2 class='siteName'>" + siteGradeDefnShort[siteGradeDef] + "</h2>" + brassels;
             }    

if (attributes["Site Name"]=="Lake Ellesmere at Lakeside") {
 var contentOverview = content8 + "<h2 class='siteName'>" + siteGradeDefnShort[siteGradeDef] + "</h2><div style='background-color:#fff495; font-weight:bold; padding:3px; font-size:1.5em;'>" + warningLake + "</div>";
}

if (attributes["Site Name"]=="Ashley River at estuary") {
 var contentOverview = content8 + "<h2 class='siteName'>" + siteGradeDefnShort[siteGradeDef] + "</h2>" + warning;
}
if (attributes["Site Name"] == "Ashbury Park") {
    var contentOverview = content8 + "<h2 class='siteName'>" + siteGradeDefnShort[siteGradeDef] + "</h2>" + ashbury;
}
var warnings = attributes["Warnings"]
if (attributes["Warnings"] != "") {
    var contentOverview = content8 + "<h2 class='siteName'>" + siteGradeDefnShort[siteGradeDef] + "</h2><div style='background-color:#fff495; font-weight:bold; padding:3px; font-size:1.5em;'>" + warnings + "</div>";
}

var contentGraphTop = "<p style='font-size:small; text-align:left;'> Please use the grade rather than this graph to find out whether a swimming site is suitable for swimming, yesterday's good results at a site may not mean it is good enough today. Please be aware that this is a logarithmic graph (see numbers on vertical or y axis) which means concentrations increase ten fold for each horizontal line!</p>"
    var content6Graph = "<p style='font-size:xx-small; text-align:left; width:420px;'>Green vertical bars in the graphs show the concentration of indicator bacteria measured in the water on particular days. " +
    "The actual value is also printed above the bar. The red line is the action level, above which the water is not safe to swim. " +
    "When concentrations are above the red line specific actions are undertaken by the organisations involved in swimming water quality monitoring.</p>";
    
    var tabs = [];


    var myhtml = GDownloadUrl(watergraph + attributes["SiteID"], function(data) {

        var content2 = content1 + contentGraphTop + "<div id='graphpic'>" + data + "</div>" + content6Graph;  ///+linkdetails;
        var content5 = "<div style='width:410px; height:500px;'>" + content4 + siteGradeDefn[siteGradeDef] + "</div>";

        tabs.push(new GInfoWindowTab("Overview", contentOverview));
        tabs.push(new GInfoWindowTab("Grade", content5));
        tabs.push(new GInfoWindowTab("Results", content2));
        //tabs.push(new GInfoWindowTab("Images", content3));
        var infoWindowOptionsTabs = { selectedTab: 0 };

        gmap.openInfoWindowTabsHtml(point.getLatLng(), tabs, infoWindowOptionsTabs);

    });      //end of function(data)

    endLoading();

    //start image searching
    ExecuteSearch(attributes["Site Name"], attributes["SiteID"]);
}


function doIdentify(overlay, point) {

    if (overlay) {
        return;
    }
    startLoading();
    //    alert("the webchick rocks!");
    var dim = gmap.getSize();
    var idparams = new esri.arcgis.gmaps.IdentifyParameters();
    idparams.geometry = point;
    idparams.tolerance = 15;
    idparams.bounds = gmap.getBounds();
    idparams.width = dim.width;
    idparams.height = dim.height;
    idparams.layerIds = [0];
    idparams.layerOption = "all";
    idparams.wkid = 4326;

    idtask.execute(idparams, idcallback);
}

function idcallback(idresults) {
    ///if no results from clicking & identity
    if (idresults.identifyResults[0] == undefined) { endLoading(); return; }

    var geometry = idresults.identifyResults[0].feature.geometry[0];
    var attributes = idresults.identifyResults[0].feature.attributes;
    createInfoWindow(geometry, attributes);
    endLoading();
}

function checkwindow() {
    var winW = 0, winH = 700;

    if (parseInt(navigator.appVersion) > 3) {
        try {            //if (navigator.appName == "Netscape")
            winW = window.innerWidth;
            winH = window.innerHeight;
        }
        catch (e) { };
        try {//if (navigator.appName.indexOf("Microsoft") != -1)
            winW = document.body.offsetWidth;
            winH = document.body.offsetHeight;
        }
        catch (e) { };
    }
    var h = winH;
    document.getElementById("gmap").style.height = h + 'px';
    // debug stuff
    //alert(winH);
}

function zoom2Area(object, zoom, winSize) {
    //change region name
    document.getElementById('regionname').innerHTML = object.toString();
    //zoom via gmap
    var centerat = new GLatLng(areas[object].substring(0, areas[object].indexOf(',')), areas[object].substring(areas[object].indexOf(',') + 1));
    gmap.setCenter(centerat, zoom);
    executeFind();
}


function ExecuteSearch(q, id) {
    try {
        var searchid = document.getElementById(id);
    }
    catch (e) { };

    //check to see if loaded
    if ((searchid == null) || (typeof (searchid) == "undefined")) {
        setTimeout("ExecuteSearch('" + q + "','" + id + "')", 1000);
        return;
    }
    searchControl.draw(searchid, drawOptions);

    //set local search location via lat lng
    // mylocalsearch.setCenterPoint(location);

    // Execute an inital search
    if (q == null) q = "ECan";
    searchControl.execute(q);
}

function changegraph(gyear,siteid)
{
   startLoading();
    var myhtml = GDownloadUrl(watergraph + siteid + "&year=" + gyear.value + "", function(data) {
        document.getElementById('graphpic').innerHTML = data;
    });      //end of function(data)
    endLoading();
}

function gradingInfo(grade, action) {

    //hide the div
    var action = document.getElementById('gradingInfo').style.display;

    if (action == 'none'&& grade !='') {
        document.getElementById('gradingInfo').style.display = "block";
        document.getElementById('gdt').innerHTML = siteGradeDefn[grade];
    }
    if (action == 'block' && grade != '') {
        //document.getElementById("show").innerHTML = "Show grading info ";
        document.getElementById('gdt').innerHTML = siteGradeDefn[grade];
    }
    
    if (action == 'block' && grade =='close') {
        //document.getElementById("show").innerHTML = "Show grading info ";
        document.getElementById('gradingInfo').style.display = "none";
        document.getElementById('gdt').innerHTML = " ";
    }

}

function mapKey(div, action) {

    //hide the div
    var action = document.getElementById(div).style.display;

    if (action == 'none') {
        document.getElementById(div).style.display = "block";
        document.getElementById("show").innerHTML = "Hide Key";
        document.getElementById('gradings').style.background = "transparent url(/Beta/waterQuality/images/keyBg.png) no-repeat scroll 0% 50%";
        
    }
    if (action == 'block') {
        document.getElementById(div).style.display = "none";    
        document.getElementById("show").innerHTML = "Show Key";
        document.getElementById('gradings').style.background = "transparent";
        
    }

}

function resizeMap() {
    var height = document.getElementById("menuSide").offsetHeight;
    var totalHeight = parseInt(height) + 20;
    var logoheight = parseInt(height)- 19;
document.getElementById("gmap").style.height = totalHeight + 'px';
    document.getElementById("logo").style.top = logoheight + 'px';
    gmap.checkResize();

} 