// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// File: USGS001.js
//
// Purpose: This file is used to customize the USGS map template #001.
//
// Description: USGS Map Template #001 is used for a public non-entry-level 
//              Website.  It contains a USGS identifier in a colored
//              banner, title, ArcIMS compatible map, and a footer.
//
// Record of Modifications:
//
//  Date          Author          Modification
//  -----------   -------------   ---------------------------------------
//  18 Apr 2001   Cast            Initial Creation
//  13 Jun 2001   Cast            Merged with Wizard
//
//  ---------------------------------------------------------------------
// 
// get machine name
var hostName = document.location.host;
 
// DO NOT MAKE ANY MODIFICATIONS IN THIS SECTION !!
       var USGSTitle      = "";
       var USGSBanner     = "usgs_images/sm_key_color_green.gif";
       var bannerColor    = "key_color_green";
       var USGScopyright  = "";
       var USGShost       = "";
       var USGSport       = "";
       var USGSsvc        = "";
       var USGShostOV     = "";
       var USGSportOV     = "";
       var USGSsvcOV      = "";
       var USGSmaintainer = "";
       var USGSyear       = 2001;
       var USGSmonth      = 1;
       var USGSdate       = 1;
       var USGSmdate      = "";
       var USGStop;
       var USGSbottom;
       var USGSright;
       var USGSleft;
       var USGSMapBackColor       = "";
       var USGSBackgroundColor    = "";
       var USGSFormFilePath       = "";
       var USGSframes             = "";
       var USGSLocalDepartment    = "";
       var USGSLocalDepartmentURL = "";
       var USGSUseTextButtons     = "";
       var USGSalternative        = "";
       var USGSThisURL            = "";
			 
//
// END OF NO MODIFICATION SECTION
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// Directions: This is the configuration file used to customize Template #1.
//             The preferred way to modify this file is to use the Wizard
//             included in this same directory.  The wizard will write the
//             necessary variables to the end of this file, and all hand-
//             editing information in this file will be ignored.  If you
//             choose to edit this file by hand, you must first go to the
//             end of this file and remove all lines AFTER the line that
//             begins  "// DO NOT CHANGE THIS LINE.  IF HAND EDITING, ...".
//             Then follow the directions listed below for each parameter.
//             Note:  Before hand-editing this file, please make a backup
//             of this file in case it gets corrupted.
//
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// 1.  Specify the Title to appear above the map.
//
//     The next line is where you define the title that you want.  It must
//     appear between the double quotes.
       USGSTitle = "Put title here";
//
// ------------------------------------------------------------------------
//
// 2.  Specify which color banner will appear at the top of the page.
//
//     Remove only the first two slashes from the line you want.  The rgb
//     values listed to the right of each choice are simply for reference
//     and should remain commented out.
//
//     bannerColor="blue";                      //   0, 102, 153
//     bannerColor="blue_green";                //   0, 102, 102
     bannerColor="blue_grey";                 // 153, 204, 204
//     bannerColor="brown";                     // 153,  51,   0
//     bannerColor="burgundy";                  // 153,   0,  51
//     bannerColor="dark_blue";                 //   0,  51, 102
//     bannerColor="dark_blue_green";           //   0,  51,  51
//     bannerColor="dark_green";                //  51, 102,  51
//     bannerColor="dark_purple";               //  51,   0, 102
//     bannerColor="dark_red_violet";           // 102,  51, 102
//     bannerColor="green_grey";                // 102, 153, 153
//     bannerColor="key_color_green";           //   0, 102,  51
//     bannerColor="light_blue";                // 102, 204, 255
//     bannerColor="light_grey";                // 204, 204, 204
//     bannerColor="purple";                    //  51,  51, 153
//     bannerColor="red";                       // 255,   0,  51
//     bannerColor="red_violet";                // 153,   0, 153
//     bannerColor="tan";                       // 204, 153, 102
//     bannerColor="warm_grey";                 // 153, 153, 153
//     bannerColor="yellow";                    // 255, 204,   0
//     bannerColor="yellow_orange";             // 255, 153,   0
//
// ------------------------------------------------------------------------
//
// 3.  Specify the location of the template on the local machine
//
       USGSFormFilePath = "d:/InetPub/wwwroot/Website/template1/";
//
// ------------------------------------------------------------------------
//
// 4.  Specify the ArcIMS host machine, port, and map service name for the
//     main map image.
//
//     Note:  21 Jun 2001 - Still testing using ports other than 80.  This
//     template will not use the port value that you specify and will default
//     to port 80 on the Host machine that you specify.
//
//     Main Map Image Host machine
       USGShost = "edcnts12.cr.usgs.gov";
//
//     Main Map Image Port
       USGSport = "80";
//
//     Main Map Image MapService Name
       USGSsvc  = "USGS_NED_DSI";
//
// ------------------------------------------------------------------------
//
// 5.  Specify whether or not your website will use an overview map.  If 
//     you will be using an overview, specify the host machine, port, and
//     map service that will be used for the overview.
//
//     Note:  21 Jun 2001 - Still testing using ports other than 80.  This
//     template will not use the port value that you specify and will default
//     to port 80 on the Host machine that you specify.
//
//     Will the website use an overview map?  Answer "Yes" or "No".
       USGSUseOverview = "Yes";
//
//     Overview Image Host machine
       USGShostOV = "edcnts12.cr.usgs.gov";
//
//     Overview Image Port
       USGSportOV = "80";
//
//     Overview Image MapService Name
       USGSsvcOV = "USGS_NED_DSI";
//
// ------------------------------------------------------------------------
//
// 6.  Specify the initial geographic limits for the map service.
//
//     Latitude:  Positive values are North latitude
//                Negative values are South latitude
//
//     Longitude: Positive values are East longitude
//                Negative values are West longitude
//
       USGStop    = 53.0;
       USGSbottom = 25.0;

       USGSright  = -65.0;
       USGSleft   = -130.0;    
//
// ------------------------------------------------------------------------
//
// 7.  Define the background color for the map window.
//     This value is a comma-separated string consisting of three values
//     between 0 (dark) and 255 (light) representing Red, Green, and Blue.
//     The values must remain between the double-quotes.
//
       USGSMapBackColor = "0,97,163"; 
//
// ------------------------------------------------------------------------
//
// 8.  Define the background color for the toolbars and legends.
//     This value is a comma-separated string consisting of three values
//     between 0 (dark) and 255 (light) representing Red, Green, and Blue.
//     The values must remain between the double-quotes.
//
       USGSBackgroundColor = "145,176,169"; 
//
// ------------------------------------------------------------------------
//
// 9.  Define the background color for the title and footer areas.
//     This value is a comma-separated string consisting of three values
//     between 0 (dark) and 255 (light) representing Red, Green, and Blue.
//     The values must remain between the double-quotes.
//
       USGSPageColor = "145,176,189";
//
// ------------------------------------------------------------------------
//
// 10.  Specify whether or not you want the frame boundaries to be visible.
//      Indicate "Yes" or "No".  Keep the double quotes in the following line.
//
       USGSframes = "No";
//
// ------------------------------------------------------------------------
//
// 11.  Specify whether you want to use a text button or an icon to toggle
//      between the legend and the layer list.  
//      Indicate "Yes" to use a button, or
//               "No"  to use an icon.
//      Keep the double quotes in the follwing line. 
//
       USGSUseTextButtons = "No";
//
// ------------------------------------------------------------------------
//
// 12.  Specify an email address for the maintainer for your website.
//      and local USGS division information
//
        USGSmaintainer = "ask@usgs.gov";
       
//
// ------------------------------------------------------------------------
// 
// 13.  By default, the links in the footer will appear as follows:
//      U.S. Department of the Interior  ||  U.S. Geological Survey
//
//      If you want to add your local USGS unit information, indicate your
//      unit and a URL to your installation website in the variables at the
//      end of step 11.  
//
//      EXAMPLE:  USGSLocalDepartmentURL = "http://edcwww.cr.usgs.gov/";
//                USGSLocalDepartment    = "EROS Data Center";
//
//      If you do not want your local USGS unit listed in the footer, do
//      not modify the following variables.
//
        USGSLocalDepartmentURL = "";
        USGSLocalDepartment = "";
//
// ------------------------------------------------------------------------
// 
// 14.  In order to provide compliance with the American Disabilities Act
//      Section 508, there must be a link to a web page that provides 
//      alternative content for certain web page elements.  One example is
//      to redirect a user to this alternative site if their browser does
//      not support Javascript.  You must specify between the double quotes
//      a valid URL to a site that contains alternative content.
//     
        USGSalternative = "http://www.usgs.gov";
//
// ------------------------------------------------------------------------
// 
// 15.  Error conditions such as having javascript disabled, the inability to
//      support frames in the browser, or the mapservice being unavailable
//      have been addressed.  In order for the error pages to display
//      correctly, you must specify the URL that is used to reach the 
//      directory that contains this template on your machine.  Keep the 
//      double quotes in the following line.
//     
        USGSThisURL = "http://edcnts12.cr.usgs.gov/website/template1";
//
// ------------------------------------------------------------------------
// 
// 16.  Specify the website Modification Date
//
//     Specify the year ( >= 2001 )
       USGSyear = 2001;
       
//     Specify the month ( 1-12 )
       USGSmonth = 5;
       
//     Specify the day of the month ( 1-31 )
       USGSdate = 07;
//
// ------------------------------------------------------------------------
// 
// 17.  Make manual modifications to index.htm and default.htm
//
//      If you are hand-editing this file, you must also modify two other
//      files in this directory:
//          index.htm
//          default.htm
//      These files will be displayed if the user's browser does not support
//      Javascript and therefore must be modified by hand.  In both of these
//      files you must update four parameters:
//          1.  the link to alternative content
//          2.  the full path to that page
//          3.  the maintainer of that page
//          4.  the modification date of that page
//      There are instructions in each file on how to make these modifications.
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// DO NOT MAKE ANY MODIFICATIONS IN THIS SECTION !!
//
    // Default Title
    if ( (USGSTitle == "") || (USGSTitle == "Put title here") )
        USGSTitle = "USGS Map";

    // Default Banner color
    var tempBanner = "usgs_images/sm_" + bannerColor + ".gif";
    USGSBanner = tempBanner;
    USGScopyright = "usgs_images/sm_logo_" + bannerColor + ".gif";

    // Build mapService urls
    //var USGSMapService = "http://" + USGShost   + ":" + USGSport   + "/servlet/com.esri.esrimap.Esrimap?ServiceName=" + USGSsvc;
    var USGSMapService = "http://" + USGShost   + "/servlet/com.esri.esrimap.Esrimap?ServiceName=" + USGSsvc;
    //var USGSOVService  = "http://" + USGShostOV + ":" + USGSportOV + "/servlet/com.esri.esrimap.Esrimap?ServiceName=" + USGSsvcOV;
    var USGSOVService  = "http://" + USGShostOV + "/servlet/com.esri.esrimap.Esrimap?ServiceName=" + USGSsvcOV;

    // Build Modification Date String
    USGSmoddate = new Date();
    USGSmoddate.setFullYear(USGSyear);
    USGSmoddate.setMonth(USGSmonth-1);
    USGSmoddate.setDate(USGSdate); 
    switch (USGSmoddate.getDay()) {
        case 0:
            USGSmdate = 'Sun ';
            break;
        case 1:
            USGSmdate = 'Mon ';
            break;
        case 2:
            USGSmdate = 'Tue ';
            break;
        case 3:
            USGSmdate = 'Wed ';
            break;
        case 4:
            USGSmdate = 'Thu ';
            break;
        case 5:
            USGSmdate = 'Fri ';
            break;
        default:
            USGSmdate = 'Sat ';
            break;
    }

    if (USGSmoddate.getDate() < 10)
        USGSmdate += '0';
    USGSmdate += USGSmoddate.getDate();

    switch (USGSmoddate.getMonth()) {
        case 0:
            USGSmdate += ' Jan ';
            break;
        case 1:
            USGSmdate += ' Feb ';
            break;
        case 2:
            USGSmdate += ' Mar ';
            break;
        case 3:
            USGSmdate += ' Apr ';
            break;
        case 4:
            USGSmdate += ' May ';
            break;
        case 5:
            USGSmdate += ' Jun ';
            break;
        case 6:
            USGSmdate += ' Jul ';
            break;
        case 7:
            USGSmdate += ' Aug ';
            break;
        case 8:
            USGSmdate += ' Sep ';
            break;
        case 9:
            USGSmdate += ' Oct ';
            break;
        case 10:
            USGSmdate += ' Nov ';
            break;
        default:
            USGSmdate += ' Dec ';
            break;
    }
    USGSmdate += USGSmoddate.getFullYear();
//
    if ( (USGStop > 90.0) || (USGStop <= -90.0) )
        USGStop = 53.0;
    if ( (USGSbottom < -90.0) || (USGSbottom >= 90.0) )
        USGSbottom = 25.0;
    if (USGStop <= USGSbottom) {
        USGStop = 53.0;
        USGSbottom = 25.0;
    }
   
    USGSBackgroundColor = rgb2hex(USGSBackgroundColor);
    USGSPageColor       = rgb2hex(USGSPageColor);
    
    if ( USGSframes.search(/y/i) == -1 )
        USGSframes = "No";
    else
        USGSframes = "Yes";
    
    if ( USGSUseTextButtons.search(/y/i) == -1 )
        USGSUseTextButtons = false;
    else
        USGSUseTextButtons = true;
    
    if ( USGSUseOverview.search(/y/i) == -1 )
        USGSUseOverview = false;
    else
        USGSUseOverview = true;
//------------------------------------------------------------------
// rgb2hex
//
// converts a comma-separated rgb string to a hex string
//
    function rgb2hex(rgb) {
        var comma1 = rgb.indexOf(",");
        var comma2 = rgb.lastIndexOf(",");
        var redStr = rgb.substring(0, comma1);
        var grnStr = rgb.substring(comma1 + 1, comma2);
        var bluStr = rgb.substring(comma2 + 1, rgb.length);
        //alert("red = " + redStr + "  green = " + grnStr + "  blue = " + bluStr);
        var hex = "#" + dec2hex(redStr) + dec2hex(grnStr) + dec2hex(bluStr);
        //alert("hex = " + hex);
        return(hex);
    }

    function dec2hex(dec) {
        var digit1 = Math.floor(dec / 16);
        var digit2 = dec - (digit1 * 16);
        var hex = "";
        switch(digit1) {
            case 10:
                hex += "A";
                break;
            case 11:
                hex += "B";
                break;
            case 12:
                hex += "C";
                break;
            case 13:
                hex += "D";
                break;
            case 14:
                hex += "E";
                break;
            case 15:
                hex += "F";
                break;
            default:
                hex += digit1;
                break;
        }
        switch(digit2) {
            case 10:
                hex += "A";
                break;
            case 11:
                hex += "B";
                break;
            case 12:
                hex += "C";
                break;
            case 13:
                hex += "D";
                break;
            case 14:
                hex += "E";
                break;
            case 15:
                hex += "F";
                break;
            default:
                hex += digit2;
                break;
        }
        return hex;
    }

// DO NOT CHANGE THIS LINE.  IF HAND EDITING, REMOVE ALL LINES AFTER THIS LINE.
USGSTitle="Apollo Footprint Viewer";
USGSframes="Yes";
USGSUseTextButtons=false;
USGSUseOverview=true;
USGSmaintainer="thare@usgs.gov";
USGSalternative="http://webgis.wr.usgs.gov";
USGSFormFilePath="C:/ArcIMS/WebSite/moon_html/";
USGSLocalDepartment="Astrogeology";
USGSLocalDepartmentURL="http://astrogeology.usgs.gov";
USGSBanner="usgs_images/sm_green_grey.gif";
USGScopyright="usgs_images/sm_logo_white.gif";
USGSPageColor="#DDD6C6";
USGSBackgroundColor="#C8C1AE";
USGSMapBackColor="170,170,169";
USGStop=95.0;
USGSbottom=-95.0;
USGSleft=-185.0;
USGSright=185.0;
USGSMapUnits="DD";
//USGSMapService="http://webgis.wr.usgs.gov/servlet/com.esri.esrimap.Esrimap?ServiceName=Moon_general_image";
//USGSOVService="http://webgis.wr.usgs.gov/servlet/com.esri.esrimap.Esrimap?ServiceName=Moon_general_image";
USGSMapService="http://" + hostName + "/servlet/com.esri.esrimap.Esrimap?ServiceName=Apollo_footprints";
USGSOVService="http://" + hostName + "/servlet/com.esri.esrimap.Esrimap?ServiceName=Moon_general_image";
USGSmdate="Jul 2007";
USGSThisURL="http://" + hostName + "Website/apollo_html";

