var VM=VM||{};VM.Classified={id:0,$form:null,$bt:null,$btGuest:null,$btGuestSubmit:null,$question:null,storageKey:"",init:function(){VM.$body.find(".toggle").click(function(){var n=$(this),t=$(n.data("target"));t.length&&t.toggleClass("hidden").toggleClass("woc");window.setTimeout(function(){n.addClass("ga-off")},100)});this.loadMap();this.$form=$("#classified-contact-form");this.storageKey="VM-classified-contact_"+this.id;this.$form.length===0?VM.Storage.setObj(this.storageKey,""):(this.$bt=$("#classified-contact-bt").click(this.onQuestionSubmit),this.$btGuest=$("#classified-contact-bt-guest").click(this.onGuestQuestionSubmit),this.$btGuestSubmit=$("#classified-contact-bt-guest-submit"));this.$question=$("#Question").val(VM.Storage.getObj(this.storageKey))},onQuestionSubmit:function(n){n.preventDefault();VM.Classified.$form.validate();VM.Classified.$form.valid()&&(VM.Classified.$bt.addClass("loading").prop("disabled",!0),VM.Classified.$form.submit())},onGuestQuestionSubmit:function(n){n.preventDefault();VM.Classified.$form.validate();VM.Classified.$form.valid()&&(VM.Storage.setObj(VM.Classified.storageKey,VM.Classified.$question.val()),VM.AccountModal.$modal.modal("show"))},onLoginSuccess:function(){var n=VM.Classified.$form.data("ga-action-signedin");VM.Classified.afterModalAction(n,"You are now signed in. Your question or comment will be submitted automatically.")},onRegisteredSuccess:function(){var n=VM.Classified.$form.data("ga-action-registered");VM.Classified.afterModalAction(n,"You are now signed in. Your question or comment will be submitted automatically.")},onRegisteredPartialSuccess:function(n){$("#classified-contact-new-userid").val(n.userid);$("#classified-contact-new-username").val(n.user.username);var t=VM.Classified.$form.data("ga-action-registered");VM.Classified.afterModalAction(t,"Your question or comment will be submitted automatically. Note that your email will be sent once your account is verified.")},afterModalAction:function(n,t){this.$btGuest.addClass("hidden");this.$btGuestSubmit.removeClass("hidden").attr("data-ga-action",n);VM.scrollTo(VM.Classified.$form);this.$form.submit();VM.Ajax.toast(t,"success")},loadMap:function(){var n=$("#map-classified"),t;n.length&&(t=[],t.push({title:n.data("title"),description:"",lat:n.data("lat"),lng:n.data("lng")}),n.data("data",t),n.data("data-loaded",!0),this.initMap(n))},initMap:function(n){VM.Mapping.loadMapApi(function(){n.removeClass("hidden");var t=VM.Mapping.initializeMap(n);VM.Mapping.loadData(n,t)})}};$(function(){VM.Classified.init();window.onclick=function(n){var t=$(n.target);t.hasClass("toggle")||t.parent().hasClass("toggle")||$(".woc").addClass("hidden").removeClass("woc")}})