function region_change()
{
	document.getElementById('ctl00_cphPageContent_hfRegionID').value = ucRegion.value;
	map.clearOverlays();
	if (ucRegion.value == 0) {
	    map.setCenter(new GLatLng(62.00, 90.00), 2);
	} else {
        var sw = new GLatLng(aspnetForm.hfLATMIN.value, aspnetForm.hfLNGMIN.value);
        var ne = new GLatLng(aspnetForm.hfLATMAX.value, aspnetForm.hfLNGMAX.value);
        var bounds = new GLatLngBounds(sw, ne);
        var center = new GLatLng(aspnetForm.hfCLAT.value, aspnetForm.hfCLNG.value);
        if (dID.length > 1){
            map.setCenter(center, map.getBoundsZoomLevel(bounds) - 1);
        } else {
            map.setCenter(center, 5);
        }
        for(d=0; d<ucDestination.options.length; d++)
        {	
            for(i=0; i<dID.length; i++)
    	    {	
    	        //alert(ucDestination.options[d].value));
    	        if (parseInt(dID[i]) == ucDestination.options[d].value){
    		        var point = new GLatLng(parseFloat(dLat[i]), parseFloat(dLng[i]));
    		        var marker = createMarker(point, ucDestination.options[d].text, dID[i]);
    		        //alert(ucDestination.options[d].text);
    		        map.addOverlay(marker);
    		        break;
    	        }
            }
        }
    }
}

function createMarker(point, name, id) { 
  var marker = new GMarker(point, {icon:customIcons, title:name} ); 
  GEvent.addListener(marker, "click", function()
  {
	map.openInfoWindowHtml(point, name);
	for(i=0; i<ucDestination.options.length; i++)
	{
		if(parseInt(id) == ucDestination.options[i].value)
		{
			ucDestination.selectedIndex = i;
		}
	}
  });
  return marker;
}

function city_change()
{
	if(ucDestination.value != 0)
	{
	    for(i=0; i<dID.length; i++)
	    {	
		    if (parseInt(dID[i]) == ucDestination.value) {
		        var point = new GLatLng(parseFloat(dLat[i]), parseFloat(dLng[i]));
		        map.openInfoWindowHtml(point, ucDestination.options[ucDestination.selectedIndex].text);
		        break;
		    }
	    }
	}
}

function load() {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("pe_map"));
	map.setCenter(new GLatLng(60.24, 78.75), 2);
	map.enableContinuousZoom();
	map.enableScrollWheelZoom();
	map.addControl(new GSmallMapControl());		
	map.setMapType(G_NORMAL_MAP);

    ucDestination = document.getElementById('ctl00_cphPageContent_ucDestination_ddlList');
    ucDestination.onchange = city_change;
    ucRegion = document.getElementById('ctl00_cphPageContent_ucRegion_ddlList')
    region_change();
  }
}


