/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function lookup(inputString) {
    if(inputString.length == 0) {
        // Hide the suggestion box.
        $('#suggestions').hide();
    } else {
        $.post("/db/jax.php", {queryString: ""+inputString+""}, function(data){
        $('#autoSuggestionsList').html("");
            //if(data.length >0) {
                $(data).find('City').each(function(){
                         var id_text = $(this).attr('Country');
                         var name_text = $(this).attr('name');
                         var lat = $(this).attr('alt');
                         var lon = $(this).attr('lon');
                         $('<li onclick="fill(\''+name_text.replace("'"," ")+'\',\''+lat+'\',\''+lon+'\')"></li>')
                             .html(name_text + ' (' + id_text + ')')
                             .appendTo('#autoSuggestionsList');
                     }); //close each(

                $('#suggestions').show();
                //$('#autoSuggestionsList').html(data);
            //}
        });
    }
} // lookup

function fill(thisValue,lat,lon) {
    $('#inputString').val(thisValue);
    $('#lat').val(lat);
     $('#lon').val(lon);
    $('#suggestions').hide();
    /*$.post("weather_saas/getweather.php",
    {lat: lat, lon: lon},
   function(xml){
     var new_html = $("description", xml).text();
     $('#weahter').html(new_html);
   });*/
}

function submitme(){
  document.getElementById('form').action= document.getElementById('inputString').value+".html";
  document.getElementById('form').submit()
}

function refuserToucheEntree(event)
{
    // Compatibilité IE / Firefox
    if(!event && window.event) {
        event = window.event;
    }
    // IE
    if(event.keyCode == 13) {
        event.returnValue = false;
        event.cancelBubble = true;
        alert("cliquez sur une ville de la liste puis sur go");
    }
    // DOM
    if(event.which == 13) {
        event.preventDefault();
        event.stopPropagation();
        alert("cliquez sur une ville de la liste puis sur go");
    }
}
