
	// Suchfeld wieder mit Standardwert f�llen, wenn unver�ndert
	function PruefeInhalt(Feld){
		if (Feld == '') {	
			document.searchform.search_terms.value = 'Stichworteingabe (optional)';
		}
	}
	
	// Blendet Hauptkategorie ein/aus und passt css-class an (Searchfilter); FlatStep 04.01.07
	function showHideCategory(mainCategory, mc_name) {

	 	catDiv = document.getElementById('maincategory_'+mainCategory);
		subCatDiv = document.getElementById('subcat_filter_'+mainCategory);
		
		// Aufblenden der Unterkategorien und Mittelbereich aktualisieren
	 	if (catDiv.className == 'maincategory') {
	 		$$('#rummagefilter_middle .active_maincategory').each(function(node) {
              node.removeClassName('active_maincategory');
              node.addClassName('maincategory');
            });
            $$('#rummagefilter_middle .active_maincategory_subact').each(function(node) {
              node.removeClassName('active_maincategory_subact');
            });
            $$('#rummagefilter_middle .subcat_filter').each(function(node) {
              node.hide();
            });
			
            catDiv.className = 'active_maincategory';
			Effect.BlindDown(subCatDiv);
			// new Ajax.Updater(catDiv, path2heaven+'/search/clearsearchlink?category='+mainCategory+'&reset=1');
            new Ajax.Updater('column2middle', path2heaven + "/search/searchresult?categorysearch=" + mc_name + "&filter=1", {evalScripts:true, asynchronous:true})
	 	}
		// Ausblenden der Hauptkategorie
	 	else {
			catDiv.className = 'maincategory';
			Effect.BlindUp(subCatDiv);
			//new Ajax.Updater(catDiv, path2heaven+'/search/clearsearchlink?category='+mainCategory);
		}
	}

  function showHideCategoryWithoutAjax(mainCategory, mc_name) {
    catDiv = $('maincategory_' + mainCategory);
    subCatDiv = $('subcat_filter_' + mainCategory);

	 	if (catDiv.className == 'maincategory') {
	 		$$('#rummagefilter_middle .active_maincategory').each(function(node) {
              node.removeClassName('active_maincategory');
              node.addClassName('maincategory');
            });
            $$('#rummagefilter_middle .active_maincategory_subact').each(function(node) {
              node.removeClassName('active_maincategory_subact');
            });
            $$('#rummagefilter_middle .subcat_filter').each(function(node) {
              node.hide();
            });

            catDiv.className = 'active_maincategory';
			Effect.BlindDown(subCatDiv);
    } else {
			catDiv.className = 'maincategory';
			Effect.BlindUp(subCatDiv);
    }
  }

    function updateSubcats(subcat, id) {
      Element.extend(subcat);
      var mc_nodes = $$('#rummagefilter_middle .active_maincategory');
      mc_nodes.each(function(node) {
        node.addClassName('active_maincategory_subact');
      });
      var sc_nodes = $$('#rummagefilter_middle .subcatsearch_active');
      sc_nodes.each(function(node) {
        node.removeClassName('subcatsearch_active');
        node.setAttribute('onmouseover', "this.up('div').setStyle({backgroundImage:'url(/" + path2heaven + "/images/pfeil_rechts_orange.gif)'});");
        node.setAttribute('onmouseout', "this.up('div').setStyle({backgroundImage:'url(/" + path2heaven + "/images/pfeil_rechts_weiss.gif)'});");
      });
      var sc2_nodes = $$('#rummagefilter_middle .subcategory');
      sc2_nodes.each(function(node) {
        node.setStyle({backgroundImage:'url(/' + path2heaven + '/images/pfeil_rechts_weiss.gif)'});
      });
      subcat.addClassName('subcatsearch_active');
      subcat.removeAttribute('onmouseover');
      subcat.removeAttribute('onmouseout');
      $('subcat_' + id).setStyle({backgroundImage:'url(/' + path2heaven + '/images/pfeil_rechts_blau.gif)'});
    }

    function clearSubcats() {
      var sc_nodes = $$('#rummagefilter_middle .subcatsearch_active');
      sc_nodes.each(function(node) {
        node.removeClassName('subcatsearch_active');
      });
      var sc2_nodes = $$('#rummagefilter_middle .subcategory');
      sc2_nodes.each(function(node) {
        node.setStyle({backgroundImage:'url(/' + path2heaven + '/images/pfeil_rechts_weiss.gif)'});
      });
    }

	// Im Select-Tag ausgew�hlte Seitenszahl zur�ck geben
	function returnChosenPage() {
		pageSelectTag = document.getElementById('selected_page');
		return pageSelectTag.value;
	}

  var ratings = new Object();

  function enableRatingMouseOver() {
    ratings = new Object();
    ratingsImgArray = $$(".ratingvotes img"); // get all rating images
    for(var i = 0; i < ratingsImgArray.length; ++i) {
      ratingsImgArray[i].src = "/" +path2heaven + "/images/star_big_yellow_empty.gif";
    }
    ratingInputArray = $$(".ratingvotes input.ratingAnswer"); // get all rating input elements
    for(var i = 0; i < ratingInputArray.length; ++i) {
      ratingInputArray[i].value = "0";
    }
  }

  function initializeRating(ratingID) {
    ratings["r" + ratingID] = false;
  }

  function disableRatingMouseOver(ratingID) {
    ratings["r" + ratingID] = true;
  }

  function deactivateStars(thisStar, ratingID) {
    if((typeof ratings["r" + ratingID] == "undefined" ) || (!ratings["r" + ratingID])) {
      thisStar.src = "/" + path2heaven + "/images/star_big_yellow_empty.gif";
      if(thisStar.id.search(/^star1/) == -1) deactivateStars(thisStar.previousSibling.previousSibling, ratingID);
    }
  }

  function activateStars(thisStar, ratingID) {
    if((typeof ratings["r" + ratingID] == "undefined" ) || (!ratings["r" + ratingID])) {
      thisStar.src = "/" + path2heaven+'/images/star_big_blue_full.gif';
      if ( thisStar.id.search(/^star1/) == -1) activatePreviousStars(thisStar.previousSibling.previousSibling);
      if ( thisStar.id.search(/^star5/) == -1) deActivateNextStars(thisStar.nextSibling.nextSibling);
    }
  }
 
  function activatePreviousStars(thisStar) {
    thisStar.src = "/" + path2heaven+'/images/star_big_blue_full.gif';
    if ( thisStar.id.search(/^star1/) == -1) activatePreviousStars(thisStar.previousSibling.previousSibling);
  }

  function deActivateNextStars(thisStar) {
    thisStar.src = "/" + path2heaven+'/images/star_big_yellow_empty.gif';
    if ( thisStar.id.search(/^star5/) == -1) deActivateNextStars(thisStar.nextSibling.nextSibling);
  }
 
	function showHideSubCategory(mainCategoryId) {
			
	 	var subcatDivId = 'subcat_'+mainCategoryId;
		var pfeilImageId = 'pfeilImage_'+mainCategoryId;
		
	 	subcatDiv = document.getElementById(subcatDivId);
	 	pfeilImage = document.getElementById(pfeilImageId);
	 	
	 	if (subcatDiv.className == 'hidden') {
	 		subcatDiv.className = 'visible';
	 		pfeilImage.src='4down.jpg';
	 	}	
	 	else {
			subcatDiv.className = 'hidden';
			pfeilImage.src='4.jpg';
		}
						
	}

  var showMap_gmap = false;
  var showMap_link = false;

  /**
   * initialize Google Map
   * called after sucessful update of div container
   * @author Torsten Sch�nebaum, Planquadrat
   * @created_at 11.08.08 
   */
  function showMap_initialize(container, linkContainer, linkText, lat, lng, infotext)
  {
      // get GMap2 object
      if (GBrowserIsCompatible()) {
        
        // unhide container
        $(container).show();
        // change link to show map
        showMap_link = $(linkContainer).innerHTML;
        $(linkContainer).update(linkText);
        
        // Mario, 04.02.08, Changed width to 430 to better fit in the railscontent div
        showMap_gmap = new GMap2(document.getElementById(container), {size: new GSize(430,300)});
        showMap_gmap.setCenter(new GLatLng(lat, lng), 12);
        showMap_gmap.enableScrollWheelZoom();
        showMap_gmap.addControl(new GSmallMapControl());
        
        // add marker
        point  = showMap_gmap.getCenter();
        marker = new GMarker(point);
        if (infotext != "") {
          marker.bindInfoWindowHtml(infotext);
        }
        showMap_gmap.addOverlay(marker);
      } else {
        // browser isn't supported - disable link to map
        /**
         * @TODO should show error message
         */
        $('showMapLink').hide();
      }
  }
      // Create arrays to collect the Values from RoR
      var google_lat = new Array();
      var google_lng = new Array();
      var google_title = new Array();
      var google_id = new Array();
      
      function setTourMap_arrays(lat,lng,title,id){
        var google_length = google_lat.length
          google_lat[google_length] = lat;
          google_lng[google_length] = lng;
          google_title[google_length] = title;
          google_id[google_length] = id;
      }
  
      function showTourMap_initialize(url){
        
        var siteurl = url;
        
        if (GBrowserIsCompatible()) {
          var map = new GMap2(document.getElementById("map_canvas"), {size: new GSize(468,250)});
          
                   
          //enables the zoom function
          map.enableScrollWheelZoom();
          map.addControl(new GSmallMapControl());
         
          map.setCenter(new GLatLng(google_lat[0], google_lng[0]), 13);
          
          //Extends the Maps with the given coordinates
          var bounds = new GLatLngBounds();
          
          //function createMarker(point){
            //var marker = new GMarker(point);
            //marker.openInfoWindowHtml(google_title.pop())
            //GEvent.addListener(marker, "click", function() {
            //marker.openInfoWindowHtml("Marker <b>" + marker.getTitle() + "</b>");
            //new Ajax.Updater('column2middle', 'blog/show/' + marker.getTitle(), {evalScripts:true});
            //new Ajax.Updater('column2middle', 'blog/show/' + id[marker.getTitle()], {evalScripts:true});
            //});
            //return marker;
          //}
          
          var count = 0;
          while(google_lat.length){
            count ++;
            var point = new GLatLng(google_lat.pop(),google_lng.pop());
            var marker = new GMarker(point);
            map.addOverlay(marker);
            marker.bindInfoWindowHtml("<div style=\"font-size:12px;font-weight:bold\">" + google_title.pop() + "</div><a href=\"#\" onclick=\"new Ajax.Updater('column2middle', '" + siteurl + "/blog/show/" + google_id.pop() + "', {asynchronous:true, evalScripts:true}); return false;\">Beitrag anzeigen</a>")
            bounds.extend(point);
          }
          
          if(count == 1){
          map.setZoom('15');
          }else{
          map.setZoom(map.getBoundsZoomLevel(bounds));
          }
          var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
          var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
          
          map.setCenter(new GLatLng(clat,clng));
          
          //Satalite View
          //map.setMapType(G_HYBRID_MAP);
          
        }else{
            map = document.getElementById("map_canvas");
            map.value = "Ihr Browser kann leider keine GoogleMaps darstellen!"
        }
        
      }
  
  /**
   * hides Google Map
   * 
   * @author Torsten Sch�nebaum, Planquadrat
   * @created_at 11.01.08
   */
  function showMap_hide(container, linkContainer)
  {
    $(container).hide();
    $(linkContainer).update(showMap_link);
    GUnload();
    showMap_gmap = false;
    showMap_link = false;
  }
  
	var editMap_gmap = false;
	var editMap_container = false;
	var editMap_baseIcon = false;
	var editMap_geocoder = false;
	var editMap_errormsg = 'Fehler! Konnte Koordinaten nicht ermitteln.';
	var editMap_markers = new Array();
	var editMap_resultsText = '';
	var editMap_results = false;
  var editMap_resultsCanvas = false;
	var editMap_markersAddresses = new Array();
	var editMap_markersLocalities = new Array();
	var editMap_containerReset = false;
	var editMap_containerLink = false;
	var editMap_container = false;
	
	/**
	 * initializes map and gets coordinates for given address
	 * 
	 *  @author Torsten Sch�nebaum, Planquadrat
	 *  @created 14.01.08
	 */
	function editMap_Initialize(container, containerResults, containerReset, containerLink)
	{
		editMap_setContainers(container, containerResults, containerReset, containerLink);
		
		// is browser compatible?
		if(GBrowserIsCompatible()) {
			editMap_results.show();
			if(!editMap_geocoder) {
				// load geocoder client
				editMap_geocoder = new GClientGeocoder();
			}
			
			// start searching coordinates
      editMap_getDetailCoordinates();
		}
	}
	
	/**
	 * initializes map with existing coordinates
	 */
	function editMap_InitializeExistingCoordinates(container, containerResults, containerReset, containerLink, lat, lng)
	{
		editMap_setContainers(container, containerResults, containerReset, containerLink);

    editMap_container.show();

    // create new GMap2 instance
    if(editMap_gmap) {
      editMap_gmap = false;
      GUnload();
    }
    editMap_gmap = new GMap2(document.getElementById('editMapCanvas'), {size: new GSize(230,250)});
    // set center and zoom level
    editMap_gmap.setCenter(new GLatLng(lat, lng), 13);
        
    // add small controll to map
    editMap_gmap.addControl(new GSmallMapControl());
        
    // set base icon
    editMap_baseIcon = new GIcon();
    editMap_baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    editMap_baseIcon.iconSize = new GSize(20, 34);
    editMap_baseIcon.shadowSize = new GSize(37, 34);
    editMap_baseIcon.iconAnchor = new GPoint(9, 34);
    editMap_baseIcon.infoWindowAnchor = new GPoint(9, 2);
    editMap_baseIcon.infoShadowAnchor = new GPoint(18, 25);

		editMap_gmap.addOverlay(editMap_createMarker(new GLatLng(lat, lng), 0));
	}
	
	function editMap_setContainers(container, containerResults, containerReset, containerLink)
	{
    editMap_containerReset = $(containerReset);
    editMap_containerLink = $(containerLink);
    editMap_container = $(container);
		editMap_results = $(containerResults);
    editMap_resultsCanvas = $(containerResults+"Canvas");
	}
	
	/**
	 * starts geocoding
	 */
	function editMap_getDetailCoordinates()
	{
		if(editMap_geocoder) {
			var query = $('post_address1').value + ', '
			          + $('post_city').value + ', '
								+ $('post_country').value;
		  // fire query
			editMap_geocoder.getLocations(query, editMap_getDetailCoordinatesCallback);
		}
	}
	
	/**
	 * callback handler for GClientGeocoder
	 * should get detail coordinates
	 */
	function editMap_getDetailCoordinatesCallback(response)
	{
		//alert(response.toSource());
		
		// status code should be 200 or there was an error
		if(response.Status.code == '200') {
      // Container anzeigen
      $(editMap_container).show();

      // create new GMap2 instance if none exists
      if(!editMap_gmap) {
        editMap_gmap = new GMap2(document.getElementById('editMapCanvas'));
        // set center and zoom level
        if(($('post_latitude_detail').value != "") && ($('post_longitude_detail').value != "") ) {
          // there are existing coordinates, so show them
          editMap_gmap.setCenter(new GLatLng($('post_latitude_detail').value, $('post_longitude_detail').value), 13);
        } else {
          // use default view
          editMap_gmap.setCenter(new GLatLng(52.855864, 15.205078), 3);
        }
        
        // add small controll to map
        editMap_gmap.addControl(new GSmallMapControl());
        
        // set base icon
        editMap_baseIcon = new GIcon();
        editMap_baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        editMap_baseIcon.iconSize = new GSize(20, 34);
        editMap_baseIcon.shadowSize = new GSize(37, 34);
        editMap_baseIcon.iconAnchor = new GPoint(9, 34);
        editMap_baseIcon.infoWindowAnchor = new GPoint(9, 2);
        editMap_baseIcon.infoShadowAnchor = new GPoint(18, 25);

      } else {
        // update existing GMap2 instance
        editMap_reset();
        return;
      }
			editMap_containerReset.show();
			editMap_containerLink.hide();

      //alert('OK! Got results');
			
			// traverse all results
			var i = 0;
			var text = "<ol type=\"A\">\n";
			for(var placemarkKey in response.Placemark) {
        if(!isNaN(placemarkKey)) {
					
					//alert(response.Placemark[placemarkKey].toSource());
					
          editMap_markers[i] = editMap_createMarker(
            new GLatLng(
              response.Placemark[placemarkKey].Point.coordinates[1],
              response.Placemark[placemarkKey].Point.coordinates[0]
            ),
            i
          );
          editMap_gmap.addOverlay(editMap_markers[i]);
          var address = response.Placemark[placemarkKey].address;
					
					var locality;
					
					// @TODO should get adminstrative area
					var placemark = response.Placemark[placemarkKey].AddressDetails;
					//alert (placemark.toSource());
					if(!(typeof placemark.Country == 'undefined')) {
						if(!(typeof placemark.Country.AdministrativeArea == 'undefined')) {
							if (typeof placemark.Country.AdministrativeArea.SubAdministrativeArea != 'undefined') {
								if(typeof placemark.Country.AdministrativeArea.SubAdministrativeArea.Locality != 'undefined') {
									/*if(typeof placemark.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality != 'undefined') {
										editMap_markersAddresses[i] = placemark.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.DependentLocalityName + ", "
										                            + placemark.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName + ", "
																								+ placemark.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName + ", "
																								+ placemark.Country.AdministrativeArea.AdministrativeAreaName + ", "
										                            + placemark.Country.CountryNameCode;
									} else {*/
                    editMap_markersAddresses[i] = placemark.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName + ", "
                                                + placemark.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName + ", "
                                                + placemark.Country.AdministrativeArea.AdministrativeAreaName + ", "
                                                + placemark.Country.CountryNameCode;
									  editMap_markersLocalities[i] = placemark.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
									//}
								}
							} else if (typeof placemark.Country.AdministrativeArea.Locality != 'undefined') {
								/*if (typeof placemark.Country.AdministrativeArea.Locality.DependentLocality != 'undefined') {
									editMap_markersAddresses[i] = placemark.Country.AdministrativeArea.Locality.DependentLocality.DependentLocalityName + ", "
									                            + placemark.Country.AdministrativeArea.Locality.LocalityName + ", "
																							+ placemark.Country.AdministrativeArea.AdministrativeAreaName + ", "
																							+ placemark.Country.CountryNameCode;
								} else {*/
                  editMap_markersLocalities[i] = placemark.Country.AdministrativeArea.Locality.LocalityName;
									editMap_markersAddresses[i] = placemark.Country.AdministrativeArea.Locality.LocalityName + ", "
                                              + placemark.Country.AdministrativeArea.AdministrativeAreaName + ", "
                                              + placemark.Country.CountryNameCode;
								//}
							}
						} else if(typeof placemark.Country.Locality != 'undefined') {
							/*if(typeof placemark.Country.Locality.DependentLocality != 'undefined') {
								editMap_markersAddresses[i] = placemark.Country.Locality.DependentLocality.DependentLocalityName + ", "
								                            + placemark.Country.Locality.LocalityName + ", "
																						+ placemark.Country.CountryNameCode;
							} else {*/
                editMap_markersLocalities[i] = placemark.Country.Locality.LocalityName;
								editMap_markersAddresses[i] = placemark.Country.Locality.LocalityName + ", "
                                            + placemark.Country.CountryNameCode;
							//}
						}
					}
					
          //alert(editMap_markersAddresses[i]);
					
          text += "<li><a href=\"javascript:void(0)\" onclick=\"editMap_setLocation(" + i + ")\">" + address + "</a></li>";
          i++;
        }
      }
      text += "</ol>\n";
      editMap_resultsText = text;
      editMap_resultsCanvas.update(text);
      editMap_gmap.setZoom(13);
      editMap_setLocation(0);
		} else {
			// error getting coordinates
			alert(editMap_errormsg);
		}
	}
	
	function editMap_setLocation(location)
	{
    editMap_gmap.panTo(editMap_markers[location].getPoint());
    editMap_resultsCanvas.update(editMap_resultsText);
    editMap_resultsCanvas.getElementsByTagName('ol')[0].getElementsByTagName('li')[location].getElementsByTagName('a')[0].innerHTML = "<b>" + editMap_resultsCanvas.getElementsByTagName('ol')[0].getElementsByTagName('li')[location].getElementsByTagName('a')[0].innerHTML + "</b>";
    $('post_latitude_detail').value = editMap_markers[location].getLatLng().lat();
    $('post_longitude_detail').value = editMap_markers[location].getLatLng().lng();
		
    if (editMap_markersLocalities.length > 0) {
      $('post_city').value = editMap_markersLocalities[location];
    }
		
		// get coordinates just for the city of this location
		if(editMap_geocoder) {
			editMap_geocoder.getLatLng(editMap_markersAddresses[location], editMap_getCityCoordinatesCallback);
		}
	}
	
	function editMap_getCityCoordinatesCallback(point)
	{
		if (point != null) {
			// there's a point, set form values correspondingly
			$('post_latitude').value = point.lat();
			$('post_longitude').value = point.lng();
		} else {
			// there's no point, delete form values
			$('post_latitude').value = "";
			$('post_longitude').value = "";
		}
	}
	
	function editMap_reset()
	{
		editMap_container.hide();
		editMap_containerReset.hide();
		editMap_containerLink.show();
		editMap_resultsCanvas.update();
		editMap_results.hide();
    GUnload();
		$('post_latitude').value = "";
    $('post_longitude').value = "";
    $('post_latitude_detail').value = "";
    $('post_longitude_detail').value = "";
		editMap_markers = new Array();
		editMap_markersAddresses = new Array();
		editMap_markersLocalities = new Array();
		editMap_gmap = false;
	}
	
	/**
	 * adds marker to map with letter corresponding to index
	 * 
	 * @param {GPoint} point
	 * @param {Integer} index
	 */
	function editMap_createMarker(point, index) {
    // Create a lettered icon for this point using our icon class
    var letter = translateIndexToLetter(index);
    var letteredIcon = new GIcon(editMap_baseIcon);
    letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
    
    // Set up our GMarkerOptions object
    var marker = new GMarker(point, { icon:letteredIcon });
    
    return marker;
  }

  /**
   * returns indexth letter of alphabet 
   * 
   * @param {Integer} index
   */
	function translateIndexToLetter(index) {
    return String.fromCharCode("A".charCodeAt(0) + index);
  }
	
	function editMap_checkCoordinates(message)
	{
		if(($('post_latitude_detail').value == "")  ||
		   ($('post_longitude_detail').value == "") ||
			 ($('post_latitude').value == "")         ||
			 ($('post_longitude').value == "") )
		{
			// one or more coordinates missing
			return confirm(message);
		} else {
			// everything looks sane
			return true;
		}
	}

  /**
   * Funktionen zum Anzeigen und Ausblenden von Hilfeboxen
   */
  var helpbox = false;
  
  function showHelpbox(helpboxContainer)
  {
    // pruefen, ob bereits eine helpbox angezeigt wird
    if(helpbox) {
      // pruefen, ob das Element dazu noch vorhanden ist
      if(typeof helpbox.hide() == 'undefined') {
        // Element ist nicht mehr vorhanden
        helpbox = false;
      } else {
        // Element ist noch vorhanden
        helpbox.hide();
        helpbox = false;
      }
    }
    // helpbox anzeigen
    helpbox = $(helpboxContainer);
    helpbox.show();
  }

  /**
   * Funktionen zum Wechseln der Anzeige in der Empfehlungsbox
   * 
   * @author Torsten Sch�nebaum, Planquadrat
   * @date 28.01.08
   */
  var recoBoxTimeout = 0;
  
  function updateRecoBox(page, timeout) {
    if(page == 1) {
      if($('recommendationbox2') != null) {
        if($('recommendationbox1') != null) $('recommendationbox1').hide();
        if($('recommendationbox3') != null) $('recommendationbox3').hide();
        $('recommendationbox2').show();
        recoBoxTimeout = window.setTimeout("updateRecoBox(2, " + timeout + ");", timeout);
      } else {
        recoBoxTimeout = window.setTimeout("updateRecoBox(1, " + timeout + ");", timeout);
      }
    } else if(page == 2) {
      if($('recommendationbox3') != null) {
        if($('recommendationbox1') != null) $('recommendationbox1').hide();
        if($('recommendationbox2') != null) $('recommendationbox2').hide();
        $('recommendationbox3').show();
        recoBoxTimeout = window.setTimeout("updateRecoBox(3, " + timeout + ");", timeout);
      } else {
        recoBoxTimeout = window.setTimeout("updateRecoBox(1, " + timeout + ");", timeout);
      }
    } else {
      if($('recommendationbox3') != null) $('recommendationbox3').hide();
      if($('recommendationbox2') != null) $('recommendationbox2').hide();
      if($('recommendationbox1') != null) $('recommendationbox1').show();
      recoBoxTimeout = window.setTimeout("updateRecoBox(1, " + timeout + ");", timeout);
    }
  }
  
  function stopRecoBoxUpdate() {
    window.clearTimeout(recoBoxTimeout);
  }

  /**
   * changes pages of middle list box
   * @author Torsten Sch�nebaum, Planquadrat
   * 19.03.2008
   */
  var listboxTimeout = 0;

  function updateListbox(box, page, timeout) {
    if(page == 1) {
      if($(box + "_2") != null) {
        if($(box + "_1") != null) $(box + "_1").hide();
        if($(box + "_3") != null) $(box + "_3").hide();
        $(box + "_2").show();
        listboxTimeout = window.setTimeout("updateListbox('" + box + "', 2," + timeout + ");", timeout);
      } else {
        listboxTimeout = window.setTimeout("updateListbox('" + box + "', 1," + timeout + ");", timeout);
      }
    } else if(page == 2) {
      if($(box + "_3") != null) {
        if($(box + "_1") != null) $(box + "_1").hide();
        if($(box + "_2") != null) $(box + "_2").hide();
        $(box + "_3").show();
        listboxTimeout = window.setTimeout("updateListbox('" + box + "', 3," + timeout + ");", timeout);
      } else {
        if($(box + "_2") != null) $(box + "_2").hide();
        if($(box + "_1") != null) $(box + "_1").show();
        listboxTimeout = window.setTimeout("updateListbox('" + box + "', 1," + timeout + ");", timeout);
      }
    } else {
      if($(box + "_3") != null) $(box + "_3").hide();
      if($(box + "_2") != null) $(box + "_2").hide();
      if($(box + "_1") != null) $(box + "_1").show();
      listboxTimeout = window.setTimeout("updateListbox('" + box + "', 1," + timeout + ");", timeout);
    }
  }

  function stopListboxUpdate() {
    window.clearTimeout(listboxTimeout);
  }

  /**
   * updates column2middle in top window by AJAX request to given url
   * 
   * @param {string} url
   */  
  function uploadokay(url) {
    new Ajax.Updater(top.$('column2middle'), url, {evalScripts: true});
  }

  function updateElement(container, url) {
    new Ajax.Updater(container, url, {asynchronous: true, evalScripts: true});
  }
  
  var postshowImagelinkActive = false;

  function togglePostshowImagelink(inactive, active) {
    if (!postshowImagelinkActive) {
      $('postshow_mail_imagelink').src = active;
      postshowImagelinkActive = true;
    } else {
      $('postshow_mail_imagelink').src = inactive;
      postshowImagelinkActive = false;
    }
  }

  function generate_password(length) {
    var rc = "";

    var charset = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!$%&/()=,.-;:';

    for(var i = 0; i < length; i++) {
      rc = rc + charset.charAt(Math.floor(Math.random() * charset.length))
    }

    return rc;
  }