var pushstream=new PushStream({host:host,port:window.location.port,modes:"websocket",useSSL:true});var pushstreamLoaded=false;var pushstreamLoadedTimeout;pushstream.onmessage=messageReceivedAuctions;pushstream.onstatuschange=function(status){auctionLoading=status==2?false:true;if(status==2){clearTimeout(pushstreamLoadedTimeout);pushstreamLoaded=true;if(typeof disableAllButtons!="undefined")disableAllButtons(status)
if($('#popup').is(':visible'))popupHide();}
if(status==0||status==1){clearTimeout(pushstreamLoadedTimeout);pushstreamLoadedTimeout=setTimeout(function(){pushstreamLoaded=false;pushstream.connect();if(user_id!=''&&auction[getCurrentAid()]){if(auction[getCurrentAid()].inCountdown)trackSocketDrop(getCurrentAid());}
clearTimeout(pushstreamLoadedTimeout);},900);}};if(pathName!='/catalog'&&user_id!=''){getCartCount();}
$(document).ready(function(){pushstream.addChannel('rb');if(pageName()=='index'||pageName()=='myHistory'){}else{pushstream.connect();}
$('.buyBids').click(function(e){if($(this).hasClass('disabled')){e.preventDefault();return;}});if(loggedIn!=''){$('#userbar').hover(function(){$(this).css({height:285});$('#ub-small').hide();$('#ub-content').show();$('#ub-large').show();},function(){$(this).css({height:70});$('#ub-small').show();$('#ub-content').hide();$('#ub-large').hide();})}
if(user_id!=''){idleInterval=setInterval("timerIncrement()",60000);$(this).mousemove(function(e){idleTime=0;});$(this).keypress(function(e){idleTime=0;});}
$(".inputs").change(function(){adjustTotal(this.val());});});function getCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function setCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function getQueuedAuctions(cat){var futureListOb=[];var futureListItem={};var futureList='';var availableSpots=10;var count=0;if(cat!=undefined){$.ajax({url:works.getAjaxUrl(),type:"post",data:{cat:cat,type:'getQueuedAuctions'},success:function(json){$.each(json.q,function(key,val){if(key=='d'){for(var key in val){futureListItem={};if(val.hasOwnProperty(key)){futureListItem.upc=val[key]['upc'];futureListItem.idProduct=val[key]['idProduct'];futureListItem.description=shortenItem('shortTitle',val[key]['description']);futureListOb.push(futureListItem);count++;}}}});},complete:function(){if(count>0){var queueId='';futureList='<div class="titleBar clearfix futureLabel"><h1 class="left">Coming Soon!</h1></div><div id="futureAuctionList" class="auctionSelection">';for(var i=0;i<count;i++){if(i<availableSpots){var pid=futureListOb[i]['idProduct'];var upc=futureListOb[i]['upc'];var description=futureListOb[i]['description'];futureList+='<a class="box future" meta-pid="'+pid+'"><div class="comingSoonBanner"></div><div class="title subjectToFade">'+description+'</div><div><div class="image subjectToFade"><img src="'+cdnUrlThumb+upc+'.jpg" /></div><div class="viewDetails">Product Details</div></div></a>';}}
futureList+='</div>';$('#auctionList').after(futureList);$('.futureLabel').show();$('#futureAuctionList div.viewDetails').click(function(e){e.stopPropagation();id=$(this).parent().parent().attr('meta-pid');popupShow('productInfo',900,550,'',id)});resizeImages('#auctionList a.box.future img',150,110);}},error:function(){}});}else{}}
function pauseAuctions(aid){if(aid=='all'){window.location.href='/allAuctionsPaused/true';}else{removeAuctionList(aid);hotAuctions.remove(aid);pushstream.removeChannel(aid);removeSelected(aid,true);}}
function rbSocketReceived(text){var parser=function(msg){obj={};msg=text.split(',');for(var i=0;i<msg.length;i++){pairItUp=msg[i].split(':');obj[pairItUp[0]]=pairItUp[1];}
return obj;},sock=parser(text);if(typeof sock.custSession!='undefined'){if(user_id==sock.custSession)window.location.href='/logout/1/alert/1/force/1';}
if(typeof sock.s!='undefined'){qualifierTime=sock.s;$('#auctionQueue > li').each(function(){checkQualification($(this).attr('meta-aid'))})}
if(typeof sock.newAuction!='undefined'){var a=sock.newAuction,p=sock.p,u=sock.u,d=sock.d,cp=sock.cp,cat=sock.cat,lp=sock.lp,r=parseInt(sock.r);if(r==reserveId&&catId==''||cat==catId){pushstream.addChannel(''+a);var newAuction=new AuctionConstructor();newAuction.init(a,p,u,shortenItem('shortTitle',d),cp,'Bid Now!',cat,lp);addAuctionList(a,p,u,shortenItem('shortTitle',d),cp,'Bid Now!',lp);getAuctionEvents(a);if(catId)getQueuedAuctions(catId);}}
if(typeof sock.pauseAll!='undefined'){pauseAuctions('all');}
if(typeof sock.c!='undefined'){var channel=sock.a,countdownTime=sock.c,username=sock.w;if(!auction[channel])return;if(loggedIn!=''){removeAuctionList(channel);}
else{if(countdownTime<1){removeAuctionList(channel);}}
hotAuctions.remove(channel);if(parseInt(countdownTime)<=0){com.redibids.BidTimer.serverCountdownComplete(channel,username,auctionType,countdownTime);}else{auction[channel].inCountdown=true;if(auction[channel].isQualified==false&&auction[channel].queued!=false||auction[channel].qualUsers!=null&&$.inArray(user_id,auction[channel].qualUsers)==-1&&auction[channel].queued!=false){if(auction[channel].showNotQualified!=true){auction[channel].showNotQualified=true;popupShow('notQualified',520,300,auction[channel].upc);removeSelected(channel);}
return;}
if($('#gridView').is(":visible")&&auctionType==2){if(channel==getCurrentAid()){$('#countdownTimer').show();$('#auctionGrid').hide();if(countdownTime==1){setTimeout(function(){},1000);}}
var switched=$('#auctionQueue li[meta-aid='+channel+']').attr('meta-switched');var meta_switched=typeof switched===typeof undefined||switched===false?0:1;var inQueue=$('#auctionQueue li[meta-aid='+channel+']').length;if(inQueue>0&&!$('#SAPwrapper .knob').is(":visible")&&meta_switched==0)
activateSelected(channel);$('#auctionQueue li[meta-aid='+channel+']').attr('meta-switched','1');var titleId=$('ul#auctionQueue li[meta-aid='+channel+']');if(titleId.length==1&&titleId.find('.knob').length==0){$('#auctionQueue').prepend(titleId);$('#auctionQueueWrapper .arrowLeft').click();titleId.attr('countdown',true)
titleId.prepend(''+'<div class="countdownTimer">'+'<input class="knob" data-readOnly="true" data-max="60" data-linecap=round data-width="70" data-thickness=".2">'+'</div>')
titleId.find(".knob").prop('disabled',true).knob({'bgColor':"#222222"});titleId.find('.img').css('opacity',0.4)}}
com.redibids.BidTimer.readyTimer(channel,username,auctionType,countdownTime);}}}
function messageReceivedAuctions(text,mid,channel){var currBidAuctions,currentPrice,username,freeBidCount,auctionClosed,triggerPrize,triggerBids;var textToParse=text;var obj={};var textArray;if(textToParse.substr(0,3)=="uq:"){auction[channel].qualUsers=textToParse.slice(3).split(', ');}
textArray=textToParse.replace(/^\s+|,\s*$/g,'').split(',');if(channel=='rb'){rbSocketReceived(text);return;}
for(var i=0;i<textArray.length;i++){var match=textArray[i].match(/^\s*"?([^":]*)"?\s*:\s*"?([^"]*)\s*$/);if(match==null)return;if(match!=null)obj[match[1]]=match[2];if(textArray.length>=3){var bidTypeArr=textArray[2].split(':');if(bidTypeArr[0]=='t'){var bidType=bidTypeArr[1];}}
if(match[1]=='pauseAuction')pauseAuctions(channel);if(match[1]=='w')username=match[2];if(match[1]=='h'){currBidAuctions=match[2];}
if(match[1]=='a'){currentPrice=match[2];}
if(match[1]=='g'){auction[channel].currentGridHash=match[2].split('||');}
if(match[1]=='p'){grid.getNextEventsInfo(channel,true);triggerPrize=1;}
if(match[1]=='f'){freeBidCount=match[2];grid.getNextEventsInfo(channel,true);triggerBids=1;}
if(match[1]=='bin'&&channel==getCurrentAid()){var limitArray=match[2].split("_");var auctionBinLimit=limitArray[0];var productBinLimit=limitArray[1];var minLimit=Math.min(auctionBinLimit,productBinLimit);var newAuctionBins=minLimit>0?minLimit:'0';updateBuyNowCount(newAuctionBins);if((parseInt(BINlimitProduct)>0&&parseInt(newAuctionBins)>0)||binSelected=='1'){allowBIN=1;}else{allowBIN=0;}}}
if(username==usernameActive){if(channel==getCurrentAid()){var msrpPrice=parseFloat($('#listPriceAuction').text().substring(1).replace(/,/g,''));var newAppliedCount='';if(bidType=='1'){newAppliedCount=parseInt($('#adjustedBidCount').val())+1;$('#adjustedBidCount').val(newAppliedCount);var binValueCalc=custBINValueBack>0?(parseFloat(custBINValueBack/100))*parseFloat(bin_value):parseFloat(bin_value);appliedBidsValue=accounting.formatMoney(newAppliedCount*binValueCalc);}
var newAppliedTotalBids=parseInt($('#adjustedTotalBidCount').val())+1;$('#adjustedTotalBidCount').val(newAppliedTotalBids);var adjustedBidCount=custBINBidsBack>0?Math.ceil((parseInt(custBINBidsBack)/100)*newAppliedTotalBids):newAppliedTotalBids;var paidAppliedAdj=$('#adjustedBidCount').val();var meterAppliedValue=paidAppliedAdj*parseFloat(bin_value);var binPercentage=(parseFloat(meterAppliedValue)/parseFloat(msrpPrice))*100;binPercentage=binPercentage>0?binPercentage:0;updateBinMeter(binPercentage);if(parseInt(newAppliedTotalBids)>0&&parseInt(custBINBidsBack)>0){if(allowBIN==1||binSelected=='1'){if(parseInt(custBINValueBack)>0&&parseInt($('#adjustedBidCount').val())>0){if($('#appBidsSpan').length>0){$('#appBidsSpan').text(adjustedBidCount);}}}}}
if(triggerPrize==1&&!auction[channel].qualUsers)
triggerEvent('prize',username,channel,currBidAuctions);if(triggerBids==1&&!auction[channel].qualUsers){triggerEvent('freebids',username,channel,currBidAuctions);setTimeout(function(){bids.increment.free(freeBidCount);updateBidPriority()},100);}}
if(currBidAuctions&&auctionClosed!=true)
updateAuctionData(channel,username,currBidAuctions,currentPrice);}
function updateBalances(p,s){if(p>=0){var newBal=p.toFixed(2);$('.pb').text(newBal);document.cookie="userBal=newBal";}
oneClick.checkBidpackAvailability()}
function countdownTest(aid,c){$.ajax({type:'post',url:works.getAjaxUrl(),data:{notes:'Client Remaining: '+c+'  aid: '+aid,type:'addCountDownToDebugLog'},success:function(){console.log('countdown : '+c);}})}
function trackSocketDrop(aid){$.ajax({type:'post',url:works.getAjaxUrl(),data:{aID:aid,type:'logSocketDisconnect'},success:function(){console.log('socket drop in countdown');}})}
function countdownComplete(channel,countdownTime,username){if(channel==com.redibids.BidTimer.getCurrentAid()){$('#gridInfo .currentWinner, #dotsView .currentWinner').text('Calculating...');}
$('#auctionQueue li[meta-aid='+channel+'] .currentWinner').text('Calculating...');pushstream.removeChannel(channel);auctionClosed=true;if($('#auctionQueue li[meta-aid='+channel+']').length>0){triggerEvent('final',username,channel);}
auction[channel].inCountdown=false;auction[channel].disabled=true;$.biddingXhrPool.abortAll();}
(function(undefined){var namespace=function(name,separator,container){var ns=name.split(separator||'.'),o=container||window,i,len;for(i=0,len=ns.length;i<len;i++){o=o[ns[i]]=o[ns[i]]||{};}
return o;};namespace('com.redibids');com.redibids.jQuery=undefined;}());(function(BidTimer,$,undefined){var currenAid=null;var counterDefault=15;var intervalCounterDefault=3;BidTimer.timerData=[];BidTimer.finishedAuctions=[];function updateTimerData(channel,username,auctionType,countdownTime)
{if(channel in BidTimer.timerData)
{BidTimer.timerData[channel].username=username;BidTimer.timerData[channel].auctionType=auctionType;BidTimer.timerData[channel].countdownTime=countdownTime;}
else
{BidTimer.timerData[channel]={username:username,auctionType:auctionType,countdownTime:countdownTime,remaining:counterDefault,countdownIntervalId:setInterval(function(){BidTimer.countdown(channel);},900),monitorCountdownIntervalId:setInterval(function(){BidTimer.monitorCountdown(channel);},10),pollIntervalId:null,pollRemaining:null,animationStarted:false};BidTimer.processOriginalLogic(channel);}};function setPollInterval(channel)
{if(channel in BidTimer.timerData)
{BidTimer.timerData[channel].pollRemaining=intervalCounterDefault;BidTimer.timerData[channel].pollIntervalId=setInterval(function()
{BidTimer.pollCountdown(channel);},1000);}};BidTimer.getCurrentAid=function()
{return currentAid;};BidTimer.setCurrentAid=function()
{currentAid=$('#SAPwrapper').attr('meta-aid');};BidTimer.readyTimer=function(channel,username,auctionType,countdownTime)
{BidTimer.setCurrentAid();updateTimerData(channel,username,auctionType,countdownTime);};BidTimer.countdown=function(channel)
{if(BidTimer.timerData[channel].remaining<1)
{BidTimer.updateViewForPollTimer(channel);clearInterval(BidTimer.timerData[channel].countdownIntervalId);setPollInterval(channel);BidTimer.pollCountdown(channel);}
else
{BidTimer.timerData[channel].remaining--;}
BidTimer.processOriginalLogic(channel);};BidTimer.monitorCountdown=function(channel)
{if(com.redibids.BidTimer.getCurrentAid()in com.redibids.BidTimer.timerData&&0==com.redibids.BidTimer.timerData[com.redibids.BidTimer.getCurrentAid()].remaining){BidTimer.updateViewForPollTimer(channel);}};BidTimer.updateViewForPollTimer=function(channel){if($('#SAPwrapper').attr('meta-aid')==BidTimer.getCurrentAid()){$('#gridView .currentWinner').html('Calculating..');var aq=$('ul#auctionQueue li[meta-aid='+channel+']');aq.find('.currentWinner').html('Calculating..');aq.find('.bid').hide();$('#SAPwrapper a.bid').hide();$('.bidAutoSingle').removeAttr('meta-bidding');clearInterval(autobidInterval);autoBidCookie.clear('autoSingle')
$('.bidAutoAll').removeAttr('meta-bidding');clearInterval(autobidAllInterval);autoBidCookie.clear('autoAll');if(BidTimer.timerData[channel].animationStarted==false){startAnimation();$('#loaderImage').show();BidTimer.timerData[channel].animationStarted=true;}}else{stopAnimation();$('#loaderImage').hide();}}
BidTimer.pollCountdown=function(channel)
{if(BidTimer.timerData[channel].countdownTime<=0&&BidTimer.timerData[channel].pollRemaining<=0)
{BidTimer.finishedAuctions[channel]='';clearInterval(BidTimer.timerData[channel].pollIntervalId);clearInterval(BidTimer.timerData[channel].monitorCountdownIntervalId);stopAnimation();$('#loaderImage').hide();$('#gridView .currentWinner').html('Bid Now!');$('#SAPwrapper a.bid').show();$('ul#auctionQueue li[meta-aid='+channel+']').find('.currentWinner').html('Bid Now!');countdownComplete(channel,null,BidTimer.timerData[channel].username);BidTimer.timerData[channel]=null;}
else
{BidTimer.timerData[channel].pollRemaining--;}};BidTimer.serverCountdownComplete=function(channel,username,auctionType,countdownTime)
{if(channel in BidTimer.timerData)
{updateTimerData(channel,username,auctionType,countdownTime);}};BidTimer.processOriginalLogic=function(channel)
{if($('#gridView').is(":visible")&&BidTimer.timerData[channel].auctionType==2)
{if(channel==getCurrentAid())
{$('#SAPwrapper .knob').prop('disabled',true).val(BidTimer.timerData[channel].remaining).trigger('change');}
var titleId=$('ul#auctionQueue li[meta-aid='+channel+']');titleId.find(".knob").val(BidTimer.timerData[channel].remaining).trigger('change');}};}(com.redibids.BidTimer=com.redibids.BidTimer||{},com.redibids.jQuery||jQuery));var cSpeed=3;var cWidth=85;var cHeight=90;var cTotalFrames=15;var cFrameWidth=88;var cImageSrc='/img/arrows_00.png';var cImageTimeout=false;var cIndex=0;var cXpos=0;var cPreloaderTimeout=false;var SECONDS_BETWEEN_FRAMES=0;function imageLoaderPreload(){document.getElementById('loaderImage').style.backgroundImage='url('+cImageSrc+')';document.getElementById('loaderImage').style.width=cWidth+'px';document.getElementById('loaderImage').style.height=cHeight+'px';}
function startAnimation(){FPS=Math.round(100/cSpeed);SECONDS_BETWEEN_FRAMES=1/FPS;cPreloaderTimeout=setTimeout('continueAnimation()',SECONDS_BETWEEN_FRAMES/1000);}
function continueAnimation(){cXpos+=cFrameWidth;cIndex+=1;if(cIndex>=cTotalFrames){cXpos=0;cIndex=0;}
if(document.getElementById('loaderImage'))
document.getElementById('loaderImage').style.backgroundPosition=(-cXpos)+'px 0';cPreloaderTimeout=setTimeout('continueAnimation()',SECONDS_BETWEEN_FRAMES*1000);}
function stopAnimation(){clearTimeout(cPreloaderTimeout);cPreloaderTimeout=false;}
function imageLoader(s,fun)
{clearTimeout(cImageTimeout);cImageTimeout=0;genImage=new Image();genImage.onload=function(){cImageTimeout=setTimeout(fun,0)};genImage.onerror=new Function('alert(\'Could not load the image\')');genImage.src=s;}
new imageLoader(cImageSrc,'imageLoaderPreload()');;
/*!
 * accounting.js v0.3.2, copyright 2011 Joss Crowcroft, MIT license, http://josscrowcroft.github.com/accounting.js
 */
(function(p,z){function q(a){return!!(""===a||a&&a.charCodeAt&&a.substr)}function m(a){return u?u(a):"[object Array]"===v.call(a)}function r(a){return"[object Object]"===v.call(a)}function s(a,b){var d,a=a||{},b=b||{};for(d in b)b.hasOwnProperty(d)&&null==a[d]&&(a[d]=b[d]);return a}function j(a,b,d){var c=[],e,h;if(!a)return c;if(w&&a.map===w)return a.map(b,d);for(e=0,h=a.length;e<h;e++)c[e]=b.call(d,a[e],e,a);return c}function n(a,b){a=Math.round(Math.abs(a));return isNaN(a)?b:a}function x(a){var b=c.settings.currency.format;"function"===typeof a&&(a=a());return q(a)&&a.match("%v")?{pos:a,neg:a.replace("-","").replace("%v","-%v"),zero:a}:!a||!a.pos||!a.pos.match("%v")?!q(b)?b:c.settings.currency.format={pos:b,neg:b.replace("%v","-%v"),zero:b}:a}var c={version:"0.3.2",settings:{currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping:3,thousand:",",decimal:"."}}},w=Array.prototype.map,u=Array.isArray,v=Object.prototype.toString,o=c.unformat=c.parse=function(a,b){if(m(a))return j(a,function(a){return o(a,b)});a=a||0;if("number"===typeof a)return a;var b=b||".",c=RegExp("[^0-9-"+b+"]",["g"]),c=parseFloat((""+a).replace(/\((.*)\)/,"-$1").replace(c,"").replace(b,"."));return!isNaN(c)?c:0},y=c.toFixed=function(a,b){var b=n(b,c.settings.number.precision),d=Math.pow(10,b);return(Math.round(c.unformat(a)*d)/d).toFixed(b)},t=c.formatNumber=function(a,b,d,i){if(m(a))return j(a,function(a){return t(a,b,d,i)});var a=o(a),e=s(r(b)?b:{precision:b,thousand:d,decimal:i},c.settings.number),h=n(e.precision),f=0>a?"-":"",g=parseInt(y(Math.abs(a||0),h),10)+"",l=3<g.length?g.length%3:0;return f+(l?g.substr(0,l)+e.thousand:"")+g.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+e.thousand)+(h?e.decimal+y(Math.abs(a),h).split(".")[1]:"")},A=c.formatMoney=function(a,b,d,i,e,h){if(m(a))return j(a,function(a){return A(a,b,d,i,e,h)});var a=o(a),f=s(r(b)?b:{symbol:b,precision:d,thousand:i,decimal:e,format:h},c.settings.currency),g=x(f.format);return(0<a?g.pos:0>a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal))};c.formatColumn=function(a,b,d,i,e,h){if(!a)return[];var f=s(r(b)?b:{symbol:b,precision:d,thousand:i,decimal:e,format:h},c.settings.currency),g=x(f.format),l=g.pos.indexOf("%s")<g.pos.indexOf("%v")?!0:!1,k=0,a=j(a,function(a){if(m(a))return c.formatColumn(a,f);a=o(a);a=(0<a?g.pos:0>a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal));if(a.length>k)k=a.length;return a});return j(a,function(a){return q(a)&&a.length<k?l?a.replace(f.symbol,f.symbol+Array(k-a.length+1).join(" ")):Array(k-a.length+1).join(" ")+a:a})};if("undefined"!==typeof exports){if("undefined"!==typeof module&&module.exports)exports=module.exports=c;exports.accounting=c}else"function"===typeof define&&define.amd?define([],function(){return c}):(c.noConflict=function(a){return function(){p.accounting=a;c.noConflict=z;return c}}(p.accounting),p.accounting=c)})(this);