// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
((function(){($("html").is(".vehicles.index")||$("html").is(".drivers.index"))&&$(document).ready(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R;return console.log("accordion loaded"),s=function(a){var b;console.log("initAccordion"),a===void 0&&(a=!0),b={header:"h3.item",autoHeight:!1,create:function(){var b;b=$("#accordion form").length,b===1&&$("div#accordion form a.delete-btn").hide();if(a&&$('#accordion form[id^="edit"]').length>0)return r()}},$("#accordion").accordion("destroy"),$("#accordion").accordion(b),$("html").is(".drivers.index")&&y();if($("html").is(".vehicles.index"))return y()},b=function(){var a,b;return a=j(),b=m($('form[id^="new"]')),$("h3.item.new:visible").length>0?b&&a:a},j=function(){var a,b;return a=$('#accordion form[id^="edit"]').length,b=0,$('#accordion form[id^="edit"]').each(function(){if(m(this))return b+=1}),a===b},n=function(a){return Math.max.apply(null,a)},h=function(){return $("#box-extension a.submit").addClass("disabled")},l=function(){return $("#box-extension a.submit").removeClass("disabled")},o=function(a){return $(a).parent().prev("h3")},p=function(a){return o(a).children("a")},u=function(){var a,b;return a=$.map($('form[id^="edit"] #index'),function(a){return parseInt($(a).attr("value"))}),b=n(a),b>0?b:0},N=function(a){return $('form[id^="new"] #index').attr("value",a),$('form[id^="new"] [data-index]').each(function(){return $(this).attr("data-index",a)})},d=function(a){return $(a+" #errorExplanation").remove(),$(a+" div.field_with_errors").each(function(){return $(this).replaceWith($(this).html())}),o(a).removeClass("errors")},J=function(){var a;console.log("show new item form"),a=$('form[id^="new"]').parent(),o('form[id^="new"]').show(),a.show(),a.find("div.attached").hide(),$("#accordion").accordion("activate",$("#accordion form").length-1),b()?l():h();if($("html").is(".drivers.index"))return L()},I=function(){return $("#accordion form").length>1?$("#accordion").accordion("activate",$("#accordion form").length-2):J()},r=function(){var a;a=$('form[id^="new"]').parent(),o('form[id^="new"]').hide("blind"),a.hide("blind"),$("#accordion").accordion("activate",$("#accordion form").length-2);if(j())return l()},q=function(a){var b;b=parseInt($('form[id$="_'+a+'"] [name="index"]').val()),console.log("index: "+b),$('h3[id$="_'+a+'"]').hide("blind"),$('div[id$="_'+a+'"]').hide("blind"),$("#accordion").accordion("activate",b-1);if(j())return l()},t=function(a){return $(a).insertBefore(o('form[id^="new"]')),$('form[id^="new"] a.delete-btn').show()},O=function(a,b,c,d){var e;return e=$('h3[id$="_'+a+'"]'),d?e.removeClass("errors"):e.addClass("errors"),e.children("a").text(b),$("#item_"+a).html(c),$("#accordion").accordion("resize")},c=function(){return $(".ui-effects-wrapper:empty").remove()},a=function(){return $('form[id^="edit"]').not(".saved").length===0},v=function(){if(a())return document.location=$("#box-extension a.submit").attr("href")},F=function(){return $("form.primary").css("opacity",1),$("h3.add a.disabled").removeClass("disabled")},R=function(){return d('form[id^="new"]'),e('form[id^="new"]'),g('form[id^="new"]'),$('form[id^="new"]').removeClass("changed"),$('form[id^="edit"]').length>=1?($('form[id^="new"] .delete-btn').show(),N(u()+1)):($('form[id^="new"] .delete-btn').hide(),N(0))},Q=function(a){return $(a+" select").attr("disabled","disabled")},P=function(a){return console.log("_clearFields"),$(":input",a).not("[type=radio], [type=checkbox], :button, :submit, :reset, :hidden").val("").removeAttr("selected"),$(a+' [type="radio"]').removeAttr("checked"),$(a+' [type="checkbox"]').removeAttr("checked")},$('form[id^="new"]').live("ajax:success",function(a,b,d){return console.log("create ajax success"),b.valid?b.add_item?(console.log("add_item"),t(b.html),H(),s(!1),J(),$("#accordion").accordion("activate",$("#accordion form").length-1)):b.next_step&&v():O("",b.title,b.html,b.valid),c(),F()}),$('form[id^="edit"]').live("ajax:success",function(a,b,c){return console.log("update ajax success"),O(b.id,b.title,b.html,b.valid),b.valid&&(b.add_item?J():b.next_step&&v()),F()}),$("h3.add a").not(".disabled").click(function(a){return console.log("add item clicked"),a.preventDefault(),$("#accordion form.changed").length>0?($("form #submit").val("add"),$("#accordion form.changed").submit(),$(this).addClass("disabled")):J()}),$("#box-extension a.submit").live("click",function(a){a.preventDefault();if(!$(this).hasClass("disabled"))return $("form #submit").val("next"),$(".changed").length===0?v():($('form[id^="new"].changed').submit(),$('#accordion form[id^="edit"].changed').submit())}),$('form[id^="new"] a.delete-btn').live("click",function(a){return a.preventDefault(),console.log("new delete button clicked"),r(),H()}),$('#accordion form[id^="edit"] a.delete-btn').live("ajax:success",function(a,b,d){return q(b.id),$('h3[id$="_'+b.id+'"]').hide("blind").remove(),$('div[id$="_'+b.id+'"]').hide("blind").remove(),c(),I(),!1}),$("#accordion form.primary").live("change",function(){return $(this).addClass("changed"),$(this).removeClass("saved"),b()?l():h()}),$(".radio-buttons label").live("click",function(a){var b,c,d;return a.preventDefault(),c=$(this),b=c.attr("data-index"),d=$("#"+c.attr("for")+'[data-index="'+b+'"]'),d.click()}),$(".checkboxes label").live("click",function(a){var b,c,d;return console.log("checkbox label clicked!"),a.preventDefault(),d=$(this),c=d.attr("data-index"),d.parent().attr("class")==="field_with_errors"?b=$(this).parent().prev("[type=checkbox]"):b=$(this).prev("[type=checkbox]"),b.click()}),$("html").is(".vehicles.index")&&(console.log("vehicles loaded"),i=function(a){return a.empty().attr("disabled","disabled"),a},E=function(a){return i(a).html('<option selected="selected">Loading...</option>')},m=function(a){var b;b=$(a).serialize(),b.match(/year[^=&]+=[\w]+/)&&b.match(/make[^=&]+=[\w]+/)&&b.match(/model[^=&]+=[\w]+/)&&b.match(/style[^=&]+=[\w]+/)&&b.match(/ownership[^=&]+=[\w]+/)&&b.match(/primary_use[^=&]+=[\w]+/);if(b.match(/primary_use[^=&]+=commute/)){if(b.match(/commute_distance[^=&]+=[\w]+/)&&b.match(/commute_frequency[^=&]+=[\w]+/))return!0}else if(b.match(/annual_mileage[^=&]+=[\w]+/))return!0},f=function(a){return $(a+" .vehicle-preview").html("")},e=function(a){return P(a),$(a+" select").not(".vehicle-year").empty()},H=function(){return R(),f('form[id^="new"]'),p('form[id^="new"]').text("New Vehicle")},g=function(a){return Q(a),$(a+" select.vehicle-year option").first().attr("selected","selected"),$(a+" select.vehicle-year").removeAttr("disabled")},O=function(a,b,c,d){var e;return e=$('h3[id$="_'+a+'"]'),d?e.removeClass("errors"):e.addClass("errors"),e.children("a").text(b),$("#item_"+a).html(c),$("#accordion").accordion("resize"),y()},y=function(){return x(),B()},x=function(){return console.log("open commute called"),$("*#vehicle_primary_use_commute").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").nextAll("div.attached.commute").show():$(this).closest("div.group").nextAll("div.attached.commute").hide()})},B=function(){return console.log("open mileage called"),$("form").each(function(a){return $(this).find("#vehicle_primary_use_pleasure").attr("checked")==="checked"||$(this).find("#vehicle_primary_use_business").attr("checked")==="checked"?$(this).find("div.attached.mileage").show():$(this).find("div.attached.mileage").hide()})},$("select.vehicle-year").live("change",function(){var a,b,c,d,e,g;return g=encodeURIComponent($(this).val()),a=$(this).parents("form"),f("#"+a.attr("id")),b=a.find("select.vehicle-make"),c=a.find("select.vehicle-model"),d=a.find("select.vehicle-style"),e=a.parent().prev("h3.item").find("a"),$(e).text(g),E(b),i(c),i(d),b.load("/dataone/"+g+"/makes.html",function(){return b.removeAttr("disabled")})}),$("select.vehicle-make").live("change",function(){var a,b,c,d,e,g;return g=encodeURIComponent($(this).parents("form").find("select.vehicle-year").val()),a=$(this).parents("form"),f("#"+a.attr("id")),b=encodeURIComponent($(this).val()),c=a.find("select.vehicle-model"),d=a.find("select.vehicle-style"),e=a.parent().prev("h3.item").find("a"),$(e).text(g+" "+decodeURIComponent(b)),E(c),i(d),c.load("/dataone/"+g+"/"+b+"/models.html",function(){return c.removeAttr("disabled")})}),$("select.vehicle-model").live("change",function(){var a,b,c,d,e,g;return g=encodeURIComponent($(this).parents("form").find("select.vehicle-year").val()),a=$(this).parents("form"),f("#"+a.attr("id")),b=encodeURIComponent(a.find("select.vehicle-make").val()),c=encodeURIComponent($(this).val().replace(".","_")),d=a.find("select.vehicle-style"),e=a.parent().prev("h3.item").find("a"),$(e).text(g+" "+decodeURIComponent(b).split(" ")[0]+" "+$(this).val()),E(d),d.load("/dataone/"+g+"/"+b+"/"+c+"/styles.html",function(){return d.removeAttr("disabled")})}),$("div.usage input:radio").live({change:function(){return console.log("open usage selector toggled"),$(this).val()==="commute"?($(this).closest("div.group").nextAll("div.attached.mileage").hide(),$(this).closest("div.group").nextAll("div.attached.commute").show()):($(this).closest("div.group").nextAll("div.attached.mileage").show(),$(this).closest("div.group").nextAll("div.attached.commute").hide())}}),H()),$("html").is(".drivers.index")&&(console.log("drivers loaded"),m=function(a){var b;b=$(a).serialize();if(b.match(/first_name[^=&]+=[\w]+/)&&b.match(/last_name[^=&]+=[\w]+/)&&b.match(/birth_month[^=&]+=[\w]+/)&&b.match(/birth_day[^=&]+=[\w]+/)&&b.match(/birth_year[^=&]+=[\w]+/)&&b.match(/gender[^=&]+=[\w]+/)&&b.match(/marital_status[^=&]+=[\w]+/)&&b.match(/education_completed[^=&]+=[\w]+/)&&b.match(/career_status[^=&]+=[\w]+/)&&b.match(/age_first_licensed[^=&]+=[\w]+/)&&b.match(/license_status[^=&]+=[\w]+/)&&b.match(/suspended_or_revoked[^=&]+=[\w]/))if(b.match(/primary_driver[^=&]+=true/)){if(b.match(/homeowner[^=&]+=[\w]/))return console.log("primary driver form is filled"),!0}else if(b.match(/relation_to_primary[^=&]+=[\w]/)&&b.match(/same_address_as_primary[^=&]+=[\w]/))return console.log("secondary driver form is filled"),!0},e=function(a){return P(a)},H=function(){return R(),p('form[id^="new"]').text("New Driver"),G($('form[id^="new"]').find("div.attached.incidents"))},g=function(a){return!0},O=function(a,b,c,d){var e;return e=$('h3[id$="_'+a+'"]'),d?e.removeClass("errors"):e.addClass("errors"),e.children("a").children("div").text(b),$("#item_"+a).html(c),$("#accordion").accordion("resize"),y()},y=function(){return A(),C(),D(),z(),w(),L(),M(),K()},k=function(){var a;a=0,$("form").each(function(b){if(m($(this)))return a+=1});if($("form").length-1===a)return l()},A=function(){return $("*#driver_suspended_or_revoked_true").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").next("div.attached.incidents").show():$(this).closest("div.group").next("div.attached.incidents").hide()})},C=function(){return $("*#driver_career_status_employed").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").next("div.attached.employment").show():$(this).closest("div.group").next("div.attached.employment").hide()})},D=function(){return $("*#driver_career_status_full-time_student").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").nextAll("div.attached.student").show():$(this).closest("div.group").nextAll("div.attached.student").hide()})},z=function(){return $("*#driver_homeowner_true").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").next("div.attached.homeowner").show():$(this).closest("div.group").next("div.attached.homeowner").hide()})},w=function(){return $("*#driver_same_address_as_primary_false").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").next("div.attached.address").show():$(this).closest("div.group").next("div.attached.address").hide()})},L=function(){return $("form").each(function(a){var b;return b=parseInt($(this).find("input[name=index]").val()),console.log(b),$(this).find("#driver_birth_month, #driver_birth_day, #driver_birth_year").autotab_magic().autotab_filter("numeric"),b===0?($(this).find("#driver_primary_driver").val("true"),$(this).find("div.primary-driver").show(),$(this).find("div.secondary-driver").hide()):($(this).find("#driver_primary_driver").val("false"),$(this).find("div.secondary-driver").show(),$(this).find("div.primary-driver").hide())})},K=function(){var a;return a=!1,$("div.attached.incidents").each(function(b){var c,d,e;return e=$(this),d=e.find("dd"),d.each(function(b,c){var d;return d=$(this).find("a"),d.each(function(b,c){if($(this).attr("id")==="incident-save")return a=!0})}),c=e.find("#incident-add"),a===!0?c.addClass("disabled"):c.removeClass("disabled")})},$("[placeholder]").focus(function(){var a;a=$(this);if(a.val()===a.attr("placeholder"))return a.val(""),a.removeClass("placeholder")}).blur(function(){var a;a=$(this);if(a.val()===""||a.val()===a.attr("placeholder"))return a.addClass("placeholder"),a.val(a.attr("placeholder"))}).blur(),$("[placeholder]").parents("form").submit(function(){return $(this).find("[placeholder]").each(function(){var a;a=$(this);if(a.attr("id")!=="driver_age_first_licensed"&&a.val()===a.attr("placeholder"))return a.val("")})}),G=function(a){return a.html($("#incident-group").html()),$("#incident_0_month, #incident_0_day, #incident_0_year").autotab_magic().autotab_filter("numeric")},M=function(a,b){return a.find("driver").html(b)},M=function(){return $("form").each(function(){var a,b,c,d,e,f;a=$(this).find("#driver_first_name").val().trim(),d=$(this).find("#driver_middle_name").val().trim(),c=$(this).find("#driver_last_name").val().trim(),b=a+" "+d+" "+c,f=$("#shopper_name").val(),b=b.replace(/\s{2,}/g," "),a.trim()!==""?f===b?($(this).find("driver").hide(),$(this).find("you").show()):(a.charAt(a.length-1)==="s"?e=a+"'":e=a+"'s",$(this).find("driver").show(),$(this).find("name").html(a),$(this).find("name.plural").html(e),$(this).find("you").hide()):($(this).find("driver").show(),$(this).find("name").html("the driver"),$(this).find("name.plural").html("the driver's"),$(this).find("you").hide()),$(this).find("#driver_gender_male").attr("checked")==="checked"&&$(this).find("pronoun").html("his");if($(this).find("#driver_gender_female").attr("checked")==="checked")return $(this).find("pronoun").html("her")})},$("[id$=_name]").live("change",function(){var a,b,c,d,e,f;return b=$(this).closest("form"),a=b.find("#driver_first_name").val(),f=b.find("#driver_middle_name").val(),e=b.find("#driver_last_name").val(),c=a+" "+f+" "+e,d=b.parent(".item").prev().children("a").children("div"),d.length===1?d.text(c):b.parent(".item").prev().children("a").text(c),M(b,a)}),$('.incidents [id$="kind"]').live("change",function(){var a;return a=$(this).closest("select"),$.ajax({url:"/driver/incident/"+$(this).closest("select").val(),success:function(b){var c;return c=a.next("select"),c.html(b),c.removeAttr("disabled")}})}),$('.employment [id$="industry"]').live("change",function(){var a;return a=$(this).closest("select"),$.ajax({url:"/driver/employment/",type:"POST",data:{industry:a.val()},success:function(b){var c;return c=a.parent().next().find("select"),c.html(b),c.removeAttr("disabled")}})}),$("#incident-edit").live("click",function(){var a,b,c,d,e,f,g,h;return event.preventDefault(),c=$(this).parent(),g=c.find("[id$=month]"),b=c.find("[id$=day]"),h=c.find("[id$=year]"),f=c.find("[id$=kind]"),d=c.find("[id$=detail]"),e=c.find("#driver_id"),g.removeAttr("disabled"),g.removeClass("greyed"),b.removeAttr("disabled"),b.removeClass("greyed"),h.removeAttr("disabled"),h.removeClass("greyed"),f.removeAttr("disabled"),f.removeClass("greyed"),d.removeAttr("disabled"),d.removeClass("greyed"),a=c.find("#incident-edit"),a.text("Save"),a.attr("id","incident-save"),K()}),$("#incident-save").live("click",function(){var a,b,c,d,e,f,g,h,i;return event.preventDefault(),console.log("ajax save incident"),c=$(this).parent(),g=c.find("[id$=month]"),b=c.find("[id$=day]"),i=c.find("[id$=year]"),f=c.find("[id$=kind]"),d=c.find("[id$=detail]"),h=$("#driver_shopper_id"),e=c.find("#incident_id"),a=c.find("#incident-save"),$.ajax({url:"/driver/incident/",type:"POST",data:{shopper_id:h.val(),incident_id:e.val(),month:g.val(),day:b.val(),year:i.val(),kind:f.val(),detail:d.val()},success:function(e){return e.valid?(a.text("Edit"),a.attr("id","incident-edit"),g.attr("disabled","disabled"),g.addClass("greyed"),b.attr("disabled","disabled"),b.addClass("greyed"),i.attr("disabled","disabled"),i.addClass("greyed"),f.attr("disabled","disabled"),d.attr("disabled","disabled"),c.parent().find("div.errors").html("")):c.parent().find("div.errors").html(e.html),K()}})}),$("div.attached.incidents a.button#incident-add").live({click:function(a){var b,c,d,e,f,g,h,i,j;a.preventDefault(),e=$(this).closest("div.group").find("dl"),c=e.find("dd:last"),i=c.find("[id$=month]").val(),b=c.find("[id$=day]").val(),j=c.find("[id$=year]").val(),h=c.find("[id$=kind]").val(),d=c.find("[id$=detail]").val();if(i!=="mm"&&i!==""&&b!=="dd"&&b!==""&&j!=="yyyy"&&j!==""&&h!==""&&d!=="")return e.find("dd:last").clone().appendTo(e),c=e.find("dd:last"),g=parseInt(c.find("[id$=month]").attr("id").replace(/[^\d\.]+/,""))+1,f=g.toString(),c.html($("#incident-group").find("dd").html()),i=c.find("[id$=month]"),i.attr("id","incident_"+f+"_month"),i.attr("name","incident_"+f+"_month"),b=c.find("[id$=day]"),b.attr("id","incident_"+f+"_day"),b.attr("name","incident_"+f+"_day"),j=c.find("[id$=year]"),j.attr("id","incident_"+f+"_year"),j.attr("name","incident_"+f+"_year"),h=c.find("[id$=kind]"),h.attr("id","incident_"+f+"_kind"),h.attr("name","incident_"+f+"_kind"),d=c.find("[id$=detail]"),d.attr("id","incident_"+f+"_detail"),d.attr("name","incident_"+f+"_detail"),$("#incident_"+f+"_month, #incident_"+f+"_day, #incident_"+f+"_year").autotab_magic().autotab_filter("numeric"),K()}}),$("div.attached.incidents a.delete").live({click:function(a){var b,c;a.preventDefault();if($(this).closest("dl").find("dd").length>=2&&confirm("Are you sure you want to delete this violation?"))return b=$(this).closest("dd"),c=b.find("#incident_id").val(),console.log(c),$.ajax({url:"/driver/incidents/delete/"+c.toString(),success:function(){return b.parent().find("div.errors").html(""),b.remove()}})}}),$("div.incidents input:radio").live({change:function(){var a;return $(this).val()==="true"?(a=$(this).closest("div.group").next("div.attached.incidents"),a.find("dd").size()===0&&G(a),a.show()):$(this).closest("div.group").next("div.attached.incidents").hide()}}),$("div.homeowner input:radio").live({change:function(){return $(this).val()==="true"?$(this).closest("div.group").next("div.attached.homeowner").show():$(this).closest("div.group").next("div.attached.homeowner").hide()}}),$("div.address input:radio").live({change:function(){return $(this).val()==="false"?$(this).closest("div.group").next("div.attached.address").show():$(this).closest("div.group").next("div.attached.address").hide()}}),$("div.gender input:radio").live({change:function(){return $(this).val()==="male"?$(this).closest("form").find("pronoun").html("his"):$(this).closest("form").find("pronoun").html("her")}}),$("div.employment input:radio").live({change:function(){return $(this).val()==="Employed"?($(this).closest("div.group").nextAll("div.attached.student").hide(),$(this).closest("div.group").next("div.attached.employment").show()):$(this).val()==="Full-Time Student"?($(this).closest("div.group").nextAll("div.attached.student").show(),$(this).closest("div.group").next("div.attached.employment").hide()):($(this).closest("div.group").nextAll("div.attached.student").hide(),$(this).closest("div.group").next("div.attached.employment").hide())}}),$("#incident_0_month, #incident_0_day, #incident_0_year").autotab_magic().autotab_filter("numeric"),$("#driver_birth_month, #driver_birth_day, #driver_birth_year").autotab_magic().autotab_filter("numeric")),s()})})).call(this),function(){$("html").is(".articles.edit")&&$(document).ready(function(){var a;return a=function(){return $("input#article_spanish").attr("checked")==="checked"?$("#entities").show():$("#entities").hide()},$("input#article_spanish").click(function(){return a()}),$("#entities a").click(function(){return console.log($(this).text()),$("textarea#article_body").insertAtCaret($(this).text())}),a()})}.call(this),function(){$("html").is(".agents.login")&&$(document).ready(function(){return $("#contact_email").focus()}),$("html").is(".agents.zips")&&$(document).ready(function(){return $("select#state_id").change(function(a){return location.href="?state="+$(this).val()}),$("[data-remote]").live("ajax:before",function(){return $("#ajax-loader").show()}).live("ajax:success",function(a,b,c){return $("#active_zips").html(b)}),$("tr.active_zip").live("click",function(){var a;return a=$(this).find("input")[0],a.checked=!a.checked}),$("tr.active_zip :checkbox").live("click",function(a){return a.stopPropagation()})})}.call(this),function(){$("html").is(".blog")&&(window.plusOne=function(a){return $.ajax({url:"/blog/plusone",data:{state:a.state,href:a.href},cache:!1})},$(document).ready(function(){return $("dl#staff h4 span").click(function(a){return a.preventDefault(),$(this).hasClass("close")?$(this).removeClass("close").parent().next().hide("slow"):$(this).addClass("close").parent().next().show("slow")})}))}.call(this),function(){$("html").is(".leads.index")&&$(document).ready(function(){var a,b,c;return $("tr.shoppers").live("click",function(a){return window.location.href=$(this).find("a").attr("href")}),$("#shopper-list nav.pagination a").live("click",function(a){var b;return a.preventDefault(),b=$(this).attr("href").split("?"),b.length===1?b=1:b=b[1].match(/(\d+)/)[0],c(b)}),c=function(a){return $.ajax({url:"/cis/shoppers?page="+a,success:function(a){return console.log("shopper list ajax success"),$("#shopper-list").html(a.html)}})},$("form[id=shopper-search-form]").live("ajax:success",function(a,b,c){return console.log("shopper search ajax success"),console.log(b.html),$("#shopper-search-results").html(b.html)}),$("tr.calls").live("click",function(a){return window.location.href=$(this).find("a").attr("href")}),$("#call-list nav.pagination a").live("click",function(a){var c;return a.preventDefault(),c=$(this).attr("href").split("?"),c.length===1?c=1:c=c[1].match(/(\d+)/)[0],b(c)}),b=function(a){return $.ajax({url:"/cis/calls?page="+a,success:function(a){return console.log("call list ajax success"),$("#call-list").html(a.html)}})},a=function(){return c($("#shopper-list nav.pagination span.current").text().trim()),b($("#call-list nav.pagination span.current").text().trim()),setTimeout(a,5e3)},a()})}.call(this),function(){$("html").is(".drivers-and-coverage")&&$(document).ready(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return f=function(){return h(),i(),j(),g(),e(),q(),$("#incident_0_month, #incident_0_day, #incident_0_year").autotab_magic().autotab_filter("numeric"),$("#driver_birth_month, #driver_birth_day, #driver_birth_year").autotab_magic().autotab_filter("numeric")},h=function(){return $("*#driver_suspended_or_revoked_true").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").next("div.attached.incidents").show():$(this).closest("div.group").next("div.attached.incidents").hide()})},i=function(){return $("*#driver_career_status_employed").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").next("div.attached.employment").show():$(this).closest("div.group").next("div.attached.employment").hide()})},j=function(){return $("*#driver_career_status_full-time_student").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").nextAll("div.attached.student").show():$(this).closest("div.group").nextAll("div.attached.student").hide()})},g=function(){return $("*#driver_homeowner_true").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").next("div.attached.homeowner").show():$(this).closest("div.group").next("div.attached.homeowner").hide()})},e=function(){return $("*#driver_same_address_as_primary_false").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").next("div.attached.address").show():$(this).closest("div.group").next("div.attached.address").hide()})},q=function(){var a;return a=!1,$("div.attached.incidents").each(function(b){var c,d,e;return e=$(this),d=e.find("dd"),d.each(function(b,c){var d;return d=$(this).find("a"),d.each(function(b,c){if($(this).attr("id")==="incident-save")return a=!0})}),c=e.find("#incident-add"),a===!0?c.addClass("disabled"):c.removeClass("disabled")})},$("[placeholder]").focus(function(){var a;a=$(this);if(a.val()===a.attr("placeholder"))return a.val(""),a.removeClass("placeholder")}).blur(function(){var a;a=$(this);if(a.val()===""||a.val()===a.attr("placeholder"))return a.addClass("placeholder"),a.val(a.attr("placeholder"))}).blur(),$("[placeholder]").parents("form").submit(function(){return $(this).find("[placeholder]").each(function(){var a;a=$(this);if(a.attr("id")!=="driver_age_first_licensed"&&a.val()===a.attr("placeholder"))return a.val("")})}),m=function(a){return a.html($("#incident-group").html()),$("#incident_0_month, #incident_0_day, #incident_0_year").autotab_magic().autotab_filter("numeric")},$('.incidents [id$="kind"]').live("change",function(){var a;return a=$(this).closest("select"),$.ajax({url:"/driver/incident/"+$(this).closest("select").val(),success:function(b){var c;return c=a.next("select"),c.html(b),c.removeAttr("disabled")}})}),$('.employment [id$="industry"]').live("change",function(){var a;return a=$(this).closest("select"),$.ajax({url:"/driver/employment/",type:"POST",data:{industry:a.val()},success:function(b){var c;return console.log(a.val()),c=a.parent().next().find("select"),console.log(b),c.html(b),c.removeAttr("disabled")}})}),$("div.incidents input:radio").live({change:function(){return $(this).val()==="true"?$("div.attached.incidents").show():$("div.attached.incidents").hide()}}),$("div.homeowner input:radio").live({change:function(){return $(this).val()==="true"?$(this).closest("div.group").next("div.attached.homeowner").show():$(this).closest("div.group").next("div.attached.homeowner").hide()}}),$("div.address input:radio").live({change:function(){return $(this).val()==="false"?$(this).closest("div.group").next("div.attached.address").show():$(this).closest("div.group").next("div.attached.address").hide()}}),$("div.gender input:radio").live({change:function(){return $(this).val()==="male"?$(this).closest("form").find("pronoun").html("his"):$(this).closest("form").find("pronoun").html("her")}}),$("div.employment input:radio").live({change:function(){return $(this).val()==="Employed"?($(this).closest("div.group").nextAll("div.attached.student").hide(),$(this).closest("div.group").next("div.attached.employment").show()):$(this).val()==="Full-Time Student"?($(this).closest("div.group").nextAll("div.attached.student").show(),$(this).closest("div.group").next("div.attached.employment").hide()):($(this).closest("div.group").nextAll("div.attached.student").hide(),$(this).closest("div.group").next("div.attached.employment").hide())}}),f(),$("form[id=driver]").live("ajax:success",function(a,b,c){return console.log("update driver ajax success"),b.valid?($("#driver-form").html(b.driver),$(".msg.success.driver").html(b.msg),$(".msg.fail.driver").html(""),k(b.sidebar),f()):($(".msg.fail.driver").html(b.msg),$(".msg.success.driver").html("")),$("#shopper-completed").html(b.completed)}),$("form[class=load-driver]").live("ajax:success",function(a,b,c){return console.log("load driver ajax success"),$("#driver-form").html(b.html),f()}),$("form[class=destroy-driver]").live("ajax:success",function(a,b,c){return $("#driver_id").val()===b.id&&$("#driver-form").html(b.html_new),k(b.sidebar),$(".msg.success.driver").html(b.html),$(".msg.fail.driver").html(""),$("#shopper-completed").html(b.completed)}),k=function(a){return $("#driver-list").html(a)},$("#incident-edit").live("click",function(){var a,b,c,d,e,f,g,h;return event.preventDefault(),c=$(this).parent(),g=c.find("[id$=month]"),b=c.find("[id$=day]"),h=c.find("[id$=year]"),f=c.find("[id$=kind]"),d=c.find("[id$=detail]"),e=c.find("#driver_id"),g.removeAttr("disabled"),g.removeClass("greyed"),b.removeAttr("disabled"),b.removeClass("greyed"),h.removeAttr("disabled"),h.removeClass("greyed"),f.removeAttr("disabled"),f.removeClass("greyed"),d.removeAttr("disabled"),d.removeClass("greyed"),a=c.find("#incident-edit"),a.text("Save"),a.attr("id","incident-save"),q()}),$("#incident-save").live("click",function(){var a,b,c,d,e,f,g,h,i;return event.preventDefault(),console.log("ajax save incident"),c=$(this).parent(),g=c.find("[id$=month]"),b=c.find("[id$=day]"),i=c.find("[id$=year]"),f=c.find("[id$=kind]"),d=c.find("[id$=detail]"),h=$("#driver_shopper_id"),e=c.find("#incident_id"),a=c.find("#incident-save"),$.ajax({url:"/cis/lead/incident/update",type:"POST",data:{shopper_id:h.val(),incident_id:e.val(),month:g.val(),day:b.val(),year:i.val(),kind:f.val(),detail:d.val()},success:function(e){return e.valid?(a.text("Edit"),a.attr("id","incident-edit"),g.attr("disabled","disabled"),g.addClass("greyed"),b.attr("disabled","disabled"),b.addClass("greyed"),i.attr("disabled","disabled"),i.addClass("greyed"),f.attr("disabled","disabled"),d.attr("disabled","disabled"),c.parent().find(".msg.fail.incident").html("")):c.parent().find(".msg.fail.incident").html(e.html),q()}})}),$("div.attached.incidents a.button#incident-add").live({click:function(a){var b,c,d,e,f,g,h,i,j;a.preventDefault(),e=$(this).closest("div.group").find("dl"),c=e.find("dd:last"),i=c.find("[id$=month]").val(),b=c.find("[id$=day]").val(),j=c.find("[id$=year]").val(),h=c.find("[id$=kind]").val(),d=c.find("[id$=detail]").val();if(i!=="mm"&&i!==""&&b!=="dd"&&b!==""&&j!=="yyyy"&&j!==""&&h!==""&&d!=="")return e.find("dd:last").clone().appendTo(e),c=e.find("dd:last"),g=parseInt(c.find("[id$=month]").attr("id").replace(/[^\d\.]+/,""))+1,f=g.toString(),c.html($("#incident-group").find("dd").html()),i=c.find("[id$=month]"),i.attr("id","incident_"+f+"_month"),i.attr("name","incident_"+f+"_month"),b=c.find("[id$=day]"),b.attr("id","incident_"+f+"_day"),b.attr("name","incident_"+f+"_day"),j=c.find("[id$=year]"),j.attr("id","incident_"+f+"_year"),j.attr("name","incident_"+f+"_year"),h=c.find("[id$=kind]"),h.attr("id","incident_"+f+"_kind"),h.attr("name","incident_"+f+"_kind"),d=c.find("[id$=detail]"),d.attr("id","incident_"+f+"_detail"),d.attr("name","incident_"+f+"_detail"),$("#incident_"+f+"_month, #incident_"+f+"_day, #incident_"+f+"_year").autotab_magic().autotab_filter("numeric"),q()}}),$("div.attached.incidents a.delete").live({click:function(a){var b,c;a.preventDefault();if($(this).closest("dl").find("dd").length>=2&&confirm("Are you sure you want to delete this violation?"))return b=$(this).closest("dd"),c=b.find("#incident_id").val(),console.log(c),$.ajax({url:"/driver/incidents/delete/"+c.toString(),success:function(){return b.parent().find("div.errors").html(""),b.remove()}})}}),p=function(){if($("#shopper_currently_insured_true").is(":checked")===!0)return $("div#current-insurance").show(),$("div#no-insurance").hide(),$("#shopper_coverage_lapse_duration").val("");if($("#shopper_currently_insured_false").is(":checked")===!0)return $("div#current-insurance").hide(),$("div#no-insurance").show(),$("#shopper_current_carrier_id").val(""),$("#shopper_current_policy_expiration_month").val(""),$("#shopper_current_policy_expiration_day").val(""),$("#shopper_current_policy_expiration_year").val(""),$("#shopper_current_insured_duration").val("")},d=function(a){var b;return b=$(a).serialize(),b.match(/currently_insured%5D=true/)?b.match(/current_carrier_id[^=&]+=[\w]/)&&b.match(/current_insured_duration[^=&]+=[\w]/)?!0:(disableFinishButton(),!1):b.match(/coverage_lapse_duration%5D=&shopper/)?(disableFinishButton(),!1):!0},$(".radio-buttons label").live("click",function(a){var b,c;return a.preventDefault(),b=$(this),c=b.prev("input[type=radio]"),c.click()}),$("[placeholder]").focus(function(){var a;a=$(this);if(a.val()===a.attr("placeholder"))return a.val(""),a.removeClass("placeholder")}).blur(function(){var a;a=$
(this);if(a.val()===""||a.val()===a.attr("placeholder"))return a.addClass("placeholder"),a.val(a.attr("placeholder"))}).blur(),$("[placeholder]").parents("form").submit(function(){return $(this).find("[placeholder]").each(function(){var a;a=$(this);if(a.attr("id")!=="driver_age_first_licensed"&&a.val()===a.attr("placeholder"))return a.val("")})}),b=function(){var a;return n(),a=Number($("#shopper_bi_coverage_id option:selected").text().split("/")[0].replace(/[^0-9\.]+/g,"")),$("select#shopper_pd_coverage_id option").each(function(){if(a<Number($(this).text().trim().replace(/[^0-9\.]+/g,"")))return $(this).remove()})},a=function(){var a;a=$("#shopper_comp_coverage_id option:selected").text().trim(),l();if($("#shopper_coll_coverage_id option:selected").text()!=="No Coverage")return $("#shopper_comp_coverage_id option").each(function(){if($(this).text().trim()==="No Coverage")return $(this).remove();if($(this).text().trim()===a)return $(this).attr("selected","selected")})},c=function(){var a;o(),a=Number($("#shopper_bi_coverage_id option:selected").text().split("/")[0].replace(/[^0-9\.]+/g,"")),$("#shopper_um_bi_coverage_id option").each(function(){if(a<Number($(this).text().split("/")[0].replace(/[^0-9\.]+/g,"")))return $(this).remove()});if($("#shopper_uim_coverage_id").length!==0)return $("#shopper_uim_coverage_id option").each(function(){if(a<Number($(this).text().split("/")[0].replace(/[^0-9\.]+/g,"")))return $(this).remove()})},n=function(){return $("select#shopper_pd_coverage_id").html($("div#pd-options").html())},l=function(){return $("select#shopper_comp_coverage_id").html($("div#comp-options").html())},o=function(){return $("select#shopper_um_bi_coverage_id").html($("div#umbi-options").html())},$("form[id=coverage]").live("ajax:success",function(a,b,c){return console.log("update coverage ajax success"),b.valid?($(".msg.success.coverage").html(b.msg),$(".msg.fail.coverage").html("")):($(".msg.fail.coverage").html(b.msg),$(".msg.success.coverage").html("")),$("#shopper-completed").html(b.completed)}),$("input[name='shopper[currently_insured]']").change(function(){return p()}),$("#shopper_bi_coverage_id").change(function(){return b(),c()}),$("#shopper_coll_coverage_id").change(function(){return a()}),$("#shopper_current_policy_expiration_month, #shopper_current_policy_expiration_day, #shopper_current_policy_expiration_year").autotab_magic().autotab_filter("numeric"),p(),$("#shopper-hover").live("mouseenter",function(){return $("#shopper-errors").show().fadeIn()}),$("#shopper-hover").live("mouseleave",function(){return $("#shopper-errors").hide().fadeOut()})})}.call(this),function(){$("html").is(".info-and-vehicles")&&$(document).ready(function(){var a,b,c,d,e,f,g,h,i,j;return $("form[id=info]").live("ajax:success",function(a,b,c){return console.log("update info ajax success"),b.valid?($(".msg.success.info").html(b.msg),$(".msg.fail.info").html("")):($(".msg.fail.info").html(b.msg),$(".msg.success.info").html("")),$("#shopper-completed").html(b.completed)}),$("#shopper_birth_month, #shopper_birth_day, #shopper_birth_year").autotab_magic().autotab_filter("numeric"),c=function(a){return a.empty().attr("disabled","disabled"),a},h=function(a){return c(a).html('<option selected="selected">Loading...</option>')},d=function(a){var b;b=$(a).serialize(),b.match(/year[^=&]+=[\w]+/)&&b.match(/make[^=&]+=[\w]+/)&&b.match(/model[^=&]+=[\w]+/)&&b.match(/style[^=&]+=[\w]+/)&&b.match(/ownership[^=&]+=[\w]+/)&&b.match(/primary_use[^=&]+=[\w]+/);if(b.match(/primary_use[^=&]+=commute/)){if(b.match(/commute_distance[^=&]+=[\w]+/)&&b.match(/commute_frequency[^=&]+=[\w]+/))return!0}else if(b.match(/annual_mileage[^=&]+=[\w]+/))return!0},b=function(a){return $(a+" .vehicle-preview").html("")},e=function(){return console.log("open commute called"),$("*#vehicle_primary_use_commute").each(function(a){return $(this).attr("checked")==="checked"?$(this).closest("div.group").nextAll("div.attached.commute").show():$(this).closest("div.group").nextAll("div.attached.commute").hide()})},f=function(){return console.log("open mileage called"),$("form").each(function(a){return $(this).find("#vehicle_primary_use_pleasure").attr("checked")==="checked"||$(this).find("#vehicle_primary_use_business").attr("checked")==="checked"?$(this).find("div.attached.mileage").show():$(this).find("div.attached.mileage").hide()})},$("select.vehicle-year").live("change",function(){var a,d,e,f,g,i;return i=encodeURIComponent($(this).val()),a=$(this).parents("form"),b("#"+a.attr("id")),d=a.find("select.vehicle-make"),e=a.find("select.vehicle-model"),f=a.find("select.vehicle-style"),g=a.parent().prev("h3.item").find("a"),$(g).text(i),h(d),c(e),c(f),d.load("/dataone/"+i+"/makes.html",function(){return d.removeAttr("disabled")})}),$("select.vehicle-make").live("change",function(){var a,d,e,f,g,i;return i=encodeURIComponent($(this).parents("form").find("select.vehicle-year").val()),a=$(this).parents("form"),b("#"+a.attr("id")),d=encodeURIComponent($(this).val()),e=a.find("select.vehicle-model"),f=a.find("select.vehicle-style"),g=a.parent().prev("h3.item").find("a"),$(g).text(i+" "+decodeURIComponent(d)),h(e),c(f),e.load("/dataone/"+i+"/"+d+"/models.html",function(){return e.removeAttr("disabled")})}),$("select.vehicle-model").live("change",function(){var a,c,d,e,f,g;return g=encodeURIComponent($(this).parents("form").find("select.vehicle-year").val()),a=$(this).parents("form"),b("#"+a.attr("id")),c=encodeURIComponent(a.find("select.vehicle-make").val()),d=encodeURIComponent($(this).val().replace(".","_")),e=a.find("select.vehicle-style"),f=a.parent().prev("h3.item").find("a"),$(f).text(g+" "+decodeURIComponent(c).split(" ")[0]+" "+$(this).val()),h(e),e.load("/dataone/"+g+"/"+c+"/"+d+"/styles.html",function(){return e.removeAttr("disabled")})}),$("div.usage input:radio").live({change:function(){return console.log("open usage selector toggled"),$(this).val()==="commute"?($(this).closest("div.group").nextAll("div.attached.mileage").hide(),$(this).closest("div.group").nextAll("div.attached.commute").show()):($(this).closest("div.group").nextAll("div.attached.mileage").show(),$(this).closest("div.group").nextAll("div.attached.commute").hide())}}),g=function(){return e(),f()},$("form[id=vehicle]").live("ajax:success",function(b,c,d){return console.log("update vehicle ajax success"),c.valid?($("#vehicle-form").html(c.vehicle),$(".msg.success.vehicle").html(c.msg),$(".msg.fail.vehicle").html(""),j(c.sidebar),a(c.title),i(c.driver),g()):($(".msg.fail.vehicle").html(c.msg),$(".msg.success.vehicle").html("")),$("#shopper-completed").html(c.completed)}),$("form[class=load-vehicle]").live("ajax:success",function(a,b,c){return console.log("load vehicle ajax success"),$("#vehicle-form").html(b.html),g()}),$("form[class=destroy-vehicle]").live("ajax:success",function(a,b,c){return $("#vehicle_id").val()===b.id&&$("#vehicle-form").html(b.html_new),j(b.sidebar),i(b.driver),$(".msg.success.vehicle").html(b.msg),$(".msg.fail.vehicle").html(""),$("#shopper-completed").html(b.completed)}),j=function(a){return $("#vehicle-list").html(a)},i=function(a){return $("#driver-form").html(a)},a=function(a){return $("#vehicle-form").find("h3").text(a)},g(),$("#shopper-hover").live("mouseenter",function(){return $("#shopper-errors").show().fadeIn()}),$("#shopper-hover").live("mouseleave",function(){return $("#shopper-errors").hide().fadeOut()})})}.call(this),function(){$("html").is(".outcome")&&$(document).ready(function(){return $("form[id=outcome]").live("ajax:success",function(a,b,c){return console.log("update outcome ajax success"),b.valid?($(".msg.success.outcome").html(b.msg),$(".msg.fail.outcome").html("")):($(".msg.fail.outcome").html(b.msg),$(".msg.success.outcome").html(""))}),$("a#ownership").live("click",function(a){var b;return a.preventDefault(),b=$("#current_advisor").val(),$.ajax({url:"/cis/lead/ownership/update",type:"POST",data:{advisor_id:b},success:function(a){return $("input#owner").val($("#current_advisor").attr("name")),$(".msg.success.ownership").html(a.msg)}})})})}.call(this),function(){$("html").is(".content.home")&&$(document).ready(function(){return $("div#rates div#marquee").marquee().mouseover(function(){return $(this).trigger("stop")}).mouseout(function(){return $(this).trigger("start")}),$("div.dialog").dialog({autoOpen:!1,modal:!0}),$("div#rates span#what-is-this a").click(function(a){return a.preventDefault(),$("div.dialog").dialog("open")}),$("#poll-box form#new_vote").submit(function(a){return a.preventDefault(),$.post(this.action,$(this).serialize(),null,"script")}),$("dl#poll dd a").click(function(a){return a.preventDefault(),$("input#"+this.id).attr("checked","checked").closest("form").submit()}),$("[placeholder]").parents("form").submit(function(){return $(this).find("[placeholder]").each(function(){var a;a=$(this);if(a.val()==="Enter Zip")return a.val("")})})}),$("html").is(".content.learning-center")&&$(document).ready(function(){return $("select#state").change(function(){return location.href="/?state="+$(this).val()})}),$("html").is(".content.services")&&$(document).ready(function(){return $("div#video-dialog").dialog({autoOpen:!1,width:640}),$("section#sub-nav p").click(function(a){return a.preventDefault(),$("div#video-dialog").dialog("open")})})}.call(this),function(){$(document).ready(function(){return $("input[placeholder]").each(function(a,b){if($(b).val()===""||$(b).val()===$(b).attr("placeholder"))return $(b).val($(b).attr("placeholder")).focusAndBlur($(b).attr("placeholder"))}),$.browser.msie&&($(".l-help").hover(function(){return $(this).parent().find(".help-r").show()},function(){return $(this).parent().find(".help-r").hide()}),$(".box-steps h3 a").hover(function(){return $(this).parent().parent().find(".help-l").show()},function(){return $(this).parent().parent().find(".help-l").hide()})),$(".blink").focus(function(){if($(this).val()===$(this).attr("title"))return $(this).val("")}),$(".blink").blur(function(){if($(this).val()==="")return $(this).val($(this).attr("title"))}),$(".btn-start").hover(function(){return $(this).css({"background-position":"0 -57px"})},function(){return $(this).css({"background-position":"0 0"})}),$(".box-steps h3 a").hover(function(){return $(this).parent().parent().find(".help-l").fadeIn("fast")},function(){return $(this).parent().parent().find(".help-l").fadeOut("fast")}),$(".btn-green").hover(function(){return $(this).css({"background-position":"0 -36px"})},function(){return $(this).css({"background-position":"0 0"})}),$(".l-help").hover(function(){return $(this).parent().find(".help-r").fadeIn("fast")},function(){return $(this).parent().find(".help-r").fadeOut("fast")}),$("a.offer").each(function(){return $(this).click(function(a){var b,c;return b=$(this).attr("data-click-path"),c=$(this).attr("data-offer-url"),$.getScript(b)}),$(this).attr("href",$(this).attr("data-offer-url"))})}),jQuery.fn.focusAndBlur=function(a){return $(this).attr("placeholder")===$(this).val()&&$(this).addClass("placeholder"),$(this).focus(function(){$(this).attr("placeholder")===$(this).val()&&$(this).removeClass("placeholder");if($(this).val()===a)return $(this).val("")}),$(this).blur(function(){$(this).val()===""&&$(this).val(a);if($(this).attr("placeholder")===$(this).val())return $(this).addClass("placeholder")})},jQuery.fn.earthquake=function(a){return $(this).animate({left:"20"},150).animate({left:"-10"},200).animate({left:"20"},200).animate({left:"0"},200)}}.call(this),function(){$("html").is(".info.team")&&$(document).ready(function(){return $("article div.bio p:first-child").show(),$("article div.bio.brief").click(function(){return $(this).toggleClass("brief")})})}.call(this),function(){}.call(this),$(document).ready(function(){$("html").is(".landings.insurance-center")&&$("section").on("click","article h3.title a",function(){if(!$(this).closest("article").is(".current"))return $(this).closest("article").addClass("current").siblings().removeClass("current"),!1})}),function(){$("html").is(".application-layout")&&$(document).ready(function(){var a,b;return a=document.createElement("script"),a.type="text/javascript",a.async=!0,a.src="https://apis.google.com/js/plusone.js",b=document.getElementsByTagName("script")[0],b.parentNode.insertBefore(a,b)})}.call(this),function(){$("html").is(".facebook-layout")&&$(document).ready(function(){var a;return $("div#fb-vote-dialog").dialog({autoOpen:!1,width:460}),a=function(a){return $("#fb-vote-dialog form").append('<input type="hidden" id="fb_uid" name="fb_uid"        value="'+a.authResponse.userID+'"/>'),$("div#fb-vote-dialog").dialog("open")},$("p#fb-vote a").click(function(b){return b.preventDefault(),FB.getLoginStatus(function(b){return b.authResponse?a(b):FB.login(function(b){return b.authResponse?a(b):alert("You need to log in to our app to vote.")})})}),$("div#fb-vote-dialog form button").click(function(a){return a.preventDefault(),$(this).closest("form").submit()}),$("div#fb-vote-dialog form a.cancel.button").click(function(a){return a.preventDefault(),$("div#fb-vote-dialog").dialog("close")}),$("div#fb-vote-dialog form").submit(function(a){return a.preventDefault(),$("div#fb-vote-dialog").dialog("close"),$.post(this.action,$(this).serialize(),null,"script")}),FB.Canvas.setSize({width:540,height:1375})})}.call(this),function(){$("html").is(".form-layout")&&$(document).ready(function(){return $("label span.help-icon").live("mouseenter",function(){return $(this).closest("div").find("div.help").show()}),$("label span.help-icon").live("mouseleave",function(){return $(this).closest("div").find("div.help").hide()}),$("dl.select dt a, dl.select dd a").live({click:function(){return $(this).closest("dl").is(".open")?$(this).closest("dl").removeClass("open"):$(this).closest("dl").addClass("open"),!1}})})}.call(this),function(){$("html").is(".premium-layout")&&$(document).ready(function(){var a,b;return b=":text.required:not([value]), ul.checkboxes.required:not(:has(:checkbox:checked)),      ul.radio-buttons.required:not(:has(:radio:checked)), select.required:not([value])",a=function(){return $(b).length!==0||$("#insured-yes:checked").length!==0&&$(":input.required-if-insured:not([value])").length!==0?$("div.buttons a").addClass("disabled"):$("div.buttons a").removeClass("disabled")},$("div.buttons a.submit").live("click",function(a){return a.preventDefault(),$(this).is(":not(.disabled)")?$(this).closest("form").submit():$(b).addClass("error").closest("div.group").addClass("error").earthquake()}),$("#insured-yes:checked").length===1&&$(":input.required-if-insured:not([value])").addClass("error").closest("div.group").addClass("error").earthquake(),$(this).addClass("disabled"),$("div#progress-bar li.current").prevAll().addClass("complete"),$("div#progress-bar li:not([class=complete])").click(function(a){return a.preventDefault()}),$(":input.required, ul.required :input, :input.required-if-insured").live("change",function(){return a()}),a()})}.call(this),function(){$("html").is(".premium.info")&&$(document).ready(function(){var a;return a=function(){if($("input#shopper_first_name").val()!==""&&$("input#shopper_last_name").val()!==""&&$("input#shopper_email").val()!==""&&$("input#shopper_street_address").val()!==""&&$("input#shopper_city").val()!==""&&$("input#state_str").val()!==""&&$("input#shopper_zip_code").val()!==""&&$("input#shopper_birth_month").val()!==""&&$("input#shopper_birth_month").val()!=="mm"&&$("input#shopper_birth_day").val()!==""&&$("input#shopper_birth_day").val()!=="dd"&&$("input#shopper_birth_year").val()!==""&&$("input#shopper_birth_year").val()!=="yyyy")return $("button#next").removeClass("disabled");if(!$("button#next").hasClass("disabled"))return $("button#next").addClass("disabled")},$("input").change(function(){return a()}),$("#shopper_birth_month, #shopper_birth_day, #shopper_birth_year").autotab_magic().autotab_filter("numeric"),a()}),$("html").is(".premium.sorry")&&$(document).ready(function(){return $("form#subscribe-form").live("ajax:success",function(a,b,c){return $("div#msg").html(b.html).show()})}),$("html").is(".premium.coverage")&&$(document).ready(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;return $("form:first").live("ajax:success",function(a,b,c){return console.log("something"),b.valid?(console.log("ajax form success (valid)"),$("#coverage-errors").html(""),$("#recommended-coverages").hide(),$("#recommended-coverages").html(b.html),l(),g()):(console.log("ajax form success (invalid)"),$("#coverage-section").hide("slow"),$("#recommended-coverages").html("").fadeTo("slow",0),$("#coverage-errors").html(b.html))}),m=function(){return console.log("toggle called"),$("#shopper_currently_insured_true").is(":checked")===!0?($("div#current-insurance").show(),$("div#no-insurance").hide(),$("#shopper_coverage_lapse_duration").val("")):$("#shopper_currently_insured_false").is(":checked")===!0&&($("div#current-insurance").hide(),$("div#no-insurance").show(),$("#shopper_current_carrier_id").val(""),$("#shopper_current_policy_expiration_month").val(""),$("#shopper_current_policy_expiration_day").val(""),$("#shopper_current_policy_expiration_year").val(""),$("#shopper_current_insured_duration").val("")),f("form:first")?(console.log("calling submit"),$("form:first").submit()):($("#recommended-coverages").html("").fadeTo("slow",0),$("#coverage-section").hide("slow"))},f=function(b){var c;return c=$(b).serialize(),c.match(/currently_insured%5D=true/)?c.match(/current_carrier_id[^=&]+=[\w]/)&&c.match(/current_insured_duration[^=&]+=[\w]/)?!0:(a(),!1):c.match(/coverage_lapse_duration%5D=&shopper/)?(a(),!1):!0},l=function(){return $("#coverage-section").show("slow"),$("#loading-screen").fadeIn("slow").delay(2e3).fadeOut("slow",function(){return $("#recommended-coverages").fadeTo("slow",1),b()})},b=function(){if($("button#finish").hasClass("disabled"))return $("button#finish").removeClass("disabled")},a=function(){if(!$("button#finish").hasClass("disabled"))return $("button#finish").addClass("disabled")},g=function(){var a,b,e;return this.recommended_bi=$("#bi-selected").find("a").attr("id"),this.recommended_pd=$("#pd-selected").find("a").attr("id"),this.recommended_comp=$("#comp-selected").find("a").attr("id"),this.recommended_coll=$("#coll-selected").find("a").attr("id"),this.recommended_um_bi=$("#dd-um-bi .recommended").attr("id"),a="",$("div#other-coverages #uim").text()==="true"?$("#dd-uim dd").each(function(){if($(this).text().trim()===$("#dd-um-bi .recommended").text().trim())return a=$(this).attr("id")}):a=$("dd.uim-item").attr("id"),this.recommended_uim=a,b="",$("#dd-um-pd dd").each(function(){if($(this).text().trim()==="No Coverage")return b=$(this).attr("id")}),this.recommended_um_pd=b,this.recommended_mp=$("div#other-coverages #mp").text().trim(),this.recommended_tl=$("div#other-coverages #tl").text().trim(),this.recommended_rr=$("div#other-coverages #rr").text().trim(),this.recommended_bi_html=$("#bi-selected").html().trim(),this.recommended_pd_html=$("#pd-selected").html().trim(),this.recommended_comp_html=$("#comp-selected").html().trim(),this.recommended_coll_html=$("#coll-selected").html().trim(),$("#shopper_bi_coverage_id").val()===""?$("#shopper_bi_coverage_id").val(this.recommended_bi):(e="a#"+$("#shopper_bi_coverage_id").val(),k($(".bi-item").find(e).parent(),"bi")),$("#shopper_pd_coverage_id").val()===""?$("#shopper_pd_coverage_id").val(this.recommended_pd):(e="a#"+$("#shopper_pd_coverage_id").val(),k($(".pd-item").find(e).parent(),"pd")),$("#shopper_comp_coverage_id").val()===""?$("#shopper_comp_coverage_id").val(this.recommended_comp):(e="a#"+$("#shopper_comp_coverage_id").val(),k($(".comp-item").find(e).parent(),"comp")),$("#shopper_coll_coverage_id").val()===""?$("#shopper_coll_coverage_id").val(this.recommended_coll):(e="a#"+$("#shopper_coll_coverage_id").val(),k($(".coll-item").find(e).parent(),"coll")),$("#shopper_um_bi_coverage_id").val()===""&&$("#shopper_um_bi_coverage_id").val(this.recommended_um_bi),$("#shopper_um_pd_coverage_id").val()===""&&$("#shopper_um_pd_coverage_id").val(this.recommended_um_pd),$("#shopper_uim_coverage_id").val()===""&&$("#shopper_uim_coverage_id").val(this.recommended_uim),$("#shopper_mp_coverage_id").val()===""&&$("#shopper_mp_coverage_id").val(this.recommended_mp),$("#shopper_tl_coverage_id").val()===""&&$("#shopper_tl_coverage_id").val(this.recommended_tl),$("#shopper_rr_coverage_id").val()===""&&$("#shopper_rr_coverage_id").val(this.recommended_rr),d(),c(),n()},n=function(){$("#bi-selected").find("a").attr("id")===this.recommended_bi&&$("#pd-selected").find("a").attr("id")===this.recommended_pd?$("#why-we-recommend-bi-pd").fadeTo("slow",1):($("#why-we-recommend-bi-pd").fadeTo("slow",0),$("#reload-recommendations").fadeIn("fast")),$("#comp-selected").find("a").attr("id")===this.recommended_comp?$("#why-we-recommend-comp").fadeTo("slow",1):($("#why-we-recommend-comp").fadeTo("slow",0),$("#reload-recommendations").fadeIn("fast")),$("#coll-selected").find("a").attr("id")===this.recommended_coll?$("#why-we-recommend-coll").fadeTo("slow",1):($("#why-we-recommend-coll").fadeTo("slow",0),$("#reload-recommendations").fadeIn("fast"));if($("#bi-selected").find("a").attr("id")===this.recommended_bi&&$("#pd-selected").find("a").attr("id")===this.recommended_pd&&$("#comp-selected").find("a").attr("id")===this.recommended_comp&&$("#coll-selected").find("a").attr("id")===this.recommended_coll)return $("#reload-recommendations").fadeOut(),d(),c()},k=function(a,b){return $("#"+b+"-selected").html($(a).html()),$("#"+b+"-selected span.item-title").css("display","inline"),$("#"+b+"-selected span.pr").addClass("br"),b==="bi"?$("#shopper_bi_coverage_id").val($(a).find("a").attr("id")):b==="pd"?$("#shopper_pd_coverage_id").val($(a).find("a").attr("id")):b==="comp"?$("#shopper_comp_coverage_id").val($(a).find("a").attr("id")):b==="coll"&&$("#shopper_coll_coverage_id").val($(a).find("a").attr("id")),n()},h=function(){return $("#bi-selected").html(this.recommended_bi_html),$("#pd-selected").html(this.recommended_pd_html),$("#comp-selected").html(this.recommended_comp_html),$("#coll-selected").html(this.recommended_coll_html),$("#shopper_bi_coverage_id").val($("#bi-selected a").attr("id")),$("#shopper_pd_coverage_id").val($("#pd-selected a").attr("id")),$("#shopper_comp_coverage_id").val($("#comp-selected a").attr("id")),$("#shopper_coll_coverage_id").val($("#coll-selected a").attr("id")),$("#shopper_um_bi_coverage_id").val(this.recommended_um_bi),$("#shopper_um_pd_coverage_id").val(this.recommended_um_pd),$("#shopper_uim_coverage_id").val(this.recommended_uim),$("#shopper_mp_coverage_id").val(this.recommended_mp),$("#shopper_tl_coverage_id").val(this.recommended_tl),$("#shopper_rr_coverage_id").val(this.recommended_rr),$("#reload-recommendations").fadeOut(),n()},j=function(){return $("div#property-coverage dl").children("dd").remove(),$("div#property-coverage dl").append($("#dd-pd").html())},i=function(){return $("div#comprehensive-deductible dl").children("dd").remove(),$("div#comprehensive-deductible dl").append($("#dd-comp").html())},d=function(){var a,b,c,d,e;j(),a=$("div#bodily-coverage dt span.pr").text().split("/"),c=a[0].trim(),d=$("dt#pd-selected span.pr").text().trim(),e=!1,b=!1,$("div#property-coverage dd.pd-item").each(function(){if(c===$(this).find("span.pr").text().trim())return e=!0;if(e===!0)return d===$(this).find("span.pr").text().trim()&&(b=!0),$(this).remove()});if(b===!0)return k($("div#property-coverage dd:last"),"pd")},e=function(){var a,b;return a=Number($("div#bodily-coverage dt span.pr").text().split(" / ")[0].replace(/[^0-9\.]+/g,"")),b=!1,$(".um-item").each(function(){var c;c=Number($(this).text().split(" / ")[0].replace(/[^0-9\.]+/g,""));if(a<c&&b===!1)return $("#shopper_uninsured_motorist_bodily_injury_liability").val($(this).prev(".um-item").text()),$("div#other-coverages #uim").text()==="true"&&$("#shopper_underinsured_motorist_bodily_injury_liability").val($(this).prev(".um-item").text()),b=!0})},c=function(){i();if($("div#collision-deductible dt span.pr").text()!=="No Coverage"){$("div#comprehensive-deductible dd.comp-item").each(function(){if($(this).find("span.pr").text()==="No Coverage")return $(this).remove()});if($("div#comprehensive-deductible dt span.pr").text()==="No Coverage")return k($("div#comprehensive-deductible dd:last"),"comp")}},$(".radio-buttons label").live("click",function(a){var b,c;return a.preventDefault(),b=$(this),c=b.prev("input[type=radio]"),c.click()}),$("[placeholder]").focus(function(){var a;a=$(this);if(a.val()===a.attr("placeholder"))return a.val(""),a.removeClass("placeholder")}).blur(function(){var a;a=$(this);if(a.val()===""||a.val()===a.attr("placeholder"))return a.addClass("placeholder"),a.val(a.attr("placeholder"))}).blur(),$("[placeholder]").parents("form").submit(function(){return $(this).find("[placeholder]").each(function(){var a;a=$(this);if(a.val()===a.attr("placeholder"))return a.val("")})}),$("input[name='shopper[currently_insured]']").change(function(){return m()}),$(".bi-item").live("mousedown",function(){return k($(this),"bi"),d(),e()}),$(".pd-item").live("mousedown",function(){return k($(this),"pd")}),$(".comp-item").live("mousedown",function(){return k($(this),"comp")}),$(".coll-item").live("mousedown",function(){return k($(this),"coll"),c()}),$("#reload").live("click",function(){return h()}),$("input, select").change(function(){if(f("form:first"))return $("form:first").submit()}),$("#shopper_current_policy_expiration_month, #shopper_current_policy_expiration_day, #shopper_current_policy_expiration_year").autotab_magic().autotab_filter("numeric"),m()}),$("html").is(".premium.done")&&$(document).ready(function(){var a,b,c,d,e,f,g,h;return d=function(){return c(),e(),h(),f(),g(),a()},h=function(){switch($('[name="proximity"]').val()){case"all":return $(".0-10miles, .11-20miles, .21plusmiles, .not-local").removeClass("hidden-miles");case"0-10miles":return $(".11-20miles, .21plusmiles, .not-local").addClass("hidden-miles"),$(".0-10miles").removeClass("hidden-miles");case"11-20miles":return $(".0-10miles, .21plusmiles, .not-local").addClass("hidden-miles"),$(".11-20miles").removeClass("hidden-miles");case"21plusmiles":return $(".0-10miles, .11-20miles, .not-local").addClass("hidden-miles"),$(".21plusmiles").removeClass("hidden-miles")}},c=function(){switch($('[name="agent"]:radio:checked').val()){case"either":return $(".carrier").removeClass("hidden-agent");case"yes":return $(".carrier.agent").removeClass("hidden-agent")&&$(".carrier.direct").addClass("hidden-agent");case"no":return $(".carrier.agent").addClass("hidden-agent")&&$(".carrier.direct").removeClass("hidden-agent")}},e=function(){switch($('[name="multi-line"]:radio:checked').val()){case"all":return $(".carrier.mono-line").removeClass("hidden-multi-line");case"only":return $(".carrier.mono-line").addClass("hidden-multi-line")}},f=function(){return $('[name="online_any"]').attr("checked")==="checked"?$(".carrier.offline").addClass("hidden-online"):$(".carrier.offline").removeClass("hidden-online")},g=function(){return $('[name="online_submit"]').attr("checked")==="checked"?$(".carrier.offline-claims").addClass("hidden-online-claim"):$(".carrier.offline-claims").removeClass("hidden-online-claim")},a=function(){var a;return a=0,$(".carrier").each(function(){if($(this).css("display")!=="none")return a+=1}),a===0?($("h2#no-results").show(),$("menu#results-head").hide()):($("h2#no-results").hide(),$("menu#results-head").show())},$('[name="agent"]:radio').live({change:function(){return c(),a()}}),$('[name="multi-line"]:radio').live({change:function(){return e(),a()}}),$('[name="online_any"]').live({click:function(b){return f(),a()}}),$('[name="online_submit"]').live({click:function(b){return g(),a()}}),$('[name="proximity"]').live({change:function(b){return h(),a()}}),$("a.email-rate").bind("ajax:before",function(a){return $(this).hasClass("request-sent")?!1:($(this).removeClass("green"),$(this).addClass("request-sent"))}),$("a.email-rate").bind("ajax:success",function(a,b,c){return $(this).text("Request Sent")}),$("menu li.toggle a").live({click:function(a){return a.preventDefault(),$(this).closest("li.carrier").toggleClass("show-info")}}),$("menu#results-head li a").click(function(a){return a.preventDefault(),$(this).parent().addClass("current").siblings().removeClass("current")}),$("h3#premium-coverage a").click(function(a){return a.preventDefault(),$(this).closest("div.box").toggleClass("collapsed")}),$(".coverage.dialog").dialog({autoOpen:!1,modal:!0,width:538}),$("div.title h3 a, span#customize a").click(function(a){return a.preventDefault(),$(this).next(".coverage.dialog").dialog("open")}),b=function(a){var b,c,d;b=a.find(".map_canvas");if(b.text()!=="")return;return c=new google.maps.Map(b[0],{zoom:8,center:new google.maps.LatLng(-34.397,150.644),mapTypeId:google.maps.MapTypeId.ROADMAP}),d=new google.maps.DirectionsService,d.route({origin:a.find(".origin").text(),destination:a.find(".destination").text(),travelMode:google.maps.TravelMode.DRIVING},function(a,b){var d;return d=new google.maps.DirectionsRenderer({directions:a,map:c})})},$(".map.dialog").dialog({autoOpen:!1,modal:!0,width:675}),$("div.info a.map").click(function(a){var c,d;return a.preventDefault(),d=$(this).attr("id").substring(4),c=$("#map-dialog-"+d),c.dialog("open"),b(c)}),$(".checkboxes label").live("click",function(a){var b,c;return a.preventDefault(),c=$(this),b=$(this).prev("[type=checkbox]"),b.click(),d()}),$("menu#results-head a").live("click",function(){return event.preventDefault(),$.ajax({url:"/results/sort",type:"POST",data:{order:$(this).attr("id")},success:function(a){return $("section#results").html(a.html),d()}})})})}.call(this),function(){$("html").is(".rec.begin")&&$(document).ready(function(){return $("div#coverage-group input").change(function(){return $(this).closest("li").addClass("current").siblings().removeClass("current")}),$("div#currently-insured input").change(function(){return $(this).val()==="true"?$("div#current-carrier").show():($("div#current-carrier").hide(),$("div#current-carrier select").val(""))})}),$("html").is(".rec.step_by_step")&&$(document).ready(function(){return $("form").submit(function(a){return a.preventDefault(),$.post($(this).attr("action"),{success:function(){return $("menu#pagination li.current").removeClass("current").next().addClass("current"),$("menu#slides li.slide.current").animate({left:"-1500",opacity:0},750,function(){return $(this).removeClass("current").next().addClass("current").css({left:"1500px",opacity:0}).animate({left:0,opacity:1},650)})}})}),$("div#coverage-group input").change(function(){return $(this).closest("li").addClass("current").siblings().removeClass("current")})})}.call(this),function(){$("html").is(".sources.login")&&$(document).ready(function(){return $("#email").focus()})}.call(this)
