Customer Rating : 
(1)
var snaptellLoadFunction = amznJQ.onReady;
var snaptellColorNameIndexToChildAsin = [];
if (window["goTwisterVariations"] != null && goTwisterVariations.dpState != null && goTwisterVariations.dpState.asin_variation_values != null) {
for (var key in goTwisterVariations.dpState.asin_variation_values) {
var value = goTwisterVariations.dpState.asin_variation_values[key];
snaptellColorNameIndexToChildAsin[value.color_name] = key;
}
}
if (document.getElementById) {
if ((document.getElementById('snaptellShoveler').offsetTop +
document.getElementById('snaptellButtonWrapper').offsetTop + 76) < (document.body.scrollTop +
document.body.clientHeight)) {
snaptellLoadFunction = amznJQ.available;
}
}
snaptellLoadFunction.apply(amznJQ, ['amazonShoveler', function() {
var snaptellAsin = "B000FCQMIW";
var parentAsin = "B000FCQMIW";
var selectedChildASIN = null;
var selectedPhysicalId = null;
var shoveler = null;
var snaptellGeneratorFunction = function(cellStart, numCells) {
var url = '/gp/product/features/snaptell/cell-render.html?ASIN=';
if (selectedChildASIN != null) {
url += parentAsin + '&childASIN='+encodeURIComponent(selectedChildASIN);
if (selectedPhysicalId != null) {
url += '&physicalID='+encodeURIComponent(selectedPhysicalId);
}
} else {
url += parentAsin + '&childASIN='+encodeURIComponent(snaptellAsin);
}
url += '&offset=' + cellStart + '&max=' + numCells;
return url;
};
window.updateSnapData = function(childASIN, physicalId) {
selectedChildASIN = childASIN;
selectedPhysicalId = physicalId;
//Reset the shoveler.
shoveler.cache = [];
shoveler.currentCell = 0;
for (var i = 0; i < 30; i++) {
shoveler.cache[i] = i;
}
shoveler.updateUI();
}
//Register with the twister if there is one. We need to know if a child
//asin is selected.
function registerTwisterCallbacks() {
if (typeof(DetailPageFramework) != 'undefined' && DetailPageFramework.registerFeature) {
var swatches = jQuery('.swatchOuter');
if ( swatches.length > 0 ) {
swatches.click(function() {
var childASIN = null;
var physicalId = null;
var swatchSelectName = jQuery('.swatchSelect',this).attr('id');
if ( swatchSelectName.match(/color_name_\d+/)) {
var swatchIndex = swatchSelectName.replace(/color_name_(\d+)/, "");
childASIN = snaptellColorNameIndexToChildAsin[swatchIndex];
}
var physicalIdUrl = jQuery('.swatchInnerImage',this).css("background-image");
if ( physicalIdUrl.match(/\/[^&?_/]+_[^&?]+.jpg/)) {
//We'll find our physical ID.
var physId = physicalIdUrl.replace(/.*\/([^?&_/.]+)\._.*\.jpg.*/,"");
if ( physId != physicalIdUrl ) {
physicalId = physId;
}
}
if (childASIN != null || physicalId != null) {
updateSnapData(childASIN, physicalId);
}
});
}
}
}
setTimeout(registerTwisterCallbacks, 0);
var snaptellCellTransformer = function(json) {
if (json == null || json == '') {
totalHits = 0;
return '';
}
shoveler.numCellsTotal = json.totalHits;
return json.content;
};
jQuery('#snaptellNextButton').addClass("next-button");
jQuery('#snaptellPrevButton').addClass("prev-button");
shoveler = jQuery("#snaptellShoveler").shoveler(
(typeof(snaptellGeneratorFunction) != 'undefined' ? snaptellGeneratorFunction : null),
2,
{ cellTransformer: (typeof(snaptellCellTransformer) != 'undefined' ? snaptellCellTransformer : null),
cellChangeSpeedInMs: 30,
ajaxTimeout: 30000,
preloadNextPage: false,
prevButtonSelector: '.prev-button',
nextButtonSelector: '.next-button',
horizPadding: 10
});
/* hack to account for IE issues with DP min width in US */
/* remove once the detail page min-width has been removed */
var shovelerDPResize = function() {
shoveler.updateUI();
}
var resizeTimer = null;
jQuery("#snaptellShoveler").resize( function() {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(shovelerDPResize,100);
});
}]);