function search_validation (from) { var geoid =document.getElementById("geoId").value; var area =document.getElementById("search_area").value; var word =document.getElementById("searchword").value; var category =document.getElementById("category").value; var str = document.getElementById("geo").value; var city = str.split(","); if (word=="Szukaj...") {word="";} var url="/szukaj?searchword="+word+"&city="+city[0]+"&geoid="+geoid+"&area="+area+"&category="+category; if (from=="city") {document.searchdetail.action = url;} if (from=="word") {document.searchword.action = url;} } $(document).ready(function() { var polandId = 170; function geoInputCheck(){ if($("input[name='country']").val()==''){ $("input[name='geo']").attr('disabled', true); $("input[name='street']").attr('disabled', true); $("input[name='home']").attr('disabled', true); $("input[name='geo']").val(''); $("input[name='home']").val(''); $("input[name='geoId']").val(''); $("input[name='street']").val(''); $("input[name='geoIdStreet']").val(''); }else if($("input[name='geo']").val()==''){ $("input[name='geo']").attr('disabled', false); $("input[name='street']").attr('disabled', true); $("input[name='home']").attr('disabled', true); $("input[name='home']").val(''); $("input[name='geoId']").val(''); $("input[name='street']").val(''); $("input[name='geoIdStreet']").val(''); }else if($("input[name='street']").val()==''){ $("input[name='street']").attr('disabled', false); $("input[name='home']").attr('disabled', true); $("input[name='home']").val(''); $("input[name='geoIdStreet']").val(''); }else if($("input[name='home']").val()==''){ $("input[name='home']").attr('disabled', false); } } function autoCompleteEnable() { $("#geo").autocomplete("http://www.topagro.eu/scripts/search/search.php?t=city", { width: 400 }).result(function(event, data, formatted) { $('input[name="geoId"]').val(data[1]); address(12); }); $("#street").autocomplete("http://www.topagro.eu/scripts/search/search.php?t=street", { width: 400, extraParams: { 'cityId': function() { return $('input[name="geoId"]').val(); }} }).result(function(event, data, formatted) { $('input[name="geoIdStreet"]').val(data[1]); address(15); }); } function clearInput(){ $("input[name='geo']").click(function() { $(this).val(''); geoInputCheck(); }); $("input[name='street']").click(function() { $(this).val(''); geoInputCheck(); }); $("input[name='home']").click(function() { $(this).val(''); geoInputCheck(); }); $("input[name='country']").keyup(function() { geoInputCheck(); }); $("input[name='geo']").keyup(function() { geoInputCheck(); }); $("input[name='street']").keyup(function() { geoInputCheck(); }); $("input[name='home']").keyup(function() { geoInputCheck(); }); } function autoCompleteDisable() { $("#geo").unautocomplete(); $("#street").unautocomplete(); clearInput(); //wazne - unautocomplete czysci events(click,keyup) dla inputow dlatego musimy ponownie je dodac } $("#country").autocomplete("http://www.topagro.eu/scripts/search/search.php?t=country", { width: 400 }).result(function(event, data, formatted) { address(5); autoCompleteDisable(); if(data[1] == polandId) { autoCompleteEnable(); } }); geoInputCheck(); autoCompleteEnable(); $("input[name='country']").click(function() { $(this).val(''); geoInputCheck(); }); clearInput(); $('#checkGoogleMaps').click(function(){ if($('#street').val().length > 0) { address(15); }else if($('#geo').val().length > 0) { address(12); }else if($('#country').val().length > 0) { address(5); } }); function address(zoom){ showAddress($("#country").val()+', '+$("#geo").val()+', '+$("#street").val()+' '+$("#home").val(), zoom); geoInputCheck(); } //gogle maps // });