var mapIcon=new GIcon(G_DEFAULT_ICON);mapIcon.image="/static/images/gicons/placeicon_selected.png";mapIcon.iconSize=new GSize(17,17);mapIcon.shadow="";mapIcon.iconAnchor=new GPoint(7,20);function add_favorite_to_favlist(a,g,c){var b=$(a).parent().parent().find("span.title").text();var f=$(a).parent().parent().find("img.photo").attr("src");var d=$(a).next("a").attr("href");var c=c;var g=g;data=new Object();data.id=g;data.link=d;data.title=b;data.type=c;data.photo=f;show_favorites(data);UpdateFavoritesNumber();$("#favorites_dd").trigger("click");$("#favorites #myfavs").children("div").removeClass("hoverclass");$("#myfav-"+g).addClass("hoverclass");$("#myfavs").scrollTop(0);return false}function AfterRemovingFavorite(){$("#close-info_slideup").trigger("click")}function bind_quicksearch(){$("#search_form").remove();if($("ul#eatout_ul_list li").length){$("ul#eatout_ul_list li").quicksearch({position:"in_header",attached:"ul#eatout_ul_list",loaderText:"",delay:1,labelText:"",formId:"search_form",focusOnLoad:true,onAfter:function(){if($("#search_form input").attr("value")!=""){$("#search_form div").removeClass("deactivated")}else{$("#search_form div").addClass("deactivated")}}});$("#search_form").append("<div></div>");$("#search_form div").addClass("deactivated");$("#search_form div").bind("click",function(){if(!$("#search_form div").hasClass("deactivated")){$("#search_form div").addClass("deactivated");$("#search_form input").attr("value","");$("#search_form input").trigger("keydown")}})}}bindEvents=function(){$("#next_10").removeClass("deactivated");RenderEatouts();bind_quicksearch();$("#filter_button").click(function(){show_loading();reset_map();cuisine=$("#filter_cuisine").val();place=$("#filter_place").val();do_filter(place,cuisine);e.map.setZoom(10);RenderEatouts();bind_quicksearch()});$("#showfilter").bind("click",slidedown);$("#eatout_filter").data("maxheight",$("#eatout_filter").css("height"));$("#sort_by").find("input").bind("click",function(){e.sorting.sortby=$(this).val();show_loading();reset_map();$.get(global.SERVER+"/ajax/eatout/?criteria="+e.sorting.sortby+"",render_eatout_data)})};function show_loading(){$("#list_div").addClass("loading1").children().hide()}function reset_map(){e.selectedMarker.setLatLng(new GLatLng(100,100));$("#close-info_slideup").trigger("click")}var render_eatout_data=function(data){data=eval(data);e.locations.eatouts=new Array();e.locations.eatouts_arr=new Array();e.locations.filtered=new Array();e.locations.filtered_arr=new Array();PrepareArray(data);if($("#filter_place").val()||$("#filter_cuisine").val()){$("#filter_button").trigger("click")}else{RenderEatouts()}bind_quicksearch()};var slidedown=function(){if($(this).hasClass("OFF")){$(this).removeClass("OFF").addClass("ON");$("#eatout_filter").animate({height:$("#eatout_filter").data("maxheight")},"normal",function(){$("#showfilter").attr("src","/static/images/up.gif")})}else{$(this).removeClass("ON").addClass("OFF");$("#eatout_filter").animate({height:"0px"},"normal",function(){$("#showfilter").attr("src","/static/images/down.gif")})}};function do_filter(a,c){e.locations.filtered=new Array();e.locations.filtered_arr=new Array();if(a&&c){filter="both"}else{if(a){filter="place"}else{if(c){filter="cuisine"}else{filter="none"}}}for(var b=0;b<e.locations.eatouts_arr.length;b++){switch(filter){case"both":arr=e.locations.eatouts[e.locations.eatouts_arr[b]];for(j=0;j<arr.length;j++){if(a==arr[j].parentplace_id&&c==arr[j].cuisine){if(!e.locations.filtered["id-"+arr[j].id]){e.locations.filtered_arr.push("id-"+arr[j].id);e.locations.filtered["id-"+arr[j].id]=new Array()}e.locations.filtered["id-"+arr[j].id].push(arr[j])}}break;case"place":arr=e.locations.eatouts[e.locations.eatouts_arr[b]];for(j=0;j<arr.length;j++){if(a==arr[j].parentplace_id){if(!e.locations.filtered["id-"+arr[j].id]){e.locations.filtered_arr.push("id-"+arr[j].id);e.locations.filtered["id-"+arr[j].id]=new Array()}e.locations.filtered["id-"+arr[j].id].push(arr[j])}}break;case"cuisine":arr=e.locations.eatouts[e.locations.eatouts_arr[b]];for(j=0;j<arr.length;j++){if(c==arr[j].cuisine){if(!e.locations.filtered["id-"+arr[j].id]){e.locations.filtered_arr.push("id-"+arr[j].id);e.locations.filtered["id-"+arr[j].id]=new Array()}e.locations.filtered["id-"+arr[j].id].push(arr[j])}}break;case"none":e.locations.filtered_arr=e.locations.eatouts_arr;e.locations.filtered=e.locations.eatouts;break}}}function get_cuisines(a,c){data="";if(c=="links"){for(var b=0;b<a.length;b++){if(a[b].cuisine){if(b==a.length-1){data+="<a href='/eatout/cuisine/"+ReplaceSpaceWithUnderscore(cuisine_dict["cuisine-"+a[b].cuisine]).toLowerCase()+"/'>"+cuisine_dict["cuisine-"+a[b].cuisine]+"</a>"}else{data+="<a href='/eatout/cuisine/"+ReplaceSpaceWithUnderscore(cuisine_dict["cuisine-"+a[b].cuisine]).toLowerCase()+"/'>"+cuisine_dict["cuisine-"+a[b].cuisine]+"</a>, "}}else{data="NOT DEFINED"}}}else{for(var b=0;b<a.length;b++){if(a[b].cuisine){if(b==a.length-1){data+=cuisine_dict["cuisine-"+a[b].cuisine]}else{data+=cuisine_dict["cuisine-"+a[b].cuisine]+", "}}else{data="NOT DEFINED"}}}return data}function get_ratings(a){ratings="";for(i=1;i<=5;i++){if(i<=a){ratings+="<img src='/static/images/rated.gif' alt='' />"}else{ratings+="<img src='/static/images/unrated.gif' alt='' />"}}return ratings}function CreateMarker(b){var a={icon:mapIcon,draggable:false,title:e.locations.eatouts[e.locations.filtered_arr[b]][0].title};marker=new GMarker(new GLatLng(e.locations.eatouts[e.locations.filtered_arr[b]][0].lat,e.locations.eatouts[e.locations.filtered_arr[b]][0].lng),a);GEvent.addListener(marker,"click",function(){GoogleMapClick("eatout",e.locations.eatouts[e.locations.filtered_arr[b]][0].id)});marker.id=e.locations.eatouts[e.locations.filtered_arr[b]][0].id;marker.can_see=true;return marker}function RenderEatouts(){$("#list_div").removeClass("loading1");e.mgr.clearMarkers();$("#eatout_ul_list").remove();$("#moreinfo_eatouts, #map").addClass("loading1");if(e.locations.filtered_arr.length){ul_data="<ul id='eatout_ul_list' class='eatout_list'>";var b=new Array();for(var a=0;a<e.locations.filtered_arr.length;a++){ul_data+="<li id='"+e.locations.filtered_arr[a]+"'><div class='title'>"+e.locations.eatouts[e.locations.filtered_arr[a]][0].title+"</div><div class='cuisine'><h4>Cuisines: "+get_cuisines(e.locations.eatouts[e.locations.filtered_arr[a]],"")+"</h4></div><span class='rating'>"+get_ratings(e.locations.eatouts[e.locations.filtered_arr[a]][0].rating)+"</span><span class='review'>"+e.locations.eatouts[e.locations.filtered_arr[a]][0].review_count+" Reviews</span></li>";marker=CreateMarker(a);b.push(marker)}e.mgr.addMarkers(b,10,17);e.mgr.refresh();ul_data+="</ul>";$("#moreinfo_eatouts, #map").removeClass("loading1");$(ul_data).prependTo("#list_div");$("#eatout_ul_list").find("li").unbind("click").bind("click",function(){$("#eatout_ul_list").find("li").removeClass("selected_onmap");moveMapTo($(this).attr("id"))})}else{$("#moreinfo_eatouts, #map").removeClass("loading1");$("<div id='eatout_ul_list'>Sorry, No Results Found.</div>").prependTo("#list_div")}}$(document).ready(function(){});