(function($){$.gmap={map:null,currentInfo:null,markers:[]};$.gmap.dispose=function(){$.gmap.map=null;$.gmap.currentInfo=null;$.gmap.markers=[]};$.gmap.initMap=function(lat,lng){var options={zoom:12,center:new google.maps.LatLng(lat,lng),mapTypeId:google.maps.MapTypeId.ROADMAP};$.gmap.map=new google.maps.Map($("#results-map").get(0),options)};$.gmap.addMarker=function(content,number,lat,lng){$.gmap.map==null&&$.gmap.initMap(lat,lng);var latlng=new google.maps.LatLng(lat,lng),style=StyledIconTypes.BUBBLE,marker=new StyledMarker({styleIcon:new StyledIcon(style,{color:"61C201",text:number}),position:latlng,map:$.gmap.map});google.maps.event.addListener(marker,"click",function(){if($.gmap.currentInfo!=null){$.gmap.currentInfo.close();$.gmap.currentInfo=null}$.gmap.clearMarkersAnim();$.gmap.currentInfo=new google.maps.InfoWindow({disableAutoPan:false});$.gmap.currentInfo.setContent(content);$.gmap.currentInfo.open($.gmap.map,marker)});$.gmap.markers.push(marker)};$.gmap.findMarker=function(lat,lng){var marker;for(i=0;i<$.gmap.markers.length;i++){marker=$.gmap.markers[i];var pos=marker.getPosition();if(pos.lat()==lat&&pos.lng()==lng)break}return marker};$.gmap.clearMarkersAnim=function(){$.each($.gmap.markers,function(i){$.gmap.markers[i].setAnimation(null)})};$.gmap.centerMap=function(lat,lng){if($.gmap.map!=null){var latlng=new google.maps.LatLng(lat,lng);$.gmap.map.setCenter(latlng);var marker=$.gmap.findMarker(lat,lng);$.gmap.bounceCurrent(marker)}};$.gmap.bounceCurrent=function(marker){$.gmap.clearMarkersAnim();marker.setAnimation(google.maps.Animation.BOUNCE)}})(jQuery);(function($){$.search={_showMap:true,_mapLoaded:false,searchUrl:null,optInUrl:null,restaurantInfoUrl:null};$.search.dispose=function(){$.search._mapLoaded=false};$.search.searchInner=function(ind,act,loc,supl,del,dist,search,rec,cid,cname,displayType,latLng){$.search.showLoading();var data={Action:act,Criteria:latLng,Location:loc,IncludeSupplementalResults:supl,OfferDelivery:del,MaxDistance:dist,SearchPhrase:search,StartIndex:ind,RecordsPerPage:rec,LandingConceptId:cid,LandingConceptName:cname,DisplayType:displayType};$.ajax({url:$.search.searchUrl,type:"POST",data:data,success:function(r){$("#search-results").html(r);$.search.rebind();$.search.hideLoading()},error:function(xhr,txt){$.search.hideLoading();$.search.handlerError(xhr,txt)}})};$.search.rememberSearchInput=function(){var loc=$("#location-text-input").val(),supl=$("input:radio[name=IncludeSupplementalResults]:checked").val(),del=$("#OfferDelivery").attr("checked"),dist=$("#radius-select-input").val(),search=$("#keyword-text-input").val();$("#input-location").val(loc);$("#input-supplemental").val(supl);$("#input-delivery").val(del);$("#input-distance").val(dist);$("#input-keywords").val(search)};$.search.next=function(ind){var act=$("#input-query-type").val(),loc=$("#input-location").val(),supl=!$("#online").attr("checked"),del=$("#delivery").attr("checked"),dist=$("#input-distance").val(),search=$("#input-keywords").val(),rec=$("#records-pre-page").val(),cid=$("#input-conceptid").val(),cname=$("#input-conceptname").val(),displayType=$("#results").is(".mapview")?"mapview":"listview",latLng=$("#Criteria").val();if(latLng=="")latLng=loc;$.search.searchInner(ind,act,loc,supl,del,dist,search,rec,cid,cname,displayType,latLng)};$.search.search=function(){$.search.rememberSearchInput();$.search.next(0)};$.search.bindMap=function(){$("#results").is(".mapview")&&$.search.loadMap()};$.search.loadMap=function(){$(".loc-result").each(function(){var ul=$(this).children("ul"),number=ul.attr("map-id"),content=$(this).find("div.restaurant-info").parent().html(),lat=ul.attr("latitude"),lng=ul.attr("longitude");$.gmap.addMarker(content,number,lat,lng)});$.search._mapLoaded=true};$.search.toggleMap=function(){$("#results").toggleClass("listview").toggleClass("mapview");$.search.bindMap()};$.search.bindUi=function(){$("#find-button").live("click",function(){$.search.search()});$("button.participate-button").live("click",function(){var p=$(this).parents("div.opt-in-dialog"),id=p.find("#opt-in-id").val(),email=p.find("#opt-in-email").val(),part=p.find("#opt-in-participate").is(":checked"),emailPattern=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/,isValid=emailPattern.test(email);if(!isValid){var v=p.find(".participate-valid");v.html("You have to put in your email address!");v.show();return}if(!part){var v=p.find(".participate-valid");v.html("You have to check the box!");v.show();return}var data={id:id,email:email,participate:part};$.ajax({url:$.search.optInUrl,type:"POST",data:data,success:function(r){var cb=$("#alert-"+id);if(part)cb.attr("checked","checked");else cb.removeAttr("checked");cb.parent().html("Thanks, we'll let you know!");p.dialog("close")},error:function(xhr,txt){$.search.handlerError(xhr,txt)}})});$(".alert-me-link").live("click",function(event){var x=event.pageX-370,y=event.pageY-65,d=$("#alert-me-dialog").clone();d.attr("id","#active-alert-me-dialog");d.dialog({modal:true,resizable:false,width:380,position:[x,y],close:function(event,ui){$(this).dialog("destroy")}});$(".ui-dialog-titlebar").hide();$(".ui-widget-overlay").live("click",function(){d.dialog("close");d.remove()});$(".ui-dialog").css({top:y,left:x});return false});$("input.alert-checkbox").live("click",function(event){var cb=$(this);if(cb.is(":checked"))cb.removeAttr("checked");else cb.attr("checked","checked");var d=$(this).parent().find(".opt-in-dialog").clone();d.dialog({modal:true,resizable:false,width:360,minHeight:220,position:[event.pageX-260,event.pageY-310],close:function(event,ui){$(this).dialog("destroy")}});$(".ui-dialog-titlebar").hide();$(".ui-widget-overlay").live("click",function(){d.dialog("close");d.remove()})})};$.search.rebindUi=function(){$.search.bindUi();$.search.bindMap();$.search.bindResults()};$.search.showLoading=function(){$("#search-results").block({message:"loading...",fadeId:100,fadeOut:100,css:{border:"none",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px",opacity:.5,color:"#fff"},overlayCSS:{backgroundColor:"#B3B3B3"}})};$.search.hideLoading=function(){$("#search-results").unblock().css("position","")};$.search.bindResults=function(){$(".loc-result").each(function(){var ul=$(this).children("ul"),lat=ul.attr("latitude"),lng=ul.attr("longitude"),locId=ul.attr("map-id"),func=function(event){$.search.showRestaurantInfo($("#popup-"+locId),event);$.gmap.centerMap(lat,lng);return false};$(this).find(".pin,.distance,.address,.phone,.logo").live("click",func);if($(this).is(".location-parent")){var parents=$(this).parents(".basicinfo");parents.find(".name").bind("click",func);parents.siblings(".logo-button").find("img").bind("click",func)}})};$.search.showPreviousOrderDetail=function(popup){var position=popup.parents(".loc-result").offset(),x=position.left+375,y=position.top-175,ri=popup.clone().dialog({modal:true,resizable:false,stack:false,width:365,minHeight:365,position:[x,y]});$(".ui-dialog-titlebar").hide();$(".ui-widget-overlay").live("click",function(){ri.dialog("close");ri.remove()})};$.search.showRestaurantInfo=function(popup){var restId=popup.find("#info-rest-id").val(),cId=popup.find("#info-concept-id").val(),suppl=popup.find("#info-suppl").val(),position=popup.parents(".loc-result").offset(),x=position.left+375,y=position.top-175,ri=popup.clone().dialog({modal:true,resizable:false,stack:false,width:365,minHeight:365,position:[x,y]});$(".ui-dialog-titlebar").hide();$(".ui-widget-overlay").live("click",function(){ri.dialog("close");ri.remove()});$.ajax({url:$.search.restaurantInfoUrl,type:"POST",data:{restaurantId:restId,conceptId:cId,supplemental:suppl},success:function(r){ri.find("#additional-info").html(r)},error:function(xhr,txt){$.search.handlerError(xhr,txt)}});$(".ui-dialog").css({top:y,left:x})};$.search.handlerError=function(xhr,txt){alert("Error during ajax call has been occured: "+txt)};$.search.bind=function(){$.gmap.dispose();$.search.dispose();$.search.bindUi();$.search.bindMap();$.search.bindResults()};$.search.rebind=function(){$.gmap.dispose();$.search.dispose();$.search.bindMap();$.search.rebindUi()}})(jQuery);(function($){$.geo={locator:null,location:null};$.geo.init=function(){if($.geo.locator==null)$.geo.locator=new google.maps.Geocoder};$.geo.locate=function(address){$.geo.init();$.geo.locator.geocode({address:address},function(response,status){if(status==google.maps.GeocoderStatus.OK){$.geo.location=response[0];return true}else{$.geo.location=null;return false}});return $.geo.location};$.geo.bindUI=function(form){form.submit(function(e){var address=form.find("#location-text-input").val();if(form.data("LastAddress")==address)return form.data("IsValid");form.data("LastAddress",address);$.geo.init();$.geo.locator.geocode({address:address},function(response,status){if(status==google.maps.GeocoderStatus.OK){$("#invalid-location-msg").hide();var loc=response[0];form.data("IsValid",true);form.find("#Criteria").val(loc.geometry.location.toString());form.find("#location-text-input").val("#location-text-input").val(loc.formatted_address.replace(", USA",""));form.submit()}else{form.data("IsValid",false);$("#invalid-location-msg").show()}});return false})}})(jQuery);(function($){$.orders={};$.orders.filter=function(id,url){$.search.showLoading();$(id).load(url,function(){$.search.hideLoading()})};$.orders.showDetails=function(popup){var orderId=popup.find("#info-order-id").val(),position=popup.parents(".loc-result").offset(),x=position.left+375,y=position.top-175,ri=popup.clone().dialog({modal:true,resizable:false,stack:false,width:365,minHeight:365,position:[x,y]});$(".ui-dialog-titlebar").hide();$(".ui-widget-overlay").live("click",function(){ri.dialog("close");ri.remove()});$(".ui-dialog").css({top:y,left:x});return ri}})(jQuery);var StyledIconTypes={},StyledMarker,StyledIcon;(function(){var bu_="http://chart.apis.google.com/chart?chst=",gm_=google.maps,gp_=gm_.Point,ge_=gm_.event,gmi_=gm_.MarkerImage;StyledMarker=function(styledMarkerOptions){var me=this,ci=me.styleIcon=styledMarkerOptions.styleIcon;me.bindTo("icon",ci);me.bindTo("shadow",ci);me.bindTo("shape",ci);me.setOptions(styledMarkerOptions)};StyledMarker.prototype=new gm_.Marker;StyledIcon=function(styledIconType,styledIconOptions,styleClass){var k,me=this,i_="icon",sw_="shadow",s_="shape",a_=[];function gs_(){var image_=document.createElement("img"),simage_=document.createElement("img");ge_.addDomListenerOnce(simage_,"load",function(){var w=simage_.width,h=simage_.height;me.set(sw_,new gmi_(styledIconType.getShadowURL(me),null,null,styledIconType.getShadowAnchor(me,w,h)));simage=null});ge_.addDomListenerOnce(image_,"load",function(){var w=image_.width,h=image_.height;me.set(i_,new gmi_(styledIconType.getURL(me),null,null,styledIconType.getAnchor(me,w,h)));me.set(s_,styledIconType.getShape(me,w,h));image_=null});image_.src=styledIconType.getURL(me);simage_.src=styledIconType.getShadowURL(me)}me.as_=function(v){a_.push(v);for(k in styledIconOptions)v.set(k,styledIconOptions[k])};if(styledIconType!==StyledIconTypes.CLASS){for(k in styledIconType.defaults)me.set(k,styledIconType.defaults[k]);me.setValues(styledIconOptions);me.set(i_,styledIconType.getURL(me));me.set(sw_,styledIconType.getShadowURL(me));styleClass&&styleClass.as_(me);gs_();me.changed=function(k){k!==i_&&k!==s_&&k!==sw_&&gs_()}}else{me.setValues(styledIconOptions);me.changed=function(v){styledIconOptions[v]=me.get(v);for(k=0;k<a_.length;k++)a_[k].set(v,me.get(v))};styleClass&&styleClass.as_(me)}};StyledIcon.prototype=new gm_.MVCObject;StyledIconTypes.CLASS={};StyledIconTypes.MARKER={defaults:{text:"",color:"00ff00",fore:"000000",starcolor:null},getURL:function(props){var _url,starcolor_=props.get("starcolor"),text_=props.get("text"),color_=props.get("color").replace(/#/,""),fore_=props.get("fore").replace(/#/,"");if(starcolor_)_url=bu_+"d_map_xpin_letter&chld=pin_star|";else _url=bu_+"d_map_pin_letter&chld=";if(text_)text_=text_.substr(0,2);_url+=text_+"|";_url+=color_+"|";_url+=fore_;if(starcolor_)_url+="|"+starcolor_.replace(/#/,"");return _url},getShadowURL:function(props){if(props.get("starcolor"))return bu_+"d_map_xpin_shadow&chld=pin_star";else return bu_+"d_map_pin_shadow"},getAnchor:function(props,width,height){return new gp_(width/2,height)},getShadowAnchor:function(props,width,height){return new gp_(width/4,height)},getShape:function(props,width,height){var _iconmap={};_iconmap.coord=[width/2,height,7/16*width,5/8*height,5/16*width,7/16*height,7/32*width,5/16*height,5/16*width,1/8*height,1/2*width,0,11/16*width,1/8*height,25/32*width,5/16*height,11/16*width,7/16*height,9/16*width,5/8*height];for(var i=0;i<_iconmap.coord.length;i++)_iconmap.coord[i]=Math.round(_iconmap.coord[i]);_iconmap.type="poly";return _iconmap}};StyledIconTypes.BUBBLE={defaults:{text:"",color:"00ff00",fore:"000000"},getURL:function(props){var _url=bu_+"d_bubble_text_small&chld=bb|";_url+=props.get("text")+"|";_url+=props.get("color").replace(/#/,"")+"|";_url+=props.get("fore").replace(/#/,"");return _url},getShadowURL:function(props){return bu_+"d_bubble_text_small_shadow&chld=bb|"+props.get("text")},getAnchor:function(props,width,height){return new google.maps.Point(0,42)},getShadowAnchor:function(props,width,height){return new google.maps.Point(0,44)},getShape:function(props,width,height){var _iconmap={};_iconmap.coord=[0,44,13,26,13,6,17,1,width-4,1,width,6,width,21,width-4,26,21,26];_iconmap.type="poly";return _iconmap}}})()
