/* ! Copyright 2009 Webroot Software, Inc. All rights reserved */
$(function() {
var wssVals = [],
wssOptions = [
"WSS",
[
"div#wss_num_years",
"div#wss_num_comp"
],
[
"#wssPrice",
"span#wssPPU",
"input#wssCartLink"
],
["1","3"],
[]
];
var imgExt = (jQuery.support.opacity) ? ".png" : ".gif";

wssOptions[4][0] = "slider-handle-blank"+imgExt;
wssOptions[4][1] = "slider-handle-1"+imgExt;
wssOptions[4][2] = "slider-handle-2"+imgExt;
wssOptions[4][3] = "slider-handle-3"+imgExt;
wssOptions[4][5] = "slider-handle-5"+imgExt;
//wss num pc slider
$(wssOptions[1][1]).slider({ 
orientation: 'horizontal',
animate: true,
value: wssOptions[3][1],
min: 1,
max: 5,
step: 2,
start: function(event,ui) {
$(ui.handle).css("background-image", "url(http://www.webroot.com/shared/img_structure/"+wssOptions[4][0]+")");
},
change: function(event, ui) {
wssVals = getPrice(wssOptions);
$(ui.handle).css("background-image", "url(http://www.webroot.com/shared/img_structure/"+wssOptions[4][ui.value]+")");
//update price/savings/cart 
$(wssOptions[2][0]).html('$'+wssVals[0]);
$(wssOptions[2][1]).html('$'+wssVals[1]);
$(wssOptions[2][2]).val(wssVals[2]);
}
});
//wss years slider
$(wssOptions[1][0]).slider({ 
orientation: 'horizontal',
animate: true,
value: wssOptions[3][0],
min: 1,
max: 3,
step: 1,
start: function(event,ui) {
$(ui.handle).css("background-image", "url(http://www.webroot.com/shared/img_structure/"+wssOptions[4][0]+")");
},
change: function(event, ui) {
wssVals = getPrice(wssOptions);
$(ui.handle).css("background-image", "url(http://www.webroot.com/shared/img_structure/"+wssOptions[4][ui.value]+")");
//update price/savings/cart 
$(wssOptions[2][0]).html('$'+wssVals[0]);
$(wssOptions[2][1]).html('$'+wssVals[1]);
$(wssOptions[2][2]).val(wssVals[2]);
}
});

//wss set initial values
wssVals = getPrice(wssOptions);
var t=0;
for (t=0;t<2;t++) {
var foo = wssOptions[1][t],
bar = foo+" .ui-slider-handle"; 
$(foo).slider({value: wssOptions[3][t]}); 
$(bar).css("background-image", "url(http://www.webroot.com/shared/img_structure/"+wssOptions[4][wssOptions[3][t]]+")");
}
//update price/savings/cart 
$(wssOptions[2][0]).html('$'+wssVals[0]);
$(wssOptions[2][1]).html('$'+wssVals[1]);
$(wssOptions[2][2]).val(wssVals[2]);
});