if(_T=="undefined"||!_T){var _T={}
}var _T=function(){return{debug:false,scrollSpeed:100,saleAlias:function(){var a;
try{a=document.getElementById("dealTime").getAttribute("deal_alias")
}catch(b){a=""
}return a
}(),baseUrl:function(){return window.location.protocol+"//"+window.location.host+"/"
}(),url:function(a){while(a.substr(0,1)=="/"){a=a.substr(1,a.length)
}return this.baseUrl+a
},globalEventController:$({}),bind:function(a,c,b){this.globalEventController.bind(a,this.scope(c,b))
},unbind:function(a,b){this.globalEventController.unbind(a,b)
},trigger:function(a){this.globalEventController.trigger(a)
},isIE7:($("#is-ie7").val()=="true"),STYLES:{noDisplay:"no-display",noAjax:"no-ajax"},scope:function(c,b){var b=b||window;
var a=Array.prototype.slice.call(arguments,2);
return function(){return c.apply(b,a.concat(Array.prototype.slice.call(arguments)))
}
},extend:function(a){this.prototype=a
},attach:function(a){this[a]=a
},log:function(a){if(!this.debug){return false
}if(typeof console!=="undefined"){console.log(a)
}},isMouseOut:function(b,e,d){var a=b[0],g=b[1],c=e,d=(typeof d==="undefined")?2:d,f=function(h){return((a<(h.left-d))||(a>(h.right+d))||(g<(h.top-d))||(g>(h.bottom+d)))
};
return(f(c))
}}
}();
(function(){var c=function(d){this.defaults={intervalSpeed:60000};
this.options=(!d)?this.defaults:$.extend(this.defaults,d);
this.eventController=$({});
window.onUnload=this.stop;
this.timeout()
};
c.prototype={MAX_DAYS:365,MAX_HOUR:23,MAX_MIN:59,MAX_SEC:59,TIME_SYNC:30,EXECUTE_START:1,interval:null,executions:0,timeout:function(){var d=this;
this.interval=setInterval(function(){d.sync()
},this.options.intervalSpeed)
},dateDiff:function(d,g){var j=(new Date()).getTime(),e=d,h=g,l=j-e,k=h-e,i=h-j;
var f={};
f.petals=10-this.getPercent(l,k);
if(this.getDay(i)>0){f.result=this.getDay(i);
if(this.getHour(i)>11){f.result=f.result+1
}f.unit="day"
}else{if(this.getHour(i)>0){f.result=this.getHour(i);
f.unit="hour"
}else{if(this.getMinutes(i)>0){f.result=this.getMinutes(i);
f.unit="minute"
}else{f.result=0;
f.unit=false;
f.petals=0
}}}if(f.result>1){f.unit+="s"
}return f
},getPercent:function(d,e){return Math.floor(d/e*10)
},getYear:function(d){return Math.floor(d/(60*60*1000*24*365))
},getDay:function(d){return Math.floor(d/(60*60*1000*24))
},getHour:function(d){return Math.floor((d%(60*60*1000*24))/(60*60*1000)*1)
},getMinutes:function(d){return Math.floor(((d%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
},prependZero:function(d){return(d<10)?"0"+d.toString():d
},reset:function(){this.executions=this.EXECUTE_START
},sync:function(){this.eventController.trigger("sync");
this.executions++
},toString:function(){return this.prependZero(this.hours)+":"+this.prependZero(this.minutes)+":"+this.prependZero(this.seconds)
},stop:function(){this._kill()
},_kill:function(){clearInterval(this.interval)
}};
_T.Counter=c;
var a=function(e){this.defaults={counterClass:"counter",fetchUrl:"",petalAttributes:"petalcount",petalClass:"petal-count",soldOutMessage:'<p class="msg">sorry, all gone!</p>',saleEndMessage:'<p class="msg">YOU MISSED IT!</p>',minutesLeftMessage:"<p>LAST CHANCE!</p>",hoursLeftMessage:"<p>DON'T MISS OUT!</p>"};
this.options=$.extend(this.defaults,e);
var g=$("."+this.options.counterClass);
if(g.length==0){return false
}this._clocks=[];
for(var d=0;
d<g.length;
d++){var f=$(g[d]);
if(f.attr("startdate")&&f.attr("enddate")){this._clocks.push({element:f,start:f.attr("startdate"),end:f.attr("enddate"),petals:f.attr("petalcount"),status:f.siblings(".sale-status")})
}}if(this._clocks.length==0){return false
}this.internalClock=new _T.Counter();
this.internalClock.eventController.bind("sync",_T.scope(this.sync,this));
window.onUnLoad=this.internalClock.stop
};
a.prototype={sync:function(){var k=this._clocks.length;
var d=[];
if(k<=0){this.internalClock.stop();
return false
}for(var j=0;
j<k;
j++){var e=this._clocks[j];
var f=this.internalClock.dateDiff(e.start,e.end);
var i=this._clocks[j].element,h=this._clocks[j].petals,g=this._clocks[j].status;
var l=(h==f.petals);
if((f.petals<=10&&f.petals>=1)){i.removeClass(this.options.petalClass+"-"+i.attr(this.options.petalAttributes));
i.addClass(this.options.petalClass+"-"+f.petals);
i.attr("petalcount",f.petals);
i.find(".count").html(f.result);
i.find(".unit").html(f.unit+" left");
if(f.unit=="hours"||f.unit=="hour"){this.status(g,this.options.hoursLeftMessage)
}if(f.unit=="minutes"||f.unit=="minute"){this.status(g,this.options.minutesLeftMessage)
}d.push(this._clocks[j])
}else{if(f.petals==0){i.removeClass(this.options.petalClass+"-"+i.attr(this.options.petalAttributes));
i.addClass(this.options.petalClass+"-"+f.petals);
i.html(this.options.saleEndMessage);
this.status(g," ")
}}}this._clocks=d
},status:function(d,e){d.removeClass(_T.STYLES.noDisplay).html(e)
}};
_T.Petals=a;
var b=new _T.Petals({counterClass:"meter"})
})();
