function showAddress(address) { var geocoder = new GClientGeocoder(); geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { if(document.getElementById("map")==null){ var form = document.createElement("form"); form.setAttribute("method", "post"); form.setAttribute("action", "/index/indexmap"); var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "q"); hiddenField.setAttribute("value", address); form.appendChild(hiddenField); document.body.appendChild(form); form.submit(); }else{ map.setCenter(point, 9); }}});} function showResult(search, option){ if(option == "place"){//If its a place we use GMap API showAddress(search); } else { var form = document.createElement("form"); form.setAttribute("method", "post"); if(option == "dive"){//If it is a dive form.setAttribute("action", "/dive-sites/search"); } if(option == "picture"){//If it is a picture form.setAttribute("action", "/dives-photos/search"); } if(option == "people"){//If it is a person form.setAttribute("action", "/users/search"); } if(option == "trip_reports"){//If it is a person form.setAttribute("action", "/travel/search"); } if(option == "boats"){//If it is a person form.setAttribute("action", "/liveaboard/search"); } if(option == "resorts"){//If it is a person form.setAttribute("action", "/resorts/search"); } if(option == "groups"){//If it is a person form.setAttribute("action", "/groups/search"); } var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "q"); hiddenField.setAttribute("value", search); form.appendChild(hiddenField); var hiddenField2 = document.createElement("input"); hiddenField2.setAttribute("type", "hidden"); hiddenField2.setAttribute("name", "combonext"); hiddenField2.setAttribute("value", option); form.appendChild(hiddenField2); document.body.appendChild(form); form.submit(); } }