<!--
  /// Container for XMLHTTP
  var xmlDoc = null ;
  /// Regular expression
  /// Only characters, at least three, limit to 15 chars length to prevent injections etc.
  var regExpLetters = /[A-Za-zÉÈÊÍÌÎÚÙÜÛÓÒÖÔÁÀÂÂÃÄÅÆÇËÏÐÑÕÖØÜÝßàáäâãåæçèéêëìíîïðñòóôõöøùúûüñ]{3,15}/;

  function $(id)
  {
    return document.getElementById(id);
  }
  
  function validateInput(objCitySearchForm)
  {
    try
    {
      var strValue = objCitySearchForm.findme.value;

      if (strValue.length >= 3)
      {
        var strLanguage = objCitySearchForm.language.value;
        var strSearchPrecicion = objCitySearchForm.search.value;
        var intCoId = objCitySearchForm.coid.value;
        var strOrderColumn = objCitySearchForm.order.value;
        var strOrderDirection = objCitySearchForm.direction.value;

        getAutoList(strLanguage, strValue, intCoId, strSearchPrecicion, strOrderColumn, strOrderDirection);
      }
    }
    catch (objException) { ; }
  }

  /// Tries to get auto-complete list for city search
  function getAutoList(strLanguage, strFindme, intCoid, strSearch, strOrderColumn, strOrderDirection)
  {
    try
    {
  	  /// Haystack must fit to regular expression
  	  /// Removed: document.forms[0].search.value != 'exactly' && 
  	  if(regExpLetters.test(strFindme)) 
  	  {
        /// Detect calling type
    	if (typeof window.ActiveXObject != 'undefined')
	    {
          xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
          xmlDoc.onreadystatechange = process ;
    	}
    	else
    	{
          xmlDoc = new XMLHttpRequest();
          xmlDoc.onload = process ;
    	}

        /// Daten vom PHP-Skript anfordern
        xmlDoc.open( "GET", "../shared/php/scripts/server.php?class=Geodb&language="+strLanguage+"&findme="+strFindme+"&coid="+intCoid+"&search="+strSearch+"&order="+strOrderColumn+"&direction="+strOrderDirection+"&limit=10", true );
        xmlDoc.send( null );
      }    
      else
      {
        /// Clear autolist on invalid parameters
        document.getElementById('autolist').innerHTML = '';
      }
    }
    catch (objException)
    {
      document.getElementById('autolist').innerHTML = '';
    }
  }
  
  /// Writes results into the document
  function process()
  {
    try
    {
      if ( xmlDoc.readyState != 4 ) return ;
      document.getElementById("autolist").innerHTML = xmlDoc.responseText ;
    }
    catch (objException) { ; }
  }

  function orderResult(order, direction)
  {
    try
    {
      var form = document.forms[0];

      form.order.value     = order == 'province' ? 'name_province' : 'name_country';
      form.direction.value = direction == 'down' ? 'ASC' : 'DESC';
      form.submit();
    }
    catch (objException) { ; }
  }
  
  //window.onload = showOrderButtons;
  setTimeout("showOrderButtons()", 0);
  
  function showOrderButtons()
  {
    try
    {
      $("orderbuttons1").style.display = '';
      $("orderbuttons2").style.display = '';
    }
    catch (Ex) { }
  }

  function switchCitySearchDisplayDetail()
  {
    try
    {
      if ($('citysearch_orderingDetails_title').style.display != 'table-row')
      {
        $('citysearch_orderingDetails_title').style.display = 'table-row';
        $('citysearch_orderingDetails_selects').style.display = 'table-row';
        $('citysearch_orderingDetails_moreOptions').style.display = 'none';
        $('citysearch_orderingDetails_lessOptions').style.display = 'table-row';
      }
      else
      {
        $('citysearch_orderingDetails_title').style.display = 'none';
        $('citysearch_orderingDetails_selects').style.display = 'none';
        $('citysearch_orderingDetails_moreOptions').style.display = 'table-row';
        $('citysearch_orderingDetails_lessOptions').style.display = 'none';
      }
    }
    catch (e)
    {
      /// IE Variante
      if ($('citysearch_orderingDetails_title').style.display != 'inline')
      {
        $('citysearch_orderingDetails_title').style.display = 'inline';
        $('citysearch_orderingDetails_selects').style.display = 'inline';
        $('citysearch_orderingDetails_moreOptions').style.display = 'none';
        $('citysearch_orderingDetails_lessOptions').style.display = 'inline';
      }
      else
      {
        $('citysearch_orderingDetails_title').style.display = 'none';
        $('citysearch_orderingDetails_selects').style.display = 'none';
        $('citysearch_orderingDetails_moreOptions').style.display = 'inline';
        $('citysearch_orderingDetails_lessOptions').style.display = 'none';
      }    
    }    
  }
//-->