﻿
//<![CDATA[
var map;
var geocoder;

function showAddress(address) 
    {
    geocoder.getLatLng(address,
        function(point) 
            {
            if (!point) 
                {
                // alert(address + " not found");
                } 
            else 
                {
                var arrHTML = address.split(",")
                
                // map.setCenter(point, 11);
                
                // alert(point);
                
                var html = "<font face=verdana size=2><b>" + arrHTML[0] + "<br />";
                html += "" + arrHTML[1] + "<br />";
                html += "" + arrHTML[2] + "</b></font>";

                map.addOverlay(createMarker(point, html));
                }
            }
         );
     }
     
     
function showAddressExtra(address, extra, nummer) 
    {
    geocoder.getLatLng(address,
        function(point) 
            {
            if (!point) 
                {
                // alert(address + " not found");
                } 
            else 
                {
                var arrHTML = address.split(",")
                
                // map.setCenter(point, 11);
                
                // alert(point);
                
                var html = "<font face=verdana size=2><b>" + extra + "<br />" + arrHTML[0] + "<br />";
                html += "" + arrHTML[1] + "<br />";
                html += "" + arrHTML[2] + "</b></font>";

                map.addOverlay(createMarker(point, html, nummer));
                }
            }
         );
     }
          
     
function showAddressZoom(address) 
    {
    geocoder.getLatLng(address,
        function(point) 
            {
            if (!point) 
                {
                // alert(address + " not found");
                } 
            else 
                {
                var myIcon = new GIcon(G_DEFAULT_ICON); 
                myIcon.image = "http://www.happybirthday.nl/images/happybirthdaypinthin.png"; 
                myIcon.iconSize = new GSize(21, 32);
                
	            var marker = new GMarker(point, {icon:myIcon});
                // map.addOverlay(marker);    
                map.setCenter(point, 13);
                }
            }
         );
     }
     
     
function centreGoogleMapOnHappyBirthdayUserPostcode(address, markermaken) 
    {
    geocoder.getLatLng(address,
        function(point) 
            {
            if (!point) 
                {
                // Adres niet gevonden dus standaard centreren!
                map.setCenter(new GLatLng(52.373812, 5.122748), 6);
                } 
            else 
                {
                // var marker = new GMarker(point);

                var myIcon = new GIcon(G_DEFAULT_ICON); 
                myIcon.image = "http://www.happybirthday.nl/images/happybirthdaypinthin.png"; 
                myIcon.iconSize = new GSize(21, 32);
                
	            var marker = new GMarker(point, {icon:myIcon});                
                if (markermaken)
                    {
                    map.addOverlay(marker);                
                    }
                map.setCenter(point, 13);
                }
            }
         );
     }
     
function centreGoogleMapOnAddress(address) 
    {
    geocoder.getLatLng(address,
        function(point) 
            {
            if (!point) 
                {
                // Adres niet gevonden dus standaard centreren!
                map.setCenter(new GLatLng(52.373812, 5.122748), 6);
                } 
            else 
                {
                map.setCenter(point, 13);
                }
            }
         );
     }     
		

function addUserMarker(address) 
    {
    geocoder.getLatLng(address,
        function(point) 
            {
            if (!point) 
                {
                // Adres niet gevonden!
                } 
            else 
                {
                var myIcon = new GIcon(G_DEFAULT_ICON); 
                myIcon.image = "http://www.happybirthday.nl/images/happybirthdaypinthin.png"; 
                myIcon.iconSize = new GSize(21, 32);
                
	            var marker = new GMarker(point, {icon:myIcon});                
                map.addOverlay(marker);      
                // Hoeft niet te centreren enkel de marker neer te zetten          
                // map.setCenter(point, 13); 
                }
            }
         );
     }		
		
function createMarker(point, html, nummer) 
    {
    var myIcon = new GIcon(G_DEFAULT_ICON); 
    myIcon.iconSize = new GSize(32, 32);
    //myIcon.iconAnchor = new GPoint(0, 35);

	if(!nummer) { //If the optional argument is not there, create a new variable with that name.
        myIcon.image = "http://www.happybirthday.nl/images/markers/marker_orange.png"; 
	    }
	else {
        myIcon.image = "http://www.happybirthday.nl/images/markers/marker_orange_" + nummer + ".png"; 
	    }
    
    myIcon.shadow = "http://www.happybirthday.nl/images/markers/marker_shadow.png"; 
    
	var marker = new GMarker(point, {icon:myIcon});
	GEvent.addListener(marker, "click", 
	    function() 
	        {
		    marker.openInfoWindowHtml(html);
		    }
		);
	 return marker;
	 }	

//]]>

