function initialize()
{
   // var latlng = new google.maps.LatLng(45.644768217751924, 47.63671875);
    var latlng = new google.maps.LatLng(47, 50);
	var CA_position_infowindow=new google.maps.LatLng(45.73685954736049, 68.5546875);
	var EE_position_infowindow=new google.maps.LatLng(51.11041991029264, 29.8388671875);
	var SC_position_infowindow=new google.maps.LatLng(40.9964840143779, 45.87890625);
	var SEE_position_infowindow=new google.maps.LatLng(43.17313537107136, 21.64306640625);
	//var Almaty = new google.maps.LatLng(43.25520534158046, 76.91253662109375); 
	//var Bishkek = new google.maps.LatLng(74.612222,42.874722 );

    var myOptions =
	{
		zoom: 3,
		center: latlng,
		disableDefaultUI: true,
		navigationControl: true,
		navigationControlOptions: {
		style: google.maps.NavigationControlStyle.SMALL
			},
		scaleControl: false,
		mapTypeControl: false,
		mapTypeId: google.maps.MapTypeId.TERRAIN
    };
    var map = new google.maps.Map(document.getElementById("map_ENVSEC_regions"), myOptions);

	// For testing, avoid caching.
	var ENVSEC_regions = new google.maps.KmlLayer(kml_path,{preserveViewport: true},{suppressInfoWindows: true});
	ENVSEC_regions.setMap(map);

	google.maps.event.addListener(ENVSEC_regions, 'click', function(kmlEvent)
	{
		var text_kml = kmlEvent.featureData.description;
		var infowindow_kml = new google.maps.InfoWindow({
			content: text_kml
		});
	});

	var Central_Asia = '<div id="content">'+
					   '</div>'+
					   '<a href="index.php?option=com_content&view=article&id=3&Itemid=107&lang=en&region=CA">'+
					   'Central Asia'+
					   '</a>'+
						'</div>';
						
	var Eastern_Europe = '<div id="content">'+
					   '</div>'+
					   '<a href="index.php?option=com_content&view=article&id=3&Itemid=108&lang=en&region=EE">'+
					   'Eastern Europe'+
					   '</a>'+
						'</div>';
						
	var South_Eastern_Europe = '<div id="content">'+
					   '</div>'+
					   '<a href="index.php?option=com_content&view=article&id=3&Itemid=123&lang=en&region=SEE">'+
					   'South Eastern Europe'+
					   '</a>'+
						'</div>';
						
	var Southern_Caucasus = '<div id="content">'+
					   '</div>'+
					   '<a href="index.php?option=com_content&view=article&id=3&Itemid=116&lang=en&region=SC">'+
					   'Southern Caucasus'+
					   '</a>'+
						'</div>';

	var infowindow_CA = new google.maps.InfoWindow({
					content: Central_Asia
					 });
					 
	var infowindow_EE = new google.maps.InfoWindow({
					content: Eastern_Europe
					 });

	var infowindow_SEE = new google.maps.InfoWindow({
					content: South_Eastern_Europe
					 });
					 
	var infowindow_SC = new google.maps.InfoWindow({
					content: Southern_Caucasus
					 });	

	var marker_CA = new google.maps.Marker({
	position: CA_position_infowindow,
	map: map,
	title:"link to Central Asia page",
	icon:envsec_icon
	});
	
	var marker_EE = new google.maps.Marker({
	position: EE_position_infowindow,
	map: map,
	title:"link to Eastern Europe page",
	icon:envsec_icon
	});
	
	var marker_SEE = new google.maps.Marker({
	position: SEE_position_infowindow,
	map: map,
	title:"link to South Eastern Europe page",
	icon:envsec_icon
	});
	
	var marker_SC = new google.maps.Marker({
	position: SC_position_infowindow,
	map: map,
	title:"link to Southern Caucasus page",
	icon:envsec_icon
	});

	google.maps.event.addListener(marker_CA, 'click', function()
	{
		//infowindow_CA.open(map,marker_CA);
		//window.location.href = 'http://google.fr';
		window.location.href = 'index.php?option=com_content&view=article&id=3&Itemid=107&lang=en&region=CA';
	});
		google.maps.event.addListener(marker_EE, 'click', function() {
		//infowindow_EE.open(map,marker_EE);
		window.location.href = 'index.php?option=com_content&view=article&id=3&Itemid=108&lang=en&region=EE';
	});
		google.maps.event.addListener(marker_SEE, 'click', function() {
		//infowindow_SEE.open(map,marker_SEE);
		window.location.href = 'index.php?option=com_content&view=article&id=3&Itemid=123&lang=en&region=SEE';
	});
		google.maps.event.addListener(marker_SC, 'click', function() {
		//infowindow_SC.open(map,marker_SC);
		window.location.href = 'index.php?option=com_content&view=article&id=3&Itemid=116&lang=en&region=SC';
	});

	var imageBounds_CA = new google.maps.LatLngBounds(
    new google.maps.LatLng(55.7, 67),
    new google.maps.LatLng(57, 86));

    var imageBounds_EE = new google.maps.LatLngBounds(
    new google.maps.LatLng(56, 28),
    new google.maps.LatLng(57.4, 49));

	var imageBounds_SEE = new google.maps.LatLngBounds(
    new google.maps.LatLng(38, 12),
    new google.maps.LatLng(42, 30));

	var imageBounds_SC = new google.maps.LatLngBounds(
    new google.maps.LatLng(34, 40),
    new google.maps.LatLng(38, 52));

	var imageBounds_RUS = new google.maps.LatLngBounds(
    new google.maps.LatLng(58, 50),
    new google.maps.LatLng(59, 64));

	var imageBounds_CHN = new google.maps.LatLngBounds(
    new google.maps.LatLng(38, 80),
    new google.maps.LatLng(39, 85));

	var EE_text = new google.maps.GroundOverlay(
	"http://www.envsec.org/templates/envsec_modofragilis_v1/images/map/EE.png", imageBounds_EE);
	google.maps.event.addListener(EE_text, 'click', function(kmlEvent)
	{
		window.location.href = 'index.php?option=com_content&view=article&id=3&Itemid=108&lang=en&region=EE';
	});

	var CA_text = new google.maps.GroundOverlay(
	"http://www.envsec.org/templates/envsec_modofragilis_v1/images/map/CEA.png", imageBounds_CA);
	google.maps.event.addListener(CA_text, 'click', function(kmlEvent)
	{
		window.location.href = 'index.php?option=com_content&view=article&id=3&Itemid=107&lang=en&region=CA';
	});

	var SC_text = new google.maps.GroundOverlay(
	"http://www.envsec.org/templates/envsec_modofragilis_v1/images/map/SC.png", imageBounds_SC);
	google.maps.event.addListener(SC_text, 'click', function(kmlEvent)
	{
		window.location.href = 'index.php?option=com_content&view=article&id=3&Itemid=116&lang=en&region=SC';
	});
	
	var SEE_text = new google.maps.GroundOverlay(
	"http://www.envsec.org/templates/envsec_modofragilis_v1/images/map/SEE.png", imageBounds_SEE);
	google.maps.event.addListener(SEE_text, 'click', function(kmlEvent)
	{
		window.location.href = 'index.php?option=com_content&view=article&id=3&Itemid=123&lang=en&region=SEE';
	});
	

	var RUS_text = new google.maps.GroundOverlay(
	"http://www.envsec.org/webadmin_scripts/maps/ENVSEC_name_RUS.png", imageBounds_RUS);
	
	var CHN_text = new google.maps.GroundOverlay(
	"http://www.envsec.org/webadmin_scripts/maps/ENVSEC_name_CHN.png", imageBounds_CHN);

	EE_text.setMap(map);
	CA_text.setMap(map);
	SC_text.setMap(map);
	SEE_text.setMap(map);
	RUS_text.setMap(map);
	CHN_text.setMap(map);

	//var ctaLayer = new google.maps.KmlLayer(kml_region,{preserveViewport: true},{suppressInfoWindows: true});
	//ctaLayer.setMap(map);
}
  
window.onload = initialize;

