function header_look (new_text) {
	original_text = "Zoom In On Your Destination";
	document.getElementById('map_heading').innerHTML = (new_text.length > 0) ? '<div style="float:right; text-align:right; width:60px;"><a href="#" onClick="map_goback(); return false;">[back]</a></div>' + new_text : original_text;
}

function map_goback(){
	GUnload();
	document.getElementById('front_map').style.display='block';
	document.getElementById('googlemap').style.display='none';
	//document.getElementById('front_map').style.backgroundImage = 'none';
	//start_moving('front_map',10,get_width('front_map'),get_width('front_map'),get_height('front_map'),241);
	//document.getElementById('front_map').innerHTML = store;
	header_look('');
}

function map_zoomin(continent_id){
	document.getElementById('front_map').style.display='none';
	document.getElementById('googlemap').style.display='block';
	load(continent_id);
	/*
	start_moving('front_map',10,get_width('front_map'),get_width('front_map'),get_height('front_map'),400);
	store = document.getElementById('front_map').innerHTML;
	document.getElementById('front_map').innerHTML = '';
	modrop();
	document.getElementById('front_map').style.backgroundImage = 'url(/images/worldmap_loading.jpg)';
	ajaxGet('ajax_zoom.php?maptop=' + Top(document.getElementById('front_map')) + '&mapleft=' + Left(document.getElementById('front_map')) + '&continent_id=' + continent_id,'front_map');
	//document.getElementById('front_map').innerHTML = '';
	*/
}
//var store = "";
    //<![CDATA[
function ajax_cityInfo(city_id,city_name){
	new Ajax.Request('ajax_cityinfo.php?city_id=' + city_id,
	{
	method:'get',

		onSuccess: function(transport){

			var response = transport.responseText || "";

			alert(response);

			return response;

		},

	onFailure: function(){ return false; }});

}

function admin_panel_load(lat,lon){
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("googlemap"));
		var mapTypeControl = new GMapTypeControl();
		var mapSizeControl = new GSmallZoomControl();

		var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
		var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
		var topLeft = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,10));
		var bottomLeft = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(10,10));

		map.addControl(mapTypeControl, topRight);
		map.addControl(mapSizeControl, topLeft);
		geocoder = new GClientGeocoder();
		
		var point = new GLatLng(lat,lon);
		map.setCenter(point, 7);

		var hereIcon = new GIcon(G_DEFAULT_ICON);
		var marker = new GMarker(point, {draggable:true, icon: hereIcon});

		GEvent.addListener(marker, "dragstart", function() { map.closeInfoWindow(); });
		GEvent.addListener(marker, "dragend", function() {
			placePoint = marker.getPoint();
			marker.openInfoWindowHtml("Updated!");
			document.getElementById('lat_field').value = marker.getPoint().lat();
			document.getElementById('lon_field').value = marker.getPoint().lng();
		  });
		map.addOverlay(marker);
	}
}


function showAddress(address) {

  if(geocoder){

	  geocoder.getLatLng(

		address,

		function(point) {

		  if (!point) {

			alert(address + " not found");

		  } else {

			map.setCenter(point, 14);

						

			var hereIcon = new GIcon(G_DEFAULT_ICON);

			

			var marker = new GMarker(point, {draggable:true, icon: hereIcon});

			placePoint = marker.getPoint();

			GEvent.addListener(marker, "dragstart", function() { map.closeInfoWindow(); });

			

			GEvent.addListener(marker, "dragend", function() {

				placePoint = marker.getPoint();

				marker.openInfoWindowHtml("Updated!");

				document.getElementById('lat_field').value = marker.getPoint().lat();

				document.getElementById('lon_field').value = marker.getPoint().lng();

			});

			map.addOverlay(marker);

			document.getElementById('lat_field').value = point.lat();

			document.getElementById('lon_field').value = point.lng();
			

		  }

		}

	  );

  }

  return false;

}



function load(continent_id) {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("googlemap"));
		var mapTypeControl = new GMapTypeControl();
		var mapSizeControl = new GSmallZoomControl();
		
		var topRight = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
		var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
		var topLeft = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,10));
		var bottomLeft = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(10,10));

		map.addControl(mapTypeControl, topRight);
		map.addControl(mapSizeControl, topLeft);
		//map.setCenter(new GLatLng(0, 0), 1);

		if(continent_id==1) map.setCenter(new GLatLng(5.6, 24), 3); //Africa
		if(continent_id==5) map.setCenter(new GLatLng(39, -95), 3); //North America
		if(continent_id==6) map.setCenter(new GLatLng(-13, -56), 3); //South America
		if(continent_id==7) map.setCenter(new GLatLng(52.4, 14.76), 3); //Europe
		if(continent_id==4) map.setCenter(new GLatLng(33.14, 43.2), 3); //Middleeast
		if(continent_id==2) map.setCenter(new GLatLng(46.7, 106.7), 3); //Asia
		if(continent_id==3 || continent_id==9) map.setCenter(new GLatLng(-18.5, 142.9), 3); //Australia
		if(continent_id==8) map.setCenter(new GLatLng(20.6, -76), 4); //Carrib
		geocoder = new GClientGeocoder();
		
		new Ajax.Request('ajax_front.php?continent_id=' + continent_id,
	{
	method:'get',
		onSuccess: function(transport) {
			var response = transport.responseText || "";
			// alert("Response: " + response);
			myArray = response.split("::");
			var hereIcon = new GIcon(G_DEFAULT_ICON);
			//hereIcon.image = "http://www.besttimetogo.com/images/small.gif";
			//hereIcon.iconSize = new GSize(9,32);
			//hereIcon.shadowSize = new GSize(9,13);
		
			var plots = new Array();
			for(i=0;i<myArray.length;i+=4){
				lat = myArray[i+0];
				lon = myArray[i+1];
				cid = myArray[i+2];
				cname = myArray[i+3];
				if(cname.length>0) {
					var point = new GLatLng(Number(lat), Number(lon));
					var markerOptions = {draggable:false, icon: hereIcon};
					plots[cid] = new GMarker(point,markerOptions);
					plots[cid].cid = cid;
					plots[cid].cname = cname;
					GEvent.addListener(plots[cid], "click", function() {
						//this.openInfoWindowHtml(ajax_cityInfo(this.cid,this.cname));
						this.openInfoWindowHtml("Go to: <a href=\"view.php?city_id=" + this.cid + "\">" + this.cname + "</a>");
					});
					map.addOverlay(plots[cid]);
				}
			}
			return false;
		},
		onFailure: function(){ alert('???'); return false; }});
		}
}

