$(document).ready(function(){(function(a){a(".ui-autocomplete-input").live("autocompleteopen",function(){var c=a(this).data("autocomplete"),d=c.menu;c.options.selectFirst&&d.activate(a.Event({type:"mouseenter"}),d.element.children().first())})})(jQuery);var b=false;$("input#search_box").autocomplete({selectFirst:true,source:function(a,c){$.ajax({url:"/searches/autocomplete/",data:{term:a.term},dataType:"json",success:function(d){c($.map(d,function(e){return{id:e.id,value:e.label,url:e.url}}))}})},
minLength:2,delay:100,open:function(){$("ul.ui-autocomplete li .type-venue").parent().parent().addClass("venue");$("ul.ui-autocomplete li .type-city").parent().parent().addClass("city");$("ul.ui-autocomplete li .type-product").parent().parent().addClass("product")},select:function(a,c){b=true;window.location=c.item.url}});$("input#search_box").bind("keypress",function(a){if(a.keyCode==13&&b==false)window.location="/searches/text:"+$("#search_box").val()});$(".btn-go").click(function(){window.location=
"/searches/text:"+$("#search_box").val()})});var latlng,map,myOptions,marker;$(document).ready(function(){var b="day_"+(new Date).getDay();$("#venue_hours tr#"+b).addClass("today")});$(document).ready(function(){$("#link_recommend").click(function(){$("#comment-dialog").dialog("destroy");$("#comment-dialog").load("/comments/add/venue:"+$("#VenueVenueId").text(),function(){$("#comment-dialog").dialog({width:"400px",modal:true})})})});
$(document).ready(function(){$("#link_error").click(function(){$("#error-dialog").dialog("destroy");$("#error-dialog").load("/comments/add_error_report/venue:"+$("#VenueVenueId").text(),function(){$("#error-dialog").dialog({width:"400px",modal:true})})})});
$(document).ready(function(){$(".fg-button:not(.ui-state-disabled)").hover(function(){$(this).addClass("ui-state-hover")},function(){$(this).removeClass("ui-state-hover")}).mousedown(function(){$(this).parents(".fg-buttonset-single:first").find(".fg-button.ui-state-active").removeClass("ui-state-active");$(this).is(".ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active")?$(this).removeClass("ui-state-active"):$(this).addClass("ui-state-active")}).mouseup(function(){$(this).is(".fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button")||
$(this).removeClass("ui-state-active")})});function venue_map_initialize(){$("body").unload("GUnload");latlng=new google.maps.LatLng($("#venueLat").attr("content"),$("#venueLng").attr("content"));myOptions={zoom:16,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP};map=new google.maps.Map(document.getElementById("gmap"),myOptions);marker=new google.maps.Marker({position:latlng,map:map,title:"Current position",draggable:false,clickable:true})}
$(document).ready(function(){$("#rat").children().not("select, #rating_title").hide();var b=$('<div id="caption"/>');$("#rat").stars({inputType:"select",oneVoteOnly:true,captionEl:b,callback:function(a,c,d){$("#messages").text("Saving...").fadeIn(30);$.post("/venue_ratings/ajax_vote",{rate:d,venue:$("#VenueVenueId").text()},function(e){$("#rating_title").text("Average rating");a.select(Math.round(e.avg));b.text(e.votes+" votes");$("#messages").text("Rating saved ("+d+"). Thanks!").stop().css("opacity",
1).fadeIn(30);setTimeout(function(){$("#messages").fadeOut(1E3)},2E3)},"json")}});b.appendTo("#rat");$('<div id="messages"/>').appendTo("#rat")});
function search_map_initialize(){$("body").unload("GUnload");latlng=new google.maps.LatLng(venueCords[0].geo_lat,venueCords[0].geo_lng);myOptions={zoom:14,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP};map=new google.maps.Map(document.getElementById("gmap"),myOptions);mapSize=new google.maps.LatLngBounds(latlng,latlng);for(var b=0;b<venueCords.length;b++){var a=new google.maps.LatLng(venueCords[b].geo_lat,venueCords[b].geo_lng);marker=new google.maps.Marker({position:a,map:map});new InfoBox({latlng:marker.getPosition(),
map:map,marker:marker,label:venueCords[b].name,url:venueCords[b].slug});mapSize.extend(a)}map.fitBounds(mapSize)}
function InfoBox(b){google.maps.OverlayView.call(this);this.latlng_=b.latlng;this.map_=b.map;this.offsetVertical_=-10;this.offsetHorizontal_=10;this.height_=165;this.width_=266;this.label=b.label;this.marker=b.marker;this.url_="/"+b.url;var a=this;google.maps.event.addListener(this.marker,"mouseover",function(){return a.div_.style.display="block"});google.maps.event.addListener(this.marker,"mouseout",function(){return a.div_.style.display="none"});google.maps.event.addListener(this.marker,"click",
function(){window.location=a.url_});this.setMap(this.map_)}InfoBox.prototype=new google.maps.OverlayView;InfoBox.prototype.remove=function(){if(this.div_){this.div_.parentNode.removeChild(this.div_);this.div_=null}};
InfoBox.prototype.draw=function(){this.createElement();if(this.div_){var b=this.getProjection().fromLatLngToDivPixel(this.latlng_);if(b){this.div_.style.left=b.x+this.offsetHorizontal_+"px";this.div_.style.top=b.y+this.offsetVertical_+"px";this.div_.style.display="none";google.maps.event.addListener(this.div_,"mouseover",function(){return this.div_.style.display="block"});google.maps.event.addListener(this.div_,"mouseout",function(){return this.div_.style.display="none"})}}};
InfoBox.prototype.createElement=function(){var b=this.getPanes(),a=this.div_;if(a){if(a.parentNode!=b.floatPane){a.parentNode.removeChild(a);b.floatPane.appendChild(a)}}else{a=this.div_=document.createElement("div");a.style.position="absolute";a.style.whiteSpace="nowrap";a.style.backgroundColor="#fff";a.style.padding="2px 5px";a.style.border="1px solid #000";a.innerHTML=this.label;a.setAttribute("class","tooltip");a.style.display="none";b.floatPane.appendChild(a)}};
