var cntBtmLine = null;

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

function objectWA(str) {
	document.write(str);
}

function showImage(imgNr, skip) {
	if (!skip) cntBtmLine = document.getElementById('cntBtmLine').innerHTML;
  var imgCount = document.getElementById('impressionen').childNodes.length;

	document.getElementById('impressionDetail').innerHTML = '<img src="../images/impression_' + imgNr + 'b.jpg" width="540" height="405" alt="" />';

	document.getElementById('impressionen').style.display = 'none';
	document.getElementById('impressionDetail').style.display = 'block';

	var navLine = '';
	if (imgNr > 1 ) {
		navLine += '<span onclick="showImage(' + (imgNr - 1) + ', true)" style="cursor: pointer; position: absolute; left: 4px; top: 0px;">voorgaande afbeelding</span>';
	}
	if (imgNr < imgCount ) {
		navLine += '<span onclick="showImage(' + (imgNr + 1) + ', true)" style="cursor: pointer; position: absolute; right: 4px; top: 0px;">volgende afbeelding</span>';
	}
	navLine += '<span onclick="closeImage()" style="cursor: pointer;">terug</span>';
	document.getElementById('cntBtmLine').innerHTML = navLine;

	return false;
}

function closeImage() {
	document.getElementById('impressionDetail').style.display = 'none';
	document.getElementById('impressionen').style.display = 'block';

	document.getElementById('cntBtmLine').innerHTML = cntBtmLine;
}

function showTours() {
	var day = document.getElementById('tour_day').value;
  var month = document.getElementById('tour_month').value;
  var year = document.getElementById('tour_year').value;
	window.open('http://www.heute-in-trier.de/show_events.php?day='+day+'&month='+month+'&year='+year+'&cat=64', '_blank');
}

function checkBuchungForm() {
	var missingText = '';
	if (document.getElementById('Name').value == '') missingText += '- Your name\n';
	if (document.getElementById('Strasse_Hausnummer').value == '') missingText += '- Your street address\n';
	if (document.getElementById('Ort').value == '') missingText += '- Your city\n';
	if (document.getElementById('Land').value == '') missingText += '- Your country\n';
	if (document.getElementById('email').value == '') missingText += '- Your email address\n';
        if (document.getElementById('Tag').value == '') missingText += '- Desired day of excursion\n';
        if (document.getElementById('Monat').value == '') missingText += '- Desired month of excursion\n';
        if (document.getElementById('Jahr').value == '') missingText += '- Desired year of excursion\n';

	if (missingText != '') {
		missingText = 'Please fill out the following fields:\n\n' + missingText;
		alert(missingText);
		return false;
	} else {
		return true;
	}
}

function getMaps(lat, lng){
    //Maps initialisieren und in einen Container laden:
            //-------------------------------------------------
           // var geocoder = new google.maps.Geocoder();
            var geoLocation = new google.maps.LatLng(lat, lng);
            var myOptions = {
                  zoom: 15,
                  center: geoLocation,
                  mapTypeId: google.maps.MapTypeId.ROADMAP,
                  mapTypeControlOptions: {
                    style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                  }
            };

            var map = new google.maps.Map(document.getElementById("googleMap"), myOptions) ;
            var marker = new google.maps.Marker({
              position: geoLocation,
              map: map,
              draggable: false
            });

}

//-----------------------------------------------------------------------------------------

function getMultiMarkerMaps(lat, lng){
var map = new google.maps.Map(document.getElementById("googleMap"), {
      center: new google.maps.LatLng(0, 0),
      zoom: 15,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      mapTypeControlOptions: {
        style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
      }
    });

    var mapMarkers = [];
    var bounds = new google.maps.LatLngBounds();

    var lat_array = lat.split(";");
    var lng_array = lng.split(";");
    for (var i = 0; i < lat_array.length; ++i){
      var markerposition = new google.maps.LatLng(lat_array[i], lng_array[i]);
      var marker = new google.maps.Marker({
        position: markerposition,
        map: map
      });

      mapMarkers.push(marker);
      bounds.extend(markerposition);
    }

    map.fitBounds(bounds);
}