var ac=null;
var bounds=null;
var goGetMap=true;
var acresults=new Object();
var placeACCurrentIndex=0;
var placeACPageSize=6;
function getMap(){
if(goGetMap||!eventCity.latLng){
geoCode($("city").value);
}
}
function showMap(){
$("mapcontrolhost").style.height="300px";
$("mapcontrolhost").style.width="300px";
}
function hideMap(){
$("mapcontrolhost").style.height="1px";
$("mapcontrolhost").style.width="1px";
}
function geoCode(c){
var _2=c;
if(_2!=""){
try{
map.Geocode(_2,geoCodeCallback);
}
catch(exception){
}
}
}
function geoCodeCallback(_3){
refreshAutoCompleter([],true);
if(!_3||_3.length<=0){
return;
}
var ll=new GLatLng(_3[0].location.coordinates[0],_3[0].location.coordinates[1]);
eventCity.latLng=_3[0].location.coordinates[0]>0?"+":"";
eventCity.latLng+=_3[0].location.coordinates[0];
eventCity.latLng+=_3[0].location.coordinates[1]>0?"+":"";
eventCity.latLng+=_3[0].location.coordinates[1];
eventCity.latLng=encodeURIComponent(eventCity.latLng);
map.setCenter(ll,15);
}
function onBlurFind(_5){
geoCode(_5.value);
}
function Find(_6){
if(!_6){
_6=0;
}
try{
if(eventVenue.value=="Type a place name"){
return;
}
map.FindPlace(eventVenue.value,eventCity.latLng,findCallback,null,_6);
}
catch(e){
}
finally{
}
}
function doFind(e){
placeACCurrentIndex=0;
$(autoCompleteDiv).innerHTML=Autocompleter.LocationLoadingText;
if(e){
e=e;
}else{
e=window.event;
}
if(e.which){
var _8=e.which;
}else{
var _8=e.keyCode;
}
if(_8==32){
return;
}
if(!__scrubWhiteSpace(eventVenue.value)){
ac.options.killAC=false;
}
if(eventVenue.value.length<2){
refreshAutoCompleter([]);
return;
}
if(acresults[__scrubWhiteSpace(eventVenue.value)+__scrubWhiteSpace(eventCity.latLng)]){
bindToAutoCompleter();
}else{
setTimeout("Find()",100);
}
}
function findCallback(b){
if(b==null||b.length!=2){
$(autoCompleteDiv).innerHTML="";
return;
}
acresults[b[1]+__scrubWhiteSpace(eventCity.latLng)]=b[0];
bindToAutoCompleter();
}
function bindToAutoCompleter(){
var b=acresults[__scrubWhiteSpace(eventVenue.value)+__scrubWhiteSpace(eventCity.latLng)];
if(b==null){
b=[];
}
var _b=[];
var _c=b.length;
if(_c<=0){
ac.options.array=_b;
return;
}
for(var i=0;i<_c;i++){
var _e=b[i].f.a+", "+b[i].f.c+", "+b[i].f.s;
var _f=b[i].title.replace("<b>","").replace("</b>","").replace(/&amp;/g,"&");
var _10=b[i].location.coordinates[0];
var _11=b[i].location.coordinates[1];
var _12=[_f+"@"+_e+"@"+b[i].guid+"~"+_10+"^"+_11,_f,_e];
_b.push(_12);
}
refreshAutoCompleter(_b);
}
function setPlaceLoc(p,l,lat,lon){
p=decodeURI(unescape(p));
l=unescape(l);
eventVenue.value=p.replace("<b>","").replace("</b>","");
eventCity.value=l.replace("<br>",", ");
var _17=p+"@"+l+"~"+lat+"^"+lon;
autoCBK("",_17);
}
function setupAutoComplete(){
ac=null;
ac=new Autocompleter.Location(eventVenue.id,autoCompleteDiv,[],{afterUpdateElement:autoCBK,minChars:2,ignoreClass:"autoIgnore",killOnIgnore:true,viewOffFocus:true});
}
function refreshAutoCompleter(_18,_19){
try{
if(eventVenue.value!=""&&eventVenue.value.length>2&&eventVenue.value!="Enter a Place"){
ac.options.array=_18;
ac.changed=false;
ac.hasFocus=true;
ac.getUpdatedChoices();
}
}
catch(err){
}
}
function syncCities(obj){
if(!obj){
return;
}
if(obj.id=="pollCity"){
$("pollCity").value=obj.value;
}else{
$("city").value=obj.value;
}
eventCity.value=obj.value;
}
function FindAtIndex(_1b){
$(autoCompleteDiv).innerHTML=Autocompleter.LocationLoadingText;
Find(_1b);
setTimeout("$(autoCompleteDiv).show()",500);
placeACCurrentIndex=_1b;
}

