var map = null;
var distributors = null;

function initialize(dist) {
	if (document.getElementById("map_canvas") == null) {
		return;
	}
	distributors = [
		[new google.maps.LatLng(42.591763, 25.418070), 'Казанлък', '0888 858653; 94338/ 2093</br><a href="mailto:support@fruitgarden.org">E-Mail</a>'],
		[new google.maps.LatLng(41.946373, 25.559971), 'Хасково', '0898 793254'],
		[new google.maps.LatLng(41.844293, 26.078711), 'Любимец', '0894 737163'],
		[new google.maps.LatLng(42.753506, 23.318533), 'София', '02/ 8380567</br>0888 345139; 0889 374936'],
		[new google.maps.LatLng(42.130618, 24.739658), 'Пловдив', '0885 690460; 0888 850009'],
		[new google.maps.LatLng(43.161578, 27.931538), 'Варна', '0899 968610; 0899 968609'],
		[new google.maps.LatLng(42.494358, 27.460381), 'Бургас', '0889 437999'],
		[new google.maps.LatLng(42.516457, 27.369733), 'Бургас', '0897 939293; 0897 939292</br>0897 938778'],
		[new google.maps.LatLng(42.872693, 25.320289), 'Габрово', '0887 030096'],
		[new google.maps.LatLng(42.880595, 25.311438), 'Габрово', '0896 857360'],
		[new google.maps.LatLng(43.841507, 25.962410), 'Русе', '082 824762; 0887 795517'],
		[new google.maps.LatLng(42.679012, 26.314080), 'Сливен', '044 624121; 0889 426406'],
		[new google.maps.LatLng(43.137661, 25.902457), 'с. Джулюница (обл. Велоко Търново)', '0885 505704; 0885 669352'],
		[new google.maps.LatLng(43.436218, 28.340607), 'Каварна', '0570 85457'],
		[new google.maps.LatLng(42.422833, 25.634546), 'Стара Загора', '0899 642286'],
		[new google.maps.LatLng(42.644408, 27.678700), 'Равда', '0887 600288'],
		[new google.maps.LatLng(43.122005, 25.689511), 'Горна Оряховица', '0887 341397; 0889 535536</br>0618 60774'],
		[new google.maps.LatLng(43.616038, 25.349879), 'Свищов', '0887 223494'],
		[new google.maps.LatLng(42.597071, 25.204757), 'Павел Баня', '0897 960981'],
		[new google.maps.LatLng(42.973312, 25.475291), 'Дряново', '0887 485381; 067 672842'],
/*		[new google.maps.LatLng(42.614412, 25.395150), 'Казанлък', ''],*/
	];
	d = 0; z = 7;
	if (dist >= 0 && dist < distributors.length) {
		d = dist; z = 13;
	}
	var opt = {
		zoom: z,
		center: distributors[d][0],
		navigationControl: true,
		mapTypeControl: false,
		scaleControl: false,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	map = new google.maps.Map(document.getElementById("map_canvas"), opt);

	for (var i = 0; i < distributors.length; i++) {
		setMarker(map, distributors[i]);
	}
}

function setMarker(map, info) {
	var marker = new google.maps.Marker(
			{position: info[0], map: map, title: info[1]}
		);
	var infowindow = new google.maps.InfoWindow(
			{content: '<b>'+info[1]+'</b><br/>'+info[2], size: new google.maps.Size(250,50)}
		);
	google.maps.event.addListener(marker, 'click', function() {
			infowindow.open(map, marker);
		});
}

function zin(dist) {
	map.set_zoom(13);
	map.set_center(distributors[dist][0]);
}

function zout() {
	map.set_zoom(7);
	map.set_center(distributors[0][0]);
}
