Advertisement
Guest User

Untitled

a guest
Jan 17th, 2012
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function query_params(qry) {
  2.     var pairs = (qry || location.search).replace(/^\?/, "").split("&"), params = {};
  3.     _.each(pairs, function (p) {
  4.         var kv = p.split("=");
  5.         params[kv[0]] = decodeURIComponent(kv[1]);
  6.     });
  7.     return params;
  8. }
  9. function euclidean_distance(pt1, pt2) {
  10.     return Math.sqrt(Math.pow(pt2[0] - pt1[0], 2) + Math.pow(pt2[1] - pt1[1], 2));
  11. }
  12. function remove_node(node) {
  13.     return node.parentNode.removeChild(node);
  14. }
  15. window.Venue = Backbone.Model.extend({});
  16. window.Event = Backbone.Model.extend({initialize:function () {
  17.     this.set({absolute_url:"http://seatgeek.com" + this.get("url")}, {silent:true});
  18. }});
  19. window.AppView = Backbone.View.extend({events:{"click .listing .select":"handleBuyClick", "click .alt-listing .select":"handleBuyClick", "click .zoom-here":"handleZoomHere", "click .show-details":"handleShowDetails", "click .details-close":"handleShowDetails"}, initialize:function () {
  20.     var that = this, params = {}, query = query_params();
  21.     this.event = new Event(this.options.event);
  22.     this.venue = new Venue(this.options.venue);
  23.     params["id"] = this.event.get("id");
  24.     _.each(query, function (value, key) {
  25.         params[key] = value;
  26.     }, this);
  27.     params["trf"] = 1;
  28.     this.listings = new ListingCollection();
  29.     function default_listings_source(callback) {
  30.         jQuery.get('/event/tickets/', params, function (response) {
  31.             if (!response.deal_quality) {
  32.                 jQuery("body").addClass("no-deal-quality");
  33.                 jQuery("#sort-bar .price").addClass("asc");
  34.             }
  35.             that.listings.reset(response.listings);
  36.             that.listings.setupDeprecatedState(response);
  37.             callback();
  38.         });
  39.     }
  40.  
  41.     (this.options.listings_source || default_listings_source)(function () {
  42.         SG.map.fire("sg:listings-ready");
  43.     });
  44.     jQuery(function () {
  45.         SG.map.init(that.options);
  46.         that.filters = new FiltersView({el:jQuery(".map-content .filters")[0]});
  47.         that.sidebar = new SidebarView({el:jQuery(".map-content .sidebar")[0]});
  48.     });
  49.     jQuery("sg:login", function () {
  50.         SG.map.track("login");
  51.     });
  52. }, handleBuyClick:function (e) {
  53.     var select = jQuery(e.currentTarget), alt = select.closest(".alt-listing"), ticket = alt.size() == 1 ? alt : select.closest(".listing");
  54.     var params = {url:ticket.find("a.select").attr("href"), price:ticket.attr("price"), section:ticket.attr("section"), row:ticket.attr("row"), quantity:ticket.attr("quantity"), original:ticket.attr("baseprice"), fees:ticket.attr("fees"), shipping:ticket.attr("shipping"), pickup_only:ticket.attr("pickup_only"), market_name:ticket.attr("market"), market_full:ticket.attr("market_full"), splits:ticket.attr("splits").split(",")};
  55.     SG.map.track("buy-now-click", jQuery(select).is(".sidebar *") ? "sidebar" : "popup");
  56.     if (this.buy_click_callback) {
  57.         if (!this.buy_click_callback.call(this, e, params)) {
  58.             return;
  59.         }
  60.     }
  61.     function post_click() {
  62.         var show_timeout, mousemove_handler;
  63.         mousemove_handler = function () {
  64.             if (show_timeout)clearTimeout(show_timeout);
  65.             jQuery(document).unbind("mousemove", mousemove_handler);
  66.         };
  67.         jQuery(document).mousemove(mousemove_handler);
  68.         show_timeout = setTimeout(function () {
  69.             jQuery(document).unbind("mousemove", mousemove_handler);
  70.             SG.post_purchase();
  71.         }, 10000);
  72.     }
  73.  
  74.     if (params["market_name"] === "ebay") {
  75.         e.preventDefault();
  76.         SG.warn_ebay(params, {callback:post_click});
  77.     } else {
  78.         post_click();
  79.     }
  80. }, setBuyClickCallback:function (cb) {
  81.     this.buy_click_callback = cb;
  82. }, handleZoomHere:function (e) {
  83.     var el = jQuery(e.currentTarget), l = el.closest(".listing-container").children(".listing"), key = l.attr("mapkey"), k = helpers.parseMapKey(key);
  84.     SG.map.zoomToSection(k.s);
  85.     SG.map.fire("sg:row-click", {key:key, el:el});
  86.     SG.map.track("zoom-here-click", el.is(".sidebar *") ? "sidebar" : "popup");
  87.     return false;
  88. }, handleShowDetails:function (e) {
  89.     var el = jQuery(e.currentTarget), showDetails = true;
  90.     if (el.hasClass("details-close")) {
  91.         var details = el.closest(".details");
  92.     }
  93.     else {
  94.         var details = el.parent().parent().parent().siblings(".details");
  95.     }
  96.     if (!details.is(":visible")) {
  97.         details.slideDown(function () {
  98.             SG.map.repositionToRevealPopup();
  99.             SG.map.showListingDetails(details);
  100.         });
  101.         el.closest(".listing-container").find(".show-details a").text("hide details");
  102.         showDetails = true;
  103.     } else {
  104.         details.slideUp();
  105.         el.closest(".listing-container").find(".show-details a").text("show details");
  106.         showDetails = false;
  107.     }
  108.     SG.map.track("show-details-" + (showDetails ? "open" : "close"), el.is(".sidebar *") ? "sidebar" : "popup");
  109.     return false;
  110. }, render:function (e) {
  111.     app.sidebar.render();
  112.     try {
  113.         SG.map.render();
  114.     } catch (e) {
  115.     }
  116. }});
  117. var SG = SG || {};
  118. SG.chart = SG.chart || {};
  119. SG.chart = (function (C) {
  120.     var loaded = false;
  121.     return{load:function () {
  122.         if (loaded)return false;
  123.         jQuery.getJSON("/event/price_graph_data", {id:app.event.get("id")}, function (data) {
  124.             loaded = true;
  125.             if (data.length <= 0) {
  126.                 jQuery(".analytics-graph .inner").html(['<div style="padding:120px 0 0 4px; text-align:center; font-size:14px; text-shadow:0px 1px 1px black; color:white">', 'Graph currently unavailable', '</div>'].join("\n"));
  127.                 return;
  128.             }
  129.             var has_price_ratio = _.all(data, function (t, date) {
  130.                 return!!t["avg_price_ratio"];
  131.             });
  132.             if (has_price_ratio) {
  133.                 jQuery(".analytics-graph h4").text("Historical prices as a % of face value")
  134.             }
  135.             var d = _.map(data, function (t, date) {
  136.                 var ps = date.split("-"), dt = new Date(parseInt(ps[0], 10), parseInt(ps[1], 10) - 1, parseInt(ps[2], 10));
  137.                 return[dt.getTime(), parseFloat(t[has_price_ratio ? "avg_price_ratio" : "avg_price"], 10), parseInt(t["quantity"], 10)];
  138.             });
  139.             var rolling_days = 5, smoothed = [], roll_sum, roll_qnt;
  140.             for (var i = 0; i < d.length; ++i) {
  141.                 if (i < rolling_days)continue;
  142.                 roll_sum = 0, roll_qnt = 0;
  143.                 for (var j = i - rolling_days + 1; j <= i; ++j) {
  144.                     roll_sum += d[j][1] * d[j][2];
  145.                     roll_qnt += d[j][2];
  146.                 }
  147.                 smoothed.push([d[i][0], Math.round((roll_sum / roll_qnt) * 100) / 100]);
  148.             }
  149.             var series1 = {data:smoothed, color:"#368EBB", shadowSize:4};
  150.             var opts = {xaxis:{mode:"time", ticks:7, minTickSize:[5, "day"]}, yaxis:{min:0, tickFormatter:function (val, axis) {
  151.                 return has_price_ratio ? Math.round(val * 100.0) + "%" : "$" + Math.round(val);
  152.             }}, grid:{borderWidth:0, minBorderMargin:0, color:"#374F6C"}, series:{lines:{fill:true, fillColor:{colors:[
  153.                 {opacity:0.55},
  154.                 {opacity:0.2}
  155.             ]}, shadowSize:5}}};
  156.             jQuery.plot(jQuery(".analytics-graph .inner"), [series1], opts);
  157.         });
  158.     }};
  159. })(SG.chart);
  160. var SG = SG || {};
  161. SG.draggable = function (elem, receiver) {
  162.     var that = this;
  163.     this.dragging = false;
  164.     this.lastdX = null;
  165.     this.lastdY = null;
  166.     this.startX = null;
  167.     this.startY = null;
  168.     this.mouseStartX = null;
  169.     this.mouseStartY = null;
  170.     this.elem = elem;
  171.     this.receiver = receiver || elem;
  172.     function dragMouse(e) {
  173.         var dX, dY;
  174.         if (!that.dragging)return;
  175.         dX = e.clientX - that.mouseStartX, dY = e.clientY - that.mouseStartY;
  176.         if (dX !== that.lastdX) {
  177.             that.elem.style.left = (that.startX + dX) + "px";
  178.             that.lastdX = dX;
  179.         }
  180.         if (dY !== that.lastdY) {
  181.             that.elem.style.top = (that.startY + dY) + "px";
  182.             that.lastdY = dY;
  183.         }
  184.     }
  185.  
  186.     function dragStop(e) {
  187.         that.dragging = false;
  188.         jQuery(that.receiver).removeClass("dragging");
  189.     }
  190.  
  191.     jQuery(document).mousemove(dragMouse);
  192.     jQuery(document).mouseup(dragStop);
  193.     if (jQuery.browser.msie)jQuery(document).click(dragStop);
  194.     jQuery(this.receiver).mousedown(function (e) {
  195.         that.dragging = true;
  196.         that.lastdX = null;
  197.         that.lastdY = null;
  198.         that.startX = that.elem.offsetLeft;
  199.         that.startY = that.elem.offsetTop;
  200.         that.mouseStartX = e.clientX;
  201.         that.mouseStartY = e.clientY;
  202.         jQuery(that.receiver).addClass("dragging");
  203.         return false;
  204.     });
  205. };
  206. jQuery(function () {
  207.     var price_slider = jQuery("#price_slider");
  208.  
  209.     function slider_tranformation(f, invf, slmin, slmax, valmin, valmax) {
  210.         this.f = f;
  211.         this.invf = invf;
  212.         this.slmin = slmin;
  213.         this.slmax = slmax;
  214.         this.valmin = valmin;
  215.         this.valmax = valmax;
  216.         this.vmin = this.invf(valmin);
  217.         this.vmax = this.invf(valmax);
  218.         this.scale = (this.vmax - this.vmin) / (this.slmax - this.slmin)
  219.     }
  220.  
  221.     slider_tranformation.prototype.sliderToVal = function (sv) {
  222.         if (sv == this.slmin)return this.valmin;
  223.         if (sv == this.slmax)return this.valmax;
  224.         return this.f(this.vmin + this.scale * (sv - this.slmin));
  225.     };
  226.     slider_tranformation.prototype.valToSlider = function (v) {
  227.         return this.slmin + (this.invf(v) - this.vmin) / this.scale;
  228.     };
  229.     function setup_price_slider(max) {
  230.         var max = max < 0 ? 1000 : max;
  231.         var transform = new slider_tranformation(function (x) {
  232.             return Math.pow(x, 2)
  233.         }, function (x) {
  234.             return Math.pow(x, 1 / 2)
  235.         }, 0, 171, 0, max);
  236.         jQuery("#max_price").val(max);
  237.         price_slider.slider({min:0, max:171, step:1, values:[0, 171], range:true, slide:function update_inputs() {
  238.             var min_handle = price_slider.slider("values", 0), max_handle = price_slider.slider("values", 1);
  239.             jQuery("#min_price").val(Math.floor(transform.sliderToVal(min_handle)));
  240.             jQuery("#max_price").val(Math.ceil(transform.sliderToVal(max_handle)));
  241.         }, stop:function (event, ui) {
  242.             var min_handle = price_slider.slider("values", 0), max_handle = price_slider.slider("values", 1);
  243.             jQuery("#min_price").val(Math.floor(transform.sliderToVal(min_handle)));
  244.             jQuery("#max_price").val(Math.ceil(transform.sliderToVal(max_handle)));
  245.             app.filters.filterListings();
  246.             SG.map.track("filter-change", "price");
  247.         }});
  248.         if (Browser.IE) {
  249.             jQuery('.filters .slider .handle').css({'top':'0', 'margin-top':'1px'});
  250.             jQuery('.filters .slider .track').css({'position':'absolute', 'margin-top':'6px'});
  251.         }
  252.         jQuery("#min_price").add("#max_price").unbind("change");
  253.         jQuery("#min_price").add("#max_price").change(function () {
  254.             price_slider.slider("values", [transform.valToSlider(jQuery("#min_price").val()), transform.valToSlider(jQuery("#max_price").val())]);
  255.         });
  256.     }
  257.  
  258.     ;
  259.     SG.map.observe("sg:listings-ready", function () {
  260.         var prices = _.map(app.listings.getAllListings(), function (l) {
  261.             return l.pf;
  262.         }), avg, median = prices[Math.floor(prices.length / 2)], sum = 0, i = 0, max = Math.max.apply(Math, prices);
  263.         setup_price_slider(max);
  264.         for (; i < prices.length; ++i)sum += prices[i];
  265.         avg = Math.round(sum / prices.length);
  266.         jQuery("#avg_price").html(avg > 0 ? "$" + avg : "--");
  267.     });
  268.     SG.map.observe("sg:listings-ready", function () {
  269.         var prs, avg, sum = 0, i = 0;
  270.         if (window.event_info.has_face_value) {
  271.             prs = _.filter(_.map(app.listings.getAllListings(), function (l) {
  272.                 return l.pr;
  273.             }), function (pr) {
  274.                 return pr !== undefined;
  275.             });
  276.             for (; i < prs.length; ++i)sum += parseFloat(prs[i], 10);
  277.             avg = Math.round(sum / prs.length);
  278.             jQuery("#avg_price_ratio").html(avg > 0 ? avg + "%" : "--");
  279.         }
  280.     });
  281.     var zoom_slider = jQuery(".zoom .track"), zoom_handle = jQuery(".zoom .handle");
  282.     zoom_slider.slider({min:0, max:3, step:1, value:0, orientation:"vertical", change:function (event, ui) {
  283.         var val = (ui.value - 3) * -1;
  284.         SG.map.setView(ui.value);
  285.         SG.map.track("zoom", "slider");
  286.     }});
  287.     jQuery(".zoom .track-ext").click(function () {
  288.         zoom_slider.slider("value", 3)
  289.     });
  290.     SG.map.observe("sg:map-view-change", function (e, data) {
  291.         zoom_slider.slider("value", data.index);
  292.     });
  293.     jQuery(".no-fees-message .close").click(function (e) {
  294.         jQuery(".no-fees-message").hide();
  295.         return false;
  296.     });
  297.     var atimeout = null;
  298.     var time = 12000;
  299.  
  300.     function runAnimation() {
  301.         jQuery('.scrolling-sellers').animate({left:'-1087px'}, time).animate({left:'286px'}, time);
  302.         jQuery('.magnified-sellers').animate({left:'-1852px'}, time).animate({left:'127px'}, time);
  303.         atimeout = setTimeout("runAnimation()", time * 2);
  304.     }
  305.  
  306.     jQuery(function () {
  307.         runAnimation();
  308.     });
  309.     function stopAnimation() {
  310.         clearTimeout(atimeout);
  311.         jQuery('.animated').stop(true, false);
  312.         jQuery('#listing_sidebar').show(100);
  313.         jQuery('#window').css('right', '332px');
  314.         SG.map.centerMap();
  315.         jQuery('#sgloading').fadeOut(250, function () {
  316.             jQuery('#loading-animation').remove();
  317.         });
  318.     }
  319.  
  320.     SG.map.observe("sg:map-ready", function () {
  321.         stopAnimation();
  322.         setTimeout('runPreloadImages();', 3000);
  323.     });
  324. });
  325. jQuery(function () {
  326.     var recursions = 0;
  327.  
  328.     function adjustTitleWidth() {
  329.         if (jQuery(".event-info h1 span").size() <= 0)return;
  330.         var m = jQuery(".event-info h1 span"), width = m.width() + parseInt(m.closest(".event-info").css("padding-left"), 10), maxwidth = jQuery("#listing_sidebar").position().left, h1;
  331.         if (width > maxwidth && recursions <= 13) {
  332.             h1 = m.closest("h1");
  333.             h1.css({fontSize:(parseInt(h1.css("fontSize"), 10) - 1) + "px"});
  334.             recursions += 1;
  335.             adjustTitleWidth();
  336.         } else {
  337.             recursions = 0;
  338.         }
  339.     }
  340.  
  341.     ;
  342.     adjustTitleWidth();
  343.     jQuery(window).resize(adjustTitleWidth);
  344. });
  345. function applyFilters(filters, ls) {
  346.     function all(fs, listing) {
  347.         for (var i = 0, ilen = fs.length; i < ilen; ++i)
  348.             if (!fs[i](listing))return false;
  349.         return true;
  350.     }
  351.  
  352.     var ret = [];
  353.     for (var i = 0, ilen = ls.length; i < ilen; ++i)
  354.         if (all(filters, ls[i]))ret.push(ls[i]);
  355.     return ret;
  356. }
  357. ;
  358. function priceFilter(min, max) {
  359.     return function (listing) {
  360.         var p = listing.pf;
  361.         if (!min && !max)return true;
  362.         if (!min)return p <= max;
  363.         if (!max)return p >= min;
  364.         return p <= max && p >= min;
  365.     };
  366. }
  367. function quantityFilter(num) {
  368.     var inum = parseInt(num, 10);
  369.     return function (l) {
  370.         return l.sp && _.indexOf(l.sp, inum) !== -1;
  371.     };
  372. }
  373. function marketFilter(market) {
  374.     var lmarket = market.toLowerCase();
  375.     return function (l) {
  376.         return l.m.toLowerCase() == lmarket;
  377.     };
  378. }
  379. function eticketsFilter() {
  380.     return function (l) {
  381.         return!!l.et;
  382.     };
  383. }
  384. function belowFaceValueFilter() {
  385.     return function (l) {
  386.         return l.pf < l.fv;
  387.     };
  388. }
  389. function parkingFilter() {
  390.     return function (l) {
  391.         if (l.pk) {
  392.             return false;
  393.         }
  394.         return!(l.sr.match(/park/i) || l.rr.match(/park/i));
  395.     };
  396. }
  397. function unmappableFilter() {
  398.     return function (l) {
  399.         return!(l.mk == '' || l.mk == undefined);
  400.     };
  401. }
  402. function compareByPriceRatioThenPriceAsc(a, b) {
  403.     if (a.pr && b.pr)
  404.         return a.pr - b.pr;
  405.     if (!a.pr && !b.pr)
  406.         return a.pf - b.pf;
  407.     if (a.pr)
  408.         return-1;
  409.     if (b.pr)
  410.         return 1;
  411.     throw"bug in compareByPriceRatioThenPriceAsc";
  412. }
  413. function compareByPriceRatioThenPriceDesc(a, b) {
  414.     if (a.pr && b.pr)
  415.         return b.pr - a.pr;
  416.     if (!a.pr && !b.pr)
  417.         return b.pf - a.pf;
  418.     if (a.pr)
  419.         return-1;
  420.     if (b.pr)
  421.         return 1;
  422.     throw"bug in compareByPriceRatioThenPriceDesc";
  423. }
  424. function compareByDealQualityDescThenPriceAsc(a, b) {
  425.     if (a.dq === b.dq)
  426.         return a.pf - b.pf;
  427.     if (a.dq === null)
  428.         return 1;
  429.     if (b.dq === null)
  430.         return-1;
  431.     return b.dq - a.dq;
  432. }
  433. function compareByDealQualityAscThenPriceDesc(a, b) {
  434.     if (a.dq === b.dq)
  435.         return b.pf - a.pf;
  436.     if (a.dq === null)
  437.         return-1;
  438.     if (b.dq === null)
  439.         return 1;
  440.     return a.dq - b.dq;
  441. }
  442. function compareByDQAsc(a, b) {
  443.     if (a.dq === null && b.dq === null) {
  444.         return 0;
  445.     }
  446.     if (b.dq === null)
  447.         return-1;
  448.     if (a.dq === null)
  449.         return 1;
  450.     return a.dq - b.dq;
  451. }
  452. function compareByDQDesc(a, b) {
  453.     if (a.dq === null && b.dq === null) {
  454.         return 0;
  455.     }
  456.     if (a.dq === null)
  457.         return-1;
  458.     if (b.dq === null)
  459.         return 1;
  460.     return b.dq - a.dq;
  461. }
  462. var comparePriceAsc = function (a, b) {
  463.     return a.pf - b.pf;
  464. }, comparePriceDesc = function (a, b) {
  465.     return b.pf - a.pf;
  466. }, compareSectionAsc = function (a, b) {
  467.     var sectionCompare = a.s.localeCompare(b.s);
  468.     if (sectionCompare == 0) {
  469.         return compareByDQAsc(a, b);
  470.     }
  471.     return sectionCompare;
  472. }, compareSectionDesc = function (a, b) {
  473.     var sectionCompare = b.s.localeCompare(a.s);
  474.     if (sectionCompare == 0) {
  475.         return compareByDQDesc(a, b);
  476.     }
  477.     return sectionCompare;
  478. }, compareAvailableAsc = function (a, b) {
  479.     return a.q - b.q;
  480. }, compareAvailableDesc = function (a, b) {
  481.     return b.q - a.q;
  482. };
  483. var groupListings = function (ls, quantitySelected) {
  484.     var grouped = {}, ungrouppable = [], markets = ["ticketsnow", "ticketnetwork", "razorgator", "vividseats", "ticketcity", "empiretickets", "stubhub"];
  485.     ls.sort(function (a, b) {
  486.         if (a.pf == b.pf) {
  487.             return _.indexOf(markets, a.m) - _.indexOf(markets, b.m);
  488.         }
  489.         return a.pf - b.pf;
  490.     });
  491.     _.each(ls, function (l) {
  492.         var key, q, section_row_key;
  493.         if (!l.s) {
  494.             l.alt = [];
  495.             ungrouppable.push(l);
  496.             return;
  497.         }
  498.         section_row_key = l.mk !== undefined ? l.mk : (l.s + "_" + l.r);
  499.         q = quantitySelected > 0 ? quantitySelected : l.q;
  500.         key = section_row_key + '--' + q + '--' + l.e;
  501.         if (!(key in grouped)) {
  502.             grouped[key] = l;
  503.             grouped[key].alt = [];
  504.             grouped[key].gidx = 1;
  505.         } else {
  506.             delete l.alt;
  507.             l.gidx = (grouped[key].alt.length + 2);
  508.             grouped[key].alt.push(l);
  509.         }
  510.     });
  511.     var vgrouped = _.values(grouped);
  512.     var catted = vgrouped.concat(ungrouppable);
  513.     return catted;
  514. };
  515. window.FiltersView = Backbone.View.extend({events:{"change":"filterListings"}, getMinPrice:function () {
  516.     return parseInt(jQuery('#min_price').val(), 10) || 0;
  517. }, getMaxPrice:function () {
  518.     if (jQuery('#max_price').val() == "2000+")return null;
  519.     return parseInt(jQuery('#max_price').val(), 10);
  520. }, getQuantity:function () {
  521.     return parseInt(jQuery('#quantity').val(), 10);
  522. }, getEtickets:function () {
  523.     return jQuery('#etickets_only').is(':checked');
  524. }, getMarket:function () {
  525.     return jQuery('#market').val();
  526. }, getBelowFaceValue:function () {
  527.     return event_info.has_face_value && jQuery('#below-face-value').is(':checked');
  528. }, getFilters:function () {
  529.     var filters = [];
  530.     filters.push(parkingFilter());
  531.     if (SG.map.hideUnmappable()) {
  532.         filters.push(unmappableFilter());
  533.     }
  534.     var min = this.getMinPrice(), max = this.getMaxPrice();
  535.     filters.push(priceFilter(min, max));
  536.     var q = this.getQuantity();
  537.     if (q > 0)filters.push(quantityFilter(q));
  538.     var et = this.getEtickets();
  539.     if (et)filters.push(eticketsFilter());
  540.     var market = this.getMarket();
  541.     if (market)filters.push(marketFilter(market));
  542.     if (this.getBelowFaceValue())filters.push(belowFaceValueFilter());
  543.     return filters;
  544. }, getSort:function () {
  545.     function getSortValue() {
  546.         var sort = jQuery("#sort-bar .asc").add("#sort-bar .desc").eq(0), sortby = sort.attr("sortby");
  547.         return sortby + ":" + (sort.is(".asc") ? "asc" : "desc");
  548.     }
  549.  
  550.     var sortValue = getSortValue();
  551.     var sortf = {"deal-quality:asc":compareByDealQualityAscThenPriceDesc, "deal-quality:desc":compareByDealQualityDescThenPriceAsc, "price-ratio:asc":compareByPriceRatioThenPriceAsc, "price-ratio:desc":compareByPriceRatioThenPriceDesc, "price:asc":comparePriceAsc, "price:desc":comparePriceDesc, "section:asc":compareSectionAsc, "section:desc":compareSectionDesc, "available:asc":compareAvailableAsc, "available:desc":compareAvailableDesc}[sortValue];
  552.     return sortf || compareByDealQualityDescThenPriceAsc;
  553. }, setRank:function (ls, key, group, checkdq) {
  554.     for (var i = 0; i < ls.length; ++i) {
  555.         if (!(checkdq && ls[i].dq === undefined)) {
  556.             ls[i].ranks[key] = i + 1;
  557.         }
  558.         if (group) {
  559.             _.each(ls[i].alt, function (n) {
  560.                 if (!(checkdq && ls[i].dq === undefined)) {
  561.                     n.ranks[key] = i + 1;
  562.                 }
  563.             });
  564.         }
  565.     }
  566. }, computeRanks:function () {
  567.     var unfiltered = app.listings.getAllListings();
  568.     _.each(unfiltered, function (n) {
  569.         n.ranks = {};
  570.     });
  571.     unfiltered = _.sortBy(unfiltered, function (n) {
  572.         return n.pf;
  573.     });
  574.     this.setRank(unfiltered, 'upf', false);
  575.     unfiltered = _.sortBy(unfiltered, function (n) {
  576.         return-1 * n.dq;
  577.     });
  578.     this.setRank(unfiltered, 'udq', false, true);
  579.     var filtered = app.listings.getListings();
  580.     this.setRank(filtered, 'fuv', true);
  581.     filtered = _.sortBy(filtered, function (n) {
  582.         return n.pf;
  583.     });
  584.     this.setRank(filtered, 'fpf', true);
  585.     filtered = _.sortBy(filtered, function (n) {
  586.         return-1 * n.dq;
  587.     });
  588.     this.setRank(filtered, 'fdq', true, true);
  589. }, filterListings:function (e) {
  590.     if (e && e.target) {
  591.         switch (jQuery(e.target).attr("id")) {
  592.             case"quantity":
  593.                 SG.map.track("filter-change", "quantity");
  594.                 break;
  595.             case"etickets_only":
  596.                 SG.map.track("filter-change", "etickets");
  597.                 break;
  598.         }
  599.     }
  600.     var ls = applyFilters(this.getFilters(), app.listings.getAllListings());
  601.     SG.map.log("sorting");
  602.     if (!SG.map.isGa()) {
  603.         ls = groupListings(ls, this.getQuantity());
  604.     }
  605.     ls.sort(this.getSort());
  606.     app.listings.setListings(ls);
  607.     this.computeRanks();
  608.     app.render();
  609.     jQuery('.scroll').animate({scrollTop:0}, 0);
  610. }});
  611. (function () {
  612.     var mapkeyre = /^s:([a-z0-9-]+)(?: r:([a-z0-9-]+))?$/i;
  613.     window.helpers = {listing_url:function (l) {
  614.         return"/event/click/?" + SG.fn.serializeParams({tid:l.id, eid:app.event.get("id"), section:l.s, row:l.r, quantity:app.filters.getQuantity() || l.q, price:l.pf, baseprice:l.p, market:l.m, sg:SG.map.isInteractive() ? 1 : 0, dq:l.dq ? l.dq : -1, rfuv:l.ranks.fuv ? l.ranks.fuv : -1, rfpf:l.ranks.fpf ? l.ranks.fpf : -1, rfdq:l.ranks.fdq ? l.ranks.fdq : -1, rupf:l.ranks.upf ? l.ranks.upf : -1, rudq:l.ranks.udq ? l.ranks.udq : -1, gidx:l.gidx ? l.gidx : -1});
  615.     }, attrs_for_listing:function (l) {
  616.         var params = {section:l.s, row:l.r || "", mapkey:l.mk || "", price:l.pf, baseprice:l.p, fees:l.f, shipping:l.sh, pickup_only:l.pu, eticket:l.et, market:l.m, market_full:l.mf, quantity:l.q, splits:l.sp.join(",")}, str = [];
  617.         for (var p in params) {
  618.             str.push(p + '="' + params[p] + '"');
  619.         }
  620.         return str.join(" ");
  621.     }, parseMapKey:function (key) {
  622.         var matches = key.match(mapkeyre);
  623.         if (matches) {
  624.             if (matches[2])
  625.                 return{s:matches[1], r:matches[2]}; else
  626.                 return{s:matches[1]};
  627.         }
  628.         throw"Improperly formatted mapkey: " + key;
  629.     }, pretty_section_name:function (s) {
  630.         if (!s)return"";
  631.         return _.map(s.split(/[\s-]+/),
  632.             function (w) {
  633.                 return w.capitalize()
  634.             }).join(" ");
  635.     }};
  636. })();
  637. var SG = SG || {};
  638. SG.map = SG.map || {};
  639. (function (M) {
  640.     M.highlightSingleSec = function (section, color) {
  641.         var view = M.getView();
  642.         var shade = (color ? color : '#ff0000');
  643.         var path_style = {"stroke":shade, "stroke-width":2, "opacity":0.75, "fill":shade, "fill-opacity":0.33};
  644.         var path = M.getMapData(section).path;
  645.         var shape = view.drawShape(path);
  646.         shape.attr(path_style);
  647.     };
  648.     M.highlightSingleRow = function (section, row, color) {
  649.         var view = M.getView();
  650.         var shade = (color ? color : '#ff0000');
  651.         var path_style = {"stroke":shade, "stroke-width":2, "opacity":0.75, "fill":shade, "fill-opacity":0.33};
  652.         var path = M.getMapData(section).rows[row].path;
  653.         var shape = view.drawShape(path);
  654.         shape.attr(path_style);
  655.     };
  656.     M.hlightSecs = function () {
  657.         if (hlight_data) {
  658.             for (var key in hlight_data) {
  659.                 if (hlight_data.hasOwnProperty(key)) {
  660.                     var options = hlight_data[key];
  661.                     M.highlightSingleSec(key, options.hue);
  662.                 }
  663.             }
  664.         }
  665.     };
  666.     M.hlightRows = function () {
  667.         var n_buckets = 30;
  668.         if (hlight_data) {
  669.             var min = 9999999, max = 0;
  670.             for (var j = 0; j < hlight_data.length; j++) {
  671.                 if (parseFloat(hlight_data[j].price) < min)min = parseFloat(hlight_data[j].price);
  672.                 if (parseFloat(hlight_data[j].price) > max)max = parseFloat(hlight_data[j].price);
  673.             }
  674.             for (var i = 0; i < hlight_data.length; i++) {
  675.                 var obj = hlight_data[i];
  676.                 var full = obj.combo;
  677.                 var sec = full.substr(0, full.indexOf(":"));
  678.                 var row = full.substr(full.indexOf(":") + 1, full.length);
  679.                 var price = parseFloat(obj.price);
  680.                 var bucket = bucketit(min, max, n_buckets, price);
  681.                 var green = Math.round(255 / n_buckets * bucket);
  682.                 var blue = Math.round(255 - 225 / n_buckets * bucket);
  683.                 var hue = rgbToHex(0, green, blue);
  684.                 if (row == 'none') {
  685.                     M.highlightSingleSec(sec, hue);
  686.                 } else {
  687.                     M.highlightSingleRow(sec, row, hue);
  688.                 }
  689.             }
  690.         }
  691.     };
  692. })(SG.map);
  693. function rgbToHex(r, g, b) {
  694.     return"#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
  695. }
  696. function componentToHex(c) {
  697.     var hex = c.toString(16);
  698.     return hex.length == 1 ? "0" + hex : hex;
  699. }
  700. function bucketit(min, max, num, value) {
  701.     for (var i = 0; i < num; i++) {
  702.         if (value <= (min + (max - min) / num * (i + 1)))return i;
  703.     }
  704.     return num - 1;
  705. }
  706. find_clusters = (function () {
  707.     function xs_from_pts(pts) {
  708.         return _.map(pts, function (p) {
  709.             return p[0]
  710.         })
  711.     }
  712.  
  713.     function ys_from_pts(pts) {
  714.         return _.map(pts, function (p) {
  715.             return p[1]
  716.         })
  717.     }
  718.  
  719.     function euclidean_distance(pt1, pt2) {
  720.         return Math.sqrt(Math.pow(pt2[0] - pt1[0], 2) + Math.pow(pt2[1] - pt1[1], 2));
  721.     }
  722.  
  723.     function nearest_cluster(pt, clusters) {
  724.         var distances = _.map(clusters, function (c) {
  725.             return euclidean_distance(c, pt)
  726.         }), min_distance = Math.min.apply(Math, distances);
  727.         return _.indexOf(distances, min_distance);
  728.     }
  729.  
  730.     return function find_clusters(pts) {
  731.         var num_clusters = 4, clusters = [], cluster_assignment = [];
  732.         xs = xs_from_pts(pts), ys = ys_from_pts(pts), xmin = Math.min.apply(Math, xs), ymin = Math.min.apply(Math, ys), xmax = Math.max.apply(Math, xs), ymax = Math.max.apply(Math, ys);
  733.         clusters = [
  734.             [xmin, ymin],
  735.             [xmax, ymin],
  736.             [xmax, ymax],
  737.             [xmin, ymax]
  738.         ];
  739.         function pts_in_cluster(cluster) {
  740.             var pt_is = [];
  741.             _.each(cluster_assignment, function (ca, i) {
  742.                 if (ca === cluster)pt_is.push(pts[i]);
  743.             });
  744.             return pt_is;
  745.         }
  746.  
  747.         while (1) {
  748.             var prev_cluster_assignment = cluster_assignment.slice(0);
  749.             cluster_assignment = _.map(pts, function (p, i) {
  750.                 var nearest = nearest_cluster(p, clusters);
  751.                 return nearest;
  752.             });
  753.             _.each(clusters, function (c, i) {
  754.                 var cpts = pts_in_cluster(i);
  755.                 if (cpts.length == 0) {
  756.                     return;
  757.                 }
  758.                 var xs = xs_from_pts(cpts), ys = ys_from_pts(cpts);
  759.                 clusters[i] = [_.reduce(xs, function (memo, num) {
  760.                     return memo + num;
  761.                 }, 0) / xs.length, _.reduce(ys, function (memo, num) {
  762.                     return memo + num;
  763.                 }, 0) / ys.length];
  764.             });
  765.             if (prev_cluster_assignment.toString() === cluster_assignment.toString())
  766.                 return clusters;
  767.         }
  768.     }
  769. })();
  770. Listing = Backbone.Model.extend({});
  771. ListingCollection = Backbone.Collection.extend({model:Listing, url:function () {
  772.     return'/event/tickets/?id=' + app.event.get("id")
  773. }, initialize:function (opts) {
  774.     this.all_listings = [];
  775.     this.current_listings = [];
  776. }, setupDeprecatedState:function (response) {
  777.     function bucketListings(ls) {
  778.         var prop = "dq", sorted = _.sortBy(ls, function (l) {
  779.             return-1 * l.get(prop);
  780.         }), props = _.map(sorted, function (l) {
  781.             return l.get(prop);
  782.         }), propslen = props.length, pts = [0.004, 0.03, 0.10, 0.23, 0.45, 0.70];
  783.         _.map(sorted, function (l) {
  784.             var bucket = 0;
  785.             _.map(pts, function (pt) {
  786.                 if (l.get(prop) < props[Math.floor(propslen * pt)])
  787.                     ++bucket;
  788.             });
  789.             l.set({bucket:bucket}, {silent:true});
  790.         });
  791.         if (sorted.length)sorted[0].set({bucket:0});
  792.     }
  793.  
  794.     if (response.deal_quality) {
  795.         bucketListings(this.models);
  796.     } else {
  797.         _.each(this.models, function (l) {
  798.             l.set({bucket:4})
  799.         });
  800.     }
  801.     _.each(this.models, function (l) {
  802.         l.set({sf:helpers.pretty_section_name(l.get("s")), rf:helpers.pretty_section_name(l.get("r")), d:l.get("d") ? SG.fn.strip_html(l.get("d")) : "", alt:[]});
  803.     });
  804.     this.all_listings = _.pluck(this.sortBy(
  805.         function (l) {
  806.             return l.get("dq");
  807.         }).reverse(), "attributes");
  808.     this.current_listings = this.all_listings.slice(0);
  809. }, getListings:function () {
  810.     return this.current_listings.slice(0);
  811. }, getAllListings:function () {
  812.     return this.all_listings.slice(0);
  813. }, setListings:function (ls) {
  814.     this.current_listings = ls.slice(0);
  815. }, getRows:function () {
  816.     function cmp(a, b) {
  817.         return a.localeCompare(b);
  818.     }
  819.  
  820.     var ls = _.filter(this.getListings(), function (l) {
  821.         return l.mk != undefined;
  822.     }), key_buckets_map = {}, section_row_buckets = [];
  823.     _.map(ls, function (l) {
  824.         var k = l.mk;
  825.         key_buckets_map[k] = key_buckets_map[k] || [];
  826.         key_buckets_map[k].push(l.bucket);
  827.     });
  828.     for (k in key_buckets_map) {
  829.         section_row_buckets.push([k, Math.min.apply(Math, key_buckets_map[k])]);
  830.     }
  831.     return section_row_buckets;
  832. }, getSections:function () {
  833.     function cmp(a, b) {
  834.         return a.localeCompare(b);
  835.     }
  836.  
  837.     var ls = _.filter(this.getListings(), function (l) {
  838.         return l.mk != undefined;
  839.     }), key_buckets_map = {}, section_buckets = [];
  840.     _.map(ls, function (l) {
  841.         var sr = helpers.parseMapKey(l.mk);
  842.         key_buckets_map[sr.s] = key_buckets_map[sr.s] || [];
  843.         key_buckets_map[sr.s].push(l.bucket);
  844.     });
  845.     for (s in key_buckets_map) {
  846.         section_buckets.push([s, Math.min.apply(Math, key_buckets_map[s])]);
  847.     }
  848.     return section_buckets;
  849. }, getListingsForRow:function (s, r) {
  850.     var key = "s:" + s + " r:" + r;
  851.     return _.filter(this.getListings(), function (l) {
  852.         return l.mk === key;
  853.     });
  854. }, getListingsForSection:function (s) {
  855.     return _.filter(this.getListings(), function (l) {
  856.         if (l.mk) {
  857.             var k = helpers.parseMapKey(l.mk);
  858.             return k && k.s === s;
  859.         } else {
  860.             return false;
  861.         }
  862.     });
  863. }});
  864. (function (R) {
  865.     R.scalePath = function (scale, pathArray) {
  866.         var ret = [];
  867.         R.is(pathArray, "string") && (pathArray = R.parsePathString(pathArray));
  868.         for (var i = 0, ilen = pathArray.length; i < ilen; ++i) {
  869.             ret[i] = pathArray[i].slice(0);
  870.             for (var j = 1, jlen = pathArray[i].length; j < jlen; ++j) {
  871.                 ret[i][j] = scale * pathArray[i][j];
  872.             }
  873.         }
  874.         return ret;
  875.     };
  876. })(Raphael);
  877. var SG = SG || {};
  878. SG.map = SG.map || {};
  879. (function (M) {
  880.     var paper = null, map_data = null, listings_ready = false, path_style = {stroke:"#3e75b5", "stroke-width":3.5, "opacity":0.8, "fill":"#3e75b5", "fill-opacity":0.31}, options = {auto_zoom:false, auto_close_sidebar:false, is_ga:false, map_base_url:null, static_map_url:"/images/map/new/pending.png", rows_at_all_zooms:false, view_from_seat_manifest:null, hide_unmappable:false}, NO_MAP;
  881.     M.debug = false;
  882.     M.log = function () {
  883.         if (!M.debug)return;
  884.         try {
  885.             console.log.apply(console, arguments);
  886.         }
  887.         catch (e) {
  888.         }
  889.     };
  890.     M.track = function (action, label, value) {
  891.         try {
  892.             M.log([action, label, value]);
  893.             _gaq.push(['_trackEvent', 'maps', action, label, value]);
  894.         }
  895.         catch (e) {
  896.         }
  897.     };
  898.     M.fire = function (e, data) {
  899.         M.log(e, data);
  900.         jQuery(document).trigger(e, data);
  901.     };
  902.     M.observe = function (e, cb) {
  903.         jQuery(document).bind(e, cb);
  904.     };
  905.     M.isInteractive = function () {
  906.         return!NO_MAP;
  907.     };
  908.     M.layers = {};
  909.     M.init = function (opts) {
  910.         options = jQuery.extend(options, opts);
  911.         NO_MAP = options.map_base_url === null;
  912.         if (NO_MAP) {
  913.             M.log("map not available");
  914.             jQuery("body").addClass("no-map no-deal-quality");
  915.         } else {
  916.             SG.map.retrieveMapData();
  917.         }
  918.         if (options.is_ga) {
  919.             M.log("venue is ga");
  920.             jQuery("body").addClass("is-ga");
  921.         } else if (options.static_map_url && options.static_map_url != "/images/pending.png") {
  922.             M.log("map is static");
  923.             jQuery("body").addClass("static-map");
  924.         }
  925.         sometimeWhen(function () {
  926.             return listings_ready && (map_data !== null || NO_MAP);
  927.         }, function () {
  928.             M.fire("sg:map-ready");
  929.         });
  930.         window.paper = paper = Raphael("canvas-spot", 100, 100);
  931.         M.layers.window = jQuery("#window")[0];
  932.         M.layers.drag_container = jQuery("#drag-container")[0];
  933.         M.layers.holder = jQuery("#holder")[0];
  934.         M.layers.map_tiles = jQuery("#map-tiles")[0];
  935.         M.layers.canvas_spot = jQuery("#canvas-spot")[0];
  936.         M.layers.marker_holder = jQuery("#marker-holder")[0];
  937.         M.layers.over_map = jQuery("#window .over-map")[0];
  938.         M.views = [new M.View({scale:0.7, detail:options.rows_at_all_zooms ? "rows" : "sections"}), new M.View({scale:1.4, detail:"rows"}), new M.View({scale:2.8, detail:"rows"}), new M.View({scale:5.6, detail:"rows"})];
  939.         M.view_from_seat_manifest = !window.DISABLE_VIEW_FROM_SEAT ? options.view_from_seat_manifest : null;
  940.         M.fire("sg:map-init");
  941.     };
  942.     M.retrieveMapData = function () {
  943.         jQuery.get(options.map_base_url.replace(/^http:\/\/cdn\.seatgeek\.com/, '') + 'map_data.json', function (json) {
  944.             map_data = json;
  945.             SG.map.fire("sg:map_data-ready");
  946.         }, "json");
  947.     };
  948.     M.getMapData = function (s, r) {
  949.         if (s === undefined)
  950.             return map_data;
  951.         if (r === undefined)
  952.             return map_data[s];
  953.         return map_data[s].rows[r];
  954.     };
  955.     var current_view = null, current_view_index = null;
  956.     M.View = function (opts) {
  957.         this.scale = opts.scale;
  958.         this.detail = opts.detail;
  959.     };
  960.     M.View.prototype.drawShape = function (path) {
  961.         var shape = paper.path(Raphael.scalePath(this.scale, path));
  962.         this.forceRender();
  963.         return shape;
  964.     };
  965.     M.View.prototype.drawCircle = function (x, y, r) {
  966.         var pt = this.scalePoint([x, y]), circle = paper.circle(pt[0], pt[1], r);
  967.         this.forceRender();
  968.         return circle;
  969.     };
  970.     M.View.prototype.scalePoint = function (pt) {
  971.         return[pt[0] * this.scale, pt[1] * this.scale];
  972.     };
  973.     M.View.prototype.forceRender = function () {
  974.         if (Browser.WebKit) {
  975.             var rect = paper.rect(-99, -99, this.scale * 1000 + 99, this.scale * 1000 + 99).attr({stroke:"none"});
  976.             window.setTimeout(function () {
  977.                 if (rect && rect.parentNode)rect.remove();
  978.             });
  979.         }
  980.     };
  981.     M.views = [];
  982.     var cancel_render_func = null;
  983.  
  984.     function renderListings(clear_first) {
  985.         var sections = map_data, view = current_view, clear_first = clear_first === undefined ? true : clear_first;
  986.         if (cancel_render_func) {
  987.             cancel_render_func();
  988.             cancel_render_func = null;
  989.         }
  990.         if (clear_first)M.clearMap();
  991.         function marker(detail, key, bucket, x, y) {
  992.             var bucket = Math.max(0, Math.min(6, bucket)), size = [23, 20, 18, 16, 14, 13, 11][bucket], offset = Math.ceil(size / 2), x = Math.round(x) - offset, y = Math.round(y) - offset;
  993.             return SG.fn.fastHtmlToDom(['<div class="marker marker' + bucket + '" detail="' + detail + '" key="' + key + '" ', 'style="position:absolute; top:' + y + 'px; left:' + x + 'px; width:' + size + 'px; height:' + size + 'px;">', '</div>'].join("\n"));
  994.         }
  995.  
  996.         if (view.detail == "sections") {
  997.             cancel_render_func = yieldingMap(function (sb) {
  998.                 var s = sb[0], b = sb[1], k = "s:" + s, section = sections[s], c = section.center;
  999.                 M.layers.marker_holder.appendChild(marker("section", k, b, c[0] * view.scale, c[1] * view.scale));
  1000.             }, app.listings.getSections(), function () {
  1001.                 cancel_render_func = null;
  1002.             });
  1003.         } else {
  1004.             cancel_render_func = yieldingMap(function (srb) {
  1005.                 var k = srb[0], b = srb[1], sr = helpers.parseMapKey(k), row = sections[sr.s].rows[sr.r], c = row ? row.center : sections[sr.s].center;
  1006.                 M.layers.marker_holder.appendChild(marker("row", k, b, c[0] * view.scale, c[1] * view.scale));
  1007.             }, app.listings.getRows(), function () {
  1008.                 cancel_render_func = null;
  1009.             });
  1010.         }
  1011.     }
  1012.  
  1013.     M.render = function (clear_first) {
  1014.         renderListings(clear_first);
  1015.     };
  1016.     jQuery(function () {
  1017.         var marker_holder = jQuery("#marker-holder");
  1018.  
  1019.         function markerObserve(browserevt, sgevt) {
  1020.             marker_holder.bind(browserevt, function (e) {
  1021.                 var el = jQuery(e.target);
  1022.                 if (!el.hasClass("marker"))return true;
  1023.                 M.fire("sg:" + el.attr("detail") + "-" + sgevt, {key:el.attr("key"), el:el});
  1024.                 return false;
  1025.             });
  1026.         }
  1027.  
  1028.         markerObserve("click", "click");
  1029.         markerObserve("mouseover", "over");
  1030.         markerObserve("mouseout", "out");
  1031.     });
  1032.     var highlighted_section_or_row = null;
  1033.     M.highlightSectionOrRow = function (key) {
  1034.         if (!key)return;
  1035.         var detail = current_view.detail;
  1036.         M.clearHighlightedSectionOrRow();
  1037.         M.fire(detail == "sections" ? "sg:section-over" : "sg:row-over", {key:key});
  1038.         highlighted_section_or_row = key;
  1039.     };
  1040.     M.clearHighlightedSectionOrRow = function () {
  1041.         var detail = current_view.detail;
  1042.         if (highlighted_section_or_row)
  1043.             M.fire(detail == "sections" ? "sg:section-out" : "sg:row-out", {key:highlighted_section_or_row});
  1044.         highlighted_section_or_row = null;
  1045.     };
  1046.     var highlighted_shape = null;
  1047.  
  1048.     function clearHighlightedShape() {
  1049.         if (highlighted_shape) {
  1050.             try {
  1051.                 highlighted_shape.remove();
  1052.             } catch (e) {
  1053.             }
  1054.             highlighted_shape = null;
  1055.         }
  1056.     }
  1057.  
  1058.     M.observe("sg:section-over", function (e, data) {
  1059.         clearHighlightedShape();
  1060.         try {
  1061.             var k = helpers.parseMapKey(data.key), section = M.getMapData(k.s), shape = highlighted_shape = current_view.drawShape(section.path), ls = app.listings.getListingsForSection(k.s);
  1062.             shape.attr(path_style);
  1063.             M.showTooltip(templates.section_tooltip(ls), shape.getBBox());
  1064.         } catch (e) {
  1065.         }
  1066.     });
  1067.     M.observe("sg:section-out", function (e) {
  1068.         clearTimeout(jQuery(tooltip).data("hiding"));
  1069.         jQuery(tooltip).data("hiding", setTimeout(function () {
  1070.             clearHighlightedShape();
  1071.             M.hideTooltip();
  1072.         }, 150));
  1073.     });
  1074.     M.observe("sg:row-over", function (e, data) {
  1075.         clearHighlightedShape();
  1076.         try {
  1077.             var k = helpers.parseMapKey(data.key), row_or_section = M.getMapData(k.s, k.r), shape = highlighted_shape = current_view.drawShape(row_or_section.path), ls = (k.r) ? app.listings.getListingsForRow(k.s, k.r) : app.listings.getListingsForSection(k.s);
  1078.             shape.attr(path_style);
  1079.             jQuery(data.el).css({zIndex:13});
  1080.             M.showTooltip(templates[(k.r ? "row" : "section") + "_tooltip"](ls), shape.getBBox());
  1081.         } catch (e) {
  1082.         }
  1083.     });
  1084.     M.observe("sg:row-out", function (e, data) {
  1085.         jQuery(data.el).css({zIndex:""});
  1086.         clearTimeout(jQuery(tooltip).data("hiding"));
  1087.         jQuery(tooltip).data("hiding", setTimeout(function () {
  1088.             clearHighlightedShape();
  1089.             M.hideTooltip();
  1090.         }, 50));
  1091.     });
  1092.     function popupTargetForPoint(pt) {
  1093.         var pt = current_view.scalePoint(pt), pos = jQuery("#holder").position();
  1094.         return{x:Math.round(pt[0] + pos.left), y:Math.round(pt[1] + pos.top)};
  1095.     }
  1096.  
  1097.     M.observe("sg:section-click sg:row-click", function (e, data) {
  1098.         var k = helpers.parseMapKey(data.key), section_or_row = M.getMapData(k.s, k.r), pos = popupTargetForPoint(section_or_row.center), ls = k.r ? app.listings.getListingsForRow(k.s, k.r) : app.listings.getListingsForSection(k.s);
  1099.         SG.map.showPopup(templates.section_row_popup(ls[0].sf, k.r ? ls[0].r : null, ls), pos.x, pos.y);
  1100.         M.showViewFromSeat(k.ss);
  1101.     });
  1102.     M.showViewFromSeat = function (s) {
  1103.         var img_html = templates.view_from_seat(s, 350);
  1104.         if (img_html != '') {
  1105.             jQuery(".view-from-seat-large").html(['<a href="#" class="close" onclick="SG.map.hideViewFromSeat(); return false;">&nbsp;</a>', '<div class="description">View from section ' + s + '</div>', img_html].join("\n")).show();
  1106.         }
  1107.     };
  1108.     M.hideViewFromSeat = function () {
  1109.         jQuery(".view-from-seat-large").html("").hide();
  1110.     };
  1111.     M.showListingDetails = function (jQel) {
  1112.         var el = jQel.closest('.ticket-container'), isPopup = !el.hasClass('scroll'), moveUp = isPopup ? -(el.height() - (jQel.position().top + jQel.outerHeight())) : -(jQuery(window).height() - (jQel.offset().top + jQel.outerHeight()));
  1113.         if (moveUp > (jQel.parent().position().top - 10)) {
  1114.             moveUp = jQel.parent().position().top - 10;
  1115.         }
  1116.         moveUp = (isPopup) ? moveUp + 10 : moveUp;
  1117.         if (moveUp > 0) {
  1118.             el.animate({scrollTop:'+=' + (moveUp) + 'px'}, 'slow');
  1119.         }
  1120.     };
  1121.     M.getPosition = function () {
  1122.         var pos = jQuery(M.layers.holder).position();
  1123.         return{x:pos.left, y:pos.top};
  1124.     };
  1125.     M.setPosition = function (x, y) {
  1126.         jQuery(M.layers.holder).css({top:y + "px", left:x + "px"});
  1127.     };
  1128.     M.getView = function () {
  1129.         return current_view;
  1130.     };
  1131.     M.setView = function (index) {
  1132.         var old_view = current_view;
  1133.         current_view_index = Math.max(Math.min(index, M.views.length - 1), 0);
  1134.         current_view = M.views[current_view_index];
  1135.         if (old_view === current_view)return;
  1136.         M.clearMap();
  1137.         M.fire("sg:map-view-change", {view:current_view, old_view:old_view, index:index});
  1138.     };
  1139.     M.zoomIn = function () {
  1140.         var z = Math.min(3, current_view_index + 1);
  1141.         M.setView(z);
  1142.     };
  1143.     M.zoomOut = function () {
  1144.         var z = Math.max(0, current_view_index - 1);
  1145.         M.setView(z);
  1146.     };
  1147.     M.zoomToPoint = function (x, y, zoom_level) {
  1148.         var zoom_level = zoom_level !== undefined ? zoom_level : 2;
  1149.         M.centerMap([x, y]);
  1150.         M.setView(zoom_level);
  1151.     };
  1152.     M.zoomToSection = function (s, zoom_level) {
  1153.         var pt = map_data[s].center, scale = current_view.scale;
  1154.         M.zoomToPoint(pt[0] * scale, pt[1] * scale, zoom_level);
  1155.     };
  1156.     var image_loader = null, loaded_images = {};
  1157.     M.clearMap = function () {
  1158.         var tiledim = 350, scale = current_view.scale, height = Math.round(1000 * scale), width = Math.round(1000 * scale), tileholder = jQuery(M.layers.map_tiles), tilecount = (height * width) / Math.pow(tiledim, 2), i = 0, tiles = [];
  1159.         M.hideTooltip();
  1160.         M.hidePopup();
  1161.         paper.clear();
  1162.         jQuery(M.layers.marker_holder).html("");
  1163.         paper.setSize(width, height);
  1164.         tileholder.css({height:height + "px", width:width + "px", position:"relative"});
  1165.         jQuery(M.layers.holder).css({height:height + "px", width:width + "px"});
  1166.         if (NO_MAP) {
  1167.             tileholder.html(['<img src="' + options.static_map_url + '" />'].join("\n"));
  1168.             return;
  1169.         }
  1170.         for (i = 0; i < tilecount; ++i) {
  1171.             tiles.push(i);
  1172.         }
  1173.         tileholder.html(_.map(tiles,
  1174.             function (tile) {
  1175.                 var src = [options.map_base_url, scale + "", "x/", "tile_", tile, ".png"].join("");
  1176.                 return'<img ' + (loaded_images[src] ? 'src' : 'deferredsrc') + '="' + src + '" style="width:' + tiledim + 'px; height:' + tiledim + 'px" />';
  1177.             }).join("\n"));
  1178.         clearTimeout(image_loader);
  1179.         function load_visible_images() {
  1180.             var imgs = _.filter(tileholder.find("img").get(), function (img) {
  1181.                 return img.src == "";
  1182.             }), mp = M.getPosition(), ww = jQuery(M.layers.window).width(), wh = jQuery(M.layers.window).height();
  1183.             if (imgs.length <= 0)return;
  1184.             _.map(imgs, function (img) {
  1185.                 var img = jQuery(img), ipos = img.position(), x = mp.x + ipos.left, y = mp.y + ipos.top, src = img.attr("deferredsrc");
  1186.                 if ((x + tiledim) < 0 || (x > ww) || (y + tiledim) < 0 || (y > wh))
  1187.                     return;
  1188.                 img.attr("src", src);
  1189.                 loaded_images[src] = true;
  1190.             });
  1191.             image_loader = setTimeout(load_visible_images, 350);
  1192.         }
  1193.  
  1194.         load_visible_images();
  1195.         M.log("map cleared");
  1196.     };
  1197.     M.centerMap = function (pt) {
  1198.         var wdw = jQuery(M.layers.window).width(), wdh = jQuery(M.layers.window).height(), wc = [wdw / 2, wdh / 2], mdw = jQuery(M.layers.holder).width(), mdh = jQuery(M.layers.holder).height(), pt = pt || [mdw / 2, mdh / 2], mp = M.getPosition(), mc = [mp.x + pt[0], mp.y + pt[1]], dx = wc[0] - mc[0], dy = wc[1] - mc[1], moveto = [Math.round(mp.x + dx), Math.round(mp.y + dy)];
  1199.         M.log("moveto", moveto);
  1200.         M.setPosition.apply(M, moveto);
  1201.     };
  1202.     M.isGa = function () {
  1203.         return options.is_ga;
  1204.     };
  1205.     M.hideUnmappable = function () {
  1206.         return options.hide_unmappable;
  1207.     };
  1208.     var popup = null;
  1209.     M.repositionToRevealPopup = function () {
  1210.         if (!popup)return;
  1211.         var jpop = jQuery(popup), po = jpop.position(), popw = jpop.width(), poph = jpop.height(), win = jQuery(M.layers.window), wdw = win.width(), wdh = win.height(), mappos = M.getPosition(), x = po.left, y = po.top, dx = 0, dy = 0;
  1212.         if (y + poph > wdh)dy = wdh - (y + poph);
  1213.         if (x + popw > wdw)dx = wdw - (x + popw);
  1214.         if ((y + dy) < 0)dy = 0 - y;
  1215.         if ((x + dx) < 0)dx = 0 - x;
  1216.         jpop.css({left:x + dx});
  1217.         jpop.animate({top:y + dy}, {queue:false, duration:500, step:function (p, details) {
  1218.             if (details.prop == "top")M.setPosition(mappos.x + dx, mappos.y + (p - y));
  1219.         }});
  1220.     };
  1221.     M.showPopup = function (html, targetx, targety, width) {
  1222.         var div, popdim = null, dx = 0, dy = 0, mappos = M.getPosition(), offsetx = 16, offsety = -75, wdw = jQuery(M.layers.window).width(), targetx = targetx || 0, targety = targety || 0, width = width || 354, flip_arrow = (wdw - targetx) < (width + offsetx), y = targety + offsety;
  1223.         x = flip_arrow ? targetx - (width + offsetx) : targetx + offsetx;
  1224.         M.hideTooltip();
  1225.         M.hidePopup();
  1226.         div = popup = SG.fn.fastHtmlToDom(['<div class="popup" style="position:absolute; width:' + width + 'px; z-index:3; top:' + y + 'px; left:' + x + 'px">', '<div class="inner' + (flip_arrow ? ' flip' : '') + '">', '<div class="arrow"></div>', '<div class="body">', html, '</div>', '<div class="bottom"></div>', '</div>', '</div>'].join("\n"));
  1227.         M.layers.over_map.appendChild(div);
  1228.         new SG.draggable(div, M.layers.drag_container);
  1229.         async(function () {
  1230.             M.repositionToRevealPopup();
  1231.         });
  1232.     };
  1233.     M.hidePopup = function () {
  1234.         if (popup) {
  1235.             remove_node(popup);
  1236.             popup = null;
  1237.         }
  1238.         M.hideViewFromSeat();
  1239.     };
  1240.     var tooltip = null;
  1241.     M.showTooltip = function (html, bb) {
  1242.         var div, tooltipTemplate = '<div class="tooltip"></div>', mappos = M.getPosition(), dragw = jQuery(M.layers.window).width(), dragh = jQuery(M.layers.window).height(), divw, divh, x = bb.x + Math.max(bb.width, 12), y = bb.y;
  1243.         clearTimeout(jQuery(tooltip).data("hiding"));
  1244.         M.hideTooltip();
  1245.         if (html.search('view-from-seat') != -1) {
  1246.             tooltipTemplate = '<div class="tooltip seatview"></div>';
  1247.         }
  1248.         div = jQuery(tooltipTemplate).mouseenter(
  1249.             function () {
  1250.                 clearTimeout(jQuery(this).data("hiding"));
  1251.             }).mouseleave(function () {
  1252.             jQuery(this).data("hiding", setTimeout(function () {
  1253.                 clearHighlightedShape();
  1254.                 M.hideTooltip();
  1255.             }, 50));
  1256.         });
  1257.         tooltip = div[0];
  1258.         div.css({position:"absolute", zIndex:14});
  1259.         div.html(['<div class="inner">', html, '</div>'].join("\n"));
  1260.         if (html.search('view-from-seat') != -1) {
  1261.             div.html('<div class="inner-left">&nbsp;</div>' + div.html() + '<div class="inner-right">&nbsp;</div>');
  1262.         }
  1263.         jQuery(M.layers.over_map).append(div);
  1264.         divw = div.width() + 2;
  1265.         divh = div.height();
  1266.         if ((x + mappos.x) + divw >= dragw)
  1267.             x = bb.x - divw - 10;
  1268.         if ((y + mappos.y) <= 0)
  1269.             y = bb.y + bb.height - 5;
  1270.         if ((y + mappos.y + divh) >= dragh) {
  1271.             y = y - divh;
  1272.             if (y + mappos.y + divh + bb.height < dragh)
  1273.                 y = y + bb.height;
  1274.         }
  1275.         div.css({top:(y + mappos.y) + "px", left:(x + mappos.x) + "px", width:divw + "px"});
  1276.     };
  1277.     M.hideTooltip = function () {
  1278.         if (tooltip) {
  1279.             remove_node(tooltip);
  1280.             tooltip = null;
  1281.         }
  1282.     };
  1283.     M.toggleSidebar = function () {
  1284.         var sidebar = jQuery(".sidebar").eq(0), win = jQuery(M.layers.window), left = parseInt(win.css("left"), 10), to = 0, direction = true, duration = 250, mappos = M.getPosition();
  1285.         M.hideTooltip();
  1286.         M.hidePopup();
  1287.         if (left < 1) {
  1288.             to = 324;
  1289.             direction = false;
  1290.             duration = 300;
  1291.         }
  1292.         sidebar.animate({left:to - 324}, {queue:false, duration:duration});
  1293.         win.animate({left:to}, {queue:false, duration:duration, step:function (p, details) {
  1294.             if (details.prop == "left") {
  1295.                 p = Math.round(p);
  1296.                 M.setPosition(mappos.x + (direction ? (324 - p) : (p * -1)), mappos.y);
  1297.             }
  1298.         }, complete:function () {
  1299.             var tab = jQuery(".toggle-sidebar");
  1300.             tab.toggleClass("toggle-sidebar-flipped");
  1301.             M.centerMap();
  1302.         }});
  1303.         M.track("sidebar-" + (direction ? "close" : "open"));
  1304.     };
  1305.     M.observe("sg:map-init", function () {
  1306.         var width = options.auto_close_sidebar ? jQuery(document).width() : jQuery(M.layers.window).width();
  1307.         if (M.isInteractive() && options.auto_zoom && 1400 < width) {
  1308.             M.setView(1);
  1309.         } else {
  1310.             M.setView(0);
  1311.         }
  1312.         M.centerMap();
  1313.         sometimeWhen(function () {
  1314.             return jQuery(M.layers.window).height() > 0;
  1315.         }, function () {
  1316.             M.centerMap();
  1317.         });
  1318.         new SG.draggable(M.layers.holder, M.layers.drag_container);
  1319.     });
  1320.     M.observe("sg:listings-ready", function () {
  1321.         listings_ready = true;
  1322.     });
  1323.     M.observe("sg:listings-ready", function () {
  1324.         jQuery('#ticket_list_loading').hide();
  1325.     });
  1326.     M.observe("sg:map-ready", function () {
  1327.         app.filters.filterListings();
  1328.     });
  1329.     M.observe("sg:map-view-change", function (e, data) {
  1330.         if (!data.old_view)return;
  1331.         var view = data.view, old_view = data.old_view, scale = view.scale / old_view.scale, new_pos = null, tempcw = jQuery(M.layers.window).width(), tempch = jQuery(M.layers.window).height(), C = [tempcw / 2, tempch / 2], tempo = M.getPosition(), O = [tempo.x, tempo.y];
  1332.         new_pos = {x:C[0] - scale * (C[0] - O[0]), y:C[1] - scale * (C[1] - O[1])};
  1333.         M.log("C", C);
  1334.         M.log("O", O);
  1335.         M.log("new_pos", new_pos);
  1336.         M.setPosition(new_pos.x, new_pos.y);
  1337.     });
  1338.     M.observe("sg:map-view-change", function () {
  1339.         M.render(false);
  1340.     });
  1341.     M.observe("sg:map-view-change", function () {
  1342.         var zoom = jQuery(".map-content .zoom");
  1343.         zoom.removeClass("level0 level1 level2 level3");
  1344.         zoom.addClass("level" + current_view_index);
  1345.     });
  1346.     M.observe("sg:map-view-change", function () {
  1347.         M.hideTooltip();
  1348.         M.hidePopup();
  1349.     });
  1350.     M.observe("sg:map-init", function () {
  1351.         if (!M.isInteractive())return;
  1352.         jQuery("#drag-container").dblclick(function (e) {
  1353.             if (NO_MAP)return;
  1354.             var wo = jQuery("#holder").offset();
  1355.             M.zoomToPoint(e.clientX - wo.left, e.clientY - wo.top, current_view_index + 1);
  1356.             SG.map.track("zoom", "dblclick");
  1357.         });
  1358.         function getWheel(event) {
  1359.             var delta = 0;
  1360.             if (!event)event = window.event;
  1361.             if (event.wheelDelta) {
  1362.                 delta = event.wheelDelta / 120;
  1363.                 if (window.opera)delta = -delta;
  1364.             } else if (event.detail) {
  1365.                 delta = -event.detail;
  1366.             }
  1367.             return Math.round(delta);
  1368.         }
  1369.  
  1370.         var disable_wheel = false;
  1371.  
  1372.         function handleScroll(e) {
  1373.             if (disable_wheel)return;
  1374.             disable_wheel = true;
  1375.             setTimeout(function () {
  1376.                 disable_wheel = false;
  1377.             }, 200);
  1378.             getWheel(e) > 0 ? M.zoomIn() : M.zoomOut();
  1379.             M.track("zoom", "scroll");
  1380.         }
  1381.  
  1382.         jQuery("#drag-container").bind("mousewheel", handleScroll).bind("DOMMouseScroll", handleScroll);
  1383.     });
  1384.     M.observe("sg:map-init", function () {
  1385.         if (jQuery.browser.msie)
  1386.             jQuery("#map-tiles")[0].ondragstart = function () {
  1387.                 return false;
  1388.             };
  1389.     });
  1390.     SG.map.observe("sg:listings-ready", function () {
  1391.         if (options.auto_close_sidebar) {
  1392.             setTimeout(function () {
  1393.                 SG.map.toggleSidebar();
  1394.             }, 500);
  1395.         }
  1396.     });
  1397. })(SG.map);
  1398. var mouseover = false, mousedown = false, quantityInitial = false, quantityTimeout = null, preloadImages = new Array(), obj = null, mode = 1;
  1399. jQuery(function () {
  1400.     jQuery(".secondbar .label, .account-dropdown .label").mousedown(function (e) {
  1401.         e.preventDefault();
  1402.         showDropdown("." + jQuery(this).attr('id'));
  1403.         mousedown = true;
  1404.         jQuery(window).trigger("resize");
  1405.     });
  1406.     jQuery('.menu a').mouseup(function (event) {
  1407.         obj = jQuery(this);
  1408.         if (mousedown) {
  1409.             if (obj.attr("href") != "#" && obj.attr("id") != "logout-link") {
  1410.                 window.location = obj.attr("href");
  1411.             }
  1412.             obj.click();
  1413.         }
  1414.     });
  1415.     jQuery('body').mouseup(function () {
  1416.         mousedown = false;
  1417.         jQuery('.menu a').removeClass('hover-state');
  1418.     });
  1419.     jQuery('#drag-container').mousedown(function () {
  1420.         jQuery('#search-bar-input').blur();
  1421.     });
  1422.     jQuery('.search h1.label').click(function () {
  1423.         jQuery('.search h1.label').addClass('hastext');
  1424.         jQuery('.search input').show();
  1425.     });
  1426.     jQuery(".menu a").hover(function () {
  1427.         if (mousedown) {
  1428.             jQuery(this).addClass('hover-state');
  1429.         }
  1430.     }, function () {
  1431.         if (mousedown) {
  1432.             jQuery(this).removeClass('hover-state');
  1433.         }
  1434.     });
  1435.     jQuery('.dd, #quantity option').hover(function () {
  1436.         mouseover = true;
  1437.     }, function () {
  1438.         mouseover = false;
  1439.     });
  1440.     jQuery("body").mouseup(function () {
  1441.         if (!mouseover) {
  1442.             quantityTimeout = window.setTimeout("resetDropdowns()", 1);
  1443.         }
  1444.     });
  1445.     jQuery('.menu a').click(function () {
  1446.         obj.addClass("active-state");
  1447.         var multiplesOf = 90;
  1448.         setTimeout("obj.addClass('blink');", 50);
  1449.         setTimeout("obj.removeClass('blink');", multiplesOf * 2);
  1450.         setTimeout("obj.removeClass('active-state'); resetDropdowns('fade');", multiplesOf * 3);
  1451.     });
  1452.     jQuery('.filters .price input').click(function () {
  1453.         this.select();
  1454.     });
  1455.     jQuery('#quantity-initial').change(function () {
  1456.         quantityInitial = true;
  1457.         jQuery('#quantity').val(this.value).trigger("change");
  1458.         jQuery('.quantity-filter').html("Thanks. You can update this in the 'Filter' dropdown.");
  1459.         jQuery('.quantity-filter').delay(2500).animate({top:"-6px", opacity:0}, 500, function () {
  1460.             jQuery('.quantity-filter').hide();
  1461.         });
  1462.         jQuery('.scroll-wrapper').delay(2500).animate({top:"36px"}, 500);
  1463.     });
  1464.     jQuery('#quantity').change(function () {
  1465.         window.clearTimeout(quantityTimeout);
  1466.         if (!quantityInitial && jQuery('.quantity-filter').is(':visible')) {
  1467.             jQuery('.quantity-filter').animate({top:"-6px", opacity:0}, 500, function () {
  1468.                 jQuery('.quantity-filter').hide();
  1469.             });
  1470.             jQuery('.scroll-wrapper').animate({top:"36px"}, 500);
  1471.         }
  1472.     });
  1473.     jQuery('#search-bar-input').focus(function () {
  1474.         jQuery('.search-container').addClass("search-focus");
  1475.     });
  1476.     jQuery('#search-bar-input').blur(function () {
  1477.         jQuery('.search-container').removeClass("search-focus");
  1478.     });
  1479.     jQuery('.search-structure').click(function () {
  1480.         jQuery('#search-bar-input').focus();
  1481.     });
  1482.     jQuery('#sglightbox_modal').live('openModal', function () {
  1483.     });
  1484.     jQuery('#sglightbox_modal').live('closeModal', function () {
  1485.     });
  1486.     jQuery("a").each(function () {
  1487.         jQuery(this).attr("hideFocus", "true").css("outline", "none");
  1488.     });
  1489.     jQuery('#search-bar-input').autoGrowInput();
  1490.     jQuery('#search-bar-input').keydown(function () {
  1491.         jQuery('.search h1 span').text(jQuery(this).val());
  1492.     });
  1493.     jQuery(window).resize(function () {
  1494.         jQuery('#search-bar-input').trigger("window-resize");
  1495.         adjustWindowSize();
  1496.     });
  1497.     jQuery(window).trigger("resize");
  1498.     jQuery('.zoom a').mousedown(function () {
  1499.         jQuery(this).addClass('active');
  1500.     });
  1501.     jQuery('.zoom a').mouseup(function () {
  1502.         jQuery(this).removeClass('active');
  1503.     });
  1504.     jQuery('.zoom a').mouseout(function () {
  1505.         if (jQuery(this).hasClass('active')) {
  1506.             jQuery(this).trigger('mouseup');
  1507.         }
  1508.     });
  1509.     jQuery('.ds .tabset a').click(function () {
  1510.         resetDealScore();
  1511.         jQuery(this).addClass('selected');
  1512.         jQuery('.ds-' + jQuery(this).attr("rel")).show();
  1513.         return false;
  1514.     });
  1515.     jQuery('#sponsorship_link').click(function () {
  1516.         if (jQuery.browser.msie) {
  1517.             window.location = this.href;
  1518.         }
  1519.     });
  1520.     jQuery('.deal-quality-data.clickable, .sort-help-button').live("click", function () {
  1521.         sglightbox.open(jQuery('#deal-score-explanation-popup')[0]);
  1522.         return false;
  1523.     });
  1524. });
  1525. function resetDealScore() {
  1526.     jQuery('.ds .tabset a').removeClass('selected');
  1527.     jQuery('.ds .tab').hide();
  1528.     return true;
  1529. }
  1530. function adjustWindowSize() {
  1531.     if (jQuery(window).width() < 1066) {
  1532.         if (mode == 1) {
  1533.             jQuery(".nav-links-full").hide();
  1534.             jQuery(".nav-links-condensed").show();
  1535.             jQuery(".first2").trigger("ninja-select");
  1536.             jQuery(".over-map .key").addClass("fit");
  1537.             mode = 0;
  1538.         }
  1539.     }
  1540.     else {
  1541.         if (mode == 0) {
  1542.             jQuery(".nav-links-full").show();
  1543.             jQuery(".nav-links-condensed").hide();
  1544.             jQuery(".first").trigger("ninja-select");
  1545.             jQuery(".over-map .key").removeClass("fit");
  1546.             mode = 1;
  1547.         }
  1548.     }
  1549. }
  1550. function setTooltips() {
  1551.     jQuery('.deal-quality-data').hoverIntent(function () {
  1552.         jQuery(this).children('.help-button').show();
  1553.     }, function () {
  1554.         jQuery(this).children('.help-button').hide();
  1555.     });
  1556. }
  1557. function preload() {
  1558.     var path = preload.arguments[0];
  1559.     for (i = 1; i < preload.arguments.length; i++) {
  1560.         preloadImages[i] = new Image()
  1561.         preloadImages[i].src = path + preload.arguments[i]
  1562.     }
  1563. }
  1564. function runPreloadImages() {
  1565.     preload("/images/map/new/", "dealscores.png", "tickets.png", "sprite.png", "modal-header.png", "nav-dropdown-end.png", "nav-dropdown-middle.png", "details-body.png", "details-ends.png", "dealscores_sample.png", "slider-handle.png");
  1566.     preload("/images/", "map/ticket-group-popup-bg-top.png", "map/ticket-group-popup-bg-arrow.png", "map/ticket-group-popup-bg-bottom.png");
  1567. }
  1568. function showDropdown(object) {
  1569.     if (jQuery(object + ' .label').hasClass('selected')) {
  1570.         resetDropdowns();
  1571.         return false;
  1572.     }
  1573.     resetDropdowns();
  1574.     jQuery(object + ' .label').addClass('selected');
  1575.     jQuery(object + ' .dropdown').show();
  1576.     return false;
  1577. }
  1578. function resetDropdowns(fade) {
  1579.     var time = 0;
  1580.     if (fade == "fade") {
  1581.         time = 100;
  1582.     }
  1583.     jQuery('.dd .dropdown').fadeOut(time, function () {
  1584.         jQuery('.dd .label').removeClass('selected');
  1585.     });
  1586. }
  1587. var recursions = 0;
  1588. function adjustTitleWidth() {
  1589.     if (jQuery(".event-info h1 span").size() <= 0)return;
  1590.     var m = jQuery(".event-info h1 span"), width = m.width() + parseInt(m.closest(".event-info").css("padding-left"), 10), maxwidth = jQuery("#listing_sidebar").position().left, h1;
  1591.     if (width > maxwidth && recursions <= 13) {
  1592.         h1 = m.closest("h1");
  1593.         h1.css({fontSize:(parseInt(h1.css("fontSize"), 10) - 1) + "px"});
  1594.         recursions += 1;
  1595.         adjustTitleWidth();
  1596.     } else {
  1597.         recursions = 0;
  1598.     }
  1599. }
  1600. (function (jQuery) {
  1601.     jQuery.fn.autoGrowInput = function (o) {
  1602.         o = jQuery.extend({minWidth:0, comfortZone:20}, o);
  1603.         this.filter('input:text').each(function () {
  1604.             var minWidth = o.minWidth || jQuery(this).width(), val = '', input = jQuery(this), testSubject = jQuery('<tester/>').css({position:'absolute', top:-9999, left:-9999, width:'auto', fontSize:input.css('fontSize'), fontFamily:input.css('fontFamily'), fontWeight:input.css('fontWeight'), letterSpacing:input.css('letterSpacing'), whiteSpace:'nowrap'}), check = function () {
  1605.                 var maxWidth = jQuery(window).width() - 425;
  1606.                 val = input.val();
  1607.                 testSubject.text(val);
  1608.                 var testerWidth = testSubject.width(), newWidth = (testerWidth + o.comfortZone) >= minWidth ? testerWidth + o.comfortZone : minWidth, currentWidth = input.width(), isValidWidthChange = (newWidth < currentWidth && newWidth >= minWidth) || (newWidth > minWidth && newWidth < maxWidth);
  1609.                 var isMax = false;
  1610.                 if (newWidth > maxWidth) {
  1611.                     newWidth = maxWidth;
  1612.                     isMax = true;
  1613.                     isValidWidthChange = true;
  1614.                 }
  1615.                 if (isValidWidthChange) {
  1616.                     input.width(newWidth);
  1617.                     jQuery('.search h1').width(newWidth);
  1618.                     jQuery(".search").width(newWidth + 10);
  1619.                     if (newWidth < 500) {
  1620.                         jQuery('.event-meta').css('maxWidth', newWidth - 10);
  1621.                     }
  1622.                 }
  1623.                 if (isMax) {
  1624.                     var h1 = jQuery(".search h1"), span = jQuery(".search h1 span"), small = false, size;
  1625.                     h1.css("width", "auto");
  1626.                     while (h1.width() > maxWidth && parseInt(span.css("fontSize"), 10) > 11) {
  1627.                         small = true;
  1628.                         size = (parseInt(span.css("fontSize"), 10) - 1) + "px";
  1629.                         span.css({fontSize:size});
  1630.                         input.css({fontSize:size});
  1631.                     }
  1632.                     if (!small) {
  1633.                         while (h1.width() < maxWidth && parseInt(span.css("fontSize"), 10) < 19) {
  1634.                             size = (parseInt(span.css("fontSize"), 10) + 1) + "px";
  1635.                             span.css({fontSize:size});
  1636.                             input.css({fontSize:size});
  1637.                         }
  1638.                     }
  1639.                 }
  1640.             };
  1641.             testSubject.insertAfter(input);
  1642.             jQuery(this).bind('keyup keydown blur update window-resize onload', check);
  1643.         });
  1644.         return this;
  1645.     };
  1646. })(jQuery);
  1647. (function () {
  1648.     SG.show_about = function (callback) {
  1649.         var popup = jQuery("#about-event-popup");
  1650.         sglightbox.open(popup[0]);
  1651.         if (callback)callback();
  1652.     };
  1653.     jQuery('.more-info a').click(function (e) {
  1654.         e.preventDefault();
  1655.         SG.show_about();
  1656.     });
  1657. })(jQuery);
  1658. var PagedList = function (ls, elem, opts) {
  1659.     this.ls = ls;
  1660.     this.elem = elem;
  1661.     this.size = opts.size || 40;
  1662.     this.render = opts.render || function (l) {
  1663.         return l + "";
  1664.     };
  1665.     this.postRender = opts.postRender;
  1666.     this.preamble = opts.preamble;
  1667.     this.page = 0;
  1668. };
  1669. PagedList.prototype.drawPage = function (page, isNextPage) {
  1670.     var page = page === undefined ? this.page : page, from = page * this.size, to = (page + 1) * this.size, listingsNodes = [], listings = this.ls.slice(from, to), that = this;
  1671.     SG.map.log(page, from, to);
  1672.     this.page = page;
  1673.     if (listings.length) {
  1674.         if (!isNextPage) {
  1675.             this.elem.innerHTML = "";
  1676.             jQuery('.scroll').scrollTop();
  1677.         }
  1678.         if (this.preamble && page == 0) {
  1679.             this.elem.appendChild(SG.fn.fastHtmlToDom(this.preamble));
  1680.         }
  1681.         if (page > 0)this.elem.appendChild(SG.fn.fastHtmlToDom('<div class="pageHeaderLabel">Page ' + (page + 1) + ' of ' + this.pageCount() + '</div>'));
  1682.         _.each(listings, function (l) {
  1683.             var html = that.render(l), node = SG.fn.fastHtmlToDom(html);
  1684.             that.elem.appendChild(node);
  1685.             if (_.isFunction(that.postRender))
  1686.                 that.postRender(node);
  1687.         });
  1688.         this.elem.appendChild(SG.fn.fastHtmlToDom([page < this.pageCount() - 1 ? '<a href="#" onclick="app.sidebar.nextPage(); this.style.display=\'none\'; return false;" class="nextPage"><span>Load More Tickets</span></a>' : '<div class="pageSpacer"></div>'].join("\n")));
  1689.     } else {
  1690.         this.elem.innerHTML = app.listings.getAllListings().length ? "<div class='no-tickets-message text-shadow'><span class='header'>No matching tickets</span><span class='weSearched'>We're sorry, there are currently no tickets available that match your filter settings.</span></div>" : "<div class='no-tickets-message text-shadow'><span class='header'>No tickets available</span><span class='weSearched'>We searched all the web's ticket sites, but no one has any tickets available for this event.</span></div>";
  1691.     }
  1692.     setTooltips();
  1693. };
  1694. PagedList.prototype.pageCount = function () {
  1695.     return Math.ceil(this.ls.length / this.size);
  1696. };
  1697. PagedList.prototype.constrainPage = function (page) {
  1698.     return Math.min(Math.max(0, page), this.pageCount());
  1699. }
  1700. PagedList.prototype.nextPage = function () {
  1701.     this.drawPage(this.constrainPage(this.page + 1), true);
  1702. };
  1703. PagedList.prototype.previousPage = function () {
  1704.     this.drawPage(this.constrainPage(this.page - 1));
  1705. };
  1706. PagedList.prototype.setList = function (ls) {
  1707.     this.ls = ls;
  1708. };
  1709. jQuery(function () {
  1710.     SG.warn_ebay = function (ticket, options) {
  1711.         options = jQuery.extend({callback:null}, options);
  1712.         var confirm = jQuery("#pre-ebay-warning"), go_link = confirm.find(".go-link"), selected_quantity = jQuery("#quantity").val() || ticket.quantity;
  1713.         confirm.find(".venue").html(app.venue.get("name"));
  1714.         confirm.find(".location").html(app.venue.get("location"));
  1715.         confirm.find(".datetime").html(jQuery(".event-details time").text());
  1716.         confirm.find(".price").html(ticket.price);
  1717.         confirm.find(".quantity").html(app.filters.getQuantity() || Math.max.apply(Math, ticket.splits));
  1718.         confirm.find(".section").html(ticket.section);
  1719.         confirm.find(".row-container").html(ticket.row ? 'Row:&nbsp;<strong><span class="row">' + ticket.row + '</span></strong>' : '');
  1720.         confirm.find(".original").html(ticket.original);
  1721.         confirm.find(".shipping").html(ticket.shipping);
  1722.         confirm.find(".fees").html(ticket.fees);
  1723.         confirm.find(".new-window").show();
  1724.         go_link.removeClass("clicked").attr("href", ticket.url).unbind("click").click(function () {
  1725.             setTimeout(function () {
  1726.                 confirm.find(".new-window").hide();
  1727.                 go_link.addClass("clicked").attr("href", "#").unbind("click").click(function (e) {
  1728.                     e.preventDefault();
  1729.                     sglightbox.close();
  1730.                     if (options.callback)options.callback.call();
  1731.                 })
  1732.             }, 1000);
  1733.         });
  1734.         if (ticket.pickup_only == 1) {
  1735.             confirm.find("#shipping_pickup").html('Pickup only');
  1736.         } else {
  1737.             confirm.find("#shipping_pickup").html('Delivery fee');
  1738.         }
  1739.         sglightbox.open(confirm[0]);
  1740.     };
  1741. });
  1742. SidebarView = Backbone.View.extend({events:{"click #sort-bar a":"handleSortClick", "click .sponsored-result .toggle":"handleToggleSponsoredListings", "click .only-sponsored-listings .remove-filter":"handleToggleSponsoredListings", "click .sponsored-result .link-out":"handleSponsoredClickOut", "mouseenter .listing":"highlightListing", "mouseleave .listing":"clearListingHighlight"}, initialize:function () {
  1743.     this.highlightedListing = null;
  1744. }, render:function () {
  1745.     var preamble = "", filter_applied = !!app.filters.getMarket(), show_sponsorship = window.sponsorship_info;
  1746.     app.has_ebay = app.has_ebay !== undefined ? app.has_ebay : _.any(app.listings.getAllListings(), function (l) {
  1747.         return l.m == "ebay";
  1748.     });
  1749.     app.has_ticketsnow = app.has_ticketsnow !== undefined ? app.has_ticketsnow : _.any(app.listings.getAllListings(), function (l) {
  1750.         return l.m == "ticketsnow";
  1751.     });
  1752.     app.has_primesport = app.has_primesport !== undefined ? app.has_primesport : _.any(app.listings.getAllListings(), function (l) {
  1753.         return l.m == "primesport";
  1754.     });
  1755.     if (show_sponsorship) {
  1756.         if (window.sponsorship_info.market_slug == 'ebay') {
  1757.             show_sponsorship = app.has_ebay
  1758.         } else if (window.sponsorship_info.market_slug == 'ticketsnow') {
  1759.             show_sponsorship = app.has_ticketsnow
  1760.         } else if (window.sponsorship_info.market_slug == 'primesport') {
  1761.             show_sponsorship = app.has_primesport
  1762.         }
  1763.     }
  1764.     if (show_sponsorship) {
  1765.         preamble = templates.sponsored_result(window.sponsorship_info.market_full);
  1766.         jQuery(".sidebar .listings")[filter_applied ? "addClass" : "removeClass"]("only-sponsored-listings");
  1767.         jQuery(".hide-sponsored-listings .market-full").text(window.sponsorship_info.market_full);
  1768.         if (!this.sponsorship_impression_tracked) {
  1769.             _gaq.push(['_trackEvent', 'ads', 'impression', (window.sponsorship_info.tracking_slug || window.sponsorship_info.market_slug) + '-event-page-listing']);
  1770.         }
  1771.         this.sponsorship_impression_tracked = true;
  1772.     }
  1773.     this.pager = new PagedList(app.listings.getListings(), jQuery(".sidebar .listings .inner")[0], {render:templates.listing, preamble:preamble});
  1774.     this.pager.drawPage(0);
  1775.     return this;
  1776. }, nextPage:function () {
  1777.     this.pager.nextPage();
  1778. }, previousPage:function () {
  1779.     this.pager.previousPage();
  1780. }, highlightListing:function (e, el) {
  1781.     var el = e.currentTarget, k;
  1782.     if (el == this.highlightedListing)return;
  1783.     this.clearListingHighlight();
  1784.     this.highlightedListing = el;
  1785.     jQuery(el).addClass("hover");
  1786.     SG.map.highlightSectionOrRow(jQuery(el).attr("mapkey"));
  1787. }, clearListingHighlight:function () {
  1788.     if (this.highlightedListing) {
  1789.         SG.map.clearHighlightedSectionOrRow();
  1790.         jQuery(this.highlightedListing).removeClass("hover");
  1791.         this.highlightedListing = null;
  1792.     }
  1793. }, handleSortClick:function (e) {
  1794.     var sorts = jQuery("#sort-bar a"), sort = jQuery(e.currentTarget), order = sort.hasClass("deal-quality") ? (sort.hasClass("desc") ? "asc" : "desc") : (sort.hasClass("asc") ? "desc" : "asc");
  1795.     sorts.removeClass("asc desc");
  1796.     sort.addClass(order);
  1797.     app.filters.filterListings();
  1798.     SG.map.track("sort", sort.attr("sortby"));
  1799.     return false;
  1800. }, handleToggleSponsoredListings:function (e) {
  1801.     var m = jQuery('#market');
  1802.     if (m.val()) {
  1803.         m.val("");
  1804.     } else {
  1805.         m.val(window.sponsorship_info.market_slug);
  1806.     }
  1807.     m.change();
  1808.     _gaq.push(['_trackEvent', 'ads', 'interaction', (window.sponsorship_info.tracking_slug || window.sponsorship_info.market_slug) + '-event-page-listing']);
  1809.     return false;
  1810. }, handleSponsoredClickOut:function (e) {
  1811.     _gaq.push(['_trackEvent', 'ads', 'click', (window.sponsorship_info.tracking_slug || window.sponsorship_info.market_slug) + '-event-page-listing']);
  1812.     return true;
  1813. }});
  1814. window.templates = {alternative:function (l, first) {
  1815.     var first = first === true;
  1816.     return['<div class="alt-listing' + (first ? ' first' : '') + '" ' + helpers.attrs_for_listing(l) + '>', (s_logo ? templates.market_logo(l.m) : templates.market_broker_logo(l.m, l.bi, l.bn)), '<div class="price amt">$' + l.pf + '</div>', '<a href="' + helpers.listing_url(l) + '" class="select" target="_blank" title="Buy"></a>', '</div>'].join("\n");
  1817. }, deal_quality:function (l) {
  1818.     if (l.dq !== null) {
  1819.         var text = "Best Great Great Good Good OK OK".split(" ")[l.bucket];
  1820.         return['<div class="deal-quality deal-quality' + l.bucket + '">', '<div class="deal-quality-data clickable">', '<div class="number"><span class="value">' + Math.round(l.dq) + '</span></div>', '<div class="name">' + text + ' Deal</div>', '<a class="help-button" title="About Deal Score" href="#"></a>', '</div>', '</div>'].join("\n");
  1821.     } else {
  1822.         return['<div class="deal-quality deal-quality-unavailable">', '<div class="deal-quality-data">', '<div class="number">&bull; &bull; &bull;</div>', '<div class="name">Unknown</div>', '</div>', '</div>'].join("\n");
  1823.     }
  1824. }, market_logo:function (m) {
  1825.     return'<div class="market market-name-text market-' + m + '"><table><tr><td><div><img src="/images/map/logos/' + m + '.png" alt=""/></div></td></tr></table></div>';
  1826. }, market_broker_logo:function (m, bi, bn) {
  1827.     if (bi != undefined) {
  1828.         return'<div class="market market-name-text market-' + m + '"><table><tr><td><div><img src="/images/map/logos/' + m + '_' + bi + '.png" alt=""/></div></td></tr></table></div>';
  1829.     } else if (bn != undefined) {
  1830.         var name = bn;
  1831.         if (bn.length > 25)bn = "<span title='" + bn.replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0') + "' class='substr'>" + bn.substr(0, 25) + "<span>&hellip;</span></span>";
  1832.         return'<div class="market market-name-text market-' + m + '"><table><tr><td><div>' + bn + '</div></td></tr></table></div>';
  1833.     } else {
  1834.         return'<div class="market market-name-text market-' + m + '"><table><tr><td><div><img src="/images/map/logos/' + m + '.png" alt=""/></div></td></tr></table></div>';
  1835.     }
  1836. }, listing:function (l) {
  1837.     var listing_class = 'listing';
  1838.     if (l.sf.length > 8)listing_class += ' long_section';
  1839.     if (l.et)listing_class += ' eticket';
  1840.     return['<div class="listing-container">', '<div class="' + listing_class + '" ' + helpers.attrs_for_listing(l) + '>', '<div class="upper">', templates.deal_quality(l), '<div class="section">', '<div class="value' + (l.sf.length > 8 ? ' long-section-name' : '') + '">' + (l.sf == '' ? '--' : l.sf) + '</div>', '<div class="name">Section</div>', '</div>', '<div class="row">', '<div class="value">' + (l.rf == '' ? '--' : l.rf) + '</div>', '<div class="name">Row</div>', '</div>', (s_logo ? templates.market_logo(l.m) : templates.market_broker_logo(l.m, l.bi, l.bn)), '<div class="price amt' + (l.pf > 9999 ? ' long-price' : '') + '">$' + l.pf + '</div>', '<a href="' + helpers.listing_url(l) + '" class="select" target="_blank" title="Buy"></a>', '</div>', '<div class="lower">', '<div class="lower-details">', '<div class="show-details"><a href="#">show details</a></div>', '<div class="badge quantity">', '<strong>' + l.q + '</strong> ticket' + (l.q == 1 ? '' : 's'), '</div>', '<div class="badge eticketText eticketIcon">e-ticket</div>', '</div>', '</div>', '</div>', '<div class="details" style="display:none">', '<div class="details-top"><a class="details-close" title="Hide Details">Hide</a>More Details</div>', '<div class="details-middle">', '<div class="section-row">', 'Section <strong>' + l.sf.toUpperCase() + '</strong>', l.rf ? ' &nbsp; Row <strong>' + l.rf.toUpperCase() + '</strong>' : '', '</div>', '<div class="alternatives best-price">', ((l.alt.length == 0) ? '<div class="header">Only one listing available with these specs:</div>' : ''), templates.alternative(l, true), '</div>', '<div class="alternatives">', ((l.alt.length != 0) ? '<div class="header">' + l.alt.length + ' listing' + (l.alt.length > 1 ? 's' : '') + ' with the same specs but a worse price:</div>' : ''), _.map(l.alt, templates.alternative).join("\n"), '</div>', '<div class="fee-structure">', '<strong>$' + l.p + '</strong> base', ' + <strong>$' + (l.pf - l.p) + '</strong> fees & shipping', ' = <strong>$' + l.pf + '</strong> total', '</div>', l.fv ? '<span class="face-value">Face value: <strong>$' + Math.round(l.fv) + '</strong></span>' : '', l.d ? '<p class="notes"><b>Seller notes: </b>' + l.d + '</p>' : '', '<div class="more">', l.mk ? '<a href="#" class="zoom-here"><span class="pin-icon"></span> Show on the map</a>' : '', '</div>', '</div>', '<div class="details-bottom"></div>', '</div>', '</div>'].join("\n");
  1841. }, section_row_popup:function (sf, rf, ls) {
  1842.     var listing_class = 'header', len = (sf ? sf.length : 0) + (rf ? rf.length : 0);
  1843.     if (len > 12)listing_class += ' long-section-name';
  1844.     return['<div class="header-wrap">', '<div class="' + listing_class + '">', '<a href="#" onclick="SG.map.hidePopup(); return false;" class="close"></a>', '<span class="title">', '<span class="section">Section ' + sf.toUpperCase() + '</span>' + (rf ? ', ' : ''), rf ? '<span class="row">Row ' + rf.toUpperCase() + '</span> ' : '', '</span>', '<span class="quantity">' + ls.length + ' listing' + (ls.length == 1 ? '' : 's') + ' available</span>', '</div>', '</div>', '<div class="listings ticket-container" style="max-height:400px; overflow:auto;">', _.map(ls, templates.listing).join("\n"), '</div>'].join("\n");
  1845. }, view_from_seat:function (s, width) {
  1846.     var w = width || 250, h = Math.ceil(752 * (w / 1400)), src = "http://fanvenues4.appspot.com";
  1847.     if (SG.map.view_from_seat_manifest && s in SG.map.view_from_seat_manifest) {
  1848.         src += SG.map.view_from_seat_manifest[s];
  1849.         src += "?size=" + w + "x" + h;
  1850.         return['<div class="view-from-seat">', '<img src="' + src + '" width="' + w + 'px" height="' + h + 'px" alt="View from section ' + s + ' in ' + app.venue.get("name") + '" />', '</div>'].join("\n");
  1851.     }
  1852.     return'';
  1853. }, section_tooltip:function (ls) {
  1854.     var lowest_price = Math.min.apply(Math, _.pluck(ls, "pf")), sf = ls[0].sf, s = ls[0].s;
  1855.     return[this.view_from_seat(s), '<strong>Section ' + sf.toUpperCase() + '</strong>, ', '<span>', ls.length + ' listing' + (ls.length == 1 ? '' : 's') + ' from $' + lowest_price, '</span>'].join("\n");
  1856. }, row_tooltip:function (ls) {
  1857.     var lowest_price = Math.min.apply(Math, _.pluck(ls, "pf")), sf = ls[0].sf, rf = ls[0].rf, s = ls[0].s, len = (sf ? sf.length : 0) + (rf ? rf.length : 0);
  1858.     return[this.view_from_seat(s), '<strong>Section ' + sf.toUpperCase() + '</strong> ', '<strong>Row ' + rf.toUpperCase() + '</strong>, ', '<span>', ls.length + ' listing' + (ls.length == 1 ? '' : 's') + ' from $' + lowest_price, '</span>'].join("\n");
  1859. }, offer:function (o) {
  1860.     var q = o.get("quantity");
  1861.     return['<span class="zone">' + o.get("name") + '</span>', '<span class="quantity">' + q + ' tix' + '</span>', '<span class="discount">', Math.round(100 * o.getDiscount()) + "%", '<br />', '<span class="currentBest">off $' + o.get("best_price") + ' / ticket</span>', '</span>', '<span class="price">', '$' + o.get("price"), '<br />', '<a href="#" class="select"></a>', '</span>'].join("\n");
  1862. }, sponsored_result:function (market) {
  1863.     var is_long_tagline = 45 < window.sponsorship_info.market_tagline.length + window.sponsorship_info.market_full.length, has_link = window.sponsorship_info.market_event_url !== undefined, has_tracking_image = window.sponsorship_info.market_tracker_image !== undefined;
  1864.     return['<div class="listing-container">', '<div class="listing sponsored-result ' + window.sponsorship_info.market_slug + '-sponsored">', '<div class="upper">', '<div class="deal-quality deal-quality-sponsor">', '<div class="deal-quality-data">', '<div class="number">Sponsor</div>', '</div>', '</div>', '<div class="logo"></div>', '<a href="#" class="toggle"></a>', '</div>', '<div class="lower">', '<div class="lower-details">', '<div class="badge description">', is_long_tagline ? '' : window.sponsorship_info.market_tagline + ' &ndash; ', has_link ? '<a href="' + window.sponsorship_info.market_event_url + '" class="link-out" rel="nofollow" target="_blank">' : '', is_long_tagline ? window.sponsorship_info.market_tagline : 'Go to ' + window.sponsorship_info.market_full, has_link ? '</a>' : '', '</div>', '</div>', has_tracking_image ? '<img style="text-decoration:none;border:0;padding:0;margin:0;" src="' + window.sponsorship_info.market_tracker_image + '" />' : '', '</div>', '</div>', '</div>'].join("\n");
  1865. }, sponsored_link:function (sponsor) {
  1866.     return['<div class="sponsored-link ' + sponsor.slug + '-link" style="' + sponsor.inline_style + '">', '<div class="link-message">', '<div class="message">' + sponsor.message + '</div>', '<div class="tagline">' + sponsor.tagline + '</div>', '</div>', '<a href="' + sponsor.url + '" class="link-image" target="_blank"></a>', '</div>'].join("\n");
  1867. }, no_fees:function () {
  1868.     return['<div class="no-fees-message" style="display:none;">', '<a href="#" class="close"></a>', '</div>'].join("\n");
  1869. }};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement