// JavaScript Document
function hidePlayer(input) {
	if(input<10)
	{
		input="0"+input;
	}
	document.getElementById("txt"+input).style.display='block';
	document.getElementById("swf"+input).style.display='none';
}
function hideAllPlayers() {
	pmax = 11;
	for (i=1;i<=pmax;i++)
	{
		hidePlayer(i);
	}
}
function showPlayer(input) {
	hideAllPlayers();
	if(input<10)
	{
		input="0"+input;
	}
	//alert("info_"+input+": "+document.getElementById("info_"+input).firstChild.nodeValue);
	//document.getElementById("info_"+input).firstChild.nodeValue = "World!";
	document.getElementById("txt"+input).style.display='none';
	document.getElementById("swf"+input).style.display='block';
}

function hideMap(mapID){
	document.getElementById("map"+mapID).style.display = 'none';
	document.getElementById("datefooter"+mapID).content = 'shmeh';
}
function showMap(lat, lng, zoom, mapID) {
	document.getElementById("map"+mapID).style.display = 'block';
	
	if (GBrowserIsCompatible()) {
		document.getElementById("map"+mapID).style.display='block';
		var point = new GLatLng(lat,lng);
		var map = new GMap2(document.getElementById("map"+mapID));
		map.setCenter(point, zoom);
		map.addControl(new GMapTypeControl());
		map.addControl(new GLargeMapControl());
		var dateIcon = new GIcon(G_DEFAULT_ICON);
		dateIcon.image = "http://www.bambergerstreichquartett.de/img/cont/date_marker.png";
		dateIcon.shadow = "http://www.bambergerstreichquartett.de/img/cont/date_shadow.png";
		dateIcon.iconSize = new GSize(18, 42);
		dateIcon.shadowSize = new GSize(27, 42);
		dateIcon.iconAnchor = new GPoint(6, 41);
		markerOptions = { icon:dateIcon };
		map.addOverlay(new GMarker(point, markerOptions));
		map.hideControls();
		GEvent.addListener(map, "mouseover", function(){
			map.showControls();
		});
		GEvent.addListener(map, "mouseout", function(){
			map.hideControls(); 
		});
	}
}
mapToggled = new Array();
function toggleMap(lat, lng, zoom, mapID) {
	if (!mapToggled[mapID]) {
		mapToggled[mapID] = true;
		//alert('SHOW #'+mapID+': '+mapToggled[mapID]);
		showMap(lat, lng, zoom, mapID);
	} else {
		mapToggled[mapID] = false;
		//alert('HIDE #'+mapID+': '+mapToggled[mapID]);
		hideMap(mapID);
	}
	//alert('map #'+mapID+': '+mapToggled[mapID]);
}

function load(lat, lng, zoom) {
	if(load.arguments.length<3){
		lat = 49.902126;
		lng = 10.888481;
		zoom = 12;
	}
	if (GBrowserIsCompatible()) {
		var point = new GLatLng(lat,lng);
		var map = new GMap2(document.getElementById("map"));
		map.setCenter(point, zoom);
		map.addControl(new GMapTypeControl());
		map.addControl(new GLargeMapControl());
		var dateIcon = new GIcon(G_DEFAULT_ICON);
		dateIcon.image = "http://neu.bambergerstreichquartett.de/img/cont/date_marker.png";
		dateIcon.shadow = "http://neu.bambergerstreichquartett.de/img/cont/date_shadow.png";
		dateIcon.iconSize = new GSize(18, 42);
		dateIcon.shadowSize = new GSize(27, 42);
		dateIcon.iconAnchor = new GPoint(6, 41);
		markerOptions = { icon:dateIcon, draggable: true };
		marker = new GMarker(point, markerOptions);
		map.addOverlay(marker);
		marker.enableDragging();
		function showZoom(){
			document.getElementById("map_zoom").value=map.getZoom();
		}
		GEvent.addListener(map,"zoomend",showZoom);
		showZoom();
		function showLatLng(){
			document.getElementById("map_lat").value=marker.getPoint().lat();
			document.getElementById("map_lng").value=marker.getPoint().lng();
		}
		GEvent.addListener(marker,"dragend",showLatLng);
		showLatLng();
		map.hideControls();
		GEvent.addListener(map, "mouseover", function(){
			map.showControls();
		});
		GEvent.addListener(map, "mouseout", function(){
			map.hideControls(); 
		});
					
	}
}
