	var aa;
	var ab;
	var ac;
	var ad = 1000;	// 1 second
	var ae = 10000;	// 10 seconds
	var af = 10;
	var ag = 50;
	var ah = 100;	// 100 meters (diagonal)
	var ai;
	var aj;
	var ak = false;
	var bg;
	var bh;
	var bi;
	
	var al;
	var am;
	var an;
	var ao = true;
	var ap = 2;
	var aq = 7;
	var ar = screen.width - 20;
	var as = screen.height*65/100;
	var at = 20;
	var au = ar;
	var av = as;
	var aw;
	var ax;
	var ay;
	var az;
	var ba;
	var bb;
	var bc = true;
	var bd = null;
	var be = null;
	var du = 0;
	var dv = 1;
	var dw = 2;
	var dx = 3;
	var dy = 4;
	var dz = 5;
	var ea = 6;
	var eb = 7;
	var ec = 8;
	var ed = 9;
	var ee = 10;
	
	var ef = 10;
	var eg = 10;
	
	var tooltip;

	/**
	* Fonction de récupération des paramètres GET de la page
	* @return Array Tableau associatif contenant les paramètres GET
	*/
	function extractUrlParams() {	
		var t = location.search.substring(1).split('&');
		var f = [];
		for (var i=0; i<t.length; i++) {
			var x = t[ i ].split('=');
			f[x[0]]=x[1];
		}
		return f;
	}

	function eh(pt, x, y) {
		var proj = new GMercatorProjection(at);
		dm = proj.fromLatLngToPixel(pt, al.getZoom());
		dm.x = dm.x - x;
		dm.y = dm.y - y;
		dn = proj.fromPixelToLatLng(dm, al.getZoom());
		dm.x = dm.x + x*2;
		dm.y = dm.y + y*2;
		dp = proj.fromPixelToLatLng(dm, al.getZoom());
		
		s = "lat=" + pt.lat() + "&lng=" + pt.lng();
		s = s + "&top_left_latitude=" + dn.lat() + "&top_left_longitude=" + dn.lng();
		s = s + "&bottom_right_latitude=" + dp.lat() + "&bottom_right_longitude=" + dp.lng();
		s = s + "&zoom=" + al.getZoom();
		s = s + "&lang=en";
		s = s + "&url=";
		return s;
	}
	
	function bj(bk) {
		ab = true;
		aa = new Array(bk.photos.length);
		for (var i = 0; i < bk.photos.length; i++) {
			aa[i] = bk.photos[i];
		}
	}
	function bl(cn) {
		var cm = {
			order: "popularity",	// or upload_date
			set: "public",	// full, or user ID number
			from: "0",
			to: "10",
			minx: "-180",
			miny: "-90",
			maxx: "180",
			maxy: "90",
			size: "small"	// original, medium (default), small, thumbnail, square, mini_square
		};
 
		for (co in cn) {
			if (cn.hasOwnProperty(co)) {
				cm[co] = cn[co];
			}
		}
 
		var url = "http://www.panoramio.com/map/get_panoramas.php?";
		var cp = "";
 
		for (co in cm) {
			if (cm.hasOwnProperty(co)) {
				var cq = "" + cm[co] + "";
				url += co + "=" + cq + "&";
				cp += cq.replace(/[^\w]+/g,"");
			}
		}
		var cr = "bj.loader" + cp;
		eval(cr + " = function(bk) { var pa = new bj(bk);}");
 
		var cs = document.createElement('script');
		cs.setAttribute('src', url + 'callback=' + cr);
		cs.setAttribute('id', 'jsonScript');
		cs.setAttribute('type', 'text/javascript');
		document.documentElement.firstChild.appendChild(cs);
	}
	
	function bm() {
		if (ak) {
			ak = false;
			document.getElementById("auto_guide_display").innerHTML = "Auto Guide&nbsp;<img border='0' src='img/icon_delete.gif'>";
		} else {
			ak = true;
			document.getElementById("auto_guide_display").innerHTML = "Auto Guide&nbsp;<img border='0' src='img/icon_check.gif'>";
		}
	}
	
	function bn(dl, markerIndex) {
		for (i=markerIndex; i<bi.boundMarkers.length; i++) {
			if (bi.boundMarkers[i].marker.photoDisplay != true) {
				continue;
			}
			line = bi.boundMarkers[i].title;
			if (line.length > 1) {
				var ct = line.split("\\");
				var lng = parseFloat(ct[du]);
				var lat = parseFloat(ct[dv]);
				var cu = parseInt(ct[dw], 10);
				if (cu < 10) {
					bi.boundMarkers[i].marker.photoDisplay = false;
					continue;
				}

				var pt = new GLatLng(lat,lng);
				
				var cv = 0;
				mk = bi.boundMarkers[i].marker;
				for (j=0; j<mk.associateList.length; j++) {
					ln = mk.associateList[j].title;
					elmts = ln.split("\\");
					if (parseInt(elmts[dw], 10) < 10) {
						continue;
					}
					cy = elmts[ed];
					s = cy.split(":");
					d = parseInt(s[0], 10)*3600 + parseInt(s[1], 10)*60 + parseInt(s[2], 10);
					cv = cv + d;
				}
				h = Math.floor(cv/3600);
				m = Math.floor((cv-h*3600)/60);
				sec = cv-h*3600-m*60;
				if (h < 10) {
					h = "0" + h;
				}
				if (m < 10) {
					m = "0" + m;
				}
				if (sec < 10) {
					sec = "0" + sec;
				}
				cy = h + ":" + m + ":" + sec;
				
				cv = cv*1000;
				if (cy.indexOf("00:") == 0) {	// 0 hour, don't display it
					cy = cy.substr(3);
				}
				
				af = Math.round(cv/ae + 1);
				if (af > ag)
					af = ag;
				
				if (!ac) {
					aa = new Array();
					ab = false;
					ac = true;
		
					var dc = pt;
					var cz = ah;
					var p = new GLatLng(dc.lat()+0.1, dc.lng()+0.1);
					var AP = dc.distanceFrom(p);
					var ratio = cz/AP;
					var dd = ratio * (p.lat()-dc.lat());
					var de = ratio * (p.lng()-dc.lng());
					var da = new GLatLng(dc.lat()-dd, dc.lng()-de);
					var db = new GLatLng(dc.lat()+dd, dc.lng()+de);

					bl({maxy: db.lat(), miny: da.lat(), maxx: db.lng(), minx: da.lng(), to: af});
					setTimeout("bn(0, 0)", ad);
					return;
				} else if (!ab) {
					setTimeout("bn(0, 0)", ad);
					return;
				}

				var df = ct[dx];
				var dg = ct[dy];
				var dh = ct[dz];
				var di = ct[eb];
				var dj = ct[ec];
				var dk = ct[ee];
				if (dk != "") {
					dk = "&nbsp;&nbsp;<a target='_blank' href='open_text_guide.php?file=../" + dk + "'>" + "<img src='img/text.jpg' border='0' width='15px' height='15px' title='display, update guide'>" + "<\/a>"
				}
				var by = "By: ";
				
				s = eh(pt, ef, eg);
		
				var player = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="230" height="45" id="uaemonplayer" align="middle"><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="uaemon.swf?' + s + '&amp;autostart=1&amp;showtime=1" /><param name="quality" value="high" /><param name="bgcolor" value="FFFFFF" /><embed src="uaemon.swf?' + s + '&amp;autostart=1&amp;showtime=1" quality="high" bgcolor="FFFFFF" width="230" height="45" name="uaemonplayer" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';

				var icon = new GIcon();
				icon.image = "http://www.panoramio.com/img/panoramio-marker.png"; 
				icon.shadow = "";  
				icon.iconSize = new GSize(24, 24); 
				icon.shadowSize = new GSize(22, 22); 
				icon.iconAnchor = new GPoint(9, 9);  
				icon.infoWindowAnchor = new GPoint(9, 0);
				var markerIcon = new GIcon(icon);
				var j = 0;
				if (aa.length == 0) {
					ai = 0;
				    aj = new GMarker(pt, {icon: aw});
					var h = 45 + 2*15;
					var html = "<div id='infowin' style='height:" + h + "px; width:240px;'>" +
						"<div style='overflow: hidden; width: 240px;'>" +
						"<p><a target='_blank' href='" + di + "'>" + df + "<\/a>&nbsp;&nbsp;" + dk + "<br>" + player + by + dh + "</p><\/div>" + 
						"<\/div>";
					al.addOverlay(aj);
					aj.openInfoWindow(html, {noCloseOnClick: true});
				} else {
				  j = dl;
				  if (j < aa.length) {
					var photo = aa[j];
					if (photo.photo_title.length > 33) {
						photo.photo_title = photo.photo_title.substring(0, 33) + "&#8230;";
					}
					var h = 45 + 15 + photo.height + 4*15;
					h = 360;	// there is no resize of infowindow
					if (j == 0) {
						ai = 0;
						aj = new GMarker(pt, {icon: markerIcon});
						var html = "<div id='infowin' style='height:" + h + "px; width:240px;'>" +
							"<div id='infowin_img' style='height:285px; width:240px;'>" +
							"<a href='http://www.panoramio.com/' target='_blank'>" + 
							"<img src='http://www.panoramio.com/img/logo-small.gif' border='0' width='119px' height='15px' alt='Panoramio logo' /><\/a>" +
							"<a id='photo_infowin' target='_blank' href='" + photo.photo_url + "'>" +
							"<img id='panoramio_photo_img' border='0' width='" + photo.width + "' height='" + photo.height + "' src='" + photo.photo_file_url + "'/><\/a>" +
							"<div style='overflow: hidden; width: 240px;'>" +
							"<a id='panoramio_photo_url' target='_blank' class='photo_title' href='" + photo.photo_url +
							"'><strong id='panoramio_photo_title'>" + photo.photo_title + "<\/strong><\/a>" +
							"<br>Posted by <a id='panoramio_photo_owner' target='_blank' href='" + photo.owner_url + "'>" + photo.owner_name + "<\/a><\/div>" + 
							"<\/div>" +
							"<div style='overflow: hidden; width: 240px;'>" +
							"<p><a target='_blank' href='" + di + "'>" + df + "<\/a>&nbsp;&nbsp;" + cy + dk + "<br>" + player + "<small id='change_display'>" + by + dh + "<\/small>" + "</p><\/div>" + 
							"<\/div>";
						var misplaced = "<a href=\"javascript:bp('" +  di + "', '" + dj + "')\">misplaced</a>&nbsp;&#124;&nbsp;";
						var inappropriate = "<a href=\"javascript:bq('" +  di + "', '" + dj + "')\">inappropriate</a>&nbsp;&#124;&nbsp;";
						var comment = "<a href=\"javascript:br('" +  di + "', '" + dj + "')\">comment</a>&nbsp;&#124;&nbsp;";
						var upload_your_guides = "<a href=\"dynUpload.php\" target=\"dyn_frame\">upload your guides</a>";
						bg = by + dh;
						bh = misplaced + inappropriate + comment + upload_your_guides;
						al.addOverlay(aj);
						aj.openInfoWindow(html, {noCloseOnClick: true});
					} else {
						var e = document.getElementById("infowin");
						if (e != null) {	// when infowindow is closed for example
							e.setAttribute("style", "height:" + h + "px; width:240px;");
						} else {
							ai = cv;
						}
						e = document.getElementById("photo_infowin");
						if (e != null) {
							e.setAttribute("href", photo.photo_url);
						} else {
							ai = cv;
						}
						e = document.getElementById("panoramio_photo_img");
						if (e != null) {
							e.setAttribute("width", photo.width);
							e.setAttribute("height", photo.height);
							e.setAttribute("src", photo.photo_file_url);
						} else {
							ai = cv;
						}
						e = document.getElementById("panoramio_photo_title");
						if (e != null) {
							e.innerHTML = photo.photo_title;
						} else {
							ai = cv;
						}
						e = document.getElementById("panoramio_photo_owner");
						if (e != null) {
							e.setAttribute("href", photo.owner_url);
							e.innerHTML = photo.owner_name;
						} else {
							ai = cv;
						}
						e = document.getElementById("change_display");
						if (e != null) {
							e.innerHTML = bh;
							bh = bg;
							bg = e.innerHTML;
						} else {
							ai = cv;
						}
						if (ai == cv) {
							for (k = i+1; k < bi.boundMarkers.length; k++) {
								bi.boundMarkers[k].marker.photoDisplay = false;
							}
						}
					}
				  }
				}
				
				if (ai >= cv) {
					bi.boundMarkers[i].marker.photoDisplay = false;
					ac = false;
					aj.closeInfoWindow();
					al.removeOverlay(aj);
				} else {
					if (aa.length != 0) {
						ai += ae;
						idx = j + 1;
						setTimeout("bn(" + idx + ", 0)", ae);
					}
					break;
				}
			}
		}
	}
	
	function bo(mrker, point) {
		if (mrker.mainMarker) {
			for (i=0; i<bi.boundMarkers.length; i++) {
				if (bi.boundMarkers[i].marker.getLatLng() == point) {
					bi.boundMarkers[i].marker.photoDisplay = true;
					bn(0, i);
					break;
				}
			}
		} else {
			line = mrker.title;
			if (line.length > 1) {
				var ct = line.split("\\");
				var lng = parseFloat(ct[du]);
				var lat = parseFloat(ct[dv]);
				var cu = parseInt(ct[dw], 10);
				if (cu < 10) {
				}

				var pt = new GLatLng(lat,lng);
				
				var cy = ct[ed];
				var s = cy.split(":");
				var cv = parseInt(s[0], 10)*3600 + parseInt(s[1], 10)*60 + parseInt(s[2], 10);
				cv = cv*1000;
				if (cy.indexOf("00:") == 0) {	// 0 hour, don't display it
					cy = cy.substr(3);
				}
				var df = ct[dx];
				var dg = ct[dy];
				var dh = ct[dz];
				var di = ct[eb];
				var dj = ct[ec];
				var cy = ct[ed];
				var s = cy.split(":");
				var cv = parseInt(s[0], 10)*3600 + parseInt(s[1], 10)*60 + parseInt(s[2], 10);
				var dk = ct[ee];
				if (dk != "") {
					dk = "&nbsp;&nbsp;<a target='_blank' href='open_text_guide.php?file=../" + dk + "'>" + "<img src='img/text.jpg' border='0' width='15px' height='15px' title='display, update guide'>" + "<\/a>"
				}
				var by = "By: ";
				
				var player = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="230" height="45" id="uaemonplayer" align="middle"><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="uaemon.swf?mp3=' + di + '&amp;duration=' + cv + '&amp;autostart=1&amp;showtime=1" /><param name="quality" value="high" /><param name="bgcolor" value="FFFFFF" /><embed src="uaemon.swf?mp3=' + di + '&amp;duration=' + cv + '&amp;autostart=1&amp;showtime=1" quality="high" bgcolor="FFFFFF" width="230" height="45" name="uaemonplayer" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
				aj = new GMarker(pt, {icon: aw});
				var h = 45 + 2*15;
				var html = "<div id='infowin_ex' style='height:" + h + "px; width:240px;'>" +
						"<div style='overflow: hidden; width: 240px;'>" +
						"<p><a target='_blank' href='" + di + "'>" + df + "<\/a>&nbsp;&nbsp;" + dk + "<br>" + player + by + dh + "</p><\/div>" + 
						"<\/div><br>";
				var misplaced = "<a href=\"javascript:bp('" +  di + "', '" + dj + "')\">misplaced</a>&nbsp;&#124;&nbsp;";
				var inappropriate = "<a href=\"javascript:bq('" +  di + "', '" + dj + "')\">inappropriate</a>&nbsp;&#124;&nbsp;";
				var comment = "<a href=\"javascript:br('" +  di + "', '" + dj + "')\">comment</a>&nbsp;&#124;&nbsp;";
				var upload_your_guides = "<a href=\"dynUpload.php\" target=\"dyn_frame\">upload your guides</a>";
				html = html + misplaced + inappropriate + comment + upload_your_guides;
				al.addOverlay(aj);
				aj.openInfoWindow(html, {noCloseOnClick: true});
			}
		}
	}
	
	function bp(guide, table) {
		document.getElementById("hide_remark_type").value = "misplaced";
		document.getElementById("hide_remark_content").value = "";
		document.getElementById("hide_remark_guide").value = guide;
		document.getElementById("hide_remark_table").value = table;
		document.form_remarks.submit();
	}
	
	function bq(guide, table) {
		document.getElementById("hide_remark_type").value = "inappropriate";
		document.getElementById("hide_remark_content").value = "";
		document.getElementById("hide_remark_guide").value = guide;
		document.getElementById("hide_remark_table").value = table;
		document.form_remarks.submit();
	}
	
	function br(guide, table) {
		s = prompt("Your comment");
		document.getElementById("hide_remark_type").value = "comment";
		document.getElementById("hide_remark_content").value = s;
		document.getElementById("hide_remark_guide").value = guide;
		document.getElementById("hide_remark_table").value = table;
		document.form_remarks.submit();
	}
	
	// source from: http://econym.org.uk/gmap/example_maptips4.htm
	function showTooltip(marker) {
		tooltip.innerHTML = marker.tooltip;
		var point = al.getCurrentMapType().getProjection().fromLatLngToPixel(al.fromDivPixelToLatLng(new GPoint(0,0), true), al.getZoom());
		var offset = al.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(), al.getZoom());
		var anchor = marker.getIcon().iconAnchor;
		var width = marker.getIcon().iconSize.width;
		var height = tooltip.clientHeight;
		var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x - point.x - anchor.x + width, offset.y - point.y - anchor.y - height)); 
		pos.apply(tooltip);
		tooltip.style.visibility = "visible";
	}
	
	function bs(point) {
		dt = function(cordinates) {
			lines = cordinates.split("\n");
			var pt;
			for (var i = 0; i < (lines.length-1); i++) {
				if (lines[i].length > 1) {
					var ct = lines[i].split("\\");
					var lng = parseFloat(ct[du]);
					var lat = parseFloat(ct[dv]);
					var df = ct[dx];
					pt = new GLatLng(lat,lng);
					var cu = parseInt(ct[dw], 10);
					var html;
					if (cu < 10) {
						continue;	// text guide will be displayed with associated audio if existed
					}
					else {
						html = "";
					}

					var mrker = bi.AddMarker(pt, lines[i]);
					mrker.bindInfoWindowHtml(html);
					marker.photoDisplay = false;
					if (cu >= 10) {
						GEvent.addListener(mrker, "click", function(point) {
							bo(this, point);
						});
						mrker.tooltip = '<div class="tooltip"><nobr>' + df + '<\/nobr><\/div>';
						GEvent.addListener(mrker, "mouseover", function(point) {
							showTooltip(this);
						});
						GEvent.addListener(mrker, "mouseout", function() {
							tooltip.style.visibility = "hidden"
						});        
						if (mrker.mainMarker) {
							GEvent.addListener(mrker.associateList[0], "click", function(point) {
								bo(this, point);
							});
							if (ak) {
								marker.photoDisplay = true;
							}
						}
					}
				}
			}
			ab = false;
			ac = false;
			ai = 0;
			if (ak) {
				bn(0, 0);
			}
		}
		
		gLatLng = point;
		document.getElementById("hide_latbox").value=gLatLng.lat();
		document.getElementById("hide_lonbox").value=gLatLng.lng();
		if (window.frames.dyn_frame.document.getElementById("latbox")) {
			window.frames.dyn_frame.document.getElementById("latbox").value = gLatLng.lat();
			window.frames.dyn_frame.document.getElementById("lonbox").value = gLatLng.lng();
			document.getElementById("hide_lang").value=window.frames.dyn_frame.document.getElementById("language").value;
		} else {
			document.getElementById("map").style.width = ar + "px";
			document.getElementById("dyn_frame").style.width = "0px";
		}
		if (ao) {
			al.setCenter(gLatLng, aq);
		} else {
			al.setCenter(gLatLng, al.getZoom());
		}
		
		var proj = new GMercatorProjection(at);
		dm = proj.fromLatLngToPixel(gLatLng, al.getZoom());	// center point
		dm.x = dm.x - au/2;
		dm.y = dm.y - av/2;	// top left point
		dn = proj.fromPixelToLatLng(dm, al.getZoom());
		dm.x = dm.x + au;
		dm.y = dm.y + av;	// bottom right point
		dp = proj.fromPixelToLatLng(dm, al.getZoom());
		
		lng1 = dn.lng();
		lng2 = dp.lng();
		if (au > proj.getWrapWidth(al.getZoom())) {		// whole map will be loaded
			lng1 = 0;
			lng2 = 180;
		}
		
//		dq = new GLatLng(dp.lat(), dn.lng());
//		dr = parseInt(dq.distanceFrom(dp), 10);
//		ds = parseInt(dq.distanceFrom(dn), 10);
		
		lat_lon = "latitude=" + gLatLng.lat() + "&longitude=" + gLatLng.lng();
		lat_lon = lat_lon + "&top_left_latitude=" + dn.lat() + "&top_left_longitude=" + lng1;
		lat_lon = lat_lon + "&bottom_right_latitude=" + dp.lat() + "&bottom_right_longitude=" + lng2;
//		lat_lon = lat_lon + "&show_map_width=" + dr + "&show_map_height=" + ds;
		lat_lon = lat_lon + "&zoom=" + al.getZoom();
		
		var params = extractUrlParams();
		if (params["proxy"] == "n") {
			GDownloadUrl("navigate.php", dt, lat_lon);
		} else {
			lat_lon = lat_lon + "&path=" + "en/navigate.php";
			GDownloadUrl("proxy.php", dt, lat_lon);
		}
		
		if (bd != null) {
			clearTimeout(bd);
			bd = null;
		}
		if (be != null) {
			clearTimeout(be);
			be = null;
		}
	}
	
	function bt() {
		GEvent.addListener(al, "click", function(overlay, point) {
			if (overlay) {
//				al.removeOverlay(overlay);
				return;
			} else if (point) {
				bi.Clean("zoomend");
				al.clearOverlays();
				am.setLatLng(point);
				al.addOverlay(am);
			}
			bs(point);
		});
		GEvent.addListener(al, "dragend", function() {
			bi.Clean("zoomend");
			point = al.getCenter();
			am.setLatLng(point);
			al.clearOverlays();
			al.addOverlay(am);
			bs(point);
		});
		GEvent.addListener(al, "zoomend", function(oldLevel, newLevel) {
			bi.Clean("zoomend");
			point = al.getCenter();
			am.setLatLng(point);
			al.clearOverlays();
			al.addOverlay(am);
			if (ao) {
				ao = false;
			} else {
				bs(point);
			}
		});
		bc = false;
	}
	
    function load() {
	  var icn = new GIcon();
	  icn.image = "img/audio.png";
	  icn.shadow = "";
	  icn.iconSize = new GSize(32, 32);
	  icn.shadowSize = new GSize(30, 30);
	  icn.iconAnchor = new GPoint(16, 16);
	  icn.infoWindowAnchor = new GPoint(9, 0);
	  aw = new GIcon(icn);
	  ax = new GIcon(icn);
	  icn = new GIcon();
	  icn.image = "img/square.gif";
	  icn.shadow = "";
	  icn.iconSize = new GSize(8, 8);
	  icn.shadowSize = new GSize(6, 6);
	  icn.iconAnchor = new GPoint(4, 4);
	  icn.infoWindowAnchor = new GPoint(4, 0);
	  ay = new GIcon(icn);
	  az = [];
	  
      if (GBrowserIsCompatible()) {		
		var vLatitude, vLongitude, vAltitude;
		vLatitude = geoip_latitude();
		vLongitude = geoip_longitude();
		vAltitude = ap;
        al = new GMap2(document.getElementById("map"), { size: new GSize(ar, as) } );
		bi = new XMarker(al);
		bi.SetIcon(aw);
		bi.SetExtraIcon(ay);
		au = ar;
		av = as;
		var center = new GLatLng(vLatitude, vLongitude);
        al.setCenter(center, vAltitude);
		
		// ====== set up marker mouseover tooltip div ======
		tooltip = document.createElement("div");
		al.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
		tooltip.style.visibility = "hidden";
	  
		// For Linux or Unix: if (navigator.platform.indexOf("X11" ) != -1 || navigator.platform.indexOf("Linux" ) != -1) 
		if ((navigator.platform.indexOf("Win") != -1) || (navigator.platform.indexOf("Mac") != -1)) {
			al.addMapType(G_SATELLITE_3D_MAP);
		}
        al.addControl(new GLargeMapControl());
		al.addControl(new GMapTypeControl());
        // bind a search control to the map, suppress result list
        al.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));
//		al.setMapType(G_SATELLITE_3D_MAP);
		var tripIcon = new GIcon(new GIcon(G_DEFAULT_ICON));
		tripIcon.image = "img/airplane.png";
		markerOptions = { icon: tripIcon, draggable: true };
		am = new GMarker(center, markerOptions);
		
        GEvent.addListener(am, "dragstart", function(pt) {
          al.closeInfoWindow();
        });

        GEvent.addListener(am, "dragend", function(pt) {
			bs(pt);
			al.clearOverlays();
			al.addOverlay(am);
        });

        GEvent.addListener(am, "click", function(pt) {
			pt.localityName = "";
			pt.regionName = "";
			az.push(pt);
			am.openInfoWindowHtml("Destination added");
			bb.getLocations(pt, function(addresses) {
				if (addresses.Status.code != 200) {
//					alert("reverse geocoder failed to find an address for " + (pt.toUrlValue());
//					localityName = "";
				} else {
					placemark = addresses.Placemark[0];
					localityName = placemark.AddressDetails && placemark.AddressDetails.Country && placemark.AddressDetails.Country.AdministrativeArea && placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea && placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality && placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
					regionName = placemark.AddressDetails && placemark.AddressDetails.Country && placemark.AddressDetails.Country.AdministrativeArea && placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea && placemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;
					if (!localityName) {
						localityName = placemark.AddressDetails && placemark.AddressDetails.Country && placemark.AddressDetails.Country.AdministrativeArea && placemark.AddressDetails.Country.AdministrativeArea.Locality && placemark.AddressDetails.Country.AdministrativeArea.Locality.LocalityName;
						regionName = placemark.AddressDetails && placemark.AddressDetails.Country && placemark.AddressDetails.Country.AdministrativeArea && placemark.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
					}
					if (!localityName) {
						localityName = placemark.AddressDetails && placemark.AddressDetails.Country && placemark.AddressDetails.Country.SubAdministrativeArea && placemark.AddressDetails.Country.SubAdministrativeArea.Locality && placemark.AddressDetails.Country.SubAdministrativeArea.Locality.LocalityName;
						regionName = placemark.AddressDetails && placemark.AddressDetails.Country && placemark.AddressDetails.Country.SubAdministrativeArea && placemark.AddressDetails.Country.SubAdministrativeAreaName;
					}
					if (!localityName) {
						localityName = placemark.AddressDetails && placemark.AddressDetails.Country && placemark.AddressDetails.Country.SubAdministrativeArea && placemark.AddressDetails.Country.SubAdministrativeArea.SubAdministrativeAreaName;
						regionName = "";
					}
					if (!localityName) {
						localityName = placemark.AddressDetails && placemark.AddressDetails.Country && placemark.AddressDetails.Country.Locality && placemark.AddressDetails.Country.Locality.LocalityName;
						regionName = "";
					}
					if (!localityName) {
						localityName = placemark.AddressDetails && placemark.AddressDetails.Country && placemark.AddressDetails.Country.AdministrativeArea && placemark.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
						regionName = "";
					}
					if (!localityName) {
						localityName = placemark.AddressDetails && placemark.AddressDetails.Country &&
placemark.AddressDetails.Country.CountryName;
						regionName = "";
					}
					if (!localityName) {
						localityName = "";
					}
					
					if (!regionName) {
						regionName = "";
					}

					pt.localityName = localityName;
					pt.regionName = regionName;
//					alert("Address : " + localityName + " " + regionName);
				}
			});
        });

        al.addOverlay(am);
		
		bt();
		
		var infoStr = "<a target='_blank' href='more.php'><img align='right' border='0' src='img/interrogation.png'></a><br>";
		infoStr += "Click the destination on the map or<br>";
		infoStr += "drag the map to the destination";
		am.openInfoWindowHtml(infoStr);
		
		bb = new GClientGeocoder();
      }
    }
	GSearch.setOnLoadCallback(load);
	
	function bu(idx) {
		az.splice(idx, 1);
		al.removeOverlay(ba[idx]);
		ba.splice(idx, 1);
		elt = window.frames.dyn_frame.document.getElementById("myTripDisplay");
		if (az.length == 0) {
			elt.innerHTML = "No destination selected";
			return;
		}
		s = "";
		del1 = " <a href='javascript:window.parent.bu(";
		del2 = ")'><img border='0' src='img/b_drop.png' title='delete'></a>";
		for (i=0; i<az.length; i++) {
			lng = "" + az[i].lng();
			lat = "" + az[i].lat();
			lng = lng.substr(0, lng.indexOf(".", 0)+6);
			lat = lat.substr(0, lat.indexOf(".", 0)+6);
			if ((az[i].localityName != "") || (az[i].regionName != "")) {
				if ((az[i].localityName == "") || (az[i].regionName == "")) {
					s1 = az[i].localityName + az[i].regionName;
				} else {
					s1 = az[i].localityName + ", " + az[i].regionName;
				}
			} else {
				s1 = lng + ", " + lat;
			}
			
			s = s + (i+1) + ": " + s1 + del1 + i + del2 + "<br>";
		}
		elt.innerHTML = s;
	}
	
	function bv() {
		elt = window.frames.dyn_frame.document.getElementById("myTripDisplay");
		if (az.length == 0) {
			elt.innerHTML = "No destination selected";
			return;
		}
		GEvent.clearListeners(al, 'click');
		GEvent.clearListeners(al, 'dragend');
		GEvent.clearListeners(al, 'zoomend');
		bc = true;
		s = "";
		var mk;
		al.clearOverlays();
		var destinationIcon = new GIcon(new GIcon(G_DEFAULT_ICON));
		destinationIcon.image = "img/flag.png";
		markerOptions = { icon: destinationIcon };
		del1 = " <a href='javascript:window.parent.bu(";
		del2 = ")'><img border='0' src='img/b_drop.png' title='delete'></a>";
		ba = [];
		for (i=0; i<az.length; i++) {
			mk = new GMarker(az[i], markerOptions);
			al.addOverlay(mk);
			ba.push(mk);
			lng = "" + az[i].lng();
			lat = "" + az[i].lat();
			lng = lng.substr(0, lng.indexOf(".", 0)+6);
			lat = lat.substr(0, lat.indexOf(".", 0)+6);
			if ((az[i].localityName != "") || (az[i].regionName != "")) {
				if ((az[i].localityName == "") || (az[i].regionName == "")) {
					s1 = az[i].localityName + az[i].regionName;
				} else {
					s1 = az[i].localityName + ", " + az[i].regionName;
				}
			} else {
				s1 = lng + ", " + lat;
			}
			
			s = s + (i+1) + ": " + s1 + del1 + i + del2 + "<br>";
		}
		elt.innerHTML = s;
	}
	
	function bw() {
		if (bc) {
			bt();
		}
		if (az.length == 0) {
			return false;
		}

		for (i=0; i<(az.length-1); i++) {
			window.frames.dyn_frame.document.form_receive_file.lng.value += az[i].lng() + ' ';
			window.frames.dyn_frame.document.form_receive_file.lat.value += az[i].lat() + ' ';
		}
		window.frames.dyn_frame.document.form_receive_file.lng.value += az[i].lng();
		window.frames.dyn_frame.document.form_receive_file.lat.value += az[i].lat();
		window.frames.dyn_frame.document.form_receive_file.zoom.value = al.getZoom();
//		window.frames.dyn_frame.document.form_receive_file.target = 'uploadFrame';
		window.frames.dyn_frame.document.form_receive_file.submit();
		elt = window.frames.dyn_frame.document.getElementById("your_trip");
		elt.innerHTML = "";
		elt = window.frames.dyn_frame.document.getElementById("myTripDisplay");
		elt.innerHTML = "<center><blink>Preparing Guides</blink></center><br>";
		return true;
	}

	function bx() {
		if (bc) {
			bt();
		}
		document.getElementById("map").style.width = screen.width - 20 - 32 + "px";
		document.getElementById("dyn_frame").style.width = "0px";
		document.getElementById("ctrl_frame").style.width = "32px";
		w_map = screen.width - 20 -250 + "px";
		w = "300px";
		document.getElementById("ctrl_frame").src = "show_hidden.php" + "?w_map=" + w_map + "&w=" + w;
	}
	
	function by(url) {
		var e = document.getElementById("cross_domain_download");
		if (e != null) {
			document.body.removeChild(e);
		}
		var s = document.createElement("script");
		s.type = "text/javascript";
		s.src = url;
		s.id = 'cross_domain_download';
		document.body.appendChild(s);
	}
	
	function bz(url, indic, timeoutPeriod) {
		if (timeoutPeriod == -1) {
			var e = window.frames.dyn_frame.document.getElementById("cross_domain_download");
			if (e) {
				window.frames.dyn_frame.document.body.removeChild(e);
			}
			var s = window.frames.dyn_frame.document.createElement("script");
			s.type = "text/javascript";
			s.src = url;
			s.id = 'cross_domain_download';
			window.frames.dyn_frame.document.body.appendChild(s);
			timeoutDownload = setTimeout("by('" + indic + "')", timeoutPeriod);
		} else if (timeoutPeriod != 0) {
			timeoutDownload = setTimeout("by('" + indic + "')", timeoutPeriod);
		} else {
			document.getElementById("map").style.width = screen.width - 20 - 250 + "px";
			document.getElementById("dyn_frame").style.width = "250px";
			document.getElementById("ctrl_frame").style.width = "32px";
			w_map = screen.width - 20 -250 + "px";
			w = "300px";
			document.getElementById("ctrl_frame").src = "show_hidden.php" + "?w_map=" + w_map + "&w=" + w;
			window.frames.dyn_frame.document.location.href = url;
			if (be != null) {
				clearTimeout(be);
				be = null;
			}
		}
		if (bc) {
			bt();
		}
	}
	
	function ca(message) {
		window.frames.dyn_frame.document.getElementById("latbox").value = "";
		window.frames.dyn_frame.document.getElementById("lonbox").value = "";
		window.frames.dyn_frame.document.getElementById("selected_file_id").value = "";
		window.frames.dyn_frame.document.getElementById("text_file_id").value = "";
		an.bindInfoWindowHtml(null);
		an.openInfoWindowHtml(message);
		if (bc) {
			bt();
		}
		if (bd != null) {
			clearTimeout(bd);
			bd = null;
		}
	}
	
	function cb(url) {
		var e = document.getElementById("cross_domain_upload");
		document.body.removeChild(e);
		var s = document.createElement("script");
		s.type = "text/javascript";
		s.src = 'http://www.uaemon.com/' + url;
		s.id = 'cross_domain_upload';
		document.body.appendChild(s);
	}
	
	function cc(url, message, timeoutPeriod) {
		if (timeoutPeriod == 0) {
			if (bd != null) {
				clearTimeout(bd);
			}
			bd = null;
			ca(message);
		} else {
			bd = setTimeout("cb('" + url + "')", timeoutPeriod);
		}
	}
	
	function cd() {
		if (window.frames.dyn_frame.document.form_send_file.latitude.value == "") {
			alert("latitude unknown");
			return false;
		}
		if (window.frames.dyn_frame.document.form_send_file.longitude.value == "") {
			alert("longitude unknown");
			return false;
		}
		if ((window.frames.dyn_frame.document.form_send_file.selected_file.value == "") && (window.frames.dyn_frame.document.form_send_file.text_file.value == "") && (window.frames.dyn_frame.document.form_send_file.source.value == "http://")) {
			alert("no guide selected");
			return false;
		}

		window.frames.dyn_frame.document.form_send_file.current_url.value = window.location.host;
		var lat = window.frames.dyn_frame.document.getElementById("latbox").value;
		var lng = window.frames.dyn_frame.document.getElementById("lonbox").value;
		uploadIcon = new GIcon(new GIcon(G_DEFAULT_ICON));
		uploadIcon.image = "img/a380-5.jpg";
		an = new GMarker(new GLatLng(lat,lng), { icon: uploadIcon });
		al.addOverlay(an);
		s = "<center><blink>Uploading ...</blink></center>";
		an.openInfoWindowHtml(s);
		
		if (window.location.host != "www.uaemon.com") {
			var id = window.parent.document.getElementById("hide_identifier").value;
			var email = window.parent.document.getElementById("hide_email").value;
			var passwd = window.parent.document.getElementById("hide_password").value;
			var s = document.createElement("script");
			s.type = "text/javascript";
			s.src = 'http://www.uaemon.com/' + 'en' + '/login_cross_domain.php?identifier=' + id + '&email=' + email + '&password=' + passwd + '&lat=' + lat + '&lng=' + lng;
			s.id = 'cross_domain_upload';
			document.body.appendChild(s);
			
			window.frames.dyn_frame.document.form_send_file.target = 'crossDomainUploadFrame';
			window.frames.dyn_frame.document.form_send_file.submit();	
		} else {
			window.frames.dyn_frame.document.form_send_file.target = 'uploadFrame';
			window.frames.dyn_frame.document.form_send_file.submit();
		}
		return true;
	}

	function ce(message) {
		container = window.frames.dyn_frame.document.getElementById("modify_guide_status_display");
		container.innerHTML = message;
		bt();
	}
	
	function cf() {
		bt();
		document.getElementById("map").style.width = screen.width - 20 - 32 + "px";
		document.getElementById("dyn_frame").style.width = "0px";
		document.getElementById("ctrl_frame").style.width = "32px";
		w_map = screen.width - 20 -300 + "px";
		w = "300px";
		document.getElementById("ctrl_frame").src = "show_hidden.php" + "?w_map=" + w_map + "&w=" + w;
	}
	
	function cg(tbl_name, href_title, title, dg, longitude, latitude, cu, lang) {
		var pt = new GLatLng(latitude, longitude);
		if (cu < 10) {
			ax.image = "img/text.jpg";
			player = "";
		}
		else {
			ax.image = "img/audio.jpg";
			player = "";
		}
		
		mrker = new GMarker(pt, { icon: ax, draggable: true });
		if (cu == 0) {
			s = "<a target='_blank' href='open_text_guide.php?file=../" + href_title + "'>" + title + "</a><br>" + player;
		} else {
			s = "<a target=\"_blank\"href=\"../" + href_title + "\">" + title + "</a><br>" + player;
		}
		al.clearOverlays();
		al.setCenter(pt, al.getZoom());
		al.addOverlay(mrker);
		mrker.openInfoWindowHtml(s);
		
        GEvent.addListener(mrker, "dragstart", function(pt) {
          al.closeInfoWindow();
        });

        GEvent.addListener(mrker, "dragend", function(pt) {
			document.getElementById("hide_latbox").value=pt.lat();
			document.getElementById("hide_lonbox").value=pt.lng();
			if (window.frames.dyn_frame.document.getElementById("latbox")) {
				window.frames.dyn_frame.document.getElementById("latbox").value = pt.lat();
				window.frames.dyn_frame.document.getElementById("lonbox").value = pt.lng();
				document.getElementById("hide_lang").value=window.frames.dyn_frame.document.getElementById("language").value;
			}
			al.clearOverlays();
			al.addOverlay(mrker);
		
        });
		document.getElementById("hide_latbox").value=pt.lat();
		document.getElementById("hide_lonbox").value=pt.lng();
		if (window.frames.dyn_frame.document.getElementById("latbox")) {
			window.frames.dyn_frame.document.getElementById("latbox").value = pt.lat();
			window.frames.dyn_frame.document.getElementById("lonbox").value = pt.lng();
			document.getElementById("hide_lang").value=window.frames.dyn_frame.document.getElementById("language").value;
//			window.frames.dyn_frame.document.getElementById("selected_file_id").value = title;
//			window.frames.dyn_frame.document.getElementById("source").value = dg;
		}
//		GEvent.clearInstanceListeners(al);
		GEvent.clearListeners(al, 'click');
		GEvent.clearListeners(al, 'dragend');
		GEvent.clearListeners(al, 'zoomend');
		bc = true;
		if (ao) {
			al.setCenter(pt, aq);
			ao = false;
		} else {
			al.setCenter(pt, al.getZoom());
		}
		window.frames.dyn_frame.document.getElementById("language").value = lang;
		window.frames.dyn_frame.document.getElementById("href_origine").value = href_title;
		window.frames.dyn_frame.document.getElementById("tbl_name").value = tbl_name;
	}

	function ch(tbl_name, href_title, title, longitude, latitude, cu) {
		var pt = new GLatLng(latitude, longitude);
		if (cu < 10) {
			ax.image = "img/text.jpg";
			var player = "<iframe src=\"" + href_title + "\" name=\"text\"></iframe><br>";
		}
		else {
			ax.image = "img/audio.jpg";
			var cx = "0";	// not used (?)
			var player = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="230" height="45" id="uaemonplayer" align="middle"><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="uaemon.swf?mp3=' + href_title + '&amp;duration=' + cx + '&amp;autostart=1&amp;showtime=1" /><param name="quality" value="high" /><param name="bgcolor" value="FFFFFF" /><embed src="uaemon.swf?mp3=' + href_title + '&amp;duration=' + cv + '&amp;autostart=1&amp;showtime=1" quality="high" bgcolor="FFFFFF" width="230" height="45" name="uaemonplayer" wmode="transparent" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
		}
		
		mrker = new GMarker(pt, { icon: ax, draggable: true });
		s = "<a href=\"" + href_title + "\">" + title + "</a><br>" + player;
		al.clearOverlays();
		al.setCenter(pt, al.getZoom());
		al.addOverlay(mrker);
		mrker.openInfoWindowHtml(s);
		
		document.getElementById("hide_latbox").value=pt.lat();
		document.getElementById("hide_lonbox").value=pt.lng();
		if (window.frames.dyn_frame.document.getElementById("latbox")) {
			window.frames.dyn_frame.document.getElementById("latbox").value = pt.lat();
			window.frames.dyn_frame.document.getElementById("lonbox").value = pt.lng();
			document.getElementById("hide_lang").value=window.frames.dyn_frame.document.getElementById("language").value;
		}
		GEvent.clearInstanceListeners(al);
		if (ao) {
			al.setCenter(pt, aq);
			ao = false;
		} else {
			al.setCenter(pt, al.getZoom());
		}
		window.frames.dyn_frame.document.getElementById("href_origine").value = href_title;
		window.frames.dyn_frame.document.getElementById("tbl_name").value = tbl_name;
		window.frames.dyn_frame.document.delete_guide.submit();
	}
	
	function ci(list) {
		container = window.frames.dyn_frame.document.getElementById("user_guides_list");
		container.innerHTML = "<u>Your uploaded guide list:</u>" + list;
		document.getElementById("hide_guide_list").value = container.innerHTML;
	}

	function cj(message) {
		container = window.frames.dyn_frame.document.getElementById("login_status_display");
		container.innerHTML = message;
	}

	function ck(message) {
		container = document.getElementById("login_account");
		container.innerHTML = message;
		
		lnk = document.getElementById("login_logout_ref");
		lnk.setAttribute("id", "login_logout_ref");
		lnk.setAttribute("href", "javascript:window.parent.cl()");
		lnk.setAttribute("title", "login_logout");
		lnk.setAttribute("target", "dyn_frame");
		lnk.innerHTML = "Log out";
	}

	function cl() {
		container = document.getElementById("login_account");
		container.innerHTML = "";
		
		lnk = document.getElementById("login_logout_ref");
		lnk.setAttribute("id", "login_logout_ref");
		lnk.setAttribute("href", "myAccount.php");
		lnk.setAttribute("title", "login_logout");
		lnk.setAttribute("target", "dyn_frame");
		lnk.innerHTML = "Log in";
		
		document.form_disconnect.target='uploadFrame';	// no importance
		document.form_disconnect.submit();
		
		document.getElementById("hide_identifier").value = "";
		document.getElementById("hide_email").value = "";
		document.getElementById("hide_password").value = "";
		document.getElementById("hide_guide_list").value = "";
	}

	function getCookieVal(offset) {
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1) endstr = document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
	}
	
	function readCookie(name) {
		var arg = name + "=";
		var alen = arg.length;
		var clen = document.cookie.length;
		var i = 0;
		while (i < clen) {
			var j = i + alen;
			if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
			i = document.cookie.indexOf(" ",i) + 1;
			if (i == 0) break;
		}
		return null;
	}
	
	function writeCookie(name, val) {
		var argv = writeCookie.arguments;
		var argc = writeCookie.arguments.length;
		var expires = (argc > 2) ? argv[2] : null;
		var path = (argc > 3) ? argv[3] : null;
		var domain = (argc > 4) ? argv[4] : null;
		var secure = (argc > 5) ? argv[5] : false;
		document.cookie=name + "=" + escape(val) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
	}

