////////////////////////////////////////////////////////////////////////////////////////////
// This script is concieved and created by Jesse Schulman (http://year2032.com). (c) 2006 //
// He cut and pasted a lot from others. Feel free to use this script in any way you like. //
//                                                                                        //
// This program is free software; you can redistribute it and/or modify it under the      //
// terms of the GNU General Public License as published by the Free Software Foundation;  //
// either version 2 of the License, or (at your option) any later version.                //
//                                                                                        //
// This program is distributed in the hope that it will be useful, but WITHOUT ANY        //
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A        //
// PARTICULAR PURPOSE.  See the GNU General Public License for more details.              //
//                                                                                        //
// http://www.gnu.org/licenses/gpl.html                                                   //
////////////////////////////////////////////////////////////////////////////////////////////

// Zoom-In Function using Geocode point only. - function zoomIN(i)

        function zoomIN(i) {
           //Zoom in on the current marker.
           //alert("markers["+i+"]="+markers[i].location+"@"+markers[i].point);
           map.setCenter(gmarkers[i].point,14);
        }

// END of Zoom-In Function using Geocode point only. - function zoomIN(i)

// Zoom-Out Function - function zoomOUT()

        function zoomOUT() {
           //Return to starting point.
           map.setCenter(new GLatLng(38.926832,1.423759), 11);
        }

// END of Zoom-Out Function - function zoomOUT()

// This Function picks up the click and opens the corresponding info window - function myclick(i)

        function myclick(i) {
          gmarkers[i].openInfoWindowHtml(htmls[i]);
        }

// END of This function picks up the click and opens the corresponding info window - function myclick(i)

// Functions that open the directions forms - function tohere(i)

        function tohere(i) {
          gmarkers[i].openInfoWindowHtml(to_htmls[i]);
	}

// END of Functions that open the directions forms - function tohere(i)

// Functions that open the directions forms - function fromhere(i)

        function fromhere(i) {
          gmarkers[i].openInfoWindowHtml(from_htmls[i]);
	}

// END of Functions that open the directions forms - function fromhere(i)

// Function If the map position is out of range, move it back - function checkBounds()

	function checkBounds() {

	  // Perform the check and return if OK
          if (allowedBounds.contains(map.getCenter())) {
            return;
          }

	  // It`s not OK, so find the nearest allowed point and move there
          var C = map.getCenter();
          var X = C.lng();
          var Y = C.lat();

          var AmaxX = allowedBounds.getNorthEast().lng();
          var AmaxY = allowedBounds.getNorthEast().lat();
          var AminX = allowedBounds.getSouthWest().lng();
          var AminY = allowedBounds.getSouthWest().lat();

          if (X < AminX) {X = AminX;}
          if (X > AmaxX) {X = AmaxX;}
          if (Y < AminY) {Y = AminY;}
          if (Y > AmaxY) {Y = AmaxY;}

          //alert ("Restricting "+Y+" "+X);
          map.setCenter(new GLatLng(Y,X));
	}

// END of Function If the map position is out of range, move it back - function checkBounds()