﻿/* **********************************************************************************************************************
    FILE: footer.js
    DIRECTORY: scripts/map
    PROJECT: GeoEye
    DATE: June 24, 2008
    AUTHORS: Grant McKenzie / Ryan Whitley
    DESCRIPTION: The footer for the base page.  
********************************************************************************************************************** */

function Footer() 
{  
    //Pull prefs from global prefs object.
    this.startDate = _searchPrefs.GetStartDate();
    this.endDate = _searchPrefs.GetEndDate();
    this.cloudCover = _searchPrefs.GetCloudCoverDescription();
    //this.resolution = _searchPrefs.GetResolutionDescription();
    this.Source = _searchPrefs.GetImagerySourceDescription();
    //this.spatialRank = _searchPrefs.GetSpatialRankingDescription();
    
    //gets reference to footer Mouse Panel
    this.MousePanel = function (){
        return $("footer-mouse");
    }
    
    //gets reference to footer Copyright Panel
    this.CopyrightPanel = function () {
        return $("footer-copyright");
    }
    
    //gets reference to footer Prefs Panel
    this.PreferencesPanel = function () {
        return $("footer-prefs");
    }
    
    //gets reference to footer VlayerInfo Panel
    this.VLayerPanel = function () {
        return $("footer-vlayer");
    }
    
    //Update the VLayer Info section of the footer
    this.SetVLayerDesc = function(msg) {
        this.VLayerPanel().innerHTML = msg;
    }
    
    //returns the VLayer Info string from the footer
    this.GetVLayerDesc = function() {
        return this.VLayerPanel().innerHTML;
    }
    
    //Initializes the footer, adds copyright and initial prefs text
    this.CreateHTML = function() {
        this.CopyrightPanel().innerHTML = _geoEyeCopyrightText;
        this.PreferencesPanel().innerHTML = _footerPrefsCollected + this.startDate + " to " + this.endDate + " • " + this.cloudCover + " • " + this.Source;

    }
    
    //Clear the overlay info div and hide the div
    this.ClearFeatureTable = function () {
    this.VLayerPanel().innerHTML = "";
    this.VLayerPanel().style.display = "";
    }
    
    //Write out the lat/long of the mouse to the footer
    this.SetMousePosition = function (point){
            var lat = Math.round(point.lat()*10000)/10000;
            var lng = Math.round(point.lng()*10000)/10000;
            
            lat = lat.toString();
            var newlat = lat.split(".");

            if (newlat.length == 2) {
                if (newlat[1].length == 3) {
                    lat = newlat[0] + "." + newlat[1] + "0";
                }
                else if (newlat[1].length == 2) {
                    lat = newlat[0] + "." + newlat[1] + "00";
                }
            }
            
            lng = lng.toString();
            var newlng = lng.split(".");
            if (newlng.length == 2) {
                if (newlng[1].length == 3) {
                    lng = newlng[0] + "." + newlng[1] + "0";
                }
                else if (newlng[1].length == 2) {
                    lng = newlng[0] + "." + newlng[1] + "00";
                }
            }
            this.MousePanel().innerHTML = "Lat: " + lat + ", Lon: " + lng;
    }
    
    this.SetPrefsDisplay= function (msg) {
        this.PreferencesPanel().innerHTML = msg;
    }
    
}