var map = null;
var geocoder = null
var prevHL = null;
var smallIcon;
var popuphtml;
var _pictureDiv ;
function HighLightCatch(id)
{
       
      var  obj = document.getElementById(id);
      
      if((_pictureDiv.scrollTop >obj.offsetTop) || ((_pictureDiv.scrollTop + 400) < obj.offsetTop ))
       _pictureDiv.scrollTop =  obj.offsetTop;
      if(prevHL!=null)
      {
        prevHL.className ="catchDiv";
      }
      obj.className ="catchDivOn";
      prevHL = obj;          
}        

function GetSmallIcon()
{
    var icon = new GIcon();
    icon.image = "images/mm_20_red.png";
    icon.shadow = "images/mm_20_shadow.png";
    icon.iconSize = new GSize(12, 20);
    icon.shadowSize = new GSize(22, 20);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);        
    return icon;
}   

function CreateMarker(p,id,ficture,fish,name,date,country)
{
     var marker =new GMarker(p);// new GMarker(p,smallIcon);
     GEvent.addListener(marker, "click", function() {   
     var html = "<a href='http://www.roven.nl/Vangst.aspx?ID={5}' target=_blank><img url style=\"float: left; margin-right: 5px\" border=0></a>";

   //  alert(popuphtml);
     html = html.replace("url","src='"+ficture+"'");
    // html = html.replace("{0}",fish);         
    // html = html.replace("{2}",name);
    // html = html.replace("{3}",date);
    // html = html.replace("{4}",country);     
     html = html.replace("{5}",id);     
    // alert(html);
     HighLightCatch("D"+id);         
     marker.openInfoWindowHtml(html);
     });
     return marker;
}        

function GotoPoint(x,y)
{
 try
 {
  var pointTarget = new GLatLng(y,x);            
  map.setCenter(pointTarget,13); 
 }
 catch(err){}
}
  

function InitVars()
{
_pictureDiv =  document.getElementById("PictureDiv");
smallIcon = GetSmallIcon();
}


function load()
 {   
    var compat = false;
    try
    {
        compat = GBrowserIsCompatible();
    }
    catch(err)
    {
        alert("The map is not available at the moment, come back soon or hit 'refresh' to retry!");
    }
    if (compat) 
    {
        InitVars();
        map =  new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(30.4419, 3), 1);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());  
        //map.setMapType(map.getMapTypes()[2]);
        //map.setMapType(G_HYBRID_TYPE); 
        map.enableDoubleClickZoom();     
        map.enableContinuousZoom(); 
        LoadFishes();
     }
}  


function OpenPic(id) 
{		
	var name = "PIC";
	var features = "width=550,height=600,top=200,left=250,scrollbars=1";
	window.open("http://www.roven.nl/Vangst.aspx?ID="+id,name,features);
}