document.write("<script type='text/javascript' src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA7TPFX5-Ilniw0UQCRZLfhBRJ2RAzHZrqd9CTJtLBdYUsLknadBQxvmJkt9TNxFo0BaIzK2MwiCFGkw&amp;hl=de'></scr" + "ipt>");


var map = null;
var geocoder = null;
var ZOOM_STEP = 11;
var DEFAULT_LAT = 46.2922057;
var DEFAULT_LNG = 7.8812394;

function create20yMap(container, callback)
{
	if(GBrowserIsCompatible()) 
	{	
		var map = new GMap2(document.getElementById(container));
		map.addControl(new GSmallZoomControl3D());
		map.enableScrollWheelZoom();
        map.setCenter(new GLatLng(DEFAULT_LAT, DEFAULT_LNG), ZOOM_STEP);
        callback(map);
	}
}

function center20yMap(map, lat, lng, zoom)
{
	var center = new GLatLng(lat, lng);
	map.setCenter(center, zoom);
}

function center20yMapOnAddress(map, address)
{
	geocoder = new GClientGeocoder();
	geocoder.getLatLng(
		address,
		function(point) 
		{
			if (point) 
			{
				map.setCenter(point, ZOOM_STEP);
				var marker = new GMarker(point);
              	map.addOverlay(marker);
			}
		}
	);
}

function show20yMap(container, callback)
{
	document.observe
	(
		"dom:loaded", 
		function() 
		{
			gmIcon = new GIcon();
    		gmIcon.image = "http://www.rro.ch/2009/cms/themes//icons/map_pin_blue.png";
			gmIcon.shadow = "http://www.rro.ch/2009/cms/themes//icons/map_pin_shadow.png";
			gmIcon.iconSize = new GSize(23.0, 32.0);
			gmIcon.shadowSize = new GSize(40.0, 32.0);
			gmIcon.iconAnchor = new GPoint(2.0, 32.0);
			gmIcon.infoWindowAnchor = new GPoint(15.0, 5.0);
			
			gmIconCurrent = new GIcon();
    		gmIconCurrent.image = "http://www.rro.ch/2009/cms/themes//icons/map_pin_red.png";
			gmIconCurrent.shadow = "http://www.rro.ch/2009/cms/themes//icons/map_pin_shadow.png";
			gmIconCurrent.iconSize = new GSize(23.0, 32.0);
			gmIconCurrent.shadowSize = new GSize(40.0, 32.0);
			gmIconCurrent.iconAnchor = new GPoint(2.0, 32.0);
			gmIconCurrent.infoWindowAnchor = new GPoint(15.0, 5.0);

			create20yMap(container, callback);
		}
	);
	
	Event.observe
	(
		window,
		"beforeunload",
		function()
		{GUnload();}
	);
}

function doCommuneSearch()
{
	location.href = "http://www.rro.ch/2009/cms/index.php/20year/communesearch/" + ($("searchGemeinde").value);
}

document.observe("dom:loaded", function() {
	var contents = $$("td.mn_content");
	var tcs = $$("td.mn_tc");
    var i, width;
    
    for (i = 0; i < tcs.length; i++) {
    	width = contents[i].getWidth()-22;
    	tcs[i].firstDescendant().setStyle({width: width+'px'});
    }
    
    if(jQuery){
		jQuery(function(){
			(function(){ 
				var links = jQuery('.tow_prg_link');
				var link;
				for (i = 0; i < links.length; i++) {
					link = jQuery('#'+links[i].id);
					link.bind('click', function(event, ui){
						var ids = event.currentTarget.id.split('_');
						id = ids[2];
						jQuery('div#prg_content_'+id).toggle('fast');
					});
				}
			})();
		})
	};
});