jQuery(document).ready(function(){
     //jQuery('.aside').stickyScroll({ container: '#main' });
     //jQuery('#primary').stickyScroll({ container: '#wrapper' });
     //jQuery('#primary').stickyfloat({duration: 400});
     
     jQuery('.submenu-widget ul li a ').last().addClass('last-menu-item');
     jQuery('.fl_food_menu_sub li a ').last().addClass('last-menu-item');
     
     //jQuery('.fl_food_menu_item_price').append(',-');
     
     //initiate_geolocation();  
     
});

function initiate_geolocation() {
	//navigator.geolocation.getCurrentPosition(handle_geolocation_query);  
}  

function handle_errors(error)  
        {  
            switch(error.code)  
            {  
                case error.PERMISSION_DENIED: alert("user did not share geolocation data");  
                break;  
  
                case error.POSITION_UNAVAILABLE: alert("could not detect current position");  
                break;  
  
                case error.TIMEOUT: alert("retrieving position timed out");  
                break;  
  
                default: alert("unknown error");  
                break;  
            }  
        } 
			  
function handle_geolocation_query(position)
{
    var image_url = "http://maps.google.com/maps/api/staticmap?sensor=false&center=" + position.coords.latitude + "," +
                    position.coords.longitude + "&zoom=14&size=300x400&markers=color:blue|label:S|" +
                    position.coords.latitude + ',' + position.coords.longitude;

    jQuery("#map").remove();
    jQuery(document.body).append(
        jQuery(document.createElement("img")).attr("src", image_url).attr('id','map')
    );
}

jQuery(document).bind('em_maps_location_hook', function( infowindow, map, marker ){
	
	var myLatlng = new google.maps.LatLng(55.6827,12.603356);
	
	var image = new google.maps.MarkerImage('http://kontikibar.dk/wordpress/wp-content/themes/kontiki/images/beachflag.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(20, 32),
      // The origin for this image is 0,0.
      new google.maps.Point(0,0),
      // The anchor for this image is the base of the flagpole at 0,32.
      new google.maps.Point(0, 32));
  var shadow = new google.maps.MarkerImage('http://kontikibar.dk/wordpress/wp-content/themes/kontiki/images/beachflag_shadow.png',
      // The shadow image is larger in the horizontal dimension
      // while the position and offset are the same as for the main image.
      new google.maps.Size(37, 32),
      new google.maps.Point(0,0),
      new google.maps.Point(0, 32));
      // Shapes define the clickable region of the icon.
      // The type defines an HTML <area> element 'poly' which
      // traces out a polygon as a series of X,Y points. The final
      // coordinate closes the poly by connecting to the first
      // coordinate.
  var shape = {
      coord: [1, 1, 1, 20, 18, 20, 18 , 1],
      type: 'poly'
  };
    
    var shape = {
      coord: [1, 1, 1, 20, 18, 20, 18 , 1],
      type: 'poly'
  };
    
 	var secondmarker = new google.maps.Marker({
    	position: myLatlng,
    	shadow: shadow,
        icon: image,
        shape: shape,
    	title:"Hello World!"
    });
    
    secondmarker.setZIndex(100);
  	
	// To add the marker to the map, call setMap();
	secondmarker.setMap(map);
	
	map.setZoom(15);
	
	
});
