var map;
var icon;
var markers = Array();
var i = 1;

var info_opts = {
	paddingX: 70,
	paddingY: 0,
	beakOffset: -3
};

$( function() {

	$('#content ul.writers li a').click( function() {

		show_writer($(this).attr('rel'));

	});

});


function loadMap() {
	map = new GMap2(document.getElementById("map"));
	
	//map.addControl(new GSmallMapControl());

	//map.enableScrollWheelZoom();
	//map.enableContinuousZoom();

	center = new GLatLng(52.633063,-1.129532);

	map.setCenter(center, 11, G_NORMAL_MAP);

	icon = new GIcon();
	icon.image = "images/marker.png";
	icon.shadow = "images/marker_shadow.png";
	icon.iconSize = new GSize(13, 23);
	icon.iconAnchor = new GPoint(7, 23);
	icon.infoWindowAnchor = new GPoint(13, 0);

	var marker = new GMarker(center, icon);
	
	G_PHYSICAL_MAP.getMinimumResolution = function () { return 8 };
    G_NORMAL_MAP.getMinimumResolution = function () { return 8 };
    G_SATELLITE_MAP.getMinimumResolution = function () { return 8 };
    G_HYBRID_MAP.getMinimumResolution = function () { return 8 };

    G_PHYSICAL_MAP.getMaximumResolution = function () { return 12 };
    G_NORMAL_MAP.getMaximumResolution = function () { return 12 };
    G_SATELLITE_MAP.getMaximumResolution = function () { return 12 };
    G_HYBRID_MAP.getMaximumResolution = function () { return 12 }; 

	load_extra();

};

function createMarker(point, info, id) {
	var marker = new GMarker(point, icon);

	marker.id = id;

	GEvent.addListener(marker, "click", function() {
		//marker.openInfoWindowHtml(info, opts);

		marker.openInfoWindowHtml(info);

		$('#content ul.writers li').removeClass("here");
		$('#marker_'+ marker.id).addClass("here");

	});

	markers[id] = marker;

	//i++;

	return marker;
};


function show_writer(id) {

	GEvent.trigger(markers[id], 'click');

	mgr.triggerClick(id);

};