(function(c){var b={map:function(){return c(this).data("cabulous:googleMap")}};var a="";c.fn.cabulous=function(J){var j=this.get(0);if(typeof(b[J])==="function"){return b[J].apply(j)}var n;var E=false;var F=false;var y=false;var q="";if(typeof(J)=="object"){var B=J;if(B.center&&B.center.latitude&&B.center.longitude){n=new google.maps.LatLng(B.center.latitude,B.center.longitude)}if(B.show_search){E=B.show_search}if(B.show_live_cities){F=B.show_live_cities}if(B.show_companies){y=B.show_companies}if(B.company_filter){Cabulous.Shared.COMPANY_FILTER=B.company_filter}if(B.default_city){q=B.default_city}if(B.mode){if(B.mode=="dispatch"){Cabulous.Status.IS_DISPATCH=true}}if(B.events){Cabulous.Shared.Events=B.events}else{Cabulous.Shared.Events=[]}}var N=new google.maps.LatLng(37.7749,-122.4194);var v=N;n=n||v;var A={mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControl:false,zoom:12,center:n};if(!!c(j).data("cabulous:googleMap")){return this}var l=new google.maps.Map(j,A);Cabulous.Shared.MAP=l;c(j).data("cabulous:googleMap",l);function K(){c(j).append(Cabulous.Partials.controlOverlayUI());c("._cabulousControlContents").css("opacity","0.75");var W=c("._cabulousControlOverlay");c(W).attr("hidden",true);var R=true;var U=15;if(E){c("._cabulousControlContents").append(Cabulous.Partials.controlOverlaySearchUI());U+=29}if(F){c("._cabulousControlContents").append(Cabulous.Partials.controlOverlayContentsLiveCabCitiesUI());c("._cabulousCitiesSelectDiv").html(Cabulous.Partials.spinner());U+=29}var T=c("._cabulousControlContents div");c(T[0]).css("padding-top","11px");c(W).height(U);c(W).css("top","-"+U+"px");var P=null;function S(){if(P!=null){clearTimeout(P);P=null}}function V(){c.getJSON("/extend/get_cities_with_online_cabbie_count?show_entity_ids=true&filter="+Cabulous.Shared.COMPANY_FILTER,function(aa){var Y=c("._cabulousCitiesSelectDiv");c(Y).html("");c(Y).append("<select>");var Z=c("._cabulousCitiesSelectDiv select");c(Z).append("<option value=''>("+Cabulous.Language.select_a_city+")</option>");for(city in aa){var X=aa[city];c(Z).append("<option value='"+X+"'>"+city+"</option>")}c(Y).append("</select>");c(Z).change(function(){var ab=c(this).val();if(ab==""){return}D.askForCabsByEntity(ab,Cabulous.Shared.COMPANY_FILTER);Q()})})}c(W).mouseover(function(){S();if(R==true){R=false;V();c(W).animate({top:"0px"},500)}}).mouseout(function(){if(P==null){P=setTimeout(function(){Q()},2000)}});function Q(){c(W).animate({top:"-"+U+"px"},500,function(){R=true;c("._cabulousCitiesSelectDiv").html(Cabulous.Partials.spinner())})}c("#_cabulous_center_map_location").keydown(function(X){S();if(X.keyCode==13){c("#_cabulous_center_map_button").click()}});c("#_cabulous_center_map_button").click(function(){c("#_cabulous_wait2").css("visibility","visible");var X=c("#_cabulous_center_map_location").val();var Y=new google.maps.Geocoder();Y.geocode({address:X,bounds:l.getBounds()},function(ab,aa){if(ab.length>=1){var ac=ab[0].geometry.location.lat();var ad=ab[0].geometry.location.lng();var Z=new google.maps.LatLng(ac,ad);l.setCenter(Z);l.setZoom(15);Q()}else{alert("Unable to find "+X)}c("#_cabulous_wait2").css("visibility","hidden")})})}if(E||F){K()}c(j).append(Cabulous.Partials.loadingUI());c("._cabulousLoadingDiv ._cabulousLoadingOpaque").css("opacity","0.75");var D=new Cabulous.Connection(j);Cabulous.Shared.CONNECTION=D.stropheConnection;Cabulous.Shared.CABULOUS_CONNECTION=D;function r(){var Q=l.getCenter();var P={northLatitude:l.getBounds().getNorthEast().lat(),eastLongitude:l.getBounds().getNorthEast().lng(),southLatitude:l.getBounds().getSouthWest().lat(),westLongitude:l.getBounds().getSouthWest().lng()};D.listenWithinBounds(P)}var u=r;setInterval(r,15000);google.maps.event.addListener(l,"idle",r);var x=new Array();var g=null;function k(){var Q=c(".hailForm :input[name=hail[pickup_location]]").val();var S=c(".hailForm :input[name=hail[phone_number]]").val();if(S==""){S=a}a=S;if(Q==""){e.setContent(Cabulous.Partials.noResultsFoundUI("empty address"));return}else{if(a==""){e.setContent(Cabulous.Partials.noResultsFoundUI("empty phone"));return}}function P(U,T){if(U.length>=1){var V=new Object();V.country_code=c(".hailForm :input[name='hail[country_code]']   ").val();V.phone_number=S;V.password=c(".hailForm :input[name='hail[password]']       ").val();V.notes_to_driver=c(".hailForm :input[name='hail[notes_to_driver]']").val();V.cab_jid=c(".hailForm :input[name='hail[cab_jid]']        ").val();V.pickup_location=U[0].formatted_address;V.latitude=U[0].geometry.location.lat();V.longitude=U[0].geometry.location.lng();e.setContent(Cabulous.Partials.confirmationFormUI(V))}else{e.setContent(Cabulous.Partials.noResultsFoundUI(Q))}}var R=new google.maps.Geocoder();R.geocode({address:Q,bounds:l.getBounds()},P)}function M(P){e.setContent(Cabulous.Partials.tooFarFormUI());c(".tooFarPhone").html(Cabulous.Status.HAILING_CAB_PHONE);c(".tooFarHail").click(function(){P()})}function f(Q,U){function T(Y){return c(U).find(":input[name='hail["+Y+"]']").val()}L();var S=T("country_code");var X=T("phone_number");var W=T("password");var P={cab_jid:T("cab_jid"),latitude:T("latitude"),longitude:T("longitude"),pickup_location:T("pickup_location"),notes_to_driver:T("notes_to_driver"),country_code:S,phone_number:X,password:W};function V(){var Z=new google.maps.LatLng(parseFloat(T("latitude")),parseFloat(T("longitude")));if(g!=null){g.setPosition(Z);g.setTitle(T("pickup_location"))}else{var Y=new google.maps.Marker({position:Z,map:l,title:T("pickup_location"),icon:"http://cabulous.com/images/cabulous-man-med.png"});g=Y}function ab(ae,aj,ad,ah){var ag=(ae<ad)?ae:ad;var ai=(aj<ah)?aj:ah;var ak=(ae>ad)?ae:ad;var al=(aj>ah)?aj:ah;var ac=new google.maps.LatLng(ag,ai);var af=new google.maps.LatLng(ak,al);l.fitBounds(new google.maps.LatLngBounds(ac,af))}var aa=x[H(Cabulous.Status.HAILING_CAB_JID)];if(aa!=undefined){ab(Z.lat(),Z.lng(),aa.position.lat(),aa.position.lng())}}V();function R(Y,Z){if(Z.validPassword){P.passenger_jid=Z.passenger_jid;c(j).unbind(Cabulous.Event.AUTHENTICATION_SUCCESS);c(j).bind(Cabulous.Event.AUTHENTICATION_SUCCESS,function(){C(P)});D.reconnectAsJid(P.passenger_jid,P.password)}else{I()}}c(j).unbind(Cabulous.Event.EXISTENT_ACCOUNT_FOUND);c(j).bind(Cabulous.Event.EXISTENT_ACCOUNT_FOUND,R);c(j).unbind(Cabulous.Event.ALREADY_LOGGED_IN);c(j).bind(Cabulous.Event.ALREADY_LOGGED_IN,function(Y){C(P)});c(j).unbind(Cabulous.Event.NEW_ACCOUNT_CREATED);c(j).bind(Cabulous.Event.NEW_ACCOUNT_CREATED,function(){C(P)});c(j).bind(Cabulous.Event.HAIL_ACCEPTED,function(){d();z(Cabulous.Shared.LAST_CAB_CLICKED);if(Cabulous.Shared.Events.on_accept!=""){c.get("/webapp/proxy.php?proxy_url="+Cabulous.Shared.Events.on_accept)}});c(j).bind(Cabulous.Event.HAIL_DECLINED,function(){o();u()});c(j).unbind(Cabulous.Event.HAIL_TIMEOUT);c(j).bind(Cabulous.Event.HAIL_TIMEOUT,function(){h();u()});c(j).unbind(Cabulous.Event.SESSION_ENDED);c(j).bind(Cabulous.Event.SESSION_ENDED,function(){if(Cabulous.Status.PASSENGER_CANCELLING==false){t()}else{O()}u()});c(j).unbind(Cabulous.Event.NOT_AVAILABLE);c(j).bind(Cabulous.Event.NOT_AVAILABLE,function(){m();u()});c(j).unbind(Cabulous.Event.CLEAR_CABS_FOR_SESSION);c(j).bind(Cabulous.Event.CLEAR_CABS_FOR_SESSION,function(){var Y=[];for(var aa in x){Y.push(aa)}for(var Z=0;Z<Y.length;Z++){var ab=x[0];if(ab.jid==Cabulous.Status.HAILING_CAB_JID){var ac=x.shift();x.push(ac)}else{c(j).trigger(Cabulous.Event.CAB_REMOVED,{jid:ab.jid})}}u()});D.signInOrSignUp(S,X,W)}function C(P){Cabulous.Status.LOGGED_IN=true;D.hail(P.cab_jid,P.latitude,P.longitude,P.pickup_location,P.notes_to_driver)}function L(){Cabulous.Status.MODE="hail";e.setContent(Cabulous.Partials.hailingScreen())}function d(){Cabulous.Status.MODE="posthail";e.setContent(Cabulous.Partials.hailSuccessPartial());var P=e.getContent();c(P).find("._cabulousEndPickup").bind("click",function(){if(confirm(Cabulous.Language.end_pickup_confirm)){c(P).find("._cabulousEndPickup").unbind("click");D.cancelHail(Cabulous.Status.SESSION_ID)}else{}})}function o(){Cabulous.Status.MODE="prehail";e.setContent(Cabulous.Partials.hailFailPartial())}function h(){Cabulous.Status.MODE="prehail";e.close();alert(Cabulous.Language.cab_timeout)}function t(){Cabulous.Status.MODE="prehail";alert(Cabulous.Language.cab_ended_pickup);var P=e.getContent();c(P).unbind("click");c(P).find("._cabulousEndPickup").css("display","none")}function O(){Cabulous.Status.MODE="prehail";Cabulous.Status.PASSENGER_CANCELLING=false;alert(Cabulous.Language.successful_end);var P=e.getContent();c(P).unbind("click");c(P).find("._cabulousEndPickup").css("display","none")}function I(){Cabulous.Status.MODE="prehail";e.close();alert("We were unable to log you in using this phone number and password.  If you would like to reset your password please call us at 1-415-683-7401.  Thank you!")}function m(){Cabulous.Status.MODE="prehail";e.close();var P=H(Cabulous.Status.HAILING_CAB_JID);if(P==-1){alert(Cabulous.Language.cab_oops)}else{alert(Cabulous.Language.cab_too_far)}}var e;var z=function(T){Cabulous.Shared.LAST_CAB_CLICKED=T;var Q=H(T.jid);var P=x[Q];if(e){e.close()}var S={cab:T};S.country_code=S.country_code||"1";S.phone="";S.password="";S.pickup="";S.note="";var R=new google.maps.InfoWindow();e=R;Cabulous.Shared.INFO_WINDOW=R;if(Cabulous.Status.MODE=="prehail"){if(Cabulous.Status.IS_DISPATCH==false){R.setContent(Cabulous.Partials.initialHailingFormUI(S));google.maps.event.addListener(R,"domready",function(){var V=R.getContent();c(V).find(".hailForm").bind("submit",function(){var W=c(V).find(".hailForm");S.country_code=W.find("#hail_country_code").val();S.phone=W.find("#hail_phone_number").val();S.password=W.find("#hail_password").val();S.pickup=W.find("#hail_pickup_location").val();S.note=W.find("#hail_notes").val();k(R)});c(V).find(".pickupConfirmationForm").bind("submit",function(){var X=this;Cabulous.Status.HAILING_CAB_PHONE=T.phone;Cabulous.Status.HAILING_CAB_JID=T.jid;var ab=function(){f(R,X)};var W=parseFloat(c(this).find(":input[name='hail[latitude]']").val());var aa=parseFloat(c(this).find(":input[name='hail[longitude]']").val());var ac=parseFloat(T.latitude);var Z=parseFloat(T.longitude);var Y=findDistance(W,aa,ac,Z);if(Y>Cabulous.Shared.MAX_HAIL_DISTANCE){M(function(){ab()})}else{ab()}});c(V).find(".noButton").bind("click",function(){e.setContent(Cabulous.Partials.initialHailingFormUI(S))})})}else{dispatchShowBubble(P,R,S)}}else{if(Cabulous.Status.MODE=="hail"){R.setContent(Cabulous.Partials.hailingScreen())}else{if(Cabulous.Status.MODE=="posthail"){d()}}}R.open(P.getMap(),P);function U(){if(e){e.close();Cabulous.Shared.LAST_CAB_CLICKED=null}}google.maps.event.clearListeners(l,"click");google.maps.event.addListener(l,"click",U)};function s(T,V){var W=new google.maps.LatLng(parseFloat(V.latitude)-0.00005,parseFloat(V.longitude));var R=H(V.jid);var U=(V.from_presence)?V.from_presence:false;var P=function(X){if(Cabulous.Status.IS_DISPATCH&&U==false){var Z="green";var aa=V.id.replace(/ /gi,"");var Y=4-aa.length;for(var ab=0;ab<Y;ab++){aa="0"+aa}if(V.is_private=="true"){Z="red"}X.setIcon("http://cabulous.com/webapp/cab_img.php?number="+aa+"&color="+Z);c(X).data("is_private",V.is_private)}};if(R>-1){var S=x[R].getPosition();if(Math.abs(S.lat()-W.lat())>0.0001||Math.abs(S.lng()-W.lng())>0.0001){x[R].setPosition(W)}P(x[R])}else{if(U==false){var Q=new google.maps.Marker({position:W,map:l,title:V.title||"",icon:"http://cabulous.com/images/cab_"+V.image+".png"});Q.jid=V.jid;P(Q);x.push(Q);google.maps.event.addListener(Q,"click",function(){z(V)})}}}Cabulous.Shared.openHailingWindowOnMarker=z;function w(R,S){var P=H(S.jid);if(P>-1){var Q=x[P];google.maps.event.clearListeners(Q,"click");Q.setMap(null);x.splice(P,1)}}function G(R,V){var U=V.split(",");var T=new Array();function P(X){for(var W=0;W<U.length;W++){if(X==U[W]){return true}}return false}for(var Q=0;Q<x.length;Q++){var S=x[Q];if(P(S.jid)==false){T.push(S.jid)}}for(var Q=0;Q<T.length;Q++){c(j).trigger(Cabulous.Event.CAB_REMOVED,{jid:T[Q]})}}c(j).bind(Cabulous.Event.CAB_UPDATE,s);c(j).bind(Cabulous.Event.CAB_REMOVED,w);c(j).bind(Cabulous.Event.RECEIVED_JIDS,G);c(j).unbind(Cabulous.Event.AUTO_ZOOM);c(j).bind(Cabulous.Event.AUTO_ZOOM,function(){var V=10000;var R=10000;var W=-10000;var T=-10000;if(x.length>0){for(var S=0;S<x.length;S++){var Q=x[S];if(Q.position.lat()<V){V=Q.position.lat()}if(Q.position.lng()<R){R=Q.position.lng()}if(Q.position.lat()>W){W=Q.position.lat()}if(Q.position.lng()>T){T=Q.position.lng()}}if(x.length==1){V-=0.003;R-=0.003;W+=0.003;T+=0.003}var P=new google.maps.LatLng(V,R);var U=new google.maps.LatLng(W,T);l.fitBounds(new google.maps.LatLngBounds(P,U))}else{if(q!=""){D.askForCabsByEntity(q,Cabulous.Shared.COMPANY_FILTER);q=""}}});function H(P){for(i in x){if(x[i].jid==P){return i}}return -1}c(j).unbind(Cabulous.Event.DISCONNECTED);c(j).bind(Cabulous.Event.DISCONNECTED,function(){var R=x.length;for(var Q=0;Q<R;Q++){var P=x.shift();P.setMap(null);google.maps.event.clearListeners(P,"click")}});return this}})(jQuery);var Rm=3961;var Rk=6373;function findDistance(x,n,e,r){var m,k,l,j,h,v,f,t,g,b,w,u,o,q,s,d;m=x;k=n;l=e;j=r;h=deg2rad(m);v=deg2rad(k);f=deg2rad(l);t=deg2rad(j);g=f-h;b=t-v;w=Math.pow(Math.sin(g/2),2)+Math.cos(h)*Math.cos(f)*Math.pow(Math.sin(b/2),2);u=2*Math.atan2(Math.sqrt(w),Math.sqrt(1-w));o=u*Rm;q=u*Rk;s=round(o);d=round(q);return s}function deg2rad(a){rad=a*Math.PI/180;return rad}function round(a){return Math.round(a*1000)/1000}Cabulous={Event:{CAB_UPDATE:"cabulous:cab_update",AUTO_ZOOM:"cabulous:auto_zoom",CAB_REMOVED:"cabulous:cab_removed",RECEIVED_JIDS:"cabulous:received_jids",HAIL_ACCEPTED:"cabulous:hail_accepted",HAIL_DECLINED:"cabulous:hail_declined",HAIL_TIMEOUT:"cabulous:hail_timeout",NEW_ACCOUNT_CREATED:"cabulous:new_account_created_from_guest_jid",EXISTENT_ACCOUNT_FOUND:"cabulous:existent_account_found",AUTHENTICATION_SUCCESS:"cabulous:authentication_success",DISCONNECTED:"cabulous:disconnected",ALREADY_LOGGED_IN:"cabulous:already_logged_in",NOT_AVAILABLE:"cabulous:not_available",SESSION_ENDED:"cabulous:session_ended",CLEAR_CABS_FOR_SESSION:"cabulous:clear_cabs_for_session"},Status:{LOGGED_IN:false,HAILING_CAB_PHONE:"",HAILING_CAB_JID:"",MODE:"prehail",SESSION_ID:"",PASSENGER_CANCELLING:false,IS_REFRESHING:false,AUTO_ZOOM_REFRESH:false,IS_DISPATCH:false,PASSENGER_JID:null,PASSENGER_PASS:null},Shared:{CONNECTION:null,MAP:null,INFO_WINDOW:null,COMPANY_FILTER:"",MAX_HAIL_DISTANCE:15}};Cabulous.Connection=function(a){this.mapElement=a;this.stropheConnection=Cabulous.ConnectionFactory.createConnection();this.eventDispatcher=new EventDispatcher(this.mapElement)};Cabulous.Connection.prototype.askForNewListOfCabs=function(b){var a=Cabulous.QueryBuilder.buildGetNearbyCabbies(b);this.stropheConnection.send(a);Cabulous.Status.IS_REFRESHING=true};Cabulous.Connection.prototype.askForCabsByEntity=function(b,a){var c=Cabulous.QueryBuilder.buildGetCabsByEntity(b,a);this.stropheConnection.send(c)};Cabulous.Connection.prototype.handleAuthenticatedConnection=function(a){var b=this;if(a==Strophe.Status.CONNECTED||a==Strophe.Status.ATTACHED){if(Cabulous.Status.IS_DISPATCH){addDispatchHandlers();Cabulous.Dispatch.Queue.start();syncQueue()}b.askForNewListOfCabs(b.savedBounds)}else{if(a==Strophe.Status.CONNFAIL||a==Strophe.Status.AUTHFAIL||a==Strophe.Status.ERROR){if(Cabulous.Status.PASSENGER_JID==null){b.stropheConnection.disconnect();b.reconnectFunction=function(){b.getConnected()}}}else{if(a==Strophe.Status.DISCONNECTED){b.connected=false;if(b.reconnectFunction!=undefined){b.reconnectFunction();b.reconnectFunction=undefined}}}}};Cabulous.Connection.prototype.getConnected=function(){var a=this;Cabulous.Connection.Utils.proxyStropheEvents(a.stropheConnection,a.eventDispatcher);if(Cabulous.Status.IS_DISPATCH==false){if(Cabulous.Status.PASSENGER_JID!=null){a.authenticate(Cabulous.Status.PASSENGER_JID,Cabulous.Status.PASSENGER_PASS)}else{a.connectAsGuest()}}else{a.eventDispatcher.trigger(Cabulous.Event.DISCONNECTED);a.getDispatchInfoAndLogin()}this.connected=true};Cabulous.Connection.prototype.listenWithinBounds=function(b){var a=this;if(this.connected){a.askForNewListOfCabs(b)}else{a.savedBounds=b;a.getConnected()}};Cabulous.Connection.prototype.connectAsGuest=function(){var a=this;$.get("/http-prebind/webapp_guest",function(c){var b=c.split("\n");a.stropheConnection.attach(b[0],b[1],b[2],function(d){a.handleAuthenticatedConnection(d)})})};Cabulous.Connection.prototype.getDispatchInfoAndLogin=function(){var b=this;var a=new Date();$.getJSON("/extend/get_dispatch_info?"+a.getTime(),function(c){initDispatch(c,function(){Cabulous.Dispatch.BOX_IDS="row"+c.jid;var d="dispatch"+a.getTime();Cabulous.Dispatch.RESOURCE=d;$.get("/http-prebind/dispatch/"+c.jid+"/"+d+"/"+c.key,function(f){var e=f.split("\n");b.stropheConnection.attach(e[0],e[1],e[2],function(g){b.handleAuthenticatedConnection(g)})})})})};Cabulous.Connection.prototype.signInOrSignUp=function(b,a,c){this.stropheConnection.send(Cabulous.QueryBuilder.registerGuestAsUser(b,a,c))};Cabulous.Connection.prototype.hail=function(d,e,b,f,a){var c=Cabulous.QueryBuilder.buildAttemptSession(d,e,b,f,a);this.stropheConnection.send(c)};Cabulous.Connection.prototype.dispatchHail=function(f,d,e,g,a,j,b,c){var h=Cabulous.QueryBuilder.buildAttemptDispatchSession(f,d,e,g,a,j,b,c);this.stropheConnection.send(h)};Cabulous.Connection.prototype.cancelHail=function(b){var a=Cabulous.QueryBuilder.buildCancelHail(b);Cabulous.Status.PASSENGER_CANCELLING=true;this.stropheConnection.send(a)};Cabulous.Connection.prototype.reconnectAsJid=function(c,b){var a=this;Cabulous.Status.PASSENGER_JID=c;Cabulous.Status.PASSENGER_PASS=b;a.reconnectFunction=function(){a.stropheConnection=Cabulous.ConnectionFactory.createConnection();a.getConnected()};a.stropheConnection.disconnect()};Cabulous.Connection.prototype.authenticate=function(c,b){var a=this;a.authReceivedResponse=false;var d=function(){a.authAttempt=$.ajax({type:"GET",url:"/http-prebind/webapp/"+c+"/webapp/"+b,success:function(f){a.authReceivedResponse=true;clearInterval(a.attemptCheckInterval);var e=f.split("\n");a.stropheConnection.attach(e[0],e[1],e[2],function(g){var h=0;if(g==Strophe.Status.ATTACHED){a.eventDispatcher.trigger(Cabulous.Event.AUTHENTICATION_SUCCESS)}else{if(g==Strophe.Status.CONNFAIL||g==Strophe.Status.AUTHFAIL||g==Strophe.Status.ERROR){setTimeout(function(){a.authenticate(c,b)},500)}}})},error:function(f,e){setTimeout(function(){a.authenticate(c,b)},500)}})};d();a.attemptCheckInterval=setInterval(function(){if(a.authReceivedResponse==false){a.authAttempt.abort();d()}},3000)};Cabulous.Connection.prototype.getCompaniesForCity=function(b){var a=Cabulous.QueryBuilder.buildCabulousQueryForCompanies(b);this.stropheConnection.send(a)};Cabulous.Connection.Utils={};Cabulous.Connection.Utils.proxyStropheEvents=function(c,a){function b(d){var e=$(d).find("type").text();var g=($(d).find("not-a-guest").length===1);if(g){a.trigger(Cabulous.Event.ALREADY_LOGGED_IN)}else{if(e==="existent_account"){var f={passenger_jid:$(d).find("jid").text(),validPassword:($(d).find("valid_password").text()==="true")};a.trigger(Cabulous.Event.EXISTENT_ACCOUNT_FOUND,f)}else{if(e==="new_account"){a.trigger(Cabulous.Event.NEW_ACCOUNT_CREATED)}}}return true}c.addHandler($.proxy(a,"triggerCabUpdatesForEachItem"),null,"iq","result","get_nearby_cabbies","localhost");c.addHandler($.proxy(a,"triggerEntityGetResult"),null,"iq","result","get_entity_cabbies","localhost");c.addHandler($.proxy(a,"triggerCabUpdateForPresence"),"jabber:iq:cabbie:update","presence",null,null,"localhost");c.addHandler($.proxy(a,"triggerItemUpdateForPresence"),null,"presence",null,"item_presence",null,null,"localhost");c.addHandler($.proxy(a,"triggerCabRemovedForPresence"),null,"presence",null,"goodbye_cabbie","localhost");c.addHandler($.proxy(a,"triggerHailAccepted"),null,"iq",null,"hail_accepted","localhost");c.addHandler($.proxy(a,"triggerHailDeclined"),null,"iq",null,"other_party_canceled","localhost");c.addHandler($.proxy(a,"triggerHailTimeout"),null,"iq",null,"session_hail_timeout","localhost");c.addHandler(b,null,"iq",null,"convert_guest","localhost");c.addHandler($.proxy(a,"triggerSessionEnded"),null,"iq",null,"end_session","localhost");c.addHandler($.proxy(a,"triggerAttemptSession"),null,"iq",null,"attempt_session","localhost");c.addHandler($.proxy(a,"triggerCabulousQueryCompanies"),null,"iq","result","companies_query","localhost")};Cabulous.ConnectionFactory={createJidConnection:function createJidConnection(){return new Strophe.Connection("/http-bind/")},createConnection:function createConnection(){return new Strophe.Connection("/http-bind/")}};Cabulous.QueryBuilder={buildGetNearbyCabbies:function(a){return $iq({id:"get_nearby_cabbies",type:"get",to:"localhost"}).c("query",{xmlns:"jabber:iq:public:presence:get"}).c("options",{hailing_nearest:"false",including_outside:"false"}).up().c("filter",{company:Cabulous.Shared.COMPANY_FILTER}).up().c("upper_left").t(a.southLatitude+","+a.westLongitude).up().c("lower_right").t(a.northLatitude+","+a.eastLongitude).tree()},buildGetCabsByEntity:function(b,a){return $iq({id:"get_entity_cabbies",type:"get",to:"localhost"}).c("query",{xmlns:"jabber:iq:entity:get"}).c("parameters",{entity_id:b,filter:a}).tree()},buildRegisterGuest:function(){return $iq({id:"register_guest",type:"set",to:"localhost"}).c("query",{xmlns:"jabber:iq:register:cabulous"}).c("username").t("guest").up().c("password").t("random").up().c("device").t("webapp").tree()},registerGuestAsUser:function(b,a,c){return $iq({to:"localhost",type:"set",id:"convert_guest"}).c("query",{xmlns:"jabber:iq:register:cabulous"}).c("password").t(c).up().c("role").t("user").up().c("phone").t(a).up().c("cc").t(b).tree()},buildAttemptSession:function(b,e,c,d,a){return $iq({to:"localhost",type:"set",id:"attempt_session"}).c("query",{xmlns:"jabber:iq:cabulous:session"}).c("for").t(b).up().c("location",{latitude:e,longitude:c,is_using_gps:0,start:d,end:a}).tree()},buildAttemptDispatchSession:function(h,d,e,c,g,b,a,f){return $iq({to:"localhost",type:"set",id:"attempt_session"+f}).c("query",{xmlns:"jabber:iq:cabulous:session"}).c("queue_item_id").t(h).up().c("for").t(d).up().c("location",{latitude:e,longitude:c,is_using_gps:0,start:g,end:b}).up().c("dispatch",{passenger_phone:a}).tree()},buildCancelHail:function(a){return $iq({to:"localhost",type:"set",id:"end_session"}).c("query",{xmlns:"jabber:iq:cabulous:session"}).c("session").t(a).up()},buildDispatchCancelHail:function(b,a){if(a=="hailing"){return Cabulous.QueryBuilder.buildCancelUnacceptedHail(b)}else{return Cabulous.QueryBuilder.buildCancelHail(b)}},buildCancelUnacceptedHail:function(a){return $iq({to:"localhost",type:"set",id:"user_cancel_session"}).c("query",{xmlns:"jabber:iq:cabulous:session"}).c("session_id").t(a).up()},buildCabulousQueryForCompanies:function(a){return $iq({to:"localhost",type:"set",id:"companies_query"}).c("query",{xmlns:"jabber:iq:cabulous:query"}).c("type").t("company").up().c("q",{field:"city"}).t(a).up().c("sort").t("true").up().c("online").t("true").up()},buildCreateNewQueue:function(a){return $iq({to:"localhost",type:"set",id:"create_new_queue"}).c("query",{xmlns:"jabber:iq:cabulous:queue"}).c("add_queue").c("name").t(a).up()},buildRegisterForQueue:function(a){return $iq({to:"localhost",type:"set",id:"register_for_queue"}).c("query",{xmlns:"jabber:iq:cabulous:queue"}).c("register").c("queue_id").t(a).up()},buildAddItemToQueue:function(g,f,b,a,d,e,c){return $iq({to:"localhost",type:"set",id:g}).c("query",{xmlns:"jabber:iq:cabulous:queue"}).c("add_item").c("queue_id").t(f).up().c("passenger_address").t(b).up().c("passenger_phone").t(a).up().c("note").t(d).up().c("passenger_lat").t(e).up().c("passenger_lng").t(c).up()},buildDeleteItemFromQueue:function(b,a){return $iq({to:"localhost",type:"set",id:b}).c("query",{xmlns:"jabber:iq:cabulous:queue"}).c("remove_item").c("item_id").t(a).up()},buildUpdateItemInQueue:function(d,b,c,a){return $iq({to:"localhost",type:"set",id:d}).c("query",{xmlns:"jabber:iq:cabulous:queue"}).c("update_item").c("item_id").t(b).up().c(c).t(a).up()},buildEditItemInQueue:function(c,b,a){return $iq({to:"localhost",type:"set",id:c}).c("query",{xmlns:"jabber:iq:cabulous:queue"}).c("update_item").c("item_id").t(b).up().c("passenger_address").t(a.passenger_address).up().c("passenger_phone").t(a.passenger_phone).up().c("passenger_lat").t(a.passenger_lat).up().c("passenger_lng").t(a.passenger_lng).up().c("note").t(a.note).up()},buildGetPageInHistory:function(d,c,b,a){return $iq({to:"localhost",type:"get",id:"get_history"}).c("query",{xmlns:"jabber:iq:cabulous:queue"}).c("from").t(d).up().c("to").t(c).up().c("page").t(b).up().c("page_size").t(a).up()},buildGetAutoHailCabbies:function(b,c,d,a){return $iq({to:"localhost",type:"get",id:b}).c("query",{xmlns:"jabber:iq:autohail:cabbies:get"}).c("info").c("lat").t(d).up().c("lng").t(a).up().c("dispatch_id").t(c).up()}};(function(){Cabulous.Partials={};Cabulous.Partials.Styles={};var a=["font-family : Arial,Helvetica,sans-serif;","font-size : 12px;","color : #000;","text-align: left;","float: none;"];Cabulous.Partials.Styles.loadingPartialStyle=["position: absolute;","width: 100%;","height: 100%;","background-color: #000;","z-index: 100;","display: block;"].concat(a).join(" ");Cabulous.Partials.Styles.loadingPartialText=a.concat(["position: absolute;","left: 50%;","margin-left: -40px;","top: 46%;","color: #ddd;","font-size: 18px;","z-index:101"]).join(" ");Cabulous.Partials.Styles.disconnectedPartialText=a.concat(["position: absolute;","left: 50%;","margin-left: -155px;","top: 38%;","color: #ddd;","font-size: 18px;","z-index:101;"]).join(" ");Cabulous.Partials.Styles.controlOverlayPartialStyle=a.concat(["position:absolute;","width:100%;","height:0px;","top:0px;","z-index:90;","display:block;",]).join(" ");Cabulous.Partials.Styles.controlContentsStyle=["position:absolute;","width:100%;","height:100%;","background-color:#000;","z-index:130;","display:block;",].concat(a).join(" ");Cabulous.Partials.Styles.controlOverlayLabel=a.concat(["font-size:15px;","color:#fff;","font-weight:normal;"]).join(" ");Cabulous.Partials.Styles.controlOverlayContentsDivStyle=a.concat(["padding-top:0px;","padding-left:20px;","padding-right:20px;","padding-bottom:7px;","color:#fff;","font-size:16px;","line-height:18px;"]).join(" ");Cabulous.Partials.Styles.infoContentStyle=["padding-bottom: 1em;","float: left;","width: 300px;"].concat(a).join(" ");Cabulous.Partials.Styles.hailFormStyle=["float: left;width:160px;"];Cabulous.Partials.Styles.cabbieName=["font-size: 14px;font-weight:bold;"];Cabulous.Partials.Styles.cabbieSubtitle=["color:#888;"];Cabulous.Partials.Styles.cabbiePhone=["color:#888;"];Cabulous.Partials.Styles.cabbieNotes=["color:#444;padding-top:5px;"];Cabulous.Partials.Styles.label=["display: block;color:#444;margin-top:5px;"];Cabulous.Partials.Styles.labelIcon=["padding-left:18px;margin-top:0;height:14px;padding-top:3px;"];Cabulous.Partials.Styles.p=["padding: 0;",].concat(a).join(" ");Cabulous.Partials.Styles.phoneInput=["width: 10em;"].concat(a).join(" ");Cabulous.Partials.Styles.countryCode=["width: 2em;","text-align: right;"].concat(a).join(" ");Cabulous.style=function(c){return Cabulous.Partials.Styles[c]};Jaml.register("loadingPartial",function(){div({style:"position:absolute;width:100%;height:100%;z-index:99;","class":"_cabulousLoadingDiv"},div({style:Cabulous.style("loadingPartialStyle"),"class":"_cabulousLoadingOpaque"}),div({style:Cabulous.style("loadingPartialText")},Cabulous.Language.loading+"..."),img({src:"http://cabulous.com/images/wait.gif",style:"position:absolute;left:50%; margin-left:-110px;top:47%;margin-top:20px;z-index:101;"}))});Jaml.register("disconnectedPartial",function(){div({style:"position:absolute;width:100%;height:100%;z-index:99;","class":"_cabulousDisconnectedDiv"},div({style:Cabulous.style("loadingPartialStyle"),"class":"_cabulousLoadingOpaque"}),div({style:Cabulous.style("disconnectedPartialText")},"Oops!  We've lost contact with the server.<br/>Please click below to reload the map."),input({type:"button",id:"_cabulousReloadButton",value:"Reload",style:"position:absolute;left:50%; margin-left:-30px;top:47%;margin-top:20px;z-index:101;"}))});Jaml.register("controlOverlayPartial",function(){div({style:Cabulous.style("controlOverlayPartialStyle"),"class":"_cabulousControlOverlay"},div({style:Cabulous.style("controlContentsStyle"),"class":"_cabulousControlContents"}),img({src:"http://cabulous.com/images/search2.png",style:"position:absolute;top:102%;left:50%;margin-left:-15px;","class":"_cabulousDownArrowBox"}))});Jaml.register("controlOverlayContentsSearch",function(){div({style:Cabulous.style("controlOverlayContentsDivStyle"),"class":"_cabulousControlOverlayContentsSearch"},label({"for":"_cabulous_center_map_location",style:Cabulous.style("controlOverlayLabel")+"float:none;"},Cabulous.Language.search_by_address+" "),input({type:"text",id:"_cabulous_center_map_location",style:"margin-left:5px;font-size:12px;width:295px;"}),input({type:"button",id:"_cabulous_center_map_button",style:"font-size:13px;width:70px;",value:Cabulous.Language.search}),img({src:"http://cabulous.com/images/wait2.gif",id:"_cabulous_wait2",style:"padding-left:10px;top:5px;visibility:hidden;"}))});Jaml.register("controlOverlayContentsLiveCabCities",function(){div({style:Cabulous.style("controlOverlayContentsDivStyle"),"class":"_cabulousControlOverlayContentsLiveCabCities"},label({"for":"_cabulousCitiesSelectDiv",style:Cabulous.style("controlOverlayLabel")+"float:left;padding-right:10px;"},Cabulous.Language.available_cabs_by_city),div({"class":"_cabulousCitiesSelectDiv",style:"padding:0;margin-top:0px;font-size:15px;"}))});Jaml.register("spinner",function(){img({src:"http://cabulous.com/images/wait2.gif",style:"padding-left:10px;top:5px;"})});Jaml.register("controlOverlayContentsCompanies",function(){div({style:Cabulous.style("controlOverlayContentsDivStyle"),"class":"_cabulousControlOverlayContentsCompanies"},label({"for":"_cabulousCompaniesDiv",style:"float:none;font-size:18px;color:#fff;font-weight:normal;"},"Display Cabs for Companies: "),div({style:"margin-top:7px;height:65px;overflow-y:auto;font-size:16px;","class":"_cabulousCompaniesDiv"}))});Jaml.register("initialHailingFormPartial",function(e){var d=Cabulous.Status.LOGGED_IN==true?"none":"block";if(decodeURIComponent(e.cab.id)!="0001"){var c=decodeURIComponent(e.cab.subtitle)+" #"+decodeURIComponent(e.cab.id)}else{var c=decodeURIComponent(e.cab.subtitle)}if(decodeURIComponent(unescape(e.cab.more_info))!=""){var f="Notes: "+decodeURIComponent(unescape(e.cab.more_info))}else{var f=""}div({style:Cabulous.style("infoContentStyle")},div({"class":"cabInfo",style:"margin-bottom: 1em; float:left;width:130px;min-height:110px;padding-right:5px;"},div({style:Cabulous.style("cabbieName")+"background:url(http://cabulous.com/images/cab_"+e.cab.image+".png) 0 -10px no-repeat;padding-left:33px;"},decodeURIComponent(e.cab.title)),div({style:Cabulous.style("cabbieSubtitle")},c),div({style:Cabulous.style("cabbiePhone")},decodeURIComponent(e.cab.phone)),div({style:Cabulous.style("cabbieNotes")},f)),div({style:Cabulous.style("hailFormStyle")},form({"class":"hailForm",onsubmit:"return false;"},label({"for":"hail_pickup_location",style:Cabulous.style("label")+Cabulous.style("labelIcon")+"background:url(/images/map.png) 0 0 no-repeat;"},Cabulous.Language.pickup_location),input({type:"text",id:"hail_pickup_location","class":"pickupLocation",style:"width:155px;",name:"hail[pickup_location]",value:e.pickup}),span({"class":"login_span",style:"display: "+d},label({"for":"hail_country_code",style:"display: none"},"Country Code"),label({"for":"hail_phone_number",style:Cabulous.style("label")+Cabulous.style("labelIcon")+"background:url(/images/phone.png) 0 0 no-repeat;"},Cabulous.Language.your_phone_number),input({type:"text",id:"hail_country_code",name:"hail[country_code]",value:e.country_code,style:Cabulous.style("countryCode")}),input({type:"text",id:"hail_phone_number",name:"hail[phone_number]",value:e.phone,style:Cabulous.style("phoneInput")}),input({type:"hidden",id:"hail_password",name:"hail[password]",value:e.password})),label({"for":"hail_notes","class":"forTextarea",style:Cabulous.style("label")+Cabulous.style("labelIcon")+"background:url(/images/pencil.png) 0 0 no-repeat;"},Cabulous.Language.note_for_driver),input({type:"text",id:"hail_notes","class":"note",style:"width:155px",name:"hail[notes_to_driver]",value:e.note}),input({type:"hidden",id:"cab_jid",name:"hail[cab_jid]"}),input({type:"submit","class":"submit",style:"float:right;",value:Cabulous.Language.lets_go}))))});Jaml.register("tooFarFormPartial",function(){div({style:Cabulous.style("infoContentStyle")},div(Cabulous.Language.too_far+" <span class='tooFarPhone'></span>"),p({style:Cabulous.style("p")},input({type:"button","class":"tooFarHail",value:Cabulous.Language.hail_a_cab})))});Jaml.register("confirmationFormPartial",function(c){div({style:Cabulous.style("infoContentStyle")},div({style:"font-size:14px;font-weight:bold;"},Cabulous.Language.please_verify_your_information),form({"class":"pickupConfirmationForm",onsubmit:"return false;"},div({style:Cabulous.style("labelIcon")+"background:url(/images/map.png) 0 0 no-repeat;color:#444;"},Cabulous.Language.pickup_location),div({style:"padding-top:5px;"},c.pickup_location),div({style:Cabulous.style("labelIcon")+"background:url(/images/pencil.png) 0 0 no-repeat;color:#444;margin-top:10px;"},Cabulous.Language.notes),div({style:"padding-top:5px;"},c.notes_to_driver),input({type:"hidden",name:"hail[country_code]"}),input({type:"hidden",name:"hail[phone_number]"}),input({type:"hidden",name:"hail[password]"}),input({type:"hidden",name:"hail[pickup_location]"}),input({type:"hidden",name:"hail[notes_to_driver]"}),input({type:"hidden",name:"hail[cab_jid]"}),input({type:"hidden",name:"hail[latitude]"}),input({type:"hidden",name:"hail[longitude]"}),p({style:Cabulous.style("p")},input({type:"button","class":"noButton",value:"&laquo; "+Cabulous.Language.go_back}),input({type:"submit","class":"submit",value:Cabulous.Language.hail_a_cab}))))});Jaml.register("hailSuccessPartial",function(){var c=Cabulous.Status.HAILING_CAB_PHONE;div({style:Cabulous.style("infoContentStyle")},p({style:Cabulous.style("p")},Cabulous.Language.accepted+" "+Cabulous.Status.HAILING_CAB_PHONE),input({type:"button","class":"_cabulousEndPickup",value:Cabulous.Language.end_pickup}))});Jaml.register("hailFailPartial",function(){div({style:Cabulous.style("infoContentStyle")},p({style:Cabulous.style("p")},Cabulous.Language.driver_declined))});Jaml.register("noResultsFoundPartial",function(c){if(c!="empty address"&&c!="empty phone"&&c!=""){div({style:Cabulous.style("infoContentStyle")},h2(Cabulous.Language.hold_on),p({style:Cabulous.style("p")},Cabulous.Language.no_results_found_for+': "'+c+'"'),p({style:Cabulous.style("p")},input({type:"button","class":"noButton",value:"&laquo; "+Cabulous.Language.go_back})))}else{div({style:Cabulous.style("infoContentStyle")},h2(Cabulous.Language.hold_on),p({style:Cabulous.style("p")},(c=="empty address"?Cabulous.Language.please_enter_your_location:Cabulous.Language.please_enter_your_phone)),p({style:Cabulous.style("p")},input({type:"button","class":"noButton",value:"&laquo; "+Cabulous.Language.go_back})))}});Jaml.register("hailingScreenPartial",function(){p({style:Cabulous.style("p")},Cabulous.Language.hailing+"...")});function b(d,e){var f=$(Jaml.render(d,e)).get(0);for(var c in e){$(f).find(":input[name='hail["+c+"]']").val(e[c])}return f}Cabulous.Partials.loadingUI=function(){return $(Jaml.render("loadingPartial")).get(0)};Cabulous.Partials.disconnectedUI=function(){return $(Jaml.render("disconnectedPartial")).get(0)};Cabulous.Partials.controlOverlayUI=function(){return $(Jaml.render("controlOverlayPartial")).get(0)};Cabulous.Partials.controlOverlaySearchUI=function(){return $(Jaml.render("controlOverlayContentsSearch")).get(0)};Cabulous.Partials.controlOverlayContentsLiveCabCitiesUI=function(){return $(Jaml.render("controlOverlayContentsLiveCabCities")).get(0)};Cabulous.Partials.spinner=function(){return $(Jaml.render("spinner")).get(0)};Cabulous.Partials.controlOverlayCompaniesUI=function(){return $(Jaml.render("controlOverlayContentsCompanies")).get(0)};Cabulous.Partials.initialHailingFormUI=function(c){var d=b("initialHailingFormPartial",c);$(d).find(":input[name='hail[cab_jid]']").val(c.cab.jid);return d};Cabulous.Partials.confirmationFormUI=function(c){return b("confirmationFormPartial",c)};Cabulous.Partials.tooFarFormUI=function(){return $(Jaml.render("tooFarFormPartial")).get(0)};Cabulous.Partials.noResultsFoundUI=function(c){return $(Jaml.render("noResultsFoundPartial",c)).get(0)};Cabulous.Partials.hailSuccessPartial=function(){return $(Jaml.render("hailSuccessPartial")).get(0)};Cabulous.Partials.hailFailPartial=function(){return $(Jaml.render("hailFailPartial")).get(0)};Cabulous.Partials.hailingScreen=function(){return $(Jaml.render("hailingScreenPartial")).get(0)}})();Cabulous.ConnectionFactory={createJidConnection:function createJidConnection(){return new Strophe.Connection("/http-bind/")},createConnection:function createConnection(){return new Strophe.Connection("/http-bind/")}};function EventDispatcher(a){this.element=a}EventDispatcher.prototype.triggerCabUpdatesForEachItem=function(c){Cabulous.Status.IS_REFRESHING=false;var b=this;var a=$(c).find("items item");var d="";a.each(function(){var f=$(this);var h=f.attr("type");if(h=="cabbie"){var g;g=Cabulous.CabFactory.stanzaItemToCab(f);$(b.element).trigger(Cabulous.Event.CAB_UPDATE,g);if(d!=""){d+=","}d+=g.jid}else{if(h=="max_hail_distance"){var e=$(f).attr("miles");Cabulous.Shared.MAX_HAIL_DISTANCE=parseFloat(e)}}});$(b.element).trigger(Cabulous.Event.RECEIVED_JIDS,d);if($("._cabulousLoadingDiv").css("display")=="block"){$(b.element).trigger(Cabulous.Event.AUTO_ZOOM);$("._cabulousLoadingDiv").animate({opacity:"0.0"},300,function(){$("._cabulousLoadingDiv").css("display","none")})}if(Cabulous.Status.AUTO_ZOOM_REFRESH){$(b.element).trigger(Cabulous.Event.AUTO_ZOOM);Cabulous.Status.AUTO_ZOOM_REFRESH=false}return true};EventDispatcher.prototype.trigger=function(a,b){if(b){$(this.element).trigger(a,b)}else{$(this.element).trigger(a)}return true};EventDispatcher.prototype.triggerEntityGetResult=function(a){this.triggerCabUpdatesForEachItem(a);$(this.element).trigger(Cabulous.Event.AUTO_ZOOM);return true};EventDispatcher.prototype.triggerCabUpdateForPresence=function(a){var b={from_presence:true,jid:$(a).find("for").text(),latitude:$(a).find("latitude").text(),longitude:$(a).find("longitude").text(),accuracy:$(a).find("accuracy").text()};$(this.element).trigger(Cabulous.Event.CAB_UPDATE,b);return true};EventDispatcher.prototype.triggerItemUpdateForPresence=function(a){var b={jid:$(a).find("from").text(),latitude:$(a).find("location").find("latitude").text(),longitude:$(a).find("location").find("longitude").text(),accuracy:$(a).find("location").find("accuracy").text()};$(this.element).trigger(Cabulous.Event.CAB_UPDATE,b);return true};EventDispatcher.prototype.triggerCabRemovedForPresence=function(a){var b={jid:$(a).find("for").text()};$(this.element).trigger(Cabulous.Event.CAB_REMOVED,b);return true};EventDispatcher.prototype.triggerHailAccepted=function(a){if(Cabulous.Status.IS_DISPATCH){dispatchHailingUpdateReceived(a,"hail_accepted")}else{$(this.element).trigger(Cabulous.Event.HAIL_ACCEPTED)}return true};EventDispatcher.prototype.triggerHailDeclined=function(a){if(Cabulous.Status.IS_DISPATCH){dispatchHailingUpdateReceived(a,"hail_declined")}else{$(this.element).trigger(Cabulous.Event.HAIL_DECLINED)}return true};EventDispatcher.prototype.triggerHailTimeout=function(a){if(Cabulous.Status.IS_DISPATCH){dispatchHailingUpdateReceived(a,"hail_timeout")}else{$(this.element).trigger(Cabulous.Event.HAIL_TIMEOUT)}return true};EventDispatcher.prototype.triggerAttemptSession=function(b){var a=$(b).find("session");var c=$(a).attr("id");if(c=="not_available"){$(this.element).trigger(Cabulous.Event.NOT_AVAILABLE)}else{Cabulous.Status.SESSION_ID=c;$(this.element).trigger(Cabulous.Event.CLEAR_CABS_FOR_SESSION)}return true};EventDispatcher.prototype.triggerCabulousQueryCompanies=function(a){};EventDispatcher.prototype.triggerSessionEnded=function(a){if(Cabulous.Status.IS_DISPATCH){dispatchHailingUpdateReceived(a,"hail_end")}else{$(this.element).trigger(Cabulous.Event.SESSION_ENDED)}return true};Cabulous.CabFactory={stanzaItemToCab:function stanzaItemToCab(b){var c={};var a=["jid","title","subtitle","image","latitude","longitude","accuracy","present_status","is_private","is_fav","id","more_info","phone","name"];$.each(a,function(){var d=this.toString();var e=b.attr(d);if(d=="phone"){e=e.replace("+1-","");e=Cabulous.CabFactory.formatPhoneStr(e)}c[d]=e});return c},formatPhoneStr:function(a){var c=a.replace(/[^0-9xX]/g,"");c=c.replace(/[xX]/g,"x");var b="";if(c.indexOf("x")>-1){b=" "+c.substr(c.indexOf("x"));c=c.substr(0,c.indexOf("x"))}switch(c.length){case (10):return c.replace(/(...)(...)(....)/g,"($1) $2-$3")+b;case (11):if(c.substr(0,1)=="1"){return c.substr(1).replace(/(...)(...)(....)/g,"($1) $2-$3")+b}break;default:}return a}};
