function jslog(n){rwx_signalR_Logging&&console.log(n)}function RegisterInterestingListing(n){interestingListings.indexOf(n)<0?($.connection.listingHub.server.registerListingInterest(n),interestingListings[interestingListings.length]=n,jslog("RegisterInterestingListing: "+n)):jslog("RegisterInterestingListing: (skipped) "+n)}function RegisterInterestingEvent(n){interestingEvents.indexOf(n)<0?($.connection.listingHub.server.registerEventInterest(n),interestingEvents[interestingEvents.length]=n,jslog("RegisterInterestingEvent: "+n)):jslog("RegisterInterestingEvent: (skipped) "+n)}function RegisterUserName(n){$.connection.listingHub.server.registerUserName(n);jslog("RegisterUserName: "+n)}function CompleteSignalRHandling(){$(document).on("SignalR_Started",function(){$("#SignalRStatus").html('<div title="'+signalrIndicatorTitlesDictionary.Started+'"><span class="glyphicon glyphicon-stats SignalRStatus-connected"><\/span><\/div>');HideSignalRAlert()});$(document).on("SignalR_ConnectionSlow",function(){$("#SignalRStatus").html('<div title="'+signalrIndicatorTitlesDictionary.ConnectionSlow+'"><span class="glyphicon glyphicon-stats SignalRStatus-reconnect"><\/span><\/div>')});$(document).on("SignalR_Reconnecting",function(){$("#SignalRStatus").html('<div title="'+signalrIndicatorTitlesDictionary.Reconnecting+'"><span class="glyphicon glyphicon-stats SignalRStatus-reconnect"><\/span><\/div>')});$(document).on("SignalR_Reconnected",function(){$("#SignalRStatus").html('<div title="'+signalrIndicatorTitlesDictionary.Reconnected+'"><span class="glyphicon glyphicon-stats SignalRStatus-connected"><\/span><\/div>');HideSignalRAlert()});$(document).on("SignalR_Disconnected",function(){$("#SignalRStatus").html('<div title="'+signalrIndicatorTitlesDictionary.Disconnected+'"><span class="glyphicon glyphicon-stats SignalRStatus-stopped"><\/span><\/div>');setTimeout(function(){ShowSignalRAlert()},5e3)});$(document).on("SignalR_UpdateCurrentTime",function(){var n=Globalize.formatDate(browserDateTime,{date:"full"})+" "+Globalize.formatDate(browserDateTime,{time:"short"});timeZoneLabel&&(n+=" "+timeZoneLabel);$("#Time").text(n)});UpdateAllCountdowns();rwx_SignalRDisabled||setInterval(function(){browserDateTime.setTime(browserDateTime.getTime()+1e3);UpdateAllCountdowns()},1e3);$(document).on("SignalR_Started",function(){interestingListings=[];$("[data-listingid]").each(function(){RegisterInterestingListing($(this).data("listingid"))});interestingEvents=[];$("[data-eventid]").each(function(){RegisterInterestingEvent($(this).data("eventid"))})});$(document).on("SignalR_Reconnected",function(){interestingListings=[];$("[data-listingid]").each(function(){RegisterInterestingListing($(this).data("listingid"))});interestingEvents=[];$("[data-eventid]").each(function(){RegisterInterestingEvent($(this).data("eventid"))})});$(document).on("SignalR_UpdateListingAction",function(n,t){var i,r,u;$('[data-listingid="'+t.ListingID+'"] .awe-rt-Quantity').each(function(){$(this).html(Globalize.formatNumber(t.Quantity,{minimumFractionDigits:0,maximumFractionDigits:0}));$(this).pulse()});$('[data-listingid="'+t.ListingID+'"] .awe-rt-AcceptedListingActionCount').each(function(){$(this).data("previousValue")!=t.AcceptedActionCount&&($(this).data("previousValue",t.AcceptedActionCount),$(this).html(t.AcceptedActionCount),$(this).pulse())});$('[data-listingid="'+t.ListingID+'"] .awe-rt-CurrentPrice span.numberpart').each(function(){$(this).html(Globalize.formatNumber(t.Price,{minimumFractionDigits:0,maximumFractionDigits:2}));$(this).pulse()});i=$("[data-currency]").data("currency");r=$.cookie("currency");i!=r&&(u=ConvertPrice(t.Price,i,r),$(".Bidding_Local_Price span.numberpart").html(Globalize.formatNumber(u,{minimumFractionDigits:2,maximumFractionDigits:2})),$(".Bidding_Local_Price").pulse())});$(document).on("SignalR_UpdateListingDTTM",function(n,t){$('[data-listingid="'+t.ListingID+'"] [data-epoch="'+t.Epoch+'"]').each(function(){var n,i;$(this).data("actionTime",t.DTTMString);n=new Date($(this).data("actionTime"));$(this).data("actionMilliseconds",n.getTime());i=n.getTime()-browserDateTime.getTime();$(this).html(TimeDifference(i))});var i=Globalize.formatDate(new Date(t.DTTMString),{date:"full"})+" "+Globalize.formatDate(new Date(t.DTTMString),{time:"short"});timeZoneLabel&&(i+=" "+timeZoneLabel);$('[data-listingid="'+t.ListingID+'"] .awe-rt-'+t.Epoch+"DTTM").each(function(){$(this).html(i);$(this).pulse()})});$(document).on("SignalR_UpdateListingStatus",function(n,t){jslog("SignalR_UpdateListingStatus: "+t.ListingID+", "+t.Source+", "+t.Status);console.log(t);t.Source=="UPDATELISTING_ORIGIN"?$('[data-listingid="'+t.ListingID+'"] .awe-rt-RefreshAlert').each(function(){$(this).show()}):(t.Status=="Active"?$('[data-listingid="'+t.ListingID+'"] [data-epoch="starting"]').each(function(){var n,t,i;$(this).removeAttr("data-action-time");$(this).removeAttr("data-action-milliseconds");$(this).removeAttr("data-epoch");n=$(this).attr("data-end-value");typeof n!=typeof undefined&&n!=!1&&($(this).html($(this).data("endValue")),$(this).pulse());t=$(this).attr("data-end-hide-selector");typeof t!=typeof undefined&&t!=!1&&$($(this).data("endHideSelector")).hide();i=$(this).attr("data-end-show-selector");typeof i!=typeof undefined&&i!=!1&&$($(this).data("endShowSelector")).show()}):$('[data-listingid="'+t.ListingID+'"] [data-epoch="ending"]').each(function(){var n,t,i;$(this).removeAttr("data-action-time");$(this).removeAttr("data-action-milliseconds");$(this).removeAttr("data-epoch");n=$(this).attr("data-end-value");typeof n!=typeof undefined&&n!=!1&&($(this).html($(this).data("endValue")),$(this).pulse());t=$(this).attr("data-end-hide-selector");typeof t!=typeof undefined&&t!=!1&&$($(this).data("endHideSelector")).hide();i=$(this).attr("data-end-show-selector");typeof i!=typeof undefined&&i!=!1&&$($(this).data("endShowSelector")).show()}),$('[data-listingid="'+t.ListingID+'"] .awe-rt-BuyBox').each(function(){t.Status=="Active"?$(this).is(":visible")||$(this).slideDown(500):$(this).is(":visible")&&$(this).slideUp(500)}),$('[data-listingid="'+t.ListingID+'"] .awe-rt-hideable').each(function(){$(this).hide()}),$('[data-listingid="'+t.ListingID+'"] .awe-rt-ShowStatus'+t.Status).each(function(){$(this).show()}),$('[data-listingid="'+t.ListingID+'"] .awe-rt-Status').each(function(){$(this).html(statusDictionary[t.Status]);$(this).pulse()}),$('[data-listingid="'+t.ListingID+'"] .awe-rt-ColoredStatus').each(function(){$(this).html(lotStatusHtmlDictionary[t.Status]);$(this).pulse()}));$(".ContextualStatus").each(function(){$(this).is(":visible")&&$(this).slideUp(500)});t.Status=="Ended"||t.Status=="Unsuccessful"||t.Status=="Successful"?$('[data-listingid="'+t.ListingID+'"] .awe-rt-ListingClosedMessage').each(function(){$(this).slideDown()}):t.Status==""});$(document).on("SignalR_UpdateEventStatus",function(n,t){jslog("onSignalR_UpdateEventStatus: "+t.EventID+", "+t.Source+", "+t.Status);t.Source=="EVENT_PUBLICATION_FINISHED_ORIGIN"&&($('[data-eventid="'+t.EventID+'"] .awe-rt-PublishIndicator').hide(),$('[data-eventid="'+t.EventID+'"] .awe-rt-PublishCompletedMessage').show());t.Source=="EVENT_DRAFT_VALIDATION_FINISHED_ORIGIN"&&($('[data-eventid="'+t.EventID+'"] .awe-rt-ValidationIndicator').hide(),$('[data-eventid="'+t.EventID+'"] .awe-rt-ValidationCompletedMessage').show(),$("#ValidateAllDraftsLink").prop("disabled",!1));$('[data-eventid="'+t.EventID+'"] .awe-rt-hideable').each(function(){$(this).hide()});$('[data-eventid="'+t.EventID+'"] .awe-rt-ShowStatus'+t.Status).each(function(){$(this).show()});$('[data-eventid="'+t.EventID+'"] .awe-rt-Status').each(function(){$(this).html(statusDictionary[t.Status]).pulse()});$('[data-eventid="'+t.EventID+'"] .awe-rt-ColoredStatus').each(function(){$(this).html(eventStatusHtmlDictionary[t.Status]).pulse()})})}function UpdateAllCountdowns(){browserDateTime!=null&&$("[data-action-time]").each(function(){var n=$(this),e=$(this).attr("data-action-milliseconds"),o,i,t,s,r,u,f;(typeof e==typeof undefined||e==!1)&&(o=new Date($(this).data("actionTime")),$(this).attr("data-action-milliseconds",o.getTime()));i=n.data("actionMilliseconds")-browserDateTime.getTime();i<=0?(t=n.closest("[data-listingid]").attr("data-listingid"),t?(s=RealTimeProxy.invokeAsync("GetTimeRemaining",{listingId:t},function(i){var r,u,f,e;i.error==""?(r=i.secondsRemaining*1e3,r<=1e3?(n.removeAttr("data-action-time"),n.removeAttr("data-action-milliseconds"),n.removeAttr("data-epoch"),u=n.attr("data-end-value"),typeof u!=typeof undefined&&u!=!1&&(n.html(n.data("endValue")),n.pulse()),f=n.attr("data-end-hide-selector"),typeof f!=typeof undefined&&f!=!1&&$(n.data("endHideSelector")).hide(),e=n.attr("data-end-show-selector"),typeof e!=typeof undefined&&e!=!1&&$(n.data("endShowSelector")).show()):(n.data("actionMilliseconds",browserDateTime.getTime()+r),n.html(TimeDifference(r)),n.pulse(),RefreshListingVitals(t),ShowSignalRAlert(),jslog("corrected EndDTTM for listing #"+t))):(ShowSignalRAlert(),jslog("error (1) retrieving EndDTTM for #"+t))},function(){ShowSignalRAlert();jslog("error (2) retrieving EndDTTM for #"+t)}),s.fail(function(){ShowSignalRAlert();jslog("error (3) retrieving EndDTTM for #"+t)})):(n.removeAttr("data-action-time"),n.removeAttr("data-action-milliseconds"),n.removeAttr("data-epoch"),r=n.attr("data-end-value"),typeof r!=typeof undefined&&r!=!1&&(n.html(n.data("endValue")),n.pulse()),u=n.attr("data-end-hide-selector"),typeof u!=typeof undefined&&u!=!1&&$(n.data("endHideSelector")).hide(),f=n.attr("data-end-show-selector"),typeof f!=typeof undefined&&f!=!1&&$(n.data("endShowSelector")).show())):n.html(TimeDifference(i))})}function ConvertPrice(n,t,i){var r=new Number(n);return t!=i&&(r=PriceFromUSD(PriceToUSD(r,t),i)),r}function RefreshListingVitals(n){var t=RealTimeProxy.invokeAsync("GetListingVitals",{listingId:n},function(t){var i,r,u;$('[data-listingid="'+n+'"] .awe-rt-Quantity').each(function(){$(this).html(Globalize.formatNumber(t.Quantity,{minimumFractionDigits:0,maximumFractionDigits:0}));$(this).pulse()});$('[data-listingid="'+n+'"] .awe-rt-AcceptedListingActionCount').each(function(){$(this).data("previousValue")!=t.AcceptedActionCount&&($(this).data("previousValue",t.AcceptedActionCount),$(this).html(t.AcceptedActionCount),$(this).pulse())});$('[data-listingid="'+n+'"] .awe-rt-CurrentPrice span.numberpart').each(function(){$(this).html(Globalize.formatNumber(t.Price,{minimumFractionDigits:2,maximumFractionDigits:2}));$(this).pulse()});i=t.Currency;r=$.cookie("currency");i!=r&&(u=ConvertPrice(t.Price,i,r),$(".Bidding_Local_Price span.numberpart").html(Globalize.formatNumber(u,{minimumFractionDigits:2,maximumFractionDigits:2})),$(".Bidding_Local_Price").pulse())},function(){ShowSignalRAlert();jslog("error (1) retrieving vital stats for listing #"+n)});t.fail(function(){ShowSignalRAlert();jslog("error (2) retrieving vital stats for listing #"+n)})}var basic_signalR_Logging=!0,rwx_signalR_Logging=!0,interestingListings=[],interestingEvents=[],browserDateTime=null,timeDifferenceDictionary={},statusDictionary={},lotStatusHtmlDictionary={},eventStatusHtmlDictionary={},contextMessageDictionary={},signalrIndicatorTitlesDictionary={};String.prototype.format||(String.prototype.format=function(){var n=arguments[0];return this.replace(/{(\d+)}/g,function(t,i){return typeof n[i]!="undefined"?n[i]:t})});jQuery.fn.quickEach=function(){var n=jQuery([1]);return function(t){var i=-1,r,u=this.length;try{while(++i<u&&(r=n[0]=this[i])&&t.call(n,i,r)!==!1);}catch(f){delete n[0];throw f;}return delete n[0],this}}();$.fn.pulse=function(){$(this).addClass("signalr-pulse",10,function(){$(this).removeClass("signalr-pulse",3e3)})};$(document).ready(function(){if(!rwx_SignalRDisabled){basic_signalR_Logging&&($.connection.hub.logging=!0);$.connection.hub.disconnected(function(){$.event.trigger({type:"SignalR_Disconnected"});setTimeout(function(){$.connection.hub.start().done(function(){$.event.trigger({type:"SignalR_Started"})})},5e3)});$.connection.hub.connectionSlow(function(){$.event.trigger({type:"SignalR_ConnectionSlow"})});$.connection.hub.reconnecting(function(){$.event.trigger({type:"SignalR_Reconnecting"})});$.connection.hub.reconnected(function(){$.event.trigger({type:"SignalR_Reconnected"})});$.connection.hub.start().done(function(){$.event.trigger({type:"SignalR_Started"})});var n=$.connection.listingHub;n.client.updateCurrentTime=function(n){browserDateTime=new Date(n);jslog("Browser Time Set (signalR): "+n);$.event.trigger("SignalR_UpdateCurrentTime")};n.client.updateListingAction=function(n){$.event.trigger("SignalR_UpdateListingAction",n)};n.client.updateListingDTTM=function(n){$.event.trigger("SignalR_UpdateListingDTTM",n)};n.client.updateListingStatus=function(n){$.event.trigger("SignalR_UpdateListingStatus",n)};n.client.listingActionResponse=function(n){$.event.trigger("SignalR_ListingActionResponse",n)};n.client.updateEventStatus=function(n){$.event.trigger("SignalR_UpdateEventStatus",n)}}})