// JavaScript Document
//-----------------------------------------------
//   Copyright ©2006 timaps.co.uk. All rights reserved
//
//  Version 1//  	
//-----------------------------------------------
var markers;


function init () {
  
    }
function getMap(){
	    var catid;
		init ();
		var dbmarkers;
		var newlat;
  		var m = document.getElementById("mapsmall");
     	m.style.height = "150px";
	 	m.style.width = "210px";
		map = new GMap2(m);
		map = new GMap2(document.getElementById("mapsmall")); 
		//map.addControl(new GMapTypeControl());
		map.addControl(new TextualZoomControl());
		//map.addControl(new GOverviewMapControl());
		llat = parseFloat(llat)
		llng = parseFloat(llng)
		lzoom = parseFloat(lzoom)

		if (isNaN(lzoom)) {lzoom=8};

		if (!isNaN(llat) && !isNaN(llng)) {
		   map.setCenter(new GLatLng(llat,llng),17-lzoom);
		 }
		 else
		 {
		 map.setCenter(new GLatLng(54.5210,-2.7246), 8);
		 }
		var icon = new GIcon();
		icon.shadow = "images/arrowshadow.png";
		icon.iconSize = new GSize(24, 34);
		icon.shadowSize = new GSize(39, 34);
		icon.iconAnchor = new GPoint(9, 34);
		icon.infoWindowAnchor = new GPoint(9, 2);
		icon.infoShadowAnchor = new GPoint(18, 25);
		icon.image = "images/arrow.png";
		if (!isNaN(llat) && !isNaN(llng)){
		   markers = new GMarker(new GPoint(llng,llat),{icon:icon});
		 }
		 else
		 {
		   markers = new GMarker(new GPoint(-10, 57.10),{icon:icon});
		 }
		//markers.setTooltip("Zoom In");
		//GEvent.addListener(markers, "click", function(){
     	   
		//    }); 
		//gmarkers = new Array();
		//gmarkers.push(markers); 
		map.addOverlay(markers); 
		// Tooltips 
		//		GEvent.addListener(markers,"click", function() {
		//			markers.openInfoWindowHtml(markers.htmls);
		//		});
		//infoHtmls = '<div class="infonarrow"><p><b>Show Nearby Places On Map:</b><br />&nbsp;<img src="images/more.gif" alt="&gt;"/>&nbsp;<a href="/map?pl='+ pl + '">Attractions</a><br />&nbsp;<img src="images/more.gif" alt="&gt;"/>&nbsp;<a href="/map?pl='+ pl + '&type=hotels">Hotels</a></p></div>';
		//	markers.htmls = infoHtmls;
		markers.clickable = false;
		//GEvent.addListener(map, "click", function(markers, point){
		//if (point) {
		 
		//} /* end if */ 
		//} /* end sub function */
		//); 
 		i=0;
}

	
function TextualZoomControl() {
}
TextualZoomControl.prototype = new GControl();

// Creates a one DIV for each of the buttons and places them in a container
// DIV which is returned as our control element. We add the control to
// to the map container and return the element for the map class to
// position properly.
TextualZoomControl.prototype.initialize = function(map) {
  var container = document.createElement("div");

  var zoomInDiv = document.createElement("div");
  this.setButtonStyle_(zoomInDiv);
  container.appendChild(zoomInDiv);
  zoomInDiv.appendChild(document.createTextNode("+ Zoom In"));
  GEvent.addDomListener(zoomInDiv, "click", function() {
    map.zoomIn();
  });

  var zoomOutDiv = document.createElement("div");
  this.setButtonStyle_(zoomOutDiv);
  container.appendChild(zoomOutDiv);
  zoomOutDiv.appendChild(document.createTextNode("- Zoom Out"));
  GEvent.addDomListener(zoomOutDiv, "click", function() {
  map.zoomOut();
  });

  map.getContainer().appendChild(container);
  return container;
}

// By default, the control will appear in the top left corner of the
// map with 7 pixels of padding.
TextualZoomControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
}

// Sets the proper CSS for the given button element.
TextualZoomControl.prototype.setButtonStyle_ = function(button) {
  button.style.textDecoration = "none";
  button.style.color = "#333333";
  button.style.backgroundColor = "white";
  button.style.font = "10px verdana";
  button.style.border = "1px solid black";
  button.style.padding = "2px";
  button.style.marginBottom = "3px";
  button.style.textAlign = "left";
  button.style.width = "7em";
  button.style.cursor = "pointer";
}
function saveme(e)
{
document.getElementById("saveme").innerHTML = '<p><img src="/images/savewait.gif" alt="Saving" /></p>';
	  var request = GXmlHttp.create();
	  var rnd = Math.floor(Math.random() * 100000000000000000000 +1);
	  request.open("GET", "/saveplace.php?pl=" + e + "&rand=" + rnd , true);
	  request.onreadystatechange = function() {
          if (request.readyState == 4) {
			      xmlDoc = request.responseXML;
				  dbtweeker = xmlDoc.documentElement.getElementsByTagName("status");
                  var tw = dbtweeker[0].getAttribute("results");
				  document.getElementById("saveme").innerHTML = tw;
				  
 			}
	}/*end sub function*/
	request.send(null);
}
