OPEN.productPage={};
OPEN.productPage.calculator={maxPercentage:64.3,sliderMaxInDollars:152500,pmcCode:"",currentSliderValue:"",sliderHandle:"",load:{cardConfigs:{92:{multiplier:1},111:{multiplier:1,bonus:{50000:25000}},89:{multiplier:1},79:{multiplier:1},756:{multiplier:1.06,bonus:{60000:30000,30000:15000}},141:{multiplier:1.06,bonus:{50000:20000}},113:{multiplier:1.05},112:{multiplier:1.03},474:{multiplier:1.02},227:{multiplier:1.36},499:{multiplier:0.015},162:{multiplier:{0:0.015203,64650:0.012419},bonus:{64650:180}},502:{multiplier:{0:0.0162,80000:0.0132},bonus:{80000:240}}},setConfigs:function(){
var _1=this.cardConfigs[OPENCALC.pmcCode];
OPENCALC.calculate.thresholds.multiplier=_1.multiplier;
if(typeof (_1.bonus)!="undefined"){
OPENCALC.calculate.thresholds.bonus=_1.bonus;
}
}},init:function(){
console.log("CALC :: INIT BEGIN");
this.pmcCode=pmccode;
this.load.setConfigs();
$("#calc-slider").slider({range:"min",animate:"true",slide:OPEN.productPage.calculator.onSlide});
if(this.pmcCode==79||this.pmcCode==92||this.pmcCode==111||this.pmcCode==89){
this.rewards.scrollable=$("#calc-rewards").scrollable({size:1,items:".items",vertical:true,api:true,keyboard:false,speed:150});
}
this.calculate.thresholds.init();
this.sliderHandle=$("a.ui-slider-handle")[0];
this.pointsBox=$("p#calc-points span")[0];
$("#lev-1").addClass("visible");
$("#calc-slider").slider("option","value",15);
this.onSlide();
this.updateDisplay();
if(this.pmcCode==113||this.pmcCode==112||this.pmcCode==474||this.pmcCode==756||this.pmcCode==141||this.pmcCode==499){
this.rewards.scrollingEnabled="false";
}else{
this.rewards.scrollingEnabled="true";
}
if($("#calc-rewards .aj_tooltip")!=[]){
var _2=$(".aj_tooltip").length-1;
var _3=parseInt($(".aj_tooltip")[_2].innerHTML);
_3++;
$("#calc-rewards .aj_tooltip").html(_3);
}
console.log("CALC :: INIT COMPLETE");
},onSlide:function(){
OPENCALC.currentSliderValue=parseFloat($("#calc-slider .ui-slider-range").css("width"));
var _4=OPENCALC.currentSliderValue/OPENCALC.maxPercentage;
if(OPENCALC.currentSliderValue>OPENCALC.calculate.thresholds.next){
console.log("next");
if(OPENCALC.rewards.current+1!=16){
OPENCALC.rewards.scroll(OPENCALC.rewards.current+1);
}
OPENCALC.calculate.thresholds.set("next");
}else{
if(OPENCALC.currentSliderValue<OPENCALC.calculate.thresholds.prev){
console.log("prev");
if(OPENCALC.rewards.current-1!=-1){
OPENCALC.rewards.scroll(OPENCALC.rewards.current-1);
}
OPENCALC.calculate.thresholds.set("prev");
}else{
console.log("inbetween");
}
}
OPENCALC.calculate.sliderValueToDollars();
OPENCALC.calculate.dollarsToPoints();
OPENCALC.updateDisplay();
console.log("CALC ::         current slider value: "+OPENCALC.currentSliderValue);
console.log("CALC ::               next threshold: "+OPENCALC.calculate.thresholds.next);
console.log("CALC ::           previous threshold: "+OPENCALC.calculate.thresholds.prev);
console.log("CALC ::  current rewards slide index: "+OPENCALC.rewards.current);
},calculate:{currentPoints:0,currentDollars:25000,thresholds:{numThresholds:15,sectionLength:"",next:"",prev:"",bonus:{},multiplier:{},init:function(){
this.sectionLength=(OPENCALC.maxPercentage-1.6)/this.numThresholds;
this.next=this.sectionLength/4;
this.prev=0;
OPENCALC.calculate.dollarsToPoints();
$("div#calc-rewards ul li, .aj_tooltip").each(function(i){
$(this).click(function(e){
e.preventDefault();
e.stopPropagation();
});
});
},getBonus:function(){
var _5;
if(Object.size(this.bonus)!=0){
for(var _6 in this.bonus){
if((OPENCALC.calculate.currentDollars*12)>=_6){
_5=this.bonus[_6];
break;
}else{
_5=0;
}
}
return _5;
}else{
return 0;
}
},getMultiplier:function(){
var _7;
if(typeof (this.multiplier)=="object"){
for(var _8 in this.multiplier){
if((OPENCALC.calculate.currentDollars*12)>=_8){
_7=this.multiplier[_8];
}
}
return _7;
}else{
return this.multiplier;
}
},set:function(_9){
if(OPENCALC.currentSliderValue<1.045){
this.next=this.sectionLength/4;
this.prev=0;
}else{
if(_9=="next"){
this.prev=this.next;
this.next=this.next+this.sectionLength;
}else{
this.next=this.prev;
this.prev=this.prev-this.sectionLength;
}
}
}},sliderValueToDollars:function(){
var _a=OPENCALC.currentSliderValue/OPENCALC.maxPercentage;
this.currentDollars=this.round((parseInt(_a*OPENCALC.sliderMaxInDollars)+2500),-3);
if(this.currentDollars==3000){
this.currentDollars=2500;
}
},dollarsToPoints:function(){
var _b=this.thresholds.getBonus();
var _c=this.thresholds.getMultiplier();
this.currentPoints=this.round(((this.currentDollars*_c*12)+_b),0);
},round:function(_d,_e){
var _f=Math.round(_d*Math.pow(10,_e))/Math.pow(10,_e);
return _f;
}},rewards:{current:2,scrollable:"",scroll:function(_10){
console.log("scroll to: "+_10);
if(this.scrollable!=""){
$("ul.items > li").removeClass("visible");
$("ul.items > li").eq(_10).addClass("visible");
this.scrollable.seekTo(_10);
this.current=_10;
}
}},commas:function(_11){
var _12;
var _13=[];
_11=_11.toString();
_11=_11.split("");
var _14=_11.length-1;
var _15=0;
while(_14>-1){
_13.push(_11[_14]);
if(_15==2){
_13.push(",");
_15=0;
}else{
_15++;
}
_14--;
}
_14=0;
var _16=[];
var _17=_13.length;
while(_14<_17){
var _18=_13.pop();
_16.push(_18);
_14++;
}
if(_16[0]==","){
_16=_16.slice(1,_17);
}
_12=_16.join("");
return _12;
},updateDisplay:function(){
console.log("in updateDisplay");
var _19=this.commas(this.calculate.currentDollars);
this.sliderHandle.innerHTML="<span>$"+_19+"</span>";
var _1a=this.commas(this.calculate.currentPoints);
this.pointsBox.innerHTML=_1a+" ";
if(OPENCALC.rewards.scrollable!=""){
var _1b=$("#calc-rewards ul li.visible").height();
console.log("height = "+$("#calc-rewards ul li.visible").height());
$("#calc-rewards").css("height",_1b+"px");
}
}};
var OPENCALC=OPEN.productPage.calculator;
$(document).ready(function(){
OPEN.productPage.calculator.init();
});

