﻿  /*  window.onload = function() {
    initialize() ;
  }*/

    var map;                    //GMap object
    var markers = new Array();  //array that holds all the markers
    var current;                //the current visible marker
    var index = 0;              //markers array next index
    var linkBox;                //custom popup box for Link button




    //creates a new marker and adds it to the 'markers' array
    function createMarker(lat, lng, title, image, description, pin, id, multiple, rss) {
        markers[index] = new Marker(lat, lng, title, image, description, pin, id, multiple, rss);


        index++;
    }



    //constructs a new marker along with all the marker's associated data
    function Marker(lat, lng, title, image, description, pin, id) {

        this.id = id;
        this.title = title;
        this.image = image;
        this.description = description;
        this.hasEvents = false;
        this.pin = pin;
        this.html = "<h3>" + title + "</h3>";
        if (image != null)
            this.html = this.html + "<img style='padding:10px' src='" + image + "' align='right' height='100' width='150'>";
        if (description != null) {
            this.html = this.html + "<p>" + description + "</p>";
            /*//formats the info box if there are css issues
            for(var i = 0; i < description.length/90; i++)
            {
            this.html = this.html + "<br/>";
            }*/
        }




        var baseIcon = new GIcon(G_DEFAULT_ICON);
        var latlng = new GLatLng(lat, lng);
        var letteredIcon = new GIcon(baseIcon);
        letteredIcon.image = pin;



        // Set up our GMarkerOptions object
        markerOptions = { icon: letteredIcon };

        this.m = new GMarker(latlng, markerOptions);

        
            var c = this.m;
            var h = this.html
            GEvent.addListener(c, "click", function() {
                c.openInfoWindowHtml(h, { maxWidth: 600 });
            });
        


        map.addOverlay(this.m);

        //this.m.hide();

    }

    function initialize() {
        if (GBrowserIsCompatible()) {
            map = new GMap2(document.getElementById("map_canvas"));
            map.setCenter(new GLatLng(30.306503259848835, -81.62429809570312), 10);

            createMarker(30.26524, -81.62311, "Famous Amos", null, "3911 University Blvd.	West<br/>Jacksonville, Fl. 32207<br/>Tel:  (904) 731-2322<br/><br/>Get Directions: <br/> <div align=\"center\"></div><form action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\"><div align=\"left\"> Enter Your Address<small> (Street, City, State)</small> <br> <input type=\"text\" class=\"text\" name=\"saddr\" id=\"mapsUsSaddr\" value=\"\" size=\"40\" /> <br/><input type=\"submit\" class=\"submit\" value=\"Go\" /> <INPUT TYPE=\"reset\" value=\"Clear\"> <input type=\"hidden\" name=\"daddr\" value=\"30.26524, -81.62311\" /> <input type=\"hidden\" name=\"hl\" value=\"en\" /></div><form></div> </font><br/>", "http://www.google.com/mapfiles/marker.png", "0");
            createMarker(30.282565741445246, -81.74686431884766, "Famous Amos", null, "6315 San Juan<br/>Jacksonville, Fl. 32210<br/>Tel:  (904)  786-4940<br/><br/>Get Directions: <br/> <div align=\"center\"></div><form action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\"><div align=\"left\"> Enter Your Address<small> (Street, City, State)</small> <br> <input type=\"text\" class=\"text\" name=\"saddr\" id=\"mapsUsSaddr\" value=\"\" size=\"40\" /> <br/><input type=\"submit\" class=\"submit\" value=\"Go\" /> <INPUT TYPE=\"reset\" value=\"Clear\"> <input type=\"hidden\" name=\"daddr\" value=\"30.282565741445246, -81.74686431884766\" /> <input type=\"hidden\" name=\"hl\" value=\"en\" /></div><form></div> </font><br/>", "http://www.google.com/mapfiles/marker.png", "1");
            createMarker(30.169877320119575, -81.74755096435547, "Famous Amos", null, "342 Blanding Blvd.<br/>Orange Park, Fl. 32073<br/>Tel:   (904) 272-7025<br/><br/>Get Directions: <br/> <div align=\"center\"></div><form action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\"><div align=\"left\"> Enter Your Address<small> (Street, City, State)</small> <br> <input type=\"text\" class=\"text\" name=\"saddr\" id=\"mapsUsSaddr\" value=\"\" size=\"40\" /> <br/><input type=\"submit\" class=\"submit\" value=\"Go\" /> <INPUT TYPE=\"reset\" value=\"Clear\"> <input type=\"hidden\" name=\"daddr\" value=\"30.169877320119575, -81.74755096435547\" /> <input type=\"hidden\" name=\"hl\" value=\"en\" /></div><form></div> </font><br/>", "http://www.google.com/mapfiles/marker.png", "2");
            createMarker(30.19117156404237, -81.62601470947266, "Famous Amos", null, "10339 San Jose Blvd.<br/>Jacksonville, Fl. 32257<br/>Tel:   (904)  268-6159<br/><br/>Get Directions: <br/> <div align=\"center\"></div><form action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\"><div align=\"left\"> Enter Your Address<small> (Street, City, State)</small> <br> <input type=\"text\" class=\"text\" name=\"saddr\" id=\"mapsUsSaddr\" value=\"\" size=\"40\" /> <br/><input type=\"submit\" class=\"submit\" value=\"Go\" /> <INPUT TYPE=\"reset\" value=\"Clear\"> <input type=\"hidden\" name=\"daddr\" value=\"30.19117156404237, -81.62601470947266\" /> <input type=\"hidden\" name=\"hl\" value=\"en\" /></div><form></div> </font><br/>", "http://www.google.com/mapfiles/marker.png", "3");
            createMarker(30.333213000548636, -81.59666061401367, "Famous Amos", null, "1111 Cesery Blvd.<br/>Jacksonville, Fl. 32211<br/>Tel:   (904)   744-1453<br/><br/>Get Directions: <br/> <div align=\"center\"></div><form action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\"><div align=\"left\"> Enter Your Address<small> (Street, City, State)</small> <br> <input type=\"text\" class=\"text\" name=\"saddr\" id=\"mapsUsSaddr\" value=\"\" size=\"40\" /> <br/><input type=\"submit\" class=\"submit\" value=\"Go\" /> <INPUT TYPE=\"reset\" value=\"Clear\"> <input type=\"hidden\" name=\"daddr\" value=\"30.333213000548636, -81.59666061401367\" /> <input type=\"hidden\" name=\"hl\" value=\"en\" /></div><form></div> </font><br/>", "http://www.google.com/mapfiles/marker.png", "4");
            createMarker(30.291589315657834, -81.78673267364502, "Famous Amos", null, "8265 Normandy Blvd.<br/>Jacksonville, Fl. 32221<br/>Tel:    (904) 786-2244<br/><br/>Get Directions: <br/> <div align=\"center\"></div><form action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\"><div align=\"left\"> Enter Your Address<small> (Street, City, State)</small> <br> <input type=\"text\" class=\"text\" name=\"saddr\" id=\"mapsUsSaddr\" value=\"\" size=\"40\" /> <br/><input type=\"submit\" class=\"submit\" value=\"Go\" /> <INPUT TYPE=\"reset\" value=\"Clear\"> <input type=\"hidden\" name=\"daddr\" value=\"30.291589315657834, -81.78673267364502\" /> <input type=\"hidden\" name=\"hl\" value=\"en\" /></div><form></div> </font><br/>", "http://www.google.com/mapfiles/marker.png", "5");
            createMarker(30.21206, -81.58418, "Famous Amos Corporate Office", null, "9310 Old Kings Road South, #1101<br/>Jacksonville, Fl. 32257<br/>Tel:    (904) 731-3396<br/>Fax:   (904) 731-3421<br/><br/>Get Directions: <br/> <div align=\"center\"></div><form action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\"><div align=\"left\"> Enter Your Address<small> (Street, City, State)</small> <br> <input type=\"text\" class=\"text\" name=\"saddr\" id=\"mapsUsSaddr\" value=\"\" size=\"40\" /> <br/><input type=\"submit\" class=\"submit\" value=\"Go\" /> <INPUT TYPE=\"reset\" value=\"Clear\"> <input type=\"hidden\" name=\"daddr\" value=\"30.21206, -81.58418\" /> <input type=\"hidden\" name=\"hl\" value=\"en\" /></div><form></div> </font><br/>", "http://www.google.com/mapfiles/marker.png", "6");
            createMarker(30.21206, -81.58418, "Famous Amos Catering Department", null, "9310 Old Kings Road South, #1101<br/>Jacksonville, Fl. 32257<br/>Tel:    (904) 731-3396<br/>Fax:   (904) 731-3421<br/><br/>Get Directions: <br/> <div align=\"center\"></div><form action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\"><div align=\"left\"> Enter Your Address<small> (Street, City, State)</small> <br> <input type=\"text\" class=\"text\" name=\"saddr\" id=\"mapsUsSaddr\" value=\"\" size=\"40\" /> <br/><input type=\"submit\" class=\"submit\" value=\"Go\" /> <INPUT TYPE=\"reset\" value=\"Clear\"> <input type=\"hidden\" name=\"daddr\" value=\"30.21206, -81.58418\" /> <input type=\"hidden\" name=\"hl\" value=\"en\" /></div><form></div> </font><br/>", "http://www.google.com/mapfiles/marker.png", "7");
          
            document.getElementById("hours").innerHTML = hours[0];
            map.setUIToDefault();
        }
    }

   function show(id)
{
    for(var i = 0; i < markers.length; i++)
    {
        if(markers[i].id == id)
        {
            markers[i].m.openInfoWindowHtml(markers[i].html, {maxWidth:600});

            break;
            
        }
    }
}


function update(dropdown) {
    
    if($("#loc_a").html() == "Show Map of Locations")
    {
        $("#map_canvas").css("display","block");
         $("#FAImg").animate({ height: 'hide', opacity: 'hide' }, 'slow');
         $("#loc_a").html("Hide Map of Locations");
         if(map == undefined)
            initialize();
    }
    var myindex = dropdown.selectedIndex;
    
        show(myindex);
        var hrsDiv = document.getElementById("hours");
        
        if (myindex.toString() == "0") {
            hrsDiv.innerHTML = hours[0];
        }
        else if (myindex.toString() == "1") {
            hrsDiv.innerHTML = hours[1];
        }
        else if (myindex.toString() == "2") {
            hrsDiv.innerHTML = hours[2];
        }
        else if (myindex.toString() == "3") {
            hrsDiv.innerHTML = hours[3];
        }
        else if (myindex.toString() == "5") {
            hrsDiv.innerHTML = hours[4];
        }
        else if (myindex.toString() == "4") {
            hrsDiv.innerHTML = hours[5];
        }
        /*else if (myindex.toString() == "6") {
            hrsDiv.innerHTML = hours[6];
        }*/
        else if (myindex.toString() == "6") {
            hrsDiv.innerHTML = hours[7];
        }
        else if (myindex.toString() == "7") {
            hrsDiv.innerHTML = hours[8];
        }
    
    }
