function FacilityDetailsSidebarMap() { $.ajaxSetup({ cache: false }); var self = this; self.bindControl = function (id, whatToDo, returnFalse, passControl) { $(id).keypress(function () { $(this).click(); }); $(id).click(function () { if (passControl) { whatToDo(this); } else { whatToDo(); } if (returnFalse) { return false; } else { return true; } }); }; self.initialize = function () { self.bindControl('#getDirectionsButton', self.bindDirectionsButton, true, false); self.bindControl('.linkGoogle', self.flipDirectionsMiniPopup, false, false); }; self.bindDirectionsButton = function () { if ($('.linkGoogle') != null && $('.linkGoogle').length == 1) { $('.linkGoogle')[0].click(); } else { self.flipDirectionsMiniPopup(); } }; self.flipDirectionsMiniPopup = function () { if ($('#mapPopout').is(':visible')) { $('#mapPopout').hide(); } else { $('#mapPopout').show(); } }; }