
    var map;
    var directions;
    var toggleGlyphs;
    /**
     *
     * @access public
     * @return void
     **/
    function initGoogleMaps(){
	    if (GBrowserIsCompatible())
		{
	        map = new GMap2(document.getElementById("map"), {mapTypes:[G_NORMAL_MAP, G_PHYSICAL_MAP, G_HYBRID_MAP]});
	        map.addControl(new GSmallMapControl());
			map.addControl(new GMenuMapTypeControl());
	        map.setCenter(new GLatLng( 50.887050, 6.175089), 15);
			var marker = new GMarker(map.getCenter(), {title: 'Boxer-Klub Alsdorf'});
	        GEvent.addListener(marker, "click", function() {
	    		marker.openInfoWindowHtml("<b>Boxer-Klub Alsdorf</b><br>&Uuml;bungsplatz");
	  			});
	  		map.addOverlay(marker);
	  		directions = new GDirections(map, document.getElementById('directions'));
	  		GEvent.addListener(directions, "load", function() {
	  			document.getElementById('directions').style.display='block';
	  			document.getElementById('closedirections').onclick=closeDirections;
			});
	  		GEvent.addListener(directions, "error", function() {
	  			alert("Die Wegbeschreibung konnte nicht erzeugt werden. Bitte überprüfen Sie die Adresse.");
			});
	      }
    }
    /**
     *
     * @access public
     * @return void
     **/
    function initDirections(){
      var dirs = Array( 'richtungaachen', 'richtungkoeln', 'richtungddorf');
      for ( var i = 0; i < dirs.length; i++)
      {
      	var item = document.getElementById(dirs[i]);
      	var image = new Image();
      	image.src = 'images/toggle0.png';
      	image.alt = 'Wegbeschreibung anzeigen';
      	image.onmouseover = toggleMouseover;
      	image.onmouseout = toggleMouseout;
      	item.appendChild(image);
      	item.className = 'linkalike toggletexton';
		item.onclick = toggleDirection;

		document.getElementById(dirs[i] + '_text').style.display = 'none';
      }
      // preload the toggle animation images
      toggleGlyphs = new Array();
      for ( i = 0; i < 8; i++)
      {
      	toggleGlyphs[i] = new Image();
      	toggleGlyphs[i].src = 'images/toggle' + i + '.png';
      }

    }
    function load() {
    	initDirections();
    	initGoogleMaps();
    }

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function toggleMouseover(){
		if (this.src.indexOf('toggle7.png')!= -1)
		{
			this.src = 'images/toggle6.png';
		}
		else if (this.src.indexOf('toggle0.png')!= -1)
		{
			this.src = 'images/toggle1.png';
		}
	}
	/**
	 *
	 * @access public
	 * @return void
	 **/
	function toggleMouseout(){
		if (this.src.indexOf('toggle6.png') != -1)
		{
			this.src = 'images/toggle7.png';
		}
		else if (this.src.indexOf('toggle1.png') != -1)
		{
			this.src = 'images/toggle0.png';
		}
	}
    /**
     *
     * @access public
     * @return void
     **/
    function toggleDirection(){
    	var place = this.id;
    	var paragraph = document.getElementById(place + '_text');
    	if (paragraph.style.display == 'none') // currently hidden. Show it.
		{
    		setTimeout('toggleUpDown(\'' + this.id + '\', 1, 1);', 40);
    	}
    	else	// currently shown. Hide it.
    	{
    		setTimeout('toggleUpDown(\'' + this.id + '\', 6, -1);', 40);
		}
    }

    function showHideDirection( id){
    	var paragraph = document.getElementById(id + '_text');
    	if (paragraph.style.display == 'none') // currently hidden. Show it.
		{
			this.className = 'linkalike toggletextoff';
    		paragraph.style.display = 'block';
    	}
    	else	// currently shown. Hide it.
    	{
    		this.className = 'linkalike toggletexton';
    		paragraph.style.display = 'none';
		}
    }

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function toggleUpDown( id, current, direction){
		current += direction;
		if (current >= 0 && current <= 7) {
			var toggle = document.getElementById(id);
			var src = 'images/toggle' + current + '.png';
			if (current == 0)
				showHideDirection(id);
			else if (current == 7)
				showHideDirection(id);
			else
				setTimeout( 'toggleUpDown( \'' + id + '\', ' + current + ', ' + direction + ');', 40);
			toggle.getElementsByTagName('img')[0].src = src;

		}
	}
    /**
     *
     * @access public
     * @return void
     **/

    function getDirections()
	{
    	if (GBrowserIsCompatible()) {
    			target = 'from: ' + document.getElementById("directionsfrom").value + ' to: 50.88705,6.175089';
    			directions.load( target);
    		}
    		else
    		alert('Leider steht diese Funktion im Ihrem Browser nicht zur Verfügung.');
    }
    /**
     *
     * @access public
     * @return void
     **/
    function closeDirections(){
    	document.getElementById('directions').style.display='none';
    }

