<?xml version="1.0" encoding="UTF-8"?>
  <Module>
    <ModulePrefs 
      title="locr - locate your photos"
	title_url="http://www.locr.com"
      description="This Mapplet shows public locr photos on your google map."
      author="locr GmbH"
      author_email="support@locr.com"
      author_affiliation="locr GmbH"
      author_location="38106 Braunschweig, Germany"
      screenshot="http://www.locr.com/gfx/png/mapplet/mapplet_screenshot.png"
      thumbnail="http://www.locr.com/gfx/png/mapplet/mapplet_thumbnail.png"
      height="1600">
    <Require feature="sharedmap"/>
    </ModulePrefs>
  <Content type="html">
    <![CDATA[

<div style="background-color: #FFFFFF;"><center><a href="http://www.locr.com" target="_blank"><img style="border: 0px;" src="http://www.locr.com/gfx/jpg/google_earth_banner.jpg" /></a>
<br /><a id="Last" href="javascript:getLastPhotos()">&lt;&lt;</a>&nbsp;Photos:&nbsp;<span id="ShownPhotos"></span>&nbsp;<a id="Next" href="javascript:getNextPhotos()">&gt;&gt;</a></center>
</center>
<div style="font-family: 'Trebuchet MS', Verdana,Arial, Sans-serif; font-size:12px;" id="Info"></div>
<!--
	<div style="left: 0px; top: 0px; width: 300px; height: 1600px; position: relative;" id="frame">
	<div style="left: 0px; top: 0px; width: 300px; height: 1600px; position: absolute;" id="photos"></div>
	</div>
-->
</div>
<script>
		
 var StartIndex = 0;
 var DisplayCount = 20;
 var CountPhotos;	

  function CreateWorldMarker(Position,Photo, PhotoLink, Location, Caption, UserName, UserId, TempIcon,WikiInfo) 
  {	
	var Marker = new GMarker(Position, {icon:TempIcon});
      GEvent.addListener(Marker, "click", function() {
    			Marker.openInfoWindowHtml("<div style='font-size:12px;'>"+Location+"</br><a href='"+PhotoLink.href+"' target='"+PhotoLink.target+"' title='"+PhotoLink.title+"'><img src='"+Photo.src+"' alt='test' /></a></br>"+Caption+"</br>by <a href='http://www.locr.com/tools/mapplet/mapplet_photo_user.php?id="+UserId+"' target='_blank'>"+UserName+"</a></div>" , {disableGoogleLinks:true});
		      document.getElementById("Info").innerHTML = "";
			document.getElementById("Info").innerHTML = WikiInfo;
		});
	GEvent.addListener(Marker, 'infowindowclose',function(){
			document.getElementById("Info").innerHTML = "";

		});
     	return Marker;
  }

  function PhotoWorldProcessData(XmlData) 
  {
    var PhotoXmlDataList;
    CountXmlDataList = XmlData.getElementsByTagName("count");
    
    CountPhotos = CountXmlDataList[0].firstChild.data;
    checkShownPhotos();
	
    //alert(CountPhotos);
    if(XmlData.getElementsByTagName("photo"))
    {
    PhotoXmlDataList = XmlData.getElementsByTagName("photo");
        
    NumberOfMarkers = MapMarkerArray.length;
   
    for(Index = 0; Index < NumberOfMarkers; Index++)
      Map.removeOverlay(MapMarkerArray[Index]);    
      
	for(Index = 0; Index < PhotoXmlDataList.length; Index++)
    	{
		var TempIcon = new GIcon();
		var TempFocusIcon = new GIcon();

		Id = PhotoXmlDataList[Index].childNodes[0].firstChild.data;
		FileName_A = PhotoXmlDataList[Index].childNodes[1].firstChild.data;
		FileName_B = PhotoXmlDataList[Index].childNodes[2].firstChild.data;
		Latitude = PhotoXmlDataList[Index].childNodes[3].firstChild.data;
		Longitude = PhotoXmlDataList[Index].childNodes[4].firstChild.data;
		UserName = PhotoXmlDataList[Index].childNodes[5].firstChild.data;
		Created = PhotoXmlDataList[Index].childNodes[6].firstChild.data;
		Submitted = PhotoXmlDataList[Index].childNodes[7].firstChild.data;
		UserId = PhotoXmlDataList[Index].childNodes[8].firstChild.data;
		Caption = PhotoXmlDataList[Index].childNodes[9].firstChild.data;
		Location = PhotoXmlDataList[Index].childNodes[10].firstChild.data;
	    	WikiInfo = PhotoXmlDataList[Index].childNodes[11].firstChild.data;	 	
					
		TempIcon.image  = "http://www.locr.com/" + FileName_A;
		TempIcon.iconSize = new GSize(40, 40);
      	//TempIcon.shadow = "http://www.locr.com/gfx/png/mapplet/mapplet_shadow.png";
		//TempIcon.shadowSize = new GSize(42, 42);
		TempIcon.iconAnchor = new GPoint(20, 20);
		TempIcon.infoWindowAnchor = new GPoint(20, 20);
			
		TempFocusIcon = TempIcon;	
    
		
	    ParentWidth = FrameWidth;
      	
	    Test = document.getElementById("square_frame");

	    var PhotoImage = document.createElement("img");
	    PhotoImage.myIndex = Index;
	    PhotoImage.setAttribute("id", "photo_" + Index);
	    PhotoImage.setAttribute("src", "http://www.locr.com/" + FileName_B);
	      		
	    var PhotoLink = document.createElement("a");
	    PhotoLink.setAttribute("href", "http://www.locr.com/tools/mapplet/mapplet_photo_detail.php?id=" + Id);
	    PhotoLink.setAttribute("target", "_blank");
	    PhotoLink.setAttribute("title", "Submitted by " + UserName);
	    PhotoLink.appendChild(PhotoImage);
	    
	    MapFocusMarkerArray[Index] = new GMarker(new GLatLng(Latitude, Longitude), TempFocusIcon);
	    MapMarkerArray[Index] = CreateWorldMarker(new GLatLng(Latitude, Longitude),PhotoImage, PhotoLink, Location, Caption, UserName, UserId, TempIcon, WikiInfo);
	    MapMarkerArray[Index].myIndex = Index;
	    //MapMarkerArray[Index].myLink = "photo_detail.php?id=" + Id;
	    Map.addOverlay(MapMarkerArray[Index]);
    	    
}}}

  function PhotoWorldBounds(Bounds)
  {
    
	  SouthWestLocation = Bounds.getSouthWest(); 
	  NorthEastLocation = Bounds.getNorthEast(); 
    	
	//checkShownPhotos();
	
	 PhotoRequestUrl = 
      "http://www.locr.com/photo/photo_mapplet.php?latitudemin=" + 
      SouthWestLocation.lat() + 
      "&longitudemin=" + SouthWestLocation.lng() + 
      "&latitudemax=" + NorthEastLocation.lat() + 
      "&longitudemax=" + NorthEastLocation.lng() + 
      "&start=" + StartIndex + 
      "&count=" + DisplayCount;
                  
     
      
    _IG_FetchXmlContent(PhotoRequestUrl, PhotoWorldProcessData)
  }
  
  function checkShownPhotos()
  {	
	var start = StartIndex;
      var count = DisplayCount;     
	
	if((StartIndex + DisplayCount) > CountPhotos)
	{
		count = (CountPhotos - StartIndex);
		document.getElementById("Next").style.visibility = 'hidden';
	}else{
		document.getElementById("Next").style.visibility = 'visible';
	}
	
	if(StartIndex <= 0 )
	{
		document.getElementById("Last").style.visibility = 'hidden';

	}else{
		document.getElementById("Last").style.visibility = 'visible';
	}

	if(CountPhotos == 0)
	{
		
		document.getElementById("Last").style.visibility = 'hidden';
		document.getElementById("Next").style.visibility = 'hidden';
		
		document.getElementById("ShownPhotos").innerHTML = " 0 ";

		
	}else{
      document.getElementById("ShownPhotos").innerHTML = (start+1) + " - " + (start+count);
	}
  }
  
  function getNextPhotos()
  {
	StartIndex = StartIndex + DisplayCount;
	Bounds = Map.getBoundsAsync(PhotoWorldBounds);
  }  

	function getLastPhotos()
   {
		StartIndex = StartIndex - DisplayCount;
  		if(StartIndex <= 0 )
		{
			StartIndex = 0;
		}
	    Bounds = Map.getBoundsAsync(PhotoWorldBounds);
   }


  function PhotoWorldMapViewChanged()
  {
  	StartIndex = 0;
	document.getElementById("ShownPhotos").innerHTML = "";
	document.getElementById("Next").style.visibility = 'hidden';
	document.getElementById("Last").style.visibility = 'hidden';	

    Bounds = Map.getBoundsAsync(PhotoWorldBounds);
  }

  var MapMarkerArray = new Array();
  var MapFocusMarkerArray = new Array();

  var Map = new GMap2();
  
	if(self.innerHeight)
	{
		FrameWidth = self.innerWidth;
		FrameHeight = self.innerHeight - 20;
	}
	else if(document.documentElement && document.documentElement.clientHeight)
	{
		FrameWidth = document.documentElement.clientWidth;
		FrameHeight = document.documentElement.clientHeight;
	}
	else if(document.body)
	{
		FrameWidth = document.body.clientWidth;
		FrameHeight = document.body.clientHeight - 40;
	}

  Bounds = Map.getBoundsAsync(PhotoWorldBounds);
	GEvent.addListener(Map, "moveend", PhotoWorldMapViewChanged);
  
</script>

]]>
  </Content>
</Module>