function initAutocompleteSignupSearch(){
   countryCodeSignupSearch = $("country").options[$("country").selectedIndex].value;
   new Ajax.Autocompleter("statesearch", "autocomplete_search_signup", "/states/ajax/getStates.php", {
        method: 'post',
        minChars: 3,
        frequency: 0.1,
        callback: function(editor, paramText) {
            return paramText + '&country=' + countryCodeSignupSearch + '&s=search';
        },
        afterUpdateElement : getSelectedProfileId
    });
}

function getSelectedProfileId(text, li){
    $("geoname_id").setAttribute("value", li.id);

}

function getStateSelectedSignup(sel){
    countryCodeSignupSearch = sel.options[sel.selectedIndex].value;
    $("geoname_id").setAttribute("value", "0");
    $("statesearch").value = lang["enter_your_city"];
}

function updateStateNameOnSearch(state, country_code){
    var geonameid = arguments[2];
    if(geonameid != undefined){
        $("geoname_id").value = geonameid;
    } else {
        $("geoname_id").value = "0";
    }

    if(country_code != ""){
        $("country").value = country_code;
    }
    if(state != ""){
        $("statesearch").value = state;
    } else {
        $("statesearch").value = lang["enter_your_city"];
    }
}

function clearSearchInput(){
    if($("statesearch").value == lang["enter_your_city"]){
        $("statesearch").value = "";
    } else if($("statesearch").value == ""){
        $("statesearch").value = lang["enter_your_city"]
    }
}
